ofsc-utility 1.0.12 → 1.0.14

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.
@@ -12,4 +12,8 @@
12
12
  * @returns {Promise<any[]>} A promise which resolves to an array of activity objects.
13
13
  * @throws {Error} If the date format is invalid or if the resources parameter is missing.
14
14
  */
15
- export declare function getAllActivities(clientId: string, clientSecret: string, instanceUrl: string, resources: string, dateFrom: string, dateTo: string, q?: string, fields?: string): Promise<any[]>;
15
+ export declare function getAllActivities(clientId: string, clientSecret: string, instanceUrl: string, resources: string, dateFrom: string, dateTo: string, q?: string, fields?: string, includeNonScheduled?: boolean): Promise<any[]>;
16
+ export declare function getActivitybyId(clientId: string, clientSecret: string, instanceUrl: string, activityId: number, token?: string): Promise<{
17
+ token: string;
18
+ data: any;
19
+ }>;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAllActivities = getAllActivities;
4
+ exports.getActivitybyId = getActivitybyId;
4
5
  const oauthTokenService_1 = require("../oauthTokenService");
6
+ const utilities_1 = require("../utilities");
5
7
  // Validate YYYY-MM-DD format
6
8
  const isValidDate = (date) => /^\d{4}-\d{2}-\d{2}$/.test(date);
7
9
  /**
@@ -18,12 +20,12 @@ const isValidDate = (date) => /^\d{4}-\d{2}-\d{2}$/.test(date);
18
20
  * @returns {Promise<any[]>} A promise which resolves to an array of activity objects.
19
21
  * @throws {Error} If the date format is invalid or if the resources parameter is missing.
20
22
  */
21
- async function getAllActivities(clientId, clientSecret, instanceUrl, resources, dateFrom, dateTo, q, fields) {
23
+ async function getAllActivities(clientId, clientSecret, instanceUrl, resources, dateFrom, dateTo, q, fields, includeNonScheduled = false) {
22
24
  // Validate date inputs
23
25
  if (!isValidDate(dateFrom) || !isValidDate(dateTo)) {
24
26
  throw new Error(`❌ Invalid date format. Expected YYYY-MM-DD.`);
25
27
  }
26
- const limit = 100;
28
+ let limit = 1000;
27
29
  let offset = 0;
28
30
  const allItems = [];
29
31
  // Prepare reusable token
@@ -44,29 +46,27 @@ async function getAllActivities(clientId, clientSecret, instanceUrl, resources,
44
46
  params.append("dateFrom", dateFrom);
45
47
  if (dateTo)
46
48
  params.append("dateTo", dateTo);
49
+ if (includeNonScheduled)
50
+ params.append("includeNonScheduled", "true");
47
51
  const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${params.toString()}`;
48
52
  console.error(url);
49
53
  console.log(`➡️ Fetching offset=${offset}, limit=${limit}`);
50
- const res = await fetch(url, {
51
- method: "GET",
52
- headers: {
53
- Authorization: `Bearer ${token}`,
54
- Accept: "application/json"
55
- }
56
- });
57
- if (!res.ok) {
58
- const data = (await res.json());
59
- throw new Error(`❌ Fetch failed: ${res.status} ${res.statusText}\n` +
60
- `Response: ${JSON.stringify(data, null, 2)}`);
61
- }
62
- const data = (await res.json());
54
+ const response = await (0, utilities_1.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token);
55
+ const data = response.data;
63
56
  if (!data.items || data.items.length === 0) {
64
57
  console.log("✔ No more items found. Stopping pagination.");
65
58
  break;
66
59
  }
67
60
  allItems.push(...data.items);
68
61
  console.log(` ✔ Received ${data.items.length} items (Total: ${allItems.length})`);
62
+ limit = data.limit;
69
63
  offset += limit;
70
64
  }
71
65
  return allItems;
72
66
  }
67
+ async function getActivitybyId(clientId, clientSecret, instanceUrl, activityId, token = "") {
68
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(activityId)}/`;
69
+ console.log(`➡️ Fetching activity by ID: ${url}`);
70
+ const response = await (0, utilities_1.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token);
71
+ return response;
72
+ }
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @returns {Promise<any[]>} A promise which resolves to an array of customer inventory objects.
10
10
  */
11
- export declare function getActivityCustomerInventories(clientId: string, clientSecret: string, instanceUrl: string, activityId: string): Promise<any[]>;
11
+ export declare function getActivityCustomerInventories(clientId: string, clientSecret: string, instanceUrl: string, activityId: string, token?: string): Promise<any[]>;
12
12
  /**
13
13
  * Creates a new customer inventory related to the given activity.
14
14
  *
@@ -14,10 +14,10 @@ const utilities_1 = require("../utilities");
14
14
  *
15
15
  * @returns {Promise<any[]>} A promise which resolves to an array of customer inventory objects.
16
16
  */
17
- async function getActivityCustomerInventories(clientId, clientSecret, instanceUrl, activityId) {
17
+ async function getActivityCustomerInventories(clientId, clientSecret, instanceUrl, activityId, token = "") {
18
18
  const limit = 100;
19
19
  let offset = 0;
20
- let token = await (0, oauthTokenService_1.getOAuthToken)(clientId, clientSecret, instanceUrl);
20
+ // let token = await getOAuthToken(clientId, clientSecret, instanceUrl);
21
21
  const allItems = [];
22
22
  const fetchCustomerInventories = async (offset) => {
23
23
  const params = new URLSearchParams({
@@ -54,6 +54,7 @@ async function getActivityCustomerInventories(clientId, clientSecret, instanceUr
54
54
  async function createActivityCustomerInventories(clientId, clientSecret, instanceUrl, activityId, payload) {
55
55
  const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${activityId}/customerInventories`;
56
56
  const token = await (0, oauthTokenService_1.getOAuthToken)(clientId, clientSecret, instanceUrl);
57
+ console.log(`➡️ creating ${url}`);
57
58
  const res = await fetch(url, {
58
59
  method: "POST",
59
60
  headers: {
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export * as InventoryType from './inventoryTypes';
6
6
  export * as OauthTokenService from './oauthTokenService';
7
7
  export * as Resource from './resources';
8
8
  export * as User from './users';
9
- export * as CSV from './utilities';
9
+ export * as Utilities from './utilities';
10
10
  export * as WorkZone from './workZones';
11
11
  export * from './types';
12
12
  export { generateAllOnHandInventoryOfAllResourcesCSV } from './inventory';
@@ -15,7 +15,7 @@ export { downloadWorkZoneCSV } from './workZones';
15
15
  export { downloadAllResourcesCSV } from './resources';
16
16
  export { downloadAllUsersCSV, generateUsersCollaborationCSV } from './users';
17
17
  export { downloadAllInventoryTypesCSV, getInventoryTypesDetail, updateCreateInventoryType } from './inventoryTypes';
18
- export { getAllActivities } from './activities';
18
+ export { getActivitybyId, getAllActivities } from './activities';
19
19
  export { createActivityCustomerInventories, getActivityCustomerInventories } from './activityInventories';
20
20
  export { downloadAllEventsOfDay, downloadAllEventsOfDayCSV } from './events';
21
21
  declare const OfscUtility: {
@@ -33,5 +33,6 @@ declare const OfscUtility: {
33
33
  downloadAllEventsOfDay: any;
34
34
  generateUsersCollaborationCSV: any;
35
35
  generateAllOnHandInventoryOfAllResourcesCSV: any;
36
+ getActivitybyId: any;
36
37
  };
37
38
  export default OfscUtility;
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.downloadAllEventsOfDayCSV = exports.downloadAllEventsOfDay = exports.getActivityCustomerInventories = exports.createActivityCustomerInventories = exports.getAllActivities = exports.updateCreateInventoryType = exports.getInventoryTypesDetail = exports.downloadAllInventoryTypesCSV = exports.generateUsersCollaborationCSV = exports.downloadAllUsersCSV = exports.downloadAllResourcesCSV = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.generateAllOnHandInventoryOfAllResourcesCSV = exports.WorkZone = exports.CSV = exports.User = exports.Resource = exports.OauthTokenService = exports.InventoryType = exports.Inventory = exports.Events = exports.ActivityInventories = exports.Activity = void 0;
39
+ exports.downloadAllEventsOfDayCSV = exports.downloadAllEventsOfDay = exports.getActivityCustomerInventories = exports.createActivityCustomerInventories = exports.getAllActivities = exports.getActivitybyId = exports.updateCreateInventoryType = exports.getInventoryTypesDetail = exports.downloadAllInventoryTypesCSV = exports.generateUsersCollaborationCSV = exports.downloadAllUsersCSV = exports.downloadAllResourcesCSV = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.generateAllOnHandInventoryOfAllResourcesCSV = exports.WorkZone = exports.Utilities = exports.User = exports.Resource = exports.OauthTokenService = exports.InventoryType = exports.Inventory = exports.Events = exports.ActivityInventories = exports.Activity = void 0;
40
40
  // Export all methods grouped by category
41
41
  exports.Activity = __importStar(require("./activities"));
42
42
  exports.ActivityInventories = __importStar(require("./activityInventories"));
@@ -46,7 +46,7 @@ exports.InventoryType = __importStar(require("./inventoryTypes"));
46
46
  exports.OauthTokenService = __importStar(require("./oauthTokenService"));
47
47
  exports.Resource = __importStar(require("./resources"));
48
48
  exports.User = __importStar(require("./users"));
49
- exports.CSV = __importStar(require("./utilities"));
49
+ exports.Utilities = __importStar(require("./utilities"));
50
50
  exports.WorkZone = __importStar(require("./workZones"));
51
51
  // Export types
52
52
  __exportStar(require("./types"), exports);
@@ -66,6 +66,7 @@ Object.defineProperty(exports, "downloadAllInventoryTypesCSV", { enumerable: tru
66
66
  Object.defineProperty(exports, "getInventoryTypesDetail", { enumerable: true, get: function () { return inventoryTypes_1.getInventoryTypesDetail; } });
67
67
  Object.defineProperty(exports, "updateCreateInventoryType", { enumerable: true, get: function () { return inventoryTypes_1.updateCreateInventoryType; } });
68
68
  var activities_1 = require("./activities");
69
+ Object.defineProperty(exports, "getActivitybyId", { enumerable: true, get: function () { return activities_1.getActivitybyId; } });
69
70
  Object.defineProperty(exports, "getAllActivities", { enumerable: true, get: function () { return activities_1.getAllActivities; } });
70
71
  var activityInventories_1 = require("./activityInventories");
71
72
  Object.defineProperty(exports, "createActivityCustomerInventories", { enumerable: true, get: function () { return activityInventories_1.createActivityCustomerInventories; } });
@@ -88,6 +89,7 @@ const OfscUtility = {
88
89
  downloadAllEventsOfDayCSV: require('./events').downloadAllEventsOfDayCSV,
89
90
  downloadAllEventsOfDay: require('./events').downloadAllEventsOfDay,
90
91
  generateUsersCollaborationCSV: require('./users').generateUsersCollaborationCSV,
91
- generateAllOnHandInventoryOfAllResourcesCSV: require('./inventory').generateAllOnHandInventoryOfAllResourcesCSV
92
+ generateAllOnHandInventoryOfAllResourcesCSV: require('./inventory').generateAllOnHandInventoryOfAllResourcesCSV,
93
+ getActivitybyId: require('./activities').getActivitybyId
92
94
  };
93
95
  exports.default = OfscUtility;
@@ -0,0 +1,59 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.downloadAllEventsOfDayCSV = exports.downloadAllEventsOfDay = exports.getActivityCustomerInventories = exports.createActivityCustomerInventories = exports.getAllActivities = exports.getActivitybyId = exports.updateCreateInventoryType = exports.getInventoryTypesDetail = exports.downloadAllInventoryTypesCSV = exports.generateUsersCollaborationCSV = exports.downloadAllUsersCSV = exports.downloadAllResourcesCSV = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.generateAllOnHandInventoryOfAllResourcesCSV = exports.WorkZone = exports.Utilities = exports.User = exports.Resource = exports.OauthTokenService = exports.InventoryType = exports.Inventory = exports.Events = exports.ActivityInventories = exports.Activity = void 0;
3
+ const tslib_1 = require("tslib");
4
+ // Export all methods grouped by category
5
+ exports.Activity = tslib_1.__importStar(require("./activities"));
6
+ exports.ActivityInventories = tslib_1.__importStar(require("./activityInventories"));
7
+ exports.Events = tslib_1.__importStar(require("./events"));
8
+ exports.Inventory = tslib_1.__importStar(require("./inventory"));
9
+ exports.InventoryType = tslib_1.__importStar(require("./inventoryTypes"));
10
+ exports.OauthTokenService = tslib_1.__importStar(require("./oauthTokenService"));
11
+ exports.Resource = tslib_1.__importStar(require("./resources"));
12
+ exports.User = tslib_1.__importStar(require("./users"));
13
+ exports.Utilities = tslib_1.__importStar(require("./utilities"));
14
+ exports.WorkZone = tslib_1.__importStar(require("./workZones"));
15
+ // Export types
16
+ tslib_1.__exportStar(require("./types"), exports);
17
+ var inventory_1 = require("./inventory");
18
+ Object.defineProperty(exports, "generateAllOnHandInventoryOfAllResourcesCSV", { enumerable: true, get: function () { return inventory_1.generateAllOnHandInventoryOfAllResourcesCSV; } });
19
+ var oauthTokenService_1 = require("./oauthTokenService");
20
+ Object.defineProperty(exports, "getOAuthToken", { enumerable: true, get: function () { return oauthTokenService_1.getOAuthToken; } });
21
+ var workZones_1 = require("./workZones");
22
+ Object.defineProperty(exports, "downloadWorkZoneCSV", { enumerable: true, get: function () { return workZones_1.downloadWorkZoneCSV; } });
23
+ var resources_1 = require("./resources");
24
+ Object.defineProperty(exports, "downloadAllResourcesCSV", { enumerable: true, get: function () { return resources_1.downloadAllResourcesCSV; } });
25
+ var users_1 = require("./users");
26
+ Object.defineProperty(exports, "downloadAllUsersCSV", { enumerable: true, get: function () { return users_1.downloadAllUsersCSV; } });
27
+ Object.defineProperty(exports, "generateUsersCollaborationCSV", { enumerable: true, get: function () { return users_1.generateUsersCollaborationCSV; } });
28
+ var inventoryTypes_1 = require("./inventoryTypes");
29
+ Object.defineProperty(exports, "downloadAllInventoryTypesCSV", { enumerable: true, get: function () { return inventoryTypes_1.downloadAllInventoryTypesCSV; } });
30
+ Object.defineProperty(exports, "getInventoryTypesDetail", { enumerable: true, get: function () { return inventoryTypes_1.getInventoryTypesDetail; } });
31
+ Object.defineProperty(exports, "updateCreateInventoryType", { enumerable: true, get: function () { return inventoryTypes_1.updateCreateInventoryType; } });
32
+ var activities_1 = require("./activities");
33
+ Object.defineProperty(exports, "getActivitybyId", { enumerable: true, get: function () { return activities_1.getActivitybyId; } });
34
+ Object.defineProperty(exports, "getAllActivities", { enumerable: true, get: function () { return activities_1.getAllActivities; } });
35
+ var activityInventories_1 = require("./activityInventories");
36
+ Object.defineProperty(exports, "createActivityCustomerInventories", { enumerable: true, get: function () { return activityInventories_1.createActivityCustomerInventories; } });
37
+ Object.defineProperty(exports, "getActivityCustomerInventories", { enumerable: true, get: function () { return activityInventories_1.getActivityCustomerInventories; } });
38
+ var events_1 = require("./events");
39
+ Object.defineProperty(exports, "downloadAllEventsOfDay", { enumerable: true, get: function () { return events_1.downloadAllEventsOfDay; } });
40
+ Object.defineProperty(exports, "downloadAllEventsOfDayCSV", { enumerable: true, get: function () { return events_1.downloadAllEventsOfDayCSV; } });
41
+ // Default export with all functionality
42
+ const OfscUtility = {
43
+ getOAuthToken: require('./oauthTokenService').getOAuthToken,
44
+ downloadWorkZoneCSV: require('./workZones').downloadWorkZoneCSV,
45
+ downloadAllResourcesCSV: require('./resources').downloadAllResourcesCSV,
46
+ downloadAllUsersCSV: require('./resources').downloadAllUsersCSV,
47
+ downloadAllInventoryTypesCSV: require('./inventoryTypes').downloadAllInventoryTypesCSV,
48
+ getInventoryTypesDetail: require('./inventoryTypes').getInventoryTypesDetail,
49
+ updateInventoryType: require('./inventoryTypes').updateInventoryType,
50
+ getAllActivities: require('./activities').getAllActivities,
51
+ getActivityCustomerInventories: require('./activityInventories').getActivityCustomerInventories,
52
+ createActivityCustomerInventories: require('./activityInventories').createActivityCustomerInventories,
53
+ downloadAllEventsOfDayCSV: require('./events').downloadAllEventsOfDayCSV,
54
+ downloadAllEventsOfDay: require('./events').downloadAllEventsOfDay,
55
+ generateUsersCollaborationCSV: require('./users').generateUsersCollaborationCSV,
56
+ generateAllOnHandInventoryOfAllResourcesCSV: require('./inventory').generateAllOnHandInventoryOfAllResourcesCSV,
57
+ getActivitybyId: require('./activities').getActivitybyId
58
+ };
59
+ exports.default = OfscUtility;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ofsc-utility.esm.js","sources":["../src/index.ts"],"sourcesContent":["\n// Export all methods grouped by category\nexport * as Activity from './activities';\nexport * as ActivityInventories from './activityInventories';\nexport * as Events from './events';\nexport * as Inventory from './inventory';\nexport * as InventoryType from './inventoryTypes';\nexport * as OauthTokenService from './oauthTokenService';\nexport * as Resource from './resources';\nexport * as User from './users';\nexport * as Utilities from './utilities';\nexport * as WorkZone from './workZones';\n// Export types\nexport * from './types';\n\nexport {\n generateAllOnHandInventoryOfAllResourcesCSV\n} from './inventory';\nexport {\n getOAuthToken\n} from './oauthTokenService';\n\nexport {\n downloadWorkZoneCSV\n} from './workZones';\n\nexport {\n downloadAllResourcesCSV\n} from './resources';\n\nexport {\n downloadAllUsersCSV, generateUsersCollaborationCSV\n} from './users';\n\nexport {\n downloadAllInventoryTypesCSV, getInventoryTypesDetail, updateCreateInventoryType\n} from './inventoryTypes';\n\nexport { getActivitybyId, getAllActivities } from './activities';\n\nexport { createActivityCustomerInventories, getActivityCustomerInventories } from './activityInventories';\n\nexport { downloadAllEventsOfDay, downloadAllEventsOfDayCSV } from './events';\n\n\n// Default export with all functionality\nconst OfscUtility = {\n getOAuthToken: require('./oauthTokenService').getOAuthToken,\n downloadWorkZoneCSV: require('./workZones').downloadWorkZoneCSV,\n downloadAllResourcesCSV: require('./resources').downloadAllResourcesCSV,\n downloadAllUsersCSV: require('./resources').downloadAllUsersCSV,\n downloadAllInventoryTypesCSV: require('./inventoryTypes').downloadAllInventoryTypesCSV,\n getInventoryTypesDetail: require('./inventoryTypes').getInventoryTypesDetail,\n updateInventoryType: require('./inventoryTypes').updateInventoryType,\n getAllActivities: require('./activities').getAllActivities,\n getActivityCustomerInventories: require('./activityInventories').getActivityCustomerInventories,\n createActivityCustomerInventories: require('./activityInventories').createActivityCustomerInventories,\n downloadAllEventsOfDayCSV: require('./events').downloadAllEventsOfDayCSV,\n downloadAllEventsOfDay: require('./events').downloadAllEventsOfDay,\n generateUsersCollaborationCSV: require('./users').generateUsersCollaborationCSV,\n generateAllOnHandInventoryOfAllResourcesCSV: require('./inventory').generateAllOnHandInventoryOfAllResourcesCSV,\n getActivitybyId: require('./activities').getActivitybyId\n\n};\n\nexport default OfscUtility;"],"names":[],"mappings":";;;AACA;AACA,OAAA,CAAA,QAAA,GAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,CAAA;AACA,OAAA,CAAA,mBAAA,GAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,uBAAA,CAAA,CAAA;AACA,OAAA,CAAA,MAAA,GAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,CAAA;AACA,OAAA,CAAA,SAAA,GAAA,OAAA,CAAA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C,CAAC,mBAAmB;AAC/D,IAAA,uBAAuB,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,uBAAuB;AACvE,IAAA,mBAAmB,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,mBAAmB;AAC/D,IAAA,4BAA4B,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,4BAA4B;AACtF,IAAA,uBAAuB,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,uBAAuB;AAC5E,IAAA,mBAAmB,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,mBAAmB;AACpE,IAAA,gBAAgB,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,gBAAgB;AAC1D,IAAA,8BAA8B,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC,8BAA8B;AAC/F,IAAA,iCAAiC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC,iCAAiC;AACrG,IAAA,yBAAyB,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,yBAAyB;AACxE,IAAA,sBAAsB,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,sBAAsB;AAClE,IAAA,6BAA6B,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,6BAA6B;AAC/E,IAAA,2CAA2C,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC,2CAA2C;AAC/G,IAAA,eAAe,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAE1C;AAED,OAAA,CAAA,OAAA,GAAe,WAAW"}
@@ -0,0 +1 @@
1
+ !function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.downloadAllEventsOfDayCSV=exports.downloadAllEventsOfDay=exports.getActivityCustomerInventories=exports.createActivityCustomerInventories=exports.getAllActivities=exports.getActivitybyId=exports.updateCreateInventoryType=exports.getInventoryTypesDetail=exports.downloadAllInventoryTypesCSV=exports.generateUsersCollaborationCSV=exports.downloadAllUsersCSV=exports.downloadAllResourcesCSV=exports.downloadWorkZoneCSV=exports.getOAuthToken=exports.generateAllOnHandInventoryOfAllResourcesCSV=exports.WorkZone=exports.Utilities=exports.User=exports.Resource=exports.OauthTokenService=exports.InventoryType=exports.Inventory=exports.Events=exports.ActivityInventories=exports.Activity=void 0;const e=require("tslib");exports.Activity=e.__importStar(require("./activities")),exports.ActivityInventories=e.__importStar(require("./activityInventories")),exports.Events=e.__importStar(require("./events")),exports.Inventory=e.__importStar(require("./inventory")),exports.InventoryType=e.__importStar(require("./inventoryTypes")),exports.OauthTokenService=e.__importStar(require("./oauthTokenService")),exports.Resource=e.__importStar(require("./resources")),exports.User=e.__importStar(require("./users")),exports.Utilities=e.__importStar(require("./utilities")),exports.WorkZone=e.__importStar(require("./workZones")),e.__exportStar(require("./types"),exports);var t=require("./inventory");Object.defineProperty(exports,"generateAllOnHandInventoryOfAllResourcesCSV",{enumerable:!0,get:function(){return t.generateAllOnHandInventoryOfAllResourcesCSV}});var r=require("./oauthTokenService");Object.defineProperty(exports,"getOAuthToken",{enumerable:!0,get:function(){return r.getOAuthToken}});var o=require("./workZones");Object.defineProperty(exports,"downloadWorkZoneCSV",{enumerable:!0,get:function(){return o.downloadWorkZoneCSV}});var n=require("./resources");Object.defineProperty(exports,"downloadAllResourcesCSV",{enumerable:!0,get:function(){return n.downloadAllResourcesCSV}});var i=require("./users");Object.defineProperty(exports,"downloadAllUsersCSV",{enumerable:!0,get:function(){return i.downloadAllUsersCSV}}),Object.defineProperty(exports,"generateUsersCollaborationCSV",{enumerable:!0,get:function(){return i.generateUsersCollaborationCSV}});var s=require("./inventoryTypes");Object.defineProperty(exports,"downloadAllInventoryTypesCSV",{enumerable:!0,get:function(){return s.downloadAllInventoryTypesCSV}}),Object.defineProperty(exports,"getInventoryTypesDetail",{enumerable:!0,get:function(){return s.getInventoryTypesDetail}}),Object.defineProperty(exports,"updateCreateInventoryType",{enumerable:!0,get:function(){return s.updateCreateInventoryType}});var l=require("./activities");Object.defineProperty(exports,"getActivitybyId",{enumerable:!0,get:function(){return l.getActivitybyId}}),Object.defineProperty(exports,"getAllActivities",{enumerable:!0,get:function(){return l.getAllActivities}});var a=require("./activityInventories");Object.defineProperty(exports,"createActivityCustomerInventories",{enumerable:!0,get:function(){return a.createActivityCustomerInventories}}),Object.defineProperty(exports,"getActivityCustomerInventories",{enumerable:!0,get:function(){return a.getActivityCustomerInventories}});var u=require("./events");Object.defineProperty(exports,"downloadAllEventsOfDay",{enumerable:!0,get:function(){return u.downloadAllEventsOfDay}}),Object.defineProperty(exports,"downloadAllEventsOfDayCSV",{enumerable:!0,get:function(){return u.downloadAllEventsOfDayCSV}});const v={getOAuthToken:require("./oauthTokenService").getOAuthToken,downloadWorkZoneCSV:require("./workZones").downloadWorkZoneCSV,downloadAllResourcesCSV:require("./resources").downloadAllResourcesCSV,downloadAllUsersCSV:require("./resources").downloadAllUsersCSV,downloadAllInventoryTypesCSV:require("./inventoryTypes").downloadAllInventoryTypesCSV,getInventoryTypesDetail:require("./inventoryTypes").getInventoryTypesDetail,updateInventoryType:require("./inventoryTypes").updateInventoryType,getAllActivities:require("./activities").getAllActivities,getActivityCustomerInventories:require("./activityInventories").getActivityCustomerInventories,createActivityCustomerInventories:require("./activityInventories").createActivityCustomerInventories,downloadAllEventsOfDayCSV:require("./events").downloadAllEventsOfDayCSV,downloadAllEventsOfDay:require("./events").downloadAllEventsOfDay,generateUsersCollaborationCSV:require("./users").generateUsersCollaborationCSV,generateAllOnHandInventoryOfAllResourcesCSV:require("./inventory").generateAllOnHandInventoryOfAllResourcesCSV,getActivitybyId:require("./activities").getActivitybyId};exports.default=v});
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ofsc-utility.min.js","sources":["../src/index.ts"],"sourcesContent":["\n// Export all methods grouped by category\nexport * as Activity from './activities';\nexport * as ActivityInventories from './activityInventories';\nexport * as Events from './events';\nexport * as Inventory from './inventory';\nexport * as InventoryType from './inventoryTypes';\nexport * as OauthTokenService from './oauthTokenService';\nexport * as Resource from './resources';\nexport * as User from './users';\nexport * as Utilities from './utilities';\nexport * as WorkZone from './workZones';\n// Export types\nexport * from './types';\n\nexport {\n generateAllOnHandInventoryOfAllResourcesCSV\n} from './inventory';\nexport {\n getOAuthToken\n} from './oauthTokenService';\n\nexport {\n downloadWorkZoneCSV\n} from './workZones';\n\nexport {\n downloadAllResourcesCSV\n} from './resources';\n\nexport {\n downloadAllUsersCSV, generateUsersCollaborationCSV\n} from './users';\n\nexport {\n downloadAllInventoryTypesCSV, getInventoryTypesDetail, updateCreateInventoryType\n} from './inventoryTypes';\n\nexport { getActivitybyId, getAllActivities } from './activities';\n\nexport { createActivityCustomerInventories, getActivityCustomerInventories } from './activityInventories';\n\nexport { downloadAllEventsOfDay, downloadAllEventsOfDayCSV } from './events';\n\n\n// Default export with all functionality\nconst OfscUtility = {\n getOAuthToken: require('./oauthTokenService').getOAuthToken,\n downloadWorkZoneCSV: require('./workZones').downloadWorkZoneCSV,\n downloadAllResourcesCSV: require('./resources').downloadAllResourcesCSV,\n downloadAllUsersCSV: require('./resources').downloadAllUsersCSV,\n downloadAllInventoryTypesCSV: require('./inventoryTypes').downloadAllInventoryTypesCSV,\n getInventoryTypesDetail: require('./inventoryTypes').getInventoryTypesDetail,\n updateInventoryType: require('./inventoryTypes').updateInventoryType,\n getAllActivities: require('./activities').getAllActivities,\n getActivityCustomerInventories: require('./activityInventories').getActivityCustomerInventories,\n createActivityCustomerInventories: require('./activityInventories').createActivityCustomerInventories,\n downloadAllEventsOfDayCSV: require('./events').downloadAllEventsOfDayCSV,\n downloadAllEventsOfDay: require('./events').downloadAllEventsOfDay,\n generateUsersCollaborationCSV: require('./users').generateUsersCollaborationCSV,\n generateAllOnHandInventoryOfAllResourcesCSV: require('./inventory').generateAllOnHandInventoryOfAllResourcesCSV,\n getActivitybyId: require('./activities').getActivitybyId\n\n};\n\nexport default OfscUtility;"],"names":["exports","Activity","tslib_1","__importStar","require","ActivityInventories","Events","Inventory","InventoryType","OauthTokenService","Resource","User","Utilities","WorkZone","__exportStar","inventory_1","Object","defineProperty","enumerable","get","generateAllOnHandInventoryOfAllResourcesCSV","oauthTokenService_1","getOAuthToken","workZones_1","downloadWorkZoneCSV","resources_1","downloadAllResourcesCSV","users_1","downloadAllUsersCSV","generateUsersCollaborationCSV","inventoryTypes_1","downloadAllInventoryTypesCSV","getInventoryTypesDetail","updateCreateInventoryType","activities_1","getActivitybyId","getAllActivities","activityInventories_1","createActivityCustomerInventories","getActivityCustomerInventories","events_1","downloadAllEventsOfDay","downloadAllEventsOfDayCSV","OfscUtility","updateInventoryType","default"],"mappings":"k2BAEAA,QAAAC,SAAAC,EAAAC,aAAAC,QAAA,iBACAJ,QAAAK,oBAAAH,EAAAC,aAAAC,QAAA,0BACAJ,QAAAM,OAAAJ,EAAAC,aAAAC,QAAA,aACAJ,QAAAO,UAAAL,EAAAC,aAAAC,QAAA,gBACAJ,QAAAQ,cAAAN,EAAAC,aAAAC,QAAA,qBACAJ,QAAAS,kBAAAP,EAAAC,aAAAC,QAAA,wBACAJ,QAAAU,SAAAR,EAAAC,aAAAC,QAAA,gBACAJ,QAAAW,KAAAT,EAAAC,aAAAC,QAAA,YACAJ,QAAAY,UAAAV,EAAAC,aAAAC,QAAA,gBACAJ,QAAAa,SAAAX,EAAAC,aAAAC,QAAA,gBAEAF,EAAAY,aAAAV,QAAA,WAAAJ,SAEA,IAAAe,EAAAX,QAAA,eACEY,OAAAC,eAAAjB,QAAA,8CAAA,CAAAkB,YAAA,EAAAC,IAAA,WAAA,OAAAJ,EAAAK,2CAA2C,IAE7C,IAAAC,EAAAjB,QAAA,uBACEY,OAAAC,eAAAjB,QAAA,gBAAA,CAAAkB,YAAA,EAAAC,IAAA,WAAA,OAAAE,EAAAC,aAAa,IAGf,IAAAC,EAAAnB,QAAA,eACEY,OAAAC,eAAAjB,QAAA,sBAAA,CAAAkB,YAAA,EAAAC,IAAA,WAAA,OAAAI,EAAAC,mBAAmB,IAGrB,IAAAC,EAAArB,QAAA,eACEY,OAAAC,e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EAAAE,yBAAyB,IAI1D,MAAMC,EAAc,CAClBrB,cAAelB,QAAQ,uBAAuBkB,cAC9CE,oBAAqBpB,QAAQ,eAAeoB,oBAC5CE,wBAAyBtB,QAAQ,eAAesB,wBAChDE,oBAAqBxB,QAAQ,eAAewB,oBAC5CG,6BAA8B3B,QAAQ,oBAAoB2B,6BAC1DC,wBAAyB5B,QAAQ,oBAAoB4B,wBACrDY,oBAAqBxC,QAAQ,oBAAoBwC,oBACjDR,iBAAkBhC,QAAQ,gBAAgBgC,iBAC1CG,+BAAgCnC,QAAQ,yBAAyBmC,+BACjED,kCAAmClC,QAAQ,yBAAyBkC,kCACpEI,0BAA2BtC,QAAQ,YAAYsC,0BAC/CD,uBAAwBrC,QAAQ,YAAYqC,uBAC5CZ,8BAA+BzB,QAAQ,WAAWyB,8BAClDT,4CAA6ChB,QAAQ,eAAegB,4CACpEe,gBAAiB/B,QAAQ,gBAAgB+B,iBAI3CnC,QAAA6C,QAAeF"}
@@ -9,8 +9,9 @@
9
9
  *
10
10
  * @returns {Promise<{ data: any; token: string }>} A promise which resolves to an object containing the parsed JSON data and the latest OAuth token.
11
11
  */
12
- export declare const fetchWithRetry: (url: string, clientId: string, clientSecret: string, instanceUrl: string, token: string) => Promise<{
12
+ export declare const fetchWithRetry: (url: string, clientId: string, clientSecret: string, instanceUrl: string, token: string, retries?: number, baseDelay?: number) => Promise<{
13
13
  data: any;
14
14
  token: string;
15
15
  }>;
16
16
  export declare function saveCsv<T extends Record<string, any>>(rows: T[], filePath: string): void;
17
+ export declare function xmlNodeToObjects(xmlString: string, parentNodeName: string): Record<string, string>[];
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchWithRetry = void 0;
7
7
  exports.saveCsv = saveCsv;
8
+ exports.xmlNodeToObjects = xmlNodeToObjects;
9
+ const xmldom_1 = require("xmldom");
8
10
  const oauthTokenService_1 = require("../oauthTokenService");
9
11
  /**
10
12
  * Fetches a URL with retry logic for expired tokens.
@@ -17,7 +19,7 @@ const oauthTokenService_1 = require("../oauthTokenService");
17
19
  *
18
20
  * @returns {Promise<{ data: any; token: string }>} A promise which resolves to an object containing the parsed JSON data and the latest OAuth token.
19
21
  */
20
- const fetchWithRetry = async (url, clientId, clientSecret, instanceUrl, token) => {
22
+ const fetchWithRetry = async (url, clientId, clientSecret, instanceUrl, token, retries = 5, baseDelay = 500) => {
21
23
  const doFetch = async (bearer) => {
22
24
  return fetch(url, {
23
25
  method: "GET",
@@ -27,14 +29,24 @@ const fetchWithRetry = async (url, clientId, clientSecret, instanceUrl, token) =
27
29
  }
28
30
  });
29
31
  };
32
+ console.log(`➡️ Fetching ${url}`);
30
33
  // Try with the current token
31
34
  let res = await doFetch(token);
32
- // If 401 renew and retry
35
+ /* ---------- 401: refresh token ONCE per call ---------- */
33
36
  if (res.status === 401) {
34
37
  console.warn("⚠️ Token expired — renewing token…");
35
38
  token = await (0, oauthTokenService_1.getOAuthToken)(clientId, clientSecret, instanceUrl);
36
39
  res = await doFetch(token);
37
40
  }
41
+ /* ---------- 429: retry with backoff ---------- */
42
+ if (res.status === 429 && retries > 0) {
43
+ const retryAfter = res.headers.get("Retry-After");
44
+ console.log("⚠️ 429 received. Retrying...", retryAfter);
45
+ const delay = retryAfter ? Number(retryAfter) * 1000 : baseDelay;
46
+ console.warn(`⚠️ 429 received. Retrying in ${delay}ms... (${retries} left)`);
47
+ await new Promise(r => setTimeout(r, delay));
48
+ return (0, exports.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token, retries - 1, baseDelay * 2);
49
+ }
38
50
  // If still not OK → fail
39
51
  if (!res.ok) {
40
52
  const body = await res.text();
@@ -84,3 +96,22 @@ function escapeCsvValue(value) {
84
96
  }
85
97
  return str;
86
98
  }
99
+ function xmlNodeToObjects(xmlString, parentNodeName) {
100
+ const parser = new xmldom_1.DOMParser();
101
+ const xml = parser.parseFromString(xmlString, "application/xml");
102
+ const nodes = Array.from(xml.getElementsByTagName(parentNodeName));
103
+ if (nodes.length === 0) {
104
+ throw new Error(`No <${parentNodeName}> nodes found`);
105
+ }
106
+ return nodes.map(node => {
107
+ const obj = {};
108
+ const fields = Array.from(node.getElementsByTagName("Field"));
109
+ for (const field of fields) {
110
+ const key = field.getAttribute("name");
111
+ if (!key)
112
+ continue;
113
+ obj[key] = field.textContent?.trim() ?? "";
114
+ }
115
+ return obj;
116
+ });
117
+ }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "ofsc-utility",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "A wrapper for Oracle Field Service REST API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "tsc && npm link",
8
+ "build": "rollup -c",
9
+ "build:link": "tsc && npm link",
9
10
  "prepublishOnly": "npm run build",
10
11
  "test": "jest",
11
12
  "test:watch": "jest --watch",
@@ -29,15 +30,23 @@
29
30
  "url": "https://github.com/mailtodanish/ofsc-utility"
30
31
  },
31
32
  "devDependencies": {
33
+ "@rollup/plugin-commonjs": "^29.0.0",
34
+ "@rollup/plugin-node-resolve": "^16.0.3",
35
+ "@rollup/plugin-terser": "^0.4.4",
36
+ "@rollup/plugin-typescript": "^12.3.0",
32
37
  "@types/jest": "^29.0.0",
33
38
  "@types/node": "^20.0.0",
34
39
  "@types/node-fetch": "^2.6.13",
40
+ "@types/xmldom": "^0.1.34",
35
41
  "jest": "^29.0.0",
42
+ "rollup": "^4.53.5",
36
43
  "ts-jest": "^29.0.0",
37
44
  "ts-node": "^10.9.0",
38
- "typescript": "^5.0.0"
45
+ "typescript": "^5.9.3"
39
46
  },
40
47
  "dependencies": {
41
- "node-fetch": "^2.7.0"
48
+ "node-fetch": "^2.7.0",
49
+ "tslib": "^2.8.1",
50
+ "xmldom": "^0.6.0"
42
51
  }
43
52
  }
package/readme.md CHANGED
@@ -17,6 +17,10 @@ A lightweight utility library for interacting with **Oracle Field Service Cloud
17
17
  npm install ofsc-utility
18
18
  ```
19
19
 
20
+ ```jsDelivr
21
+ https://unpkg.com/ofsc-utility@1.0.13/dist/ofsc-utility.min.js
22
+ ```
23
+
20
24
  ## Functions implemented
21
25
 
22
26
  ### Download
@@ -44,6 +48,7 @@ Please see the code snippet below.
44
48
  getActivityCustomerInventories("clientId", "clientSecret", "instanceId"."activityId")
45
49
  createActivityCustomerInventories( "clientId", "clientSecret", "instanceId"."activityId","payload")
46
50
  downloadAllEventsOfDay(process.env.clientID, process.env.clientSecret, process.env.instanceId, process.env.subscriptionId,"2025-12-05")
51
+ getActivitybyId("clientId", "clientSecret", "instanceId"."activityId")
47
52
 
48
53
  ## Usage
49
54