ofsc-utility 1.0.48 → 1.0.50
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 +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -1
- package/dist/users/index.d.ts +4 -0
- package/dist/users/index.js +21 -1
- package/package.json +1 -1
- package/readme.md +84 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,7 @@ 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
|
+
- add user management methods for standalone OFSC
|
|
13
14
|
- Update version and add resource management APIs
|
|
14
15
|
- version 1.0.47 and add resource APIs
|
|
15
16
|
- release v1.0.44 with getResource function and updated keywords
|
package/dist/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export * from './types';
|
|
|
13
13
|
export { generateAllOnHandInventoryOfAllResources, generateAllOnHandInventoryOfAllResourcesCSV } from './inventory';
|
|
14
14
|
export { getOAuthToken } from './oauthTokenService';
|
|
15
15
|
export { downloadWorkZoneCSV } from './workZones';
|
|
16
|
-
export { AllResources, downloadAllResourcesCSV, getResourcebyId, getworkSkillsOfResource } from './resources';
|
|
17
|
-
export { downloadAllInactiveUsers, downloadAllInactiveUsersCSV, downloadAllUsersCSV, generateUsersCollaborationCSV } from './users';
|
|
16
|
+
export { AllResources, downloadAllResourcesCSV, getResourcebyId, getworkSkillsOfResource, updateResourcebyId } from './resources';
|
|
17
|
+
export { downloadAllInactiveUsers, downloadAllInactiveUsersCSV, downloadAllUsersCSV, generateUsersCollaborationCSV, getUserByLogin, updateUserbyLogin } from './users';
|
|
18
18
|
export { downloadAllInventoryTypesCSV, getInventoryTypesDetail, updateCreateInventoryType } from './inventoryTypes';
|
|
19
19
|
export { getActivitybyId, getAllActivities } from './activities';
|
|
20
20
|
export { createActivityCustomerInventories, getActivityCustomerInventories } from './activityInventories';
|
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.generateUsersCollaborationCSV = exports.downloadAllUsersCSV = exports.downloadAllInactiveUsersCSV = exports.downloadAllInactiveUsers = 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.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"));
|
|
@@ -63,11 +63,14 @@ Object.defineProperty(exports, "AllResources", { enumerable: true, get: function
|
|
|
63
63
|
Object.defineProperty(exports, "downloadAllResourcesCSV", { enumerable: true, get: function () { return resources_1.downloadAllResourcesCSV; } });
|
|
64
64
|
Object.defineProperty(exports, "getResourcebyId", { enumerable: true, get: function () { return resources_1.getResourcebyId; } });
|
|
65
65
|
Object.defineProperty(exports, "getworkSkillsOfResource", { enumerable: true, get: function () { return resources_1.getworkSkillsOfResource; } });
|
|
66
|
+
Object.defineProperty(exports, "updateResourcebyId", { enumerable: true, get: function () { return resources_1.updateResourcebyId; } });
|
|
66
67
|
var users_1 = require("./users");
|
|
67
68
|
Object.defineProperty(exports, "downloadAllInactiveUsers", { enumerable: true, get: function () { return users_1.downloadAllInactiveUsers; } });
|
|
68
69
|
Object.defineProperty(exports, "downloadAllInactiveUsersCSV", { enumerable: true, get: function () { return users_1.downloadAllInactiveUsersCSV; } });
|
|
69
70
|
Object.defineProperty(exports, "downloadAllUsersCSV", { enumerable: true, get: function () { return users_1.downloadAllUsersCSV; } });
|
|
70
71
|
Object.defineProperty(exports, "generateUsersCollaborationCSV", { enumerable: true, get: function () { return users_1.generateUsersCollaborationCSV; } });
|
|
72
|
+
Object.defineProperty(exports, "getUserByLogin", { enumerable: true, get: function () { return users_1.getUserByLogin; } });
|
|
73
|
+
Object.defineProperty(exports, "updateUserbyLogin", { enumerable: true, get: function () { return users_1.updateUserbyLogin; } });
|
|
71
74
|
var inventoryTypes_1 = require("./inventoryTypes");
|
|
72
75
|
Object.defineProperty(exports, "downloadAllInventoryTypesCSV", { enumerable: true, get: function () { return inventoryTypes_1.downloadAllInventoryTypesCSV; } });
|
|
73
76
|
Object.defineProperty(exports, "getInventoryTypesDetail", { enumerable: true, get: function () { return inventoryTypes_1.getInventoryTypesDetail; } });
|
package/dist/users/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResourceResponse } from "../types";
|
|
1
2
|
export declare function downloadAllUsersCSV(clientId: string, clientSecret: string, instanceUrl: string): Promise<void>;
|
|
2
3
|
export { generateUsersCollaborationCSV } from './collaborationGroups';
|
|
3
4
|
declare const OfscUserUtility: {
|
|
@@ -5,7 +6,10 @@ declare const OfscUserUtility: {
|
|
|
5
6
|
downloadAllUsersCSV: typeof downloadAllUsersCSV;
|
|
6
7
|
downloadAllInactiveUsersCSV: typeof downloadAllInactiveUsersCSV;
|
|
7
8
|
downloadAllInactiveUsers: typeof downloadAllInactiveUsers;
|
|
9
|
+
getUserByLogin: typeof getUserByLogin;
|
|
8
10
|
};
|
|
9
11
|
export declare function downloadAllInactiveUsersCSV(clientId: string, clientSecret: string, instanceUrl: string, inactivityThresholdDays?: number): Promise<void>;
|
|
10
12
|
export declare function downloadAllInactiveUsers(clientId: string, clientSecret: string, instanceUrl: string, inactivityThresholdDays?: number): Promise<Record<string, any>[]>;
|
|
13
|
+
export declare function getUserByLogin(login: string, clientId: string, clientSecret: string, instanceUrl: string, initialToken?: string): Promise<any>;
|
|
14
|
+
export declare function updateUserbyLogin(login: string, clientId: string, clientSecret: string, instanceUrl: string, initialToken: string | undefined, payload: {}): Promise<ResourceResponse>;
|
|
11
15
|
export default OfscUserUtility;
|
package/dist/users/index.js
CHANGED
|
@@ -40,6 +40,8 @@ exports.generateUsersCollaborationCSV = void 0;
|
|
|
40
40
|
exports.downloadAllUsersCSV = downloadAllUsersCSV;
|
|
41
41
|
exports.downloadAllInactiveUsersCSV = downloadAllInactiveUsersCSV;
|
|
42
42
|
exports.downloadAllInactiveUsers = downloadAllInactiveUsers;
|
|
43
|
+
exports.getUserByLogin = getUserByLogin;
|
|
44
|
+
exports.updateUserbyLogin = updateUserbyLogin;
|
|
43
45
|
const fs = __importStar(require("fs"));
|
|
44
46
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
45
47
|
const index_1 = require("../oauthTokenService/index");
|
|
@@ -123,7 +125,8 @@ const OfscUserUtility = {
|
|
|
123
125
|
generateUsersCollaborationCSV: require('./collaborationGroups').generateUsersCollaborationCSV,
|
|
124
126
|
downloadAllUsersCSV,
|
|
125
127
|
downloadAllInactiveUsersCSV,
|
|
126
|
-
downloadAllInactiveUsers
|
|
128
|
+
downloadAllInactiveUsers,
|
|
129
|
+
getUserByLogin
|
|
127
130
|
};
|
|
128
131
|
/**
|
|
129
132
|
* Returns true if the user is "inactive":
|
|
@@ -292,4 +295,21 @@ async function downloadAllInactiveUsers(clientId, clientSecret, instanceUrl, ina
|
|
|
292
295
|
console.log("-------------------------------------");
|
|
293
296
|
return result;
|
|
294
297
|
}
|
|
298
|
+
// /rest/ofscCore/v1/users/{login}
|
|
299
|
+
async function getUserByLogin(login, clientId, clientSecret, instanceUrl, initialToken = "") {
|
|
300
|
+
const fetchUser = async (offset, token) => {
|
|
301
|
+
const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/${encodeURIComponent(login)}?offset=${offset}&limit=100`;
|
|
302
|
+
const res = await (0, index_2.fetchWithRetry)(url, clientId, clientSecret, instanceUrl, token);
|
|
303
|
+
return res.data;
|
|
304
|
+
};
|
|
305
|
+
return fetchUser(0, initialToken);
|
|
306
|
+
}
|
|
307
|
+
async function updateUserbyLogin(login, clientId, clientSecret, instanceUrl, initialToken = "", payload) {
|
|
308
|
+
const fetchUser = async (offset, token) => {
|
|
309
|
+
const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/${encodeURIComponent(login)}`;
|
|
310
|
+
const res = await (0, index_2.fetchPatchWithRetry)(url, clientId, clientSecret, instanceUrl, token, payload);
|
|
311
|
+
return res.data;
|
|
312
|
+
};
|
|
313
|
+
return fetchUser(0, initialToken);
|
|
314
|
+
}
|
|
295
315
|
exports.default = OfscUserUtility;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ofsc-utility",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.50",
|
|
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
|
@@ -8,6 +8,11 @@ This package exposes grouped API helpers for common OFSC operations, including:
|
|
|
8
8
|
- export/download helpers
|
|
9
9
|
- inventory and activity records
|
|
10
10
|
- metadata file generation
|
|
11
|
+
- user and resource operations for standalone OFSC environments
|
|
12
|
+
|
|
13
|
+
> Note: User and resource-related methods are applicable exclusively to standalone OFSC environments and are not supported in Fusion OFSC.
|
|
14
|
+
|
|
15
|
+
This library is intended for OFSC integrations where the standard OFSC REST APIs are available. The user and resource-related methods are designed for standalone OFSC deployments and should not be relied on for Fusion OFSC environments, where the underlying APIs and behavior can differ.
|
|
11
16
|
|
|
12
17
|
### Built-in resilience for OFSC's server errors
|
|
13
18
|
|
|
@@ -537,8 +542,87 @@ node scripts/test-download-inactive-users-data.js
|
|
|
537
542
|
|
|
538
543
|
`INACTIVITY_THRESHOLD_DAYS` is optional in the test script and defaults to `14`.
|
|
539
544
|
|
|
545
|
+
#### Get user by login
|
|
546
|
+
|
|
547
|
+
`getUserByLogin` fetches a single user record by login name and returns the raw OFSC response payload.
|
|
548
|
+
|
|
549
|
+
```js
|
|
550
|
+
const user = await ofs.getUserByLogin(
|
|
551
|
+
"user@example.com",
|
|
552
|
+
process.env.CLIENT_ID,
|
|
553
|
+
process.env.CLIENT_SECRET,
|
|
554
|
+
process.env.INSTANCE_NAME,
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
console.log(user);
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
**Function signature**
|
|
561
|
+
|
|
562
|
+
```ts
|
|
563
|
+
getUserByLogin(
|
|
564
|
+
login: string,
|
|
565
|
+
clientId: string,
|
|
566
|
+
clientSecret: string,
|
|
567
|
+
instanceUrl: string,
|
|
568
|
+
initialToken?: string,
|
|
569
|
+
): Promise<any>
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Notes:
|
|
573
|
+
|
|
574
|
+
- This method is intended for standalone OFSC environments.
|
|
575
|
+
- The response is the raw OFSC user payload returned by the API.
|
|
576
|
+
- `initialToken` is optional and can be reused if a bearer token is already available.
|
|
577
|
+
|
|
578
|
+
#### Update user by login
|
|
579
|
+
|
|
580
|
+
`updateUserbyLogin` updates a user record by login using a PATCH request.
|
|
581
|
+
|
|
582
|
+
```js
|
|
583
|
+
const payload = {
|
|
584
|
+
firstName: "Updated",
|
|
585
|
+
lastName: "User",
|
|
586
|
+
status: "ACTIVE",
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
const response = await ofs.updateUserbyLogin(
|
|
590
|
+
"user@example.com",
|
|
591
|
+
process.env.CLIENT_ID,
|
|
592
|
+
process.env.CLIENT_SECRET,
|
|
593
|
+
process.env.INSTANCE_NAME,
|
|
594
|
+
"",
|
|
595
|
+
payload,
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
console.log(response);
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
**Function signature**
|
|
602
|
+
|
|
603
|
+
```ts
|
|
604
|
+
updateUserbyLogin(
|
|
605
|
+
login: string,
|
|
606
|
+
clientId: string,
|
|
607
|
+
clientSecret: string,
|
|
608
|
+
instanceUrl: string,
|
|
609
|
+
initialToken?: string,
|
|
610
|
+
payload: object,
|
|
611
|
+
): Promise<ResourceResponse>
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Notes:
|
|
615
|
+
|
|
616
|
+
- The payload is sent as a PATCH body to the OFSC user update endpoint.
|
|
617
|
+
- It uses the same retry wrapper as the other OFSC API helpers.
|
|
618
|
+
- This method is also intended for standalone OFSC usage and may not behave the same in Fusion OFSC.
|
|
619
|
+
|
|
540
620
|
### Resource related methods
|
|
541
621
|
|
|
622
|
+
> Note: User and resource-related methods are applicable exclusively to standalone OFSC environments and are not supported in Fusion OFSC.
|
|
623
|
+
|
|
624
|
+
These methods are for standalone OFSC environments only. If you are connecting to Fusion OFSC, the user- and resource-based APIs may not behave the same way, and the request/response structure may not match the standalone endpoints.
|
|
625
|
+
|
|
542
626
|
#### Get all resources
|
|
543
627
|
|
|
544
628
|
`AllResources` retrieves all resources from the OFSC Resources API. Results are
|