ofsc-utility 1.0.28 → 1.0.30

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.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Fetch enumeration metadata for a specific property label.
3
+ *
4
+ * This helper will page through the OFSC metadata API until all enumeration
5
+ * values are retrieved for the requested property label.
6
+ *
7
+ * @param clientId - OFSC client ID
8
+ * @param clientSecret - OFSC client secret
9
+ * @param instanceUrl - OFSC instance host portion
10
+ * @param label - property label used to fetch enumeration values
11
+ * @param allUsedPropes - collection of properties used in other metadata sheets
12
+ * @param token - optional existing OAuth token
13
+ * @returns array of enumeration rows for the property
14
+ */
15
+ export declare function getPropertiesDropDownMetaData(clientId: string, clientSecret: string, instanceUrl: string, label: string, allUsedPropes: any[], token?: string): Promise<any[]>;
16
+ /**
17
+ * Transform raw enumeration items into the final sheet row format.
18
+ *
19
+ * The output is a simple array of enumeration rows, and each row includes the
20
+ * property label, enumeration label, active flag, and translated name.
21
+ *
22
+ * @param data - raw enumeration items returned by the API
23
+ * @param allUsedPropes - collection of properties used elsewhere, used for comments
24
+ * @param label - parent property label for this enumeration list
25
+ * @returns transformed enumeration rows
26
+ */
27
+ export declare function transformData(data: any[], allUsedPropes: any[], label: string): Promise<any[]>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPropertiesDropDownMetaData = getPropertiesDropDownMetaData;
4
+ exports.transformData = transformData;
5
+ const utilities_1 = require("../utilities");
6
+ /**
7
+ * Fetch enumeration metadata for a specific property label.
8
+ *
9
+ * This helper will page through the OFSC metadata API until all enumeration
10
+ * values are retrieved for the requested property label.
11
+ *
12
+ * @param clientId - OFSC client ID
13
+ * @param clientSecret - OFSC client secret
14
+ * @param instanceUrl - OFSC instance host portion
15
+ * @param label - property label used to fetch enumeration values
16
+ * @param allUsedPropes - collection of properties used in other metadata sheets
17
+ * @param token - optional existing OAuth token
18
+ * @returns array of enumeration rows for the property
19
+ */
20
+ async function getPropertiesDropDownMetaData(clientId, clientSecret, instanceUrl, label, allUsedPropes, token = "") {
21
+ let responsedata = [];
22
+ let offset = 0;
23
+ const limit = 100;
24
+ // Continue paging until the API indicates there are no more items.
25
+ while (true) {
26
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/properties/${label}/enumerationList?offset=${offset}&limit=${limit}`;
27
+ const res = await (0, utilities_1.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token);
28
+ // Keep the latest token for subsequent requests.
29
+ token = res.token;
30
+ if (res.data.items) {
31
+ responsedata = [...responsedata, ...res.data.items];
32
+ }
33
+ // If the API indicates there are no more items, exit the loop.
34
+ if (!res.data.hasMore)
35
+ break;
36
+ // Update the offset for the next page of results.
37
+ offset = res.data.offset + limit;
38
+ }
39
+ // Transform the raw enumeration data into the final sheet format.
40
+ return transformData(responsedata, allUsedPropes, label);
41
+ }
42
+ /**
43
+ * Transform raw enumeration items into the final sheet row format.
44
+ *
45
+ * The output is a simple array of enumeration rows, and each row includes the
46
+ * property label, enumeration label, active flag, and translated name.
47
+ *
48
+ * @param data - raw enumeration items returned by the API
49
+ * @param allUsedPropes - collection of properties used elsewhere, used for comments
50
+ * @param label - parent property label for this enumeration list
51
+ * @returns transformed enumeration rows
52
+ */
53
+ async function transformData(data, allUsedPropes, label) {
54
+ const overview = data.map(d => {
55
+ // Find all matching comments from the shared property usage data.
56
+ const comments = [
57
+ ...new Set(allUsedPropes
58
+ .filter((p) => p.label === d.label)
59
+ .map((p) => p.comment)
60
+ .filter(Boolean))
61
+ ].join(', ');
62
+ return {
63
+ propertyLabel: label,
64
+ Label: d.label,
65
+ active: d.active,
66
+ name: d.translations?.[0]?.name || '',
67
+ comments
68
+ };
69
+ });
70
+ return overview;
71
+ }
@@ -1,4 +1,4 @@
1
1
  type SheetData = Record<string, any[]>;
2
2
  export declare function getPropertiesMetaData(clientId: string, clientSecret: string, instanceUrl: string, allUsedPropes: any[], token?: string): Promise<SheetData>;
3
- export declare function transformData(data: any[], allUsedPropes: any[]): SheetData;
3
+ export declare function transformData(data: any[], allUsedPropes: any[], clientId: string, clientSecret: string, instanceUrl: string, token: string): Promise<SheetData>;
4
4
  export {};
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPropertiesMetaData = getPropertiesMetaData;
4
4
  exports.transformData = transformData;
5
5
  const utilities_1 = require("../utilities");
6
+ const enumerations_1 = require("./enumerations");
6
7
  async function getPropertiesMetaData(clientId, clientSecret, instanceUrl, allUsedPropes, token = "") {
7
8
  let responsedata = [];
8
9
  let offset = 0;
@@ -16,10 +17,10 @@ async function getPropertiesMetaData(clientId, clientSecret, instanceUrl, allUse
16
17
  break;
17
18
  offset = res.data.offset + limit;
18
19
  }
19
- const sheet = transformData(responsedata, allUsedPropes);
20
+ const sheet = transformData(responsedata, allUsedPropes, clientId, clientSecret, instanceUrl, token);
20
21
  return sheet;
21
22
  }
22
- function transformData(data, allUsedPropes) {
23
+ async function transformData(data, allUsedPropes, clientId, clientSecret, instanceUrl, token) {
23
24
  const sheets = {};
24
25
  // Sheet 1: Activity Type Groups Overview
25
26
  const overview = data.map(d => {
@@ -41,5 +42,14 @@ function transformData(data, allUsedPropes) {
41
42
  };
42
43
  });
43
44
  sheets['Properties Overview'] = overview;
45
+ const dropDownData = [];
46
+ const enumerationProps = overview.filter((prop) => prop["Data Type"] === 'enumeration');
47
+ console.log(`Found ${enumerationProps.length} enumeration properties to fetch dropdown data for.`);
48
+ for (const prop of enumerationProps) {
49
+ // Process each property
50
+ let enums = await (0, enumerations_1.getPropertiesDropDownMetaData)(clientId, clientSecret, instanceUrl, prop.Label, allUsedPropes, token);
51
+ dropDownData.push(...enums);
52
+ }
53
+ sheets['Properties Enumerations'] = dropDownData;
44
54
  return sheets;
45
55
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Example script to generate the OFSC metadata configuration file using the `src/metadata` helpers.
3
+ *
4
+ * Environment variables:
5
+ * - CLIENT_ID
6
+ * - CLIENT_SECRET
7
+ * - INSTANCE_URL (host portion, e.g. example-instance)
8
+ * - OUTPUT_FILE_NAME (optional)
9
+ *
10
+ * compile + run:
11
+ * tsc && node dist/metadata/scripts/create-configuration-example.js
12
+ */
13
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Example script to generate the OFSC metadata configuration file using the `src/metadata` helpers.
4
+ *
5
+ * Environment variables:
6
+ * - CLIENT_ID
7
+ * - CLIENT_SECRET
8
+ * - INSTANCE_URL (host portion, e.g. example-instance)
9
+ * - OUTPUT_FILE_NAME (optional)
10
+ *
11
+ * compile + run:
12
+ * tsc && node dist/metadata/scripts/create-configuration-example.js
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const __1 = require("..");
16
+ const clientId = process.env.CLIENT_ID;
17
+ const clientSecret = process.env.CLIENT_SECRET;
18
+ const instanceUrl = process.env.INSTANCE_URL;
19
+ const fileName = process.env.OUTPUT_FILE_NAME || "OFSC_CONFIGURATION_SHEET.xlsx";
20
+ if (!clientId || !clientSecret || !instanceUrl) {
21
+ console.error("Missing required env vars: CLIENT_ID, CLIENT_SECRET, INSTANCE_URL");
22
+ process.exit(1);
23
+ }
24
+ (async () => {
25
+ try {
26
+ console.log("Generating OFSC metadata configuration file...");
27
+ await (0, __1.createConfigurationFile)(clientId, clientSecret, instanceUrl, fileName);
28
+ console.log(`Configuration workbook saved to ${fileName}`);
29
+ }
30
+ catch (err) {
31
+ console.error("Error generating metadata configuration file:", err);
32
+ process.exit(2);
33
+ }
34
+ })();
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Example script to fetch properties metadata using `src/metadata/properties.ts`.
3
+ *
4
+ * Environment variables:
5
+ * - CLIENT_ID
6
+ * - CLIENT_SECRET
7
+ * - INSTANCE_URL (host portion, e.g. example-instance)
8
+ * - ALL_USED_PROPES_PATH (optional) - local JSON file path containing an array of property usage records
9
+ * - OUTPUT_FILE_NAME (optional) - save JSON output to this file
10
+ *
11
+ * compile + run:
12
+ * source src/events/scripts/.env
13
+ * tsc && node dist/metadata/scripts/fetch-properties-example.js
14
+ */
15
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * Example script to fetch properties metadata using `src/metadata/properties.ts`.
4
+ *
5
+ * Environment variables:
6
+ * - CLIENT_ID
7
+ * - CLIENT_SECRET
8
+ * - INSTANCE_URL (host portion, e.g. example-instance)
9
+ * - ALL_USED_PROPES_PATH (optional) - local JSON file path containing an array of property usage records
10
+ * - OUTPUT_FILE_NAME (optional) - save JSON output to this file
11
+ *
12
+ * compile + run:
13
+ * source src/events/scripts/.env
14
+ * tsc && node dist/metadata/scripts/fetch-properties-example.js
15
+ */
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const fs_1 = __importDefault(require("fs"));
21
+ const path_1 = __importDefault(require("path"));
22
+ const __1 = require("..");
23
+ const clientId = process.env.CLIENT_ID;
24
+ const clientSecret = process.env.CLIENT_SECRET;
25
+ const instanceUrl = process.env.INSTANCE_URL;
26
+ const allUsedPropesPath = process.env.ALL_USED_PROPES_PATH;
27
+ const outputFileName = process.env.OUTPUT_FILE_NAME;
28
+ if (!clientId || !clientSecret || !instanceUrl) {
29
+ console.error("Missing required env vars: CLIENT_ID, CLIENT_SECRET, INSTANCE_URL");
30
+ process.exit(1);
31
+ }
32
+ function loadAllUsedPropes() {
33
+ if (!allUsedPropesPath) {
34
+ return [];
35
+ }
36
+ const resolvedPath = path_1.default.isAbsolute(allUsedPropesPath)
37
+ ? allUsedPropesPath
38
+ : path_1.default.resolve(process.cwd(), allUsedPropesPath);
39
+ if (!fs_1.default.existsSync(resolvedPath)) {
40
+ console.error(`ALL_USED_PROPES_PATH file not found: ${resolvedPath}`);
41
+ process.exit(1);
42
+ }
43
+ try {
44
+ const fileContents = fs_1.default.readFileSync(resolvedPath, "utf8");
45
+ const parsed = JSON.parse(fileContents);
46
+ if (!Array.isArray(parsed)) {
47
+ throw new Error("Expected JSON array");
48
+ }
49
+ return parsed;
50
+ }
51
+ catch (err) {
52
+ console.error("Failed to read ALL_USED_PROPES_PATH:", err);
53
+ process.exit(1);
54
+ }
55
+ }
56
+ (async () => {
57
+ try {
58
+ const allUsedPropes = loadAllUsedPropes();
59
+ console.log("Fetching properties metadata...");
60
+ const response = await (0, __1.getPropertiesMetaData)(clientId, clientSecret, instanceUrl, allUsedPropes);
61
+ console.log("Properties metadata response:");
62
+ console.log(JSON.stringify(response, null, 2));
63
+ if (outputFileName) {
64
+ fs_1.default.writeFileSync(outputFileName, JSON.stringify(response, null, 2), "utf8");
65
+ console.log(`Saved response to ${outputFileName}`);
66
+ }
67
+ }
68
+ catch (err) {
69
+ console.error("Error fetching properties metadata:", err);
70
+ process.exit(2);
71
+ }
72
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofsc-utility",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "A wrapper for Oracle Field Service REST API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -1,15 +1,13 @@
1
- # Enhanced ofsc utility
1
+ # OFSC Utility
2
2
 
3
- A lightweight utility library for interacting with **Oracle Field Service Cloud (OFSC)**.
3
+ A small TypeScript wrapper for Oracle Field Service Cloud (OFSC) REST APIs.
4
4
 
5
- ## Features
5
+ This package exposes grouped API helpers for common OFSC operations, including:
6
6
 
7
- - 🚀 **40+ utility methods**
8
- - 📚 **Written in TypeScript** with full type definitions
9
- - 🧪 **Completely tested** with Jest
10
- - 📦 **Zero dependencies**
11
- - 🎯 **Modular architecture** for tree-shaking
12
- - 🔧 **Multiple import styles** for flexibility
7
+ - authentication
8
+ - export/download helpers
9
+ - inventory and activity records
10
+ - metadata file generation
13
11
 
14
12
  ## Installation
15
13
 
@@ -17,191 +15,285 @@ A lightweight utility library for interacting with **Oracle Field Service Cloud
17
15
  npm install ofsc-utility
18
16
  ```
19
17
 
20
- ## Functions implemented
18
+ ## Getting Started
21
19
 
22
- ### Download
20
+ 1. Install the package:
23
21
 
24
- Please see the code snippet below.
25
-
26
- #### csv
27
-
28
- downloadWorkZoneCSV(process.env.clientID, process.env.clientSecret, process.env.instanceId)
29
- downloadAllResourcesCSV(process.env.clientID, process.env.clientSecret, process.env.instanceId)
30
- downloadAllUsersCSV(process.env.clientID, process.env.clientSecret, process.env.instanceId)
31
- downloadAllInventoryTypesCSV(process.env.clientID, process.env.clientSecret, process.env.instanceId)
32
- downloadAllEventsOfDayCSV(process.env.clientID, process.env.clientSecret, process.env.instanceId, process.env.subscriptionId,"2025-12-05")
33
- // Download Collaboration groups assigned to users
34
- generateUsersCollaborationCSV(process.env.clientID, process.env.clientSecret, process.env.instanceId)
35
- // Download all resource's inventories
36
- generateAllOnHandInventoryOfAllResourcesCSV(process.env.clientID, process.env.clientSecret, process.env.instanceId)
22
+ ```bash
23
+ npm install ofsc-utility
24
+ ```
37
25
 
38
- #### records
26
+ 2. Create a `.env` file or export environment variables in your shell:
39
27
 
40
- getOAuthToken("clientId", "clientSecret", "instanceId")
41
- getInventoryTypesDetail("clientId", "clientSecret", "instanceId"."inventory_label")
42
- updateCreateInventoryType("clientId", "clientSecret", "instanceId"."inventory_label")
43
- getAllActivities("clientId", "clientSecret", "instanceId"."resources","dateFrom","dateTo","q","fields")
44
- getActivityCustomerInventories("clientId", "clientSecret", "instanceId"."activityId")
45
- createActivityCustomerInventories( "clientId", "clientSecret", "instanceId"."activityId","payload")
46
- downloadAllEventsOfDay(process.env.clientID, process.env.clientSecret, process.env.instanceId, process.env.subscriptionId,"2025-12-05")
47
- getActivitybyId("clientId", "clientSecret", "instanceId"."activityId")
28
+ ```bash
29
+ export CLIENT_ID=yourClientId
30
+ export CLIENT_SECRET=yourClientSecret
31
+ export INSTANCE_NAME=yourInstanceName
32
+ export SUBSCRIPTION_ID=yourSubscriptionId
33
+ ```
48
34
 
49
- ### Technical Design Doc - Configurations
35
+ 3. Create a file such as `example.js` and add the sample code below.
50
36
 
51
- // It will create a techncial configuration file
52
- createConfigurationFile(process.env.clientID, process.env.clientSecreat,process.env.instanceId,"OFSC_CONFIGURATION_SHEET.xlsx")
37
+ 4. Run the example:
53
38
 
54
- ## Usage
39
+ ```bash
40
+ node example.js
41
+ ```
55
42
 
56
- downloadWorkZoneCSV("bot", "XXXXXXXXX", "compXXX.test")
43
+ ## Quick Start
57
44
 
58
45
  ### CommonJS
59
46
 
60
47
  ```js
61
48
  const ofs = require("ofsc-utility");
62
49
 
63
- ofs.User.generateUsersCollaborationCSV(
64
- process.env.clientID,
65
- process.env.clientSecret,
66
- process.env.instanceId,
67
- process.env.subscriptionId
68
- );
50
+ async function main() {
51
+ const token = await ofs.getOAuthToken(
52
+ "CLIENT_ID",
53
+ "CLIENT_SECRET",
54
+ "INSTANCE_NAME",
55
+ );
56
+ console.log("OAuth token:", token);
57
+ }
58
+
59
+ main().catch(console.error);
69
60
  ```
70
61
 
62
+ ### ES Modules
63
+
71
64
  ```js
72
- async function run() {
73
- let data = await ofs.InventoryType.getInventoryTypesDetail("clientId", "clientSecret", "instanceId", "inventory_label");
74
- console.error(data);
65
+ import ofs from "ofsc-utility";
66
+
67
+ async function main() {
68
+ const token = await ofs.getOAuthToken(
69
+ "CLIENT_ID",
70
+ "CLIENT_SECRET",
71
+ "INSTANCE_NAME",
72
+ );
73
+ console.log("OAuth token:", token);
75
74
  }
76
- run();
75
+
76
+ main().catch(console.error);
77
77
  ```
78
78
 
79
- ```js
80
- const ofs = require("ofsc-utility");
79
+ ## Complete Example
81
80
 
82
- ofs
83
- .getOAuthToken("clientId", "clientSecret", "instanceId")
84
- .then((token) => {
85
- console.log(token);
86
- })
87
- .catch((err) => {
88
- console.error("Error fetching token:", err);
89
- });
90
- ```
81
+ This example shows a full CommonJS script that retrieves activity type metadata and prints the result.
91
82
 
92
83
  ```js
93
84
  const ofs = require("ofsc-utility");
94
85
 
95
- ofs.WorkZone.downloadWorkZoneCSV("clientId", "clientSecret", "instanceId")
96
- .then(() => {
97
- console.log("successful");
98
- })
99
- .catch((err) => {
100
- console.error("Error:", err);
101
- });
86
+ async function main() {
87
+ const clientId = process.env.CLIENT_ID;
88
+ const clientSecret = process.env.CLIENT_SECRET;
89
+ const instanceUrl = process.env.INSTANCE_NAME;
90
+
91
+ if (!clientId || !clientSecret || !instanceUrl) {
92
+ throw new Error(
93
+ "Please set CLIENT_ID, CLIENT_SECRET and INSTANCE_NAME environment variables",
94
+ );
95
+ }
96
+
97
+ const activityTypes = await ofs.metadata.getActivityTypesMetaData(
98
+ clientId,
99
+ clientSecret,
100
+ instanceUrl,
101
+ );
102
+
103
+ console.log("Activity type metadata:");
104
+ console.log(JSON.stringify(activityTypes, null, 2));
105
+ }
106
+
107
+ main().catch((error) => {
108
+ console.error("Error running example:", error);
109
+ process.exit(1);
110
+ });
102
111
  ```
103
112
 
104
- ```js
105
- const ofs = require("ofsc-utility");
113
+ ## Usage
114
+
115
+ ### Authentication
106
116
 
107
- ofs
108
- .downloadAllResourcesCSV("clientId", "clientSecret", "instanceId")
109
- .then(() => {
110
- console.log("successful");
111
- })
112
- .catch((err) => {
113
- console.error("Error:", err);
114
- });
117
+ ```js
118
+ const token = await ofs.getOAuthToken(
119
+ process.env.CLIENT_ID,
120
+ process.env.CLIENT_SECRET,
121
+ process.env.INSTANCE_NAME,
122
+ );
115
123
  ```
116
124
 
125
+ ### Download CSV files
126
+
117
127
  ```js
118
- const ofs = require("ofsc-utility");
128
+ await ofs.downloadWorkZoneCSV(
129
+ process.env.CLIENT_ID,
130
+ process.env.CLIENT_SECRET,
131
+ process.env.INSTANCE_NAME,
132
+ );
133
+
134
+ await ofs.downloadAllResourcesCSV(
135
+ process.env.CLIENT_ID,
136
+ process.env.CLIENT_SECRET,
137
+ process.env.INSTANCE_NAME,
138
+ );
119
139
 
120
- ofs
121
- .downloadAllUsersCSV("clientId", "clientSecret", "instanceId")
122
- .then(() => {
123
- console.log("successful");
124
- })
125
- .catch((err) => {
126
- console.error("Error:", err);
127
- });
140
+ await ofs.downloadAllUsersCSV(
141
+ process.env.CLIENT_ID,
142
+ process.env.CLIENT_SECRET,
143
+ process.env.INSTANCE_NAME,
144
+ );
128
145
  ```
129
146
 
147
+ ### Activity and inventory helpers
148
+
130
149
  ```js
131
- const ofs = require("ofsc-utility");
150
+ const activities = await ofs.getAllActivities(
151
+ process.env.CLIENT_ID,
152
+ process.env.CLIENT_SECRET,
153
+ process.env.INSTANCE_NAME,
154
+ "US",
155
+ "2025-11-01",
156
+ "2025-11-30",
157
+ "status=='pending'",
158
+ "activityId,activityType,date,status",
159
+ );
132
160
 
133
- async function run() {
134
- const payload = {
135
- label: "inventory_label",
136
- name: "Ordered Part",
137
- unitOfMeasurement: "ea",
138
- active: true,
139
- nonSerialized: true,
140
- modelProperty: "part_item_number_rev",
141
- quantityPrecision: 0,
142
- translations: [
143
- {
144
- language: "en",
145
- name: "Ordered Part",
146
- unitOfMeasurement: "ea",
147
- languageISO: "en-US",
148
- },
149
- ],
150
- };
151
-
152
- try {
153
- const result = await updateCreateInventoryType("CLIENT_ID", "CLIENT_SECRET", "INSTANCE_URL", "inventory_label", payload);
154
-
155
- console.log("Updated:", result);
156
- } catch (err) {
157
- console.error(err);
158
- }
159
- }
161
+ const activityData = await ofs.getActivitybyId(
162
+ process.env.CLIENT_ID,
163
+ process.env.CLIENT_SECRET,
164
+ process.env.INSTANCE_NAME,
165
+ "ACTIVITY_ID",
166
+ );
160
167
 
161
- run();
168
+ const inventoryDetail = await ofs.InventoryType.getInventoryTypesDetail(
169
+ process.env.CLIENT_ID,
170
+ process.env.CLIENT_SECRET,
171
+ process.env.INSTANCE_NAME,
172
+ "inventory_label",
173
+ );
162
174
  ```
163
175
 
176
+ ### Create a configuration workbook
177
+
164
178
  ```js
165
- const ofs = require("ofsc-utility");
166
- async function run() {
167
- try {
168
- const result = await ofs.getAllActivities(
169
- (clientId = "CLIENT_ID"),
170
- (clientSecret = "CLIENT_SECRET"),
171
- (instanceUrl = "INSTANCE_URL"),
172
- (resources = "US"),
173
- (dateFrom = "2025-11-05"),
174
- (dateTo = "2025-12-05"),
175
- (q = "status=='pending' and ACTIVITY_NOTES!=''"),
176
- (fields = "ACTIVITY_NOTES,status,activityId,activityType,date,resourceId")
177
- );
179
+ await ofs.createConfigurationFile(
180
+ process.env.CLIENT_ID,
181
+ process.env.CLIENT_SECRET,
182
+ process.env.INSTANCE_NAME,
183
+ "OFSC_CONFIGURATION_SHEET.xlsx",
184
+ );
185
+ ```
178
186
 
179
- console.log("Updated:", result);
180
- } catch (err) {
181
- console.error(err);
182
- }
183
- }
187
+ ### Metadata helpers
184
188
 
185
- run();
186
- ```
189
+ The `metadata` group exposes metadata-specific retrieval helpers.
187
190
 
188
191
  ```js
189
- ofs.getActivityCustomerInventories("CLIENT_ID", "CLIENT_SECRET", "INSTANCE_URL", "activityId").then((data) => {
190
- console.log(data);
191
- });
192
+ const meta = ofs.metadata;
193
+
194
+ const activityTypes = await meta.getActivityTypesMetaData(
195
+ process.env.CLIENT_ID,
196
+ process.env.CLIENT_SECRET,
197
+ process.env.INSTANCE_NAME,
198
+ );
199
+
200
+ const activityGroups = await meta.getActivityTypesGroupsMetaData(
201
+ process.env.CLIENT_ID,
202
+ process.env.CLIENT_SECRET,
203
+ process.env.INSTANCE_NAME,
204
+ );
205
+
206
+ const workZones = await meta.getWorkZonesMetaData(
207
+ process.env.CLIENT_ID,
208
+ process.env.CLIENT_SECRET,
209
+ process.env.INSTANCE_NAME,
210
+ );
192
211
  ```
193
212
 
213
+ ### Namespace-style imports
214
+
194
215
  ```js
195
216
  const ofs = require("ofsc-utility");
196
- ofs.Events.downloadAllEventsOfDayCSV(
197
- process.env.clientID,
198
- process.env.clientSecret,
199
- process.env.instanceId,
200
- process.env.subscriptionId,
201
- "2025-12-05"
217
+
218
+ await ofs.WorkZone.downloadWorkZoneCSV(
219
+ process.env.CLIENT_ID,
220
+ process.env.CLIENT_SECRET,
221
+ process.env.INSTANCE_NAME,
222
+ );
223
+
224
+ await ofs.User.generateUsersCollaborationCSV(
225
+ process.env.CLIENT_ID,
226
+ process.env.CLIENT_SECRET,
227
+ process.env.INSTANCE_NAME,
228
+ process.env.SUBSCRIPTION_ID,
202
229
  );
203
230
  ```
204
231
 
232
+ ## Available exports
233
+
234
+ Top-level exports include:
235
+
236
+ - `getOAuthToken`
237
+ - `downloadWorkZoneCSV`
238
+ - `downloadAllResourcesCSV`
239
+ - `downloadAllUsersCSV`
240
+ - `downloadAllInventoryTypesCSV`
241
+ - `getInventoryTypesDetail`
242
+ - `updateCreateInventoryType`
243
+ - `getAllActivities`
244
+ - `getActivitybyId`
245
+ - `getActivityCustomerInventories`
246
+ - `createActivityCustomerInventories`
247
+ - `downloadAllEventsOfDay`
248
+ - `downloadAllEventsOfDayCSV`
249
+ - `createExcelFile`
250
+ - `createConfigurationFile`
251
+
252
+ Grouped exports include:
253
+
254
+ - `ofs.Activity`
255
+ - `ofs.ActivityInventories`
256
+ - `ofs.Events`
257
+ - `ofs.Inventory`
258
+ - `ofs.InventoryType`
259
+ - `ofs.OauthTokenService`
260
+ - `ofs.Resource`
261
+ - `ofs.User`
262
+ - `ofs.Utilities`
263
+ - `ofs.WorkZone`
264
+ - `ofs.metadata`
265
+
266
+ ## Metadata namespace
267
+
268
+ The `metadata` object exposes metadata helpers such as:
269
+
270
+ - `getActivityTypesMetaData`
271
+ - `getActivityTypesGroupsMetaData`
272
+ - `getApplictaionsIntegrationsDetailMetaData`
273
+ - `getCapacityMetaData`
274
+ - `getFormsMetaData`
275
+ - `getInventoryTypesMetaData`
276
+ - `getPropertiesMetaData`
277
+ - `getResourceTypesMetaData`
278
+ - `getShiftMetaData`
279
+ - `getTimeSlotsMetaData`
280
+ - `getWorkSkillsMetaData`
281
+ - `getWorkZoneKeyMetaData`
282
+ - `getWorkZonesMetaData`
283
+ - `createConfigurationFile`
284
+
285
+ ## Notes
286
+
287
+ - `instanceUrl` is the OFSC instance name only, not the full URL. For example: `mycompany` for `mycompany.fs.ocs.oraclecloud.com`.
288
+ - All API helper methods accept the same `clientId`, `clientSecret`, and `instanceUrl` parameters at minimum.
289
+ - Most helper methods return a promise and should be used with `await` or `.then()`.
290
+
291
+ ## Testing
292
+
293
+ ```bash
294
+ npm test
295
+ ```
296
+
205
297
  ## License
206
298
 
207
299
  MIT