ofsc-utility 1.0.10 → 1.0.11
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/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/users/collaborationGroups.d.ts +1 -0
- package/dist/users/collaborationGroups.js +70 -0
- package/dist/users/index.d.ts +6 -0
- package/dist/users/index.js +8 -0
- package/package.json +1 -1
- package/readme.md +12 -0
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export * from './types';
|
|
|
11
11
|
export { getOAuthToken } from './oauthTokenService';
|
|
12
12
|
export { downloadWorkZoneCSV } from './workZones';
|
|
13
13
|
export { downloadAllResourcesCSV } from './resources';
|
|
14
|
-
export { downloadAllUsersCSV } from './users';
|
|
14
|
+
export { downloadAllUsersCSV, generateUsersCollaborationCSV } from './users';
|
|
15
15
|
export { downloadAllInventoryTypesCSV, getInventoryTypesDetail, updateCreateInventoryType } from './inventoryTypes';
|
|
16
16
|
export { getAllActivities } from './activities';
|
|
17
17
|
export { createActivityCustomerInventories, getActivityCustomerInventories } from './activityInventories';
|
|
@@ -29,5 +29,6 @@ declare const OfscUtility: {
|
|
|
29
29
|
createActivityCustomerInventories: any;
|
|
30
30
|
downloadAllEventsOfDayCSV: any;
|
|
31
31
|
downloadAllEventsOfDay: any;
|
|
32
|
+
generateUsersCollaborationCSV: any;
|
|
32
33
|
};
|
|
33
34
|
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.downloadAllUsersCSV = exports.downloadAllResourcesCSV = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.WorkZone = exports.CSV = exports.User = exports.Resource = exports.OauthTokenService = exports.InventoryType = exports.Events = exports.ActivityInventories = exports.Activity = void 0;
|
|
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.WorkZone = exports.CSV = exports.User = exports.Resource = exports.OauthTokenService = exports.InventoryType = 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"));
|
|
@@ -58,6 +58,7 @@ var resources_1 = require("./resources");
|
|
|
58
58
|
Object.defineProperty(exports, "downloadAllResourcesCSV", { enumerable: true, get: function () { return resources_1.downloadAllResourcesCSV; } });
|
|
59
59
|
var users_1 = require("./users");
|
|
60
60
|
Object.defineProperty(exports, "downloadAllUsersCSV", { enumerable: true, get: function () { return users_1.downloadAllUsersCSV; } });
|
|
61
|
+
Object.defineProperty(exports, "generateUsersCollaborationCSV", { enumerable: true, get: function () { return users_1.generateUsersCollaborationCSV; } });
|
|
61
62
|
var inventoryTypes_1 = require("./inventoryTypes");
|
|
62
63
|
Object.defineProperty(exports, "downloadAllInventoryTypesCSV", { enumerable: true, get: function () { return inventoryTypes_1.downloadAllInventoryTypesCSV; } });
|
|
63
64
|
Object.defineProperty(exports, "getInventoryTypesDetail", { enumerable: true, get: function () { return inventoryTypes_1.getInventoryTypesDetail; } });
|
|
@@ -83,6 +84,7 @@ const OfscUtility = {
|
|
|
83
84
|
getActivityCustomerInventories: require('./activityInventories').getActivityCustomerInventories,
|
|
84
85
|
createActivityCustomerInventories: require('./activityInventories').createActivityCustomerInventories,
|
|
85
86
|
downloadAllEventsOfDayCSV: require('./events').downloadAllEventsOfDayCSV,
|
|
86
|
-
downloadAllEventsOfDay: require('./events').downloadAllEventsOfDay
|
|
87
|
+
downloadAllEventsOfDay: require('./events').downloadAllEventsOfDay,
|
|
88
|
+
generateUsersCollaborationCSV: require('./users').generateUsersCollaborationCSV
|
|
87
89
|
};
|
|
88
90
|
exports.default = OfscUtility;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateUsersCollaborationCSV(clientId: string, clientSecret: string, instanceUrl: string): Promise<void>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateUsersCollaborationCSV = generateUsersCollaborationCSV;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const utilities_1 = require("../utilities");
|
|
9
|
+
async function generateUsersCollaborationCSV(clientId, clientSecret, instanceUrl) {
|
|
10
|
+
let offset = 0;
|
|
11
|
+
const limit = 100;
|
|
12
|
+
const allUsers = [];
|
|
13
|
+
let token = "";
|
|
14
|
+
console.log("🚀 Starting Users Collaboration Groups export...");
|
|
15
|
+
console.log("--------------------------------------------------");
|
|
16
|
+
while (true) {
|
|
17
|
+
const usersUrl = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${offset}&limit=${limit}`;
|
|
18
|
+
console.log(`➡️ Fetching users offset=${offset}`);
|
|
19
|
+
const res = await (0, utilities_1.fetchWithRetry)(usersUrl, clientId, clientSecret, instanceUrl, token);
|
|
20
|
+
token = res.token;
|
|
21
|
+
const data = res.data;
|
|
22
|
+
if (!data?.items?.length) {
|
|
23
|
+
console.warn("⚠ No user items returned. Breaking.");
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
allUsers.push(...data.items);
|
|
27
|
+
console.log(` ✔ Received ${data.items.length} users (Total: ${allUsers.length})`);
|
|
28
|
+
if (offset + limit >= data.totalResults)
|
|
29
|
+
break;
|
|
30
|
+
offset += limit;
|
|
31
|
+
}
|
|
32
|
+
console.log("--------------------------------------------------");
|
|
33
|
+
console.log(`🧩 Total users to process: ${allUsers.length}`);
|
|
34
|
+
console.log("--------------------------------------------------");
|
|
35
|
+
// 2. Fetch collaboration groups for each user
|
|
36
|
+
const rows = [];
|
|
37
|
+
for (const user of allUsers) {
|
|
38
|
+
console.log(`👤 Fetching groups for ${user.login}`);
|
|
39
|
+
if (user.status !== "active") {
|
|
40
|
+
console.log(` ⚠ Skipping inactive user ${user.login}`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const groupUrl = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/${user.login}/collaborationGroups`;
|
|
45
|
+
const res = await (0, utilities_1.fetchWithRetry)(groupUrl, clientId, clientSecret, instanceUrl, token);
|
|
46
|
+
token = res.token;
|
|
47
|
+
const groupData = res.data;
|
|
48
|
+
const groups = groupData?.items ?? [];
|
|
49
|
+
if (groups.length === 0) {
|
|
50
|
+
console.log(` ⚠ No groups found for ${user.login}`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
for (const group of groups) {
|
|
54
|
+
rows.push({ ...group, login: user.login, userType: user.userType, timeZoneIANA: user.timeZoneIANA, userName: user.name });
|
|
55
|
+
}
|
|
56
|
+
console.log(` ✔ Found ${groups.length} groups`);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error(`❌ Error fetching groups for ${user.login}:`, err);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
console.log("--------------------------------------------------");
|
|
63
|
+
console.log(`📦 Total rows: ${rows.length}`);
|
|
64
|
+
console.log("--------------------------------------------------");
|
|
65
|
+
const ts = Math.floor(Date.now() / 1000);
|
|
66
|
+
const filename = `collaborationGroups_${ts}.csv`;
|
|
67
|
+
const fullPath = path_1.default.resolve(filename);
|
|
68
|
+
(0, utilities_1.saveCsv)(rows, filename);
|
|
69
|
+
console.log(`📁 CSV saved: ${fullPath}`);
|
|
70
|
+
}
|
package/dist/users/index.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
1
|
export declare function downloadAllUsersCSV(clientId: string, clientSecret: string, instanceUrl: string): Promise<void>;
|
|
2
|
+
export { generateUsersCollaborationCSV } from './collaborationGroups';
|
|
3
|
+
declare const OfscUserUtility: {
|
|
4
|
+
generateUsersCollaborationCSV: any;
|
|
5
|
+
downloadAllUsersCSV: typeof downloadAllUsersCSV;
|
|
6
|
+
};
|
|
7
|
+
export default OfscUserUtility;
|
package/dist/users/index.js
CHANGED
|
@@ -36,6 +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.generateUsersCollaborationCSV = void 0;
|
|
39
40
|
exports.downloadAllUsersCSV = downloadAllUsersCSV;
|
|
40
41
|
const fs = __importStar(require("fs"));
|
|
41
42
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
@@ -113,3 +114,10 @@ async function downloadAllUsersCSV(clientId, clientSecret, instanceUrl) {
|
|
|
113
114
|
console.log(`🧩 Date Time: ${new Date()}`);
|
|
114
115
|
console.log("-------------------------------------");
|
|
115
116
|
}
|
|
117
|
+
var collaborationGroups_1 = require("./collaborationGroups");
|
|
118
|
+
Object.defineProperty(exports, "generateUsersCollaborationCSV", { enumerable: true, get: function () { return collaborationGroups_1.generateUsersCollaborationCSV; } });
|
|
119
|
+
const OfscUserUtility = {
|
|
120
|
+
generateUsersCollaborationCSV: require('./collaborationGroups').generateUsersCollaborationCSV,
|
|
121
|
+
downloadAllUsersCSV
|
|
122
|
+
};
|
|
123
|
+
exports.default = OfscUserUtility;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -30,6 +30,7 @@ Please see the code snippet below.
|
|
|
30
30
|
downloadAllUsersCSV(process.env.clientID, process.env.clientSecreat, process.env.instanceId)
|
|
31
31
|
downloadAllInventoryTypesCSV(process.env.clientID, process.env.clientSecreat, process.env.instanceId)
|
|
32
32
|
downloadAllEventsOfDayCSV(process.env.clientID, process.env.clientSecreat, process.env.instanceId, process.env.subscriptionId,"2025-12-05")
|
|
33
|
+
generateUsersCollaborationCSV(process.env.clientID, process.env.clientSecreat, process.env.instanceId) // all Collaboration groups of a user
|
|
33
34
|
|
|
34
35
|
#### records
|
|
35
36
|
|
|
@@ -47,6 +48,17 @@ downloadWorkZoneCSV("bot", "XXXXXXXXX", "compXXX.test")
|
|
|
47
48
|
|
|
48
49
|
### CommonJS
|
|
49
50
|
|
|
51
|
+
```js
|
|
52
|
+
const ofs = require("ofsc-utility");
|
|
53
|
+
|
|
54
|
+
ofs.User.generateUsersCollaborationCSV(
|
|
55
|
+
process.env.clientID,
|
|
56
|
+
process.env.clientSecreat,
|
|
57
|
+
process.env.instanceId,
|
|
58
|
+
process.env.subscriptionId
|
|
59
|
+
);
|
|
60
|
+
```
|
|
61
|
+
|
|
50
62
|
```js
|
|
51
63
|
async function run() {
|
|
52
64
|
let data = await ofs.InventoryType.getInventoryTypesDetail("clientId", "clientSecret", "instanceId", "inventory_label");
|