ofsc-utility 1.0.50 → 1.0.52

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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
10
10
  - version 1.0.46
11
11
 
12
12
  ### Added
13
+ - update version to 1.0.51 and add user/inventory type management functions
14
+ - Bump version to 1.0.50 and add new export functions
13
15
  - add user management methods for standalone OFSC
14
16
  - Update version and add resource management APIs
15
17
  - version 1.0.47 and add resource APIs
@@ -0,0 +1,16 @@
1
+ export declare function startActivity(clientId: string, clientSecret: string, instanceUrl: string, activityId: number, token?: string): Promise<{
2
+ token: string;
3
+ data: any;
4
+ }>;
5
+ export declare function cancelActivity(clientId: string, clientSecret: string, instanceUrl: string, activityId: number, token?: string): Promise<{
6
+ token: string;
7
+ data: any;
8
+ }>;
9
+ export declare function completeActivity(clientId: string, clientSecret: string, instanceUrl: string, activityId: number, token?: string): Promise<{
10
+ token: string;
11
+ data: any;
12
+ }>;
13
+ export declare function deleteActivity(clientId: string, clientSecret: string, instanceUrl: string, activityId: number, token?: string): Promise<{
14
+ token: string;
15
+ data: any;
16
+ }>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startActivity = startActivity;
4
+ exports.cancelActivity = cancelActivity;
5
+ exports.completeActivity = completeActivity;
6
+ exports.deleteActivity = deleteActivity;
7
+ const utilities_1 = require("../utilities");
8
+ async function startActivity(clientId, clientSecret, instanceUrl, activityId, token = "") {
9
+ if (!activityId || isNaN(activityId)) {
10
+ throw new Error("Invalid activityId. It must be a valid number.");
11
+ }
12
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(activityId)}/custom-actions/start`;
13
+ console.log(`➡️ Fetching activity by ID: ${url}`);
14
+ const response = await (0, utilities_1.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token);
15
+ return response;
16
+ }
17
+ async function cancelActivity(clientId, clientSecret, instanceUrl, activityId, token = "") {
18
+ if (!activityId || isNaN(activityId)) {
19
+ throw new Error("Invalid activityId. It must be a valid number.");
20
+ }
21
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(activityId)}/custom-actions/cancel`;
22
+ console.log(`➡️ Fetching activity by ID: ${url}`);
23
+ const response = await (0, utilities_1.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token);
24
+ return response;
25
+ }
26
+ async function completeActivity(clientId, clientSecret, instanceUrl, activityId, token = "") {
27
+ if (!activityId || isNaN(activityId)) {
28
+ throw new Error("Invalid activityId. It must be a valid number.");
29
+ }
30
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(activityId)}/custom-actions/complete`;
31
+ console.log(`Completing activity by ID: ${url}`);
32
+ const response = await (0, utilities_1.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token);
33
+ return response;
34
+ }
35
+ async function deleteActivity(clientId, clientSecret, instanceUrl, activityId, token = "") {
36
+ if (!activityId || isNaN(activityId)) {
37
+ throw new Error("Invalid activityId. It must be a valid number.");
38
+ }
39
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(activityId)}`;
40
+ console.log(`Deleting activity by ID: ${url}`);
41
+ const response = await (0, utilities_1.deleteWithRetry)(url, clientId, clientSecret, instanceUrl, token);
42
+ return response;
43
+ }
@@ -1,3 +1,4 @@
1
+ export { startActivity, cancelActivity, completeActivity, deleteActivity } from "./activityActions";
1
2
  /**
2
3
  * Fetches all activities from the OFSC instance.
3
4
  *
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteActivity = exports.completeActivity = exports.cancelActivity = exports.startActivity = void 0;
3
4
  exports.getAllActivities = getAllActivities;
4
5
  exports.getActivitybyId = getActivitybyId;
5
6
  const oauthTokenService_1 = require("../oauthTokenService");
6
7
  const utilities_1 = require("../utilities");
8
+ var activityActions_1 = require("./activityActions");
9
+ Object.defineProperty(exports, "startActivity", { enumerable: true, get: function () { return activityActions_1.startActivity; } });
10
+ Object.defineProperty(exports, "cancelActivity", { enumerable: true, get: function () { return activityActions_1.cancelActivity; } });
11
+ Object.defineProperty(exports, "completeActivity", { enumerable: true, get: function () { return activityActions_1.completeActivity; } });
12
+ Object.defineProperty(exports, "deleteActivity", { enumerable: true, get: function () { return activityActions_1.deleteActivity; } });
7
13
  // Validate YYYY-MM-DD format
8
14
  const isValidDate = (date) => /^\d{4}-\d{2}-\d{2}$/.test(date);
9
15
  /**
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { downloadWorkZoneCSV } from './workZones';
16
16
  export { AllResources, downloadAllResourcesCSV, getResourcebyId, getworkSkillsOfResource, updateResourcebyId } from './resources';
17
17
  export { downloadAllInactiveUsers, downloadAllInactiveUsersCSV, downloadAllUsersCSV, generateUsersCollaborationCSV, getUserByLogin, updateUserbyLogin } from './users';
18
18
  export { downloadAllInventoryTypesCSV, getInventoryTypesDetail, updateCreateInventoryType } from './inventoryTypes';
19
- export { getActivitybyId, getAllActivities } from './activities';
19
+ export { getActivitybyId, getAllActivities, startActivity, cancelActivity, completeActivity, deleteActivity } from './activities';
20
20
  export { createActivityCustomerInventories, getActivityCustomerInventories } from './activityInventories';
21
21
  export { downloadAllEventsOfDay, downloadAllEventsOfDayCSV, downloadAllEventsOfDLastTwoMinutes, downloadAllEventsOfLastOneHour } from './events';
22
22
  export { createExcelFile } from './utilities';
@@ -29,9 +29,16 @@ declare const OfscUtility: {
29
29
  downloadAllInventoryTypesCSV: any;
30
30
  getInventoryTypesDetail: any;
31
31
  updateInventoryType: any;
32
- getAllActivities: any;
33
- getActivityCustomerInventories: any;
34
- createActivityCustomerInventories: any;
32
+ Activity: {
33
+ getAllActivities: any;
34
+ getActivitybyId: any;
35
+ startActivity: any;
36
+ cancelActivity: any;
37
+ completeActivity: any;
38
+ deleteActivity: any;
39
+ getActivityCustomerInventories: any;
40
+ createActivityCustomerInventories: any;
41
+ };
35
42
  metadata: {
36
43
  getActivityTypesMetaData: any;
37
44
  getActivityTypesGroupsMetaData: any;
@@ -53,10 +60,15 @@ declare const OfscUtility: {
53
60
  downloadAllEventsOfLastOneHour: any;
54
61
  generateUsersCollaborationCSV: any;
55
62
  generateAllOnHandInventoryOfAllResourcesCSV: any;
56
- getActivitybyId: any;
57
63
  AllResources: any;
58
64
  getworkSkillsOfResource: any;
59
65
  getResource: any;
66
+ updateResourcebyId: any;
67
+ getUserByLogin: any;
68
+ updateUserbyLogin: any;
69
+ downloadAllInactiveUsersCSV: any;
70
+ downloadAllInactiveUsers: any;
71
+ updateCreateInventoryType: any;
60
72
  createExcelFile: any;
61
73
  };
62
74
  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.createConfigurationFile = exports.createExcelFile = exports.downloadAllEventsOfLastOneHour = exports.downloadAllEventsOfDLastTwoMinutes = exports.downloadAllEventsOfDayCSV = exports.downloadAllEventsOfDay = exports.getActivityCustomerInventories = exports.createActivityCustomerInventories = exports.getAllActivities = exports.getActivitybyId = exports.updateCreateInventoryType = exports.getInventoryTypesDetail = exports.downloadAllInventoryTypesCSV = exports.updateUserbyLogin = exports.getUserByLogin = exports.generateUsersCollaborationCSV = exports.downloadAllUsersCSV = exports.downloadAllInactiveUsersCSV = exports.downloadAllInactiveUsers = exports.updateResourcebyId = exports.getworkSkillsOfResource = exports.getResourcebyId = exports.downloadAllResourcesCSV = exports.AllResources = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.generateAllOnHandInventoryOfAllResourcesCSV = exports.generateAllOnHandInventoryOfAllResources = exports.WorkZone = exports.Utilities = exports.User = exports.Resource = exports.OauthTokenService = exports.CreateConfigurationFile = exports.InventoryType = exports.Inventory = exports.Events = exports.ActivityInventories = exports.Activity = void 0;
39
+ exports.createConfigurationFile = exports.createExcelFile = exports.downloadAllEventsOfLastOneHour = exports.downloadAllEventsOfDLastTwoMinutes = exports.downloadAllEventsOfDayCSV = exports.downloadAllEventsOfDay = exports.getActivityCustomerInventories = exports.createActivityCustomerInventories = exports.deleteActivity = exports.completeActivity = exports.cancelActivity = exports.startActivity = exports.getAllActivities = exports.getActivitybyId = exports.updateCreateInventoryType = exports.getInventoryTypesDetail = exports.downloadAllInventoryTypesCSV = exports.updateUserbyLogin = exports.getUserByLogin = exports.generateUsersCollaborationCSV = exports.downloadAllUsersCSV = exports.downloadAllInactiveUsersCSV = exports.downloadAllInactiveUsers = exports.updateResourcebyId = exports.getworkSkillsOfResource = exports.getResourcebyId = exports.downloadAllResourcesCSV = exports.AllResources = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.generateAllOnHandInventoryOfAllResourcesCSV = exports.generateAllOnHandInventoryOfAllResources = exports.WorkZone = exports.Utilities = exports.User = exports.Resource = exports.OauthTokenService = exports.CreateConfigurationFile = 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"));
@@ -78,6 +78,10 @@ Object.defineProperty(exports, "updateCreateInventoryType", { enumerable: true,
78
78
  var activities_1 = require("./activities");
79
79
  Object.defineProperty(exports, "getActivitybyId", { enumerable: true, get: function () { return activities_1.getActivitybyId; } });
80
80
  Object.defineProperty(exports, "getAllActivities", { enumerable: true, get: function () { return activities_1.getAllActivities; } });
81
+ Object.defineProperty(exports, "startActivity", { enumerable: true, get: function () { return activities_1.startActivity; } });
82
+ Object.defineProperty(exports, "cancelActivity", { enumerable: true, get: function () { return activities_1.cancelActivity; } });
83
+ Object.defineProperty(exports, "completeActivity", { enumerable: true, get: function () { return activities_1.completeActivity; } });
84
+ Object.defineProperty(exports, "deleteActivity", { enumerable: true, get: function () { return activities_1.deleteActivity; } });
81
85
  var activityInventories_1 = require("./activityInventories");
82
86
  Object.defineProperty(exports, "createActivityCustomerInventories", { enumerable: true, get: function () { return activityInventories_1.createActivityCustomerInventories; } });
83
87
  Object.defineProperty(exports, "getActivityCustomerInventories", { enumerable: true, get: function () { return activityInventories_1.getActivityCustomerInventories; } });
@@ -99,9 +103,16 @@ const OfscUtility = {
99
103
  downloadAllInventoryTypesCSV: require('./inventoryTypes').downloadAllInventoryTypesCSV,
100
104
  getInventoryTypesDetail: require('./inventoryTypes').getInventoryTypesDetail,
101
105
  updateInventoryType: require('./inventoryTypes').updateInventoryType,
102
- getAllActivities: require('./activities').getAllActivities,
103
- getActivityCustomerInventories: require('./activityInventories').getActivityCustomerInventories,
104
- createActivityCustomerInventories: require('./activityInventories').createActivityCustomerInventories,
106
+ Activity: {
107
+ getAllActivities: require('./activities').getAllActivities,
108
+ getActivitybyId: require('./activities').getActivitybyId,
109
+ startActivity: require('./activities').startActivity,
110
+ cancelActivity: require('./activities').cancelActivity,
111
+ completeActivity: require('./activities').completeActivity,
112
+ deleteActivity: require('./activities').deleteActivity,
113
+ getActivityCustomerInventories: require('./activityInventories').getActivityCustomerInventories,
114
+ createActivityCustomerInventories: require('./activityInventories').createActivityCustomerInventories,
115
+ },
105
116
  metadata: {
106
117
  getActivityTypesMetaData: require('./metadata').getActivityTypesMetaData,
107
118
  getActivityTypesGroupsMetaData: require('./metadata').getActivityTypesGroupsMetaData,
@@ -123,10 +134,15 @@ const OfscUtility = {
123
134
  downloadAllEventsOfLastOneHour: require('./events').downloadAllEventsOfLastOneHour,
124
135
  generateUsersCollaborationCSV: require('./users').generateUsersCollaborationCSV,
125
136
  generateAllOnHandInventoryOfAllResourcesCSV: require('./inventory').generateAllOnHandInventoryOfAllResourcesCSV,
126
- getActivitybyId: require('./activities').getActivitybyId,
127
- AllResources: require('./activities').AllResources,
137
+ AllResources: require('./resources').AllResources,
128
138
  getworkSkillsOfResource: require('./resources').getworkSkillsOfResource,
129
139
  getResource: require('./resources').getResourcebyId,
140
+ updateResourcebyId: require('./resources').updateResourcebyId,
141
+ getUserByLogin: require('./users').getUserByLogin,
142
+ updateUserbyLogin: require('./users').updateUserbyLogin,
143
+ downloadAllInactiveUsersCSV: require('./users').downloadAllInactiveUsersCSV,
144
+ downloadAllInactiveUsers: require('./users').downloadAllInactiveUsers,
145
+ updateCreateInventoryType: require('./inventoryTypes').updateCreateInventoryType,
130
146
  createExcelFile: require('./utilities').createExcelFile
131
147
  };
132
148
  exports.default = OfscUtility;
@@ -13,6 +13,10 @@ export declare const fetchWithRetry: (url: string, clientId: string, clientSecre
13
13
  data: any;
14
14
  token: string;
15
15
  }>;
16
+ export declare const deleteWithRetry: (url: string, clientId: string, clientSecret: string, instanceUrl: string, token: string, retries?: number, baseDelay?: number) => Promise<{
17
+ data: any;
18
+ token: string;
19
+ }>;
16
20
  export declare const fetchPatchWithRetry: (url: string, clientId: string, clientSecret: string, instanceUrl: string, token: string, body: any, retries?: number, baseDelay?: number) => Promise<{
17
21
  data: any;
18
22
  token: string;
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.fetchPostWithRetry = exports.fetchPatchWithRetry = exports.fetchWithRetry = void 0;
39
+ exports.fetchPostWithRetry = exports.fetchPatchWithRetry = exports.deleteWithRetry = exports.fetchWithRetry = void 0;
40
40
  exports.saveCsv = saveCsv;
41
41
  exports.xmlNodeToObjects = xmlNodeToObjects;
42
42
  exports.createExcelFile = createExcelFile;
@@ -122,6 +122,78 @@ const fetchWithRetry = async (url, clientId, clientSecret, instanceUrl, token, r
122
122
  }
123
123
  };
124
124
  exports.fetchWithRetry = fetchWithRetry;
125
+ const deleteWithRetry = async (url, clientId, clientSecret, instanceUrl, token, retries = 5, baseDelay = 500) => {
126
+ const doDelete = async (bearer) => {
127
+ return fetch(url, {
128
+ method: "DELETE",
129
+ headers: {
130
+ Authorization: `Bearer ${bearer}`,
131
+ Accept: "application/json"
132
+ }
133
+ });
134
+ };
135
+ console.log(`Deleting ${url}`);
136
+ let currentToken = token;
137
+ let tokenRefreshed = false;
138
+ let remainingRetries = retries;
139
+ let delay = baseDelay;
140
+ while (true) {
141
+ const res = await doDelete(currentToken);
142
+ // Token expired
143
+ if (res.status === 401 && !tokenRefreshed) {
144
+ console.warn("Token expired — renewing token…");
145
+ currentToken = await (0, oauthTokenService_1.getOAuthToken)(clientId, clientSecret, instanceUrl);
146
+ tokenRefreshed = true;
147
+ continue;
148
+ }
149
+ const responseText = await res.text();
150
+ const isNoRouteToHost = res.status === 400 &&
151
+ responseText.includes("NoRouteToHostException");
152
+ const isRetryableStatus = res.status === 400 ||
153
+ res.status === 429 ||
154
+ res.status === 502 ||
155
+ res.status === 503 ||
156
+ res.status === 504;
157
+ if ((isRetryableStatus || isNoRouteToHost) &&
158
+ remainingRetries > 0) {
159
+ const retryAfter = res.headers.get("Retry-After");
160
+ let retryDelay = delay;
161
+ if (retryAfter) {
162
+ const retryAfterSeconds = Number(retryAfter);
163
+ if (!Number.isNaN(retryAfterSeconds)) {
164
+ retryDelay = retryAfterSeconds * 1000;
165
+ }
166
+ }
167
+ console.warn(`Retrying DELETE in ${retryDelay}ms... (${remainingRetries} retries left)`);
168
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
169
+ remainingRetries--;
170
+ delay *= 2;
171
+ continue;
172
+ }
173
+ if (!res.ok) {
174
+ throw new Error(`DELETE request failed: ${res.status} ${res.statusText}\n${responseText}`);
175
+ }
176
+ // DELETE APIs commonly return 204 No Content
177
+ if (res.status === 204 || !responseText.trim()) {
178
+ return {
179
+ data: null,
180
+ token: currentToken
181
+ };
182
+ }
183
+ let data;
184
+ try {
185
+ data = JSON.parse(responseText);
186
+ }
187
+ catch {
188
+ throw new Error(`Invalid JSON response from ${url}\n${responseText}`);
189
+ }
190
+ return {
191
+ data,
192
+ token: currentToken
193
+ };
194
+ }
195
+ };
196
+ exports.deleteWithRetry = deleteWithRetry;
125
197
  const fetchPatchWithRetry = async (url, clientId, clientSecret, instanceUrl, token, body, retries = 5, baseDelay = 500) => {
126
198
  const doFetch = async (bearer) => {
127
199
  return fetch(url, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofsc-utility",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "TypeScript helpers for Oracle Field Service Cloud (OFSC): events, resources, inventories, metadata and CSV/Excel utilities.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -102,6 +102,94 @@ async function main() {
102
102
  main().catch(console.error);
103
103
  ```
104
104
 
105
+ ## Available exports
106
+
107
+ The package exposes both top-level helpers and grouped namespaces. This list is validated against the actual exports in [src/index.ts](src/index.ts).
108
+
109
+ ### Top-level exports
110
+
111
+ - `getOAuthToken`
112
+ - `downloadWorkZoneCSV`
113
+ - `generateAllOnHandInventoryOfAllResources`
114
+ - `generateAllOnHandInventoryOfAllResourcesCSV`
115
+ - `downloadAllResourcesCSV`
116
+ - `AllResources`
117
+ - `getResourcebyId`
118
+ - `getworkSkillsOfResource`
119
+ - `updateResourcebyId`
120
+ - `downloadAllUsersCSV`
121
+ - `downloadAllInactiveUsersCSV`
122
+ - `downloadAllInactiveUsers`
123
+ - `generateUsersCollaborationCSV`
124
+ - `getUserByLogin`
125
+ - `updateUserbyLogin`
126
+ - `downloadAllInventoryTypesCSV`
127
+ - `getInventoryTypesDetail`
128
+ - `updateCreateInventoryType`
129
+ - `getAllActivities`
130
+ - `getActivitybyId`
131
+ - `startActivity`
132
+ - `cancelActivity`
133
+ - `completeActivity`
134
+ - `deleteActivity`
135
+ - `getActivityCustomerInventories`
136
+ - `createActivityCustomerInventories`
137
+ - `downloadAllEventsOfDay`
138
+ - `downloadAllEventsOfDayCSV`
139
+ - `downloadAllEventsOfDLastTwoMinutes`
140
+ - `downloadAllEventsOfLastOneHour`
141
+ - `createExcelFile`
142
+ - `createConfigurationFile`
143
+
144
+ ### Grouped exports
145
+
146
+ The module-level namespace exports are:
147
+
148
+ - `ofs.Activity`
149
+ - `getAllActivities`
150
+ - `getActivitybyId`
151
+ - `startActivity`
152
+ - `cancelActivity`
153
+ - `completeActivity`
154
+ - `deleteActivity`
155
+ - `ofs.ActivityInventories`
156
+ - `getActivityCustomerInventories`
157
+ - `createActivityCustomerInventories`
158
+ - `ofs.Events`
159
+ - `downloadAllEventsOfDay`
160
+ - `downloadAllEventsOfDayCSV`
161
+ - `downloadAllEventsOfDLastTwoMinutes`
162
+ - `downloadAllEventsOfLastOneHour`
163
+ - `ofs.Inventory`
164
+ - `generateAllOnHandInventoryOfAllResources`
165
+ - `generateAllOnHandInventoryOfAllResourcesCSV`
166
+ - `ofs.InventoryType`
167
+ - `downloadAllInventoryTypesCSV`
168
+ - `getInventoryTypesDetail`
169
+ - `updateCreateInventoryType`
170
+ - `ofs.CreateConfigurationFile`
171
+ - `createConfigurationFile`
172
+ - `ofs.OauthTokenService`
173
+ - `getOAuthToken`
174
+ - `ofs.Resource`
175
+ - `AllResources`
176
+ - `downloadAllResourcesCSV`
177
+ - `getResourcebyId`
178
+ - `getworkSkillsOfResource`
179
+ - `updateResourcebyId`
180
+ - `ofs.User`
181
+ - `downloadAllUsersCSV`
182
+ - `downloadAllInactiveUsersCSV`
183
+ - `downloadAllInactiveUsers`
184
+ - `generateUsersCollaborationCSV`
185
+ - `getUserByLogin`
186
+ - `updateUserbyLogin`
187
+ - `ofs.Utilities`
188
+ - `createExcelFile`
189
+ - `ofs.WorkZone`
190
+ - `downloadWorkZoneCSV`
191
+
192
+
105
193
  ## Complete Example
106
194
 
107
195
  This example shows a full CommonJS script that retrieves activity type metadata and prints the result.
@@ -759,8 +847,10 @@ This gives you a dynamic table definition based on the actual inventory row fiel
759
847
 
760
848
  ### Activity and inventory helpers
761
849
 
850
+ The activity API supports both listing and lifecycle actions. Prefer the grouped namespace for organization:
851
+
762
852
  ```js
763
- const activities = await ofs.getAllActivities(
853
+ const activities = await ofs.Activity.getAllActivities(
764
854
  process.env.CLIENT_ID,
765
855
  process.env.CLIENT_SECRET,
766
856
  process.env.INSTANCE_NAME,
@@ -769,13 +859,61 @@ const activities = await ofs.getAllActivities(
769
859
  "2025-11-30",
770
860
  "status=='pending'",
771
861
  "activityId,activityType,date,status",
862
+ true,
772
863
  );
773
864
 
774
- const activityData = await ofs.getActivitybyId(
865
+ const activityData = await ofs.Activity.getActivitybyId(
775
866
  process.env.CLIENT_ID,
776
867
  process.env.CLIENT_SECRET,
777
868
  process.env.INSTANCE_NAME,
778
- "ACTIVITY_ID",
869
+ 123456,
870
+ );
871
+
872
+ await ofs.Activity.startActivity(
873
+ process.env.CLIENT_ID,
874
+ process.env.CLIENT_SECRET,
875
+ process.env.INSTANCE_NAME,
876
+ 123456,
877
+ );
878
+
879
+ await ofs.Activity.completeActivity(
880
+ process.env.CLIENT_ID,
881
+ process.env.CLIENT_SECRET,
882
+ process.env.INSTANCE_NAME,
883
+ 123456,
884
+ );
885
+
886
+ await ofs.Activity.cancelActivity(
887
+ process.env.CLIENT_ID,
888
+ process.env.CLIENT_SECRET,
889
+ process.env.INSTANCE_NAME,
890
+ 123456,
891
+ );
892
+
893
+ await ofs.Activity.deleteActivity(
894
+ process.env.CLIENT_ID,
895
+ process.env.CLIENT_SECRET,
896
+ process.env.INSTANCE_NAME,
897
+ 123456,
898
+ );
899
+
900
+ const customerInventories = await ofs.ActivityInventories.getActivityCustomerInventories(
901
+ process.env.CLIENT_ID,
902
+ process.env.CLIENT_SECRET,
903
+ process.env.INSTANCE_NAME,
904
+ 123456,
905
+ );
906
+
907
+ const createdInventory = await ofs.ActivityInventories.createActivityCustomerInventories(
908
+ process.env.CLIENT_ID,
909
+ process.env.CLIENT_SECRET,
910
+ process.env.INSTANCE_NAME,
911
+ 123456,
912
+ {
913
+ code: "INV-1001",
914
+ quantity: 1,
915
+ status: "active",
916
+ },
779
917
  );
780
918
 
781
919
  const inventoryDetail = await ofs.InventoryType.getInventoryTypesDetail(
@@ -786,6 +924,28 @@ const inventoryDetail = await ofs.InventoryType.getInventoryTypesDetail(
786
924
  );
787
925
  ```
788
926
 
927
+ ### Activity lifecycle actions
928
+
929
+ The activity action helpers let you transition an OFSC activity through its standard custom actions:
930
+
931
+ - `startActivity(clientId, clientSecret, instanceUrl, activityId)`
932
+ - `completeActivity(clientId, clientSecret, instanceUrl, activityId)`
933
+ - `cancelActivity(clientId, clientSecret, instanceUrl, activityId)`
934
+ - `deleteActivity(clientId, clientSecret, instanceUrl, activityId)`
935
+
936
+ Example:
937
+
938
+ ```js
939
+ const started = await ofs.Activity.startActivity(
940
+ process.env.CLIENT_ID,
941
+ process.env.CLIENT_SECRET,
942
+ process.env.INSTANCE_NAME,
943
+ 123456,
944
+ );
945
+
946
+ console.log(started.data);
947
+ ```
948
+
789
949
  ### Create a configuration workbook
790
950
 
791
951
  ```js
@@ -842,43 +1002,37 @@ await ofs.User.generateUsersCollaborationCSV(
842
1002
  );
843
1003
  ```
844
1004
 
845
- ## Available exports
846
1005
 
847
- Top-level exports include:
1006
+ ### Default export object
848
1007
 
849
- - `getOAuthToken`
850
- - `downloadWorkZoneCSV`
851
- - `downloadAllResourcesCSV`
852
- - `getResource`
853
- - `downloadAllUsersCSV`
854
- - `downloadAllInactiveUsersCSV`
855
- - `generateAllOnHandInventoryOfAllResourcesCSV`
856
- - `generateAllOnHandInventoryOfAllResources`
857
- - `downloadAllInventoryTypesCSV`
858
- - `getInventoryTypesDetail`
859
- - `updateCreateInventoryType`
860
- - `getAllActivities`
861
- - `getActivitybyId`
862
- - `getActivityCustomerInventories`
863
- - `createActivityCustomerInventories`
864
- - `downloadAllEventsOfDay`
865
- - `downloadAllEventsOfDayCSV`
866
- - `createExcelFile`
867
- - `createConfigurationFile`
1008
+ The default export object exposes the same functions in a single object, with the metadata helpers grouped under `metadata`:
868
1009
 
869
- Grouped exports include:
1010
+ ```js
1011
+ const ofs = require("ofsc-utility");
870
1012
 
871
- - `ofs.Activity`
872
- - `ofs.ActivityInventories`
873
- - `ofs.Events`
874
- - `ofs.Inventory`
875
- - `ofs.InventoryType`
876
- - `ofs.OauthTokenService`
877
- - `ofs.Resource`
878
- - `ofs.User`
879
- - `ofs.Utilities`
880
- - `ofs.WorkZone`
881
- - `ofs.metadata`
1013
+ const activities = await ofs.Activity.getAllActivities(
1014
+ process.env.CLIENT_ID,
1015
+ process.env.CLIENT_SECRET,
1016
+ process.env.INSTANCE_NAME,
1017
+ "US",
1018
+ "2025-11-01",
1019
+ "2025-11-30",
1020
+ );
1021
+
1022
+ await ofs.Activity.startActivity(
1023
+ process.env.CLIENT_ID,
1024
+ process.env.CLIENT_SECRET,
1025
+ process.env.INSTANCE_NAME,
1026
+ 123456,
1027
+ );
1028
+
1029
+ const meta = ofs.metadata;
1030
+ const activityTypes = await meta.getActivityTypesMetaData(
1031
+ process.env.CLIENT_ID,
1032
+ process.env.CLIENT_SECRET,
1033
+ process.env.INSTANCE_NAME,
1034
+ );
1035
+ ```
882
1036
 
883
1037
  ## Metadata namespace
884
1038