ofsc-utility 1.0.6 → 1.0.7

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 CHANGED
@@ -8,12 +8,14 @@ export { getOAuthToken } from './oauthTokenService';
8
8
  export { downloadWorkZoneCSV } from './workZones';
9
9
  export { downloadAllResourcesCSV } from './resources';
10
10
  export { downloadAllUsersCSV } from './users';
11
- export { downloadAllInventoryTypesCSV } from './inventoryTypes';
11
+ export { downloadAllInventoryTypesCSV, getInventoryTypesDetail, updateCreateInventoryType } from './inventoryTypes';
12
12
  declare const OfscUtility: {
13
13
  getOAuthToken: any;
14
14
  downloadWorkZoneCSV: any;
15
15
  downloadAllResourcesCSV: any;
16
16
  downloadAllUsersCSV: any;
17
17
  downloadAllInventoryTypesCSV: any;
18
+ getInventoryTypesDetail: any;
19
+ updateInventoryType: any;
18
20
  };
19
21
  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.downloadAllInventoryTypesCSV = exports.downloadAllUsersCSV = exports.downloadAllResourcesCSV = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.WorkZone = exports.User = exports.Resource = exports.OauthTokenService = exports.InventoryType = void 0;
39
+ exports.updateCreateInventoryType = exports.getInventoryTypesDetail = exports.downloadAllInventoryTypesCSV = exports.downloadAllUsersCSV = exports.downloadAllResourcesCSV = exports.downloadWorkZoneCSV = exports.getOAuthToken = exports.WorkZone = exports.User = exports.Resource = exports.OauthTokenService = exports.InventoryType = void 0;
40
40
  // Export all methods grouped by category
41
41
  exports.InventoryType = __importStar(require("./inventoryTypes"));
42
42
  exports.OauthTokenService = __importStar(require("./oauthTokenService"));
@@ -56,6 +56,8 @@ var users_1 = require("./users");
56
56
  Object.defineProperty(exports, "downloadAllUsersCSV", { enumerable: true, get: function () { return users_1.downloadAllUsersCSV; } });
57
57
  var inventoryTypes_1 = require("./inventoryTypes");
58
58
  Object.defineProperty(exports, "downloadAllInventoryTypesCSV", { enumerable: true, get: function () { return inventoryTypes_1.downloadAllInventoryTypesCSV; } });
59
+ Object.defineProperty(exports, "getInventoryTypesDetail", { enumerable: true, get: function () { return inventoryTypes_1.getInventoryTypesDetail; } });
60
+ Object.defineProperty(exports, "updateCreateInventoryType", { enumerable: true, get: function () { return inventoryTypes_1.updateCreateInventoryType; } });
59
61
  // Default export with all functionality
60
62
  const OfscUtility = {
61
63
  // Case converters
@@ -63,6 +65,8 @@ const OfscUtility = {
63
65
  downloadWorkZoneCSV: require('./workZones').downloadWorkZoneCSV,
64
66
  downloadAllResourcesCSV: require('./resources').downloadAllResourcesCSV,
65
67
  downloadAllUsersCSV: require('./resources').downloadAllUsersCSV,
66
- downloadAllInventoryTypesCSV: require('./inventoryTypes').downloadAllInventoryTypesCSV
68
+ downloadAllInventoryTypesCSV: require('./inventoryTypes').downloadAllInventoryTypesCSV,
69
+ getInventoryTypesDetail: require('./inventoryTypes').getInventoryTypesDetail,
70
+ updateInventoryType: require('./inventoryTypes').updateInventoryType
67
71
  };
68
72
  exports.default = OfscUtility;
@@ -1 +1,4 @@
1
+ import { InventoryTypePayload, Response } from "../types";
1
2
  export declare function downloadAllInventoryTypesCSV(clientId: string, clientSecret: string, instanceUrl: string): Promise<void>;
3
+ export declare function getInventoryTypesDetail(clientId: string, clientSecret: string, instanceUrl: string, label: string): Promise<Response>;
4
+ export declare function updateCreateInventoryType(clientId: string, clientSecret: string, instanceUrl: string, label: string, payload: InventoryTypePayload): Promise<InventoryTypePayload>;
@@ -37,6 +37,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.downloadAllInventoryTypesCSV = downloadAllInventoryTypesCSV;
40
+ exports.getInventoryTypesDetail = getInventoryTypesDetail;
41
+ exports.updateCreateInventoryType = updateCreateInventoryType;
40
42
  const fs = __importStar(require("fs"));
41
43
  const node_fetch_1 = __importDefault(require("node-fetch"));
42
44
  const index_1 = require("../oauthTokenService/index");
@@ -113,3 +115,35 @@ async function downloadAllInventoryTypesCSV(clientId, clientSecret, instanceUrl)
113
115
  console.log(`🧩 Date Time: ${new Date()}`);
114
116
  console.log("-------------------------------------");
115
117
  }
118
+ async function getInventoryTypesDetail(clientId, clientSecret, instanceUrl, label) {
119
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/inventoryTypes/${label}`;
120
+ const token = await (0, index_1.getOAuthToken)(clientId, clientSecret, instanceUrl);
121
+ const res = await (0, node_fetch_1.default)(url, {
122
+ method: "GET",
123
+ headers: {
124
+ Authorization: `Bearer ${token}`,
125
+ Accept: "application/json"
126
+ }
127
+ });
128
+ if (!res.ok) {
129
+ throw new Error(`❌ Fetch failed: ${res.status} ${res.statusText}`);
130
+ }
131
+ return await res.json();
132
+ }
133
+ async function updateCreateInventoryType(clientId, clientSecret, instanceUrl, label, payload) {
134
+ const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/inventoryTypes/${label}`;
135
+ const token = await (0, index_1.getOAuthToken)(clientId, clientSecret, instanceUrl);
136
+ const res = await (0, node_fetch_1.default)(url, {
137
+ method: "PUT",
138
+ headers: {
139
+ Authorization: `Bearer ${token}`,
140
+ Accept: "application/json",
141
+ "Content-Type": "application/json"
142
+ },
143
+ body: JSON.stringify(payload)
144
+ });
145
+ if (!res.ok) {
146
+ throw new Error(`❌ PUT failed: ${res.status} ${res.statusText}`);
147
+ }
148
+ return await res.json();
149
+ }
package/dist/types.d.ts CHANGED
@@ -17,3 +17,25 @@ export interface ResourceResponse {
17
17
  limit: number;
18
18
  totalResults: number;
19
19
  }
20
+ export interface Response {
21
+ items: any[];
22
+ offset: number;
23
+ limit: number;
24
+ totalResults: number;
25
+ }
26
+ export interface InventoryTranslation {
27
+ language: string;
28
+ name: string;
29
+ unitOfMeasurement: string;
30
+ languageISO: string;
31
+ }
32
+ export interface InventoryTypePayload {
33
+ label: string;
34
+ name: string;
35
+ unitOfMeasurement: string;
36
+ active: boolean;
37
+ nonSerialized: boolean;
38
+ modelProperty: string;
39
+ quantityPrecision: number;
40
+ translations: InventoryTranslation[];
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofsc-utility",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
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
@@ -32,6 +32,8 @@ npm install ofsc-utility
32
32
  #### records
33
33
 
34
34
  getOAuthToken("clientId", "clientSecret", "instanceId")
35
+ getInventoryTypesDetail("clientId", "clientSecret", "instanceId"."inventory_label")
36
+
35
37
 
36
38
 
37
39
  ## Usage
@@ -40,6 +42,18 @@ npm install ofsc-utility
40
42
 
41
43
  ### CommonJS
42
44
 
45
+ ```js
46
+
47
+ async function run (){
48
+ let data = await ofs.InventoryType.getInventoryTypesDetail(
49
+ "clientId", "clientSecret", "instanceId", "inventory_label");
50
+ console.error(data);
51
+ }
52
+ run();
53
+
54
+
55
+ ```
56
+
43
57
  ```js
44
58
  const ofs = require("ofsc-utility");
45
59
 
@@ -91,6 +105,47 @@ ofs
91
105
  });
92
106
  ```
93
107
 
108
+ ```js
109
+ const ofs = require('ofsc-utility');
110
+
111
+ async function run() {
112
+ const payload = {
113
+ label: "inventory_label",
114
+ name: "Ordered Part",
115
+ unitOfMeasurement: "ea",
116
+ active: true,
117
+ nonSerialized: true,
118
+ modelProperty: "part_item_number_rev",
119
+ quantityPrecision: 0,
120
+ translations: [
121
+ {
122
+ language: "en",
123
+ name: "Ordered Part",
124
+ unitOfMeasurement: "ea",
125
+ languageISO: "en-US"
126
+ }
127
+ ]
128
+ };
129
+
130
+ try {
131
+ const result = await updateCreateInventoryType(
132
+ "CLIENT_ID",
133
+ "CLIENT_SECRET",
134
+ "INSTANCE_URL",
135
+ "inventory_label",
136
+ payload
137
+ );
138
+
139
+ console.log("Updated:", result);
140
+ } catch (err) {
141
+ console.error(err);
142
+ }
143
+ }
144
+
145
+ run();
146
+
147
+ ```
148
+
94
149
  ## License
95
150
 
96
151
  MIT