wanas-zcrm-extractor 1.6.1 → 1.6.2
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/bin/cli.js +4 -1
- package/package.json +4 -2
- package/src/services/auditLogService.js +7 -5
- package/src/utils/apiClient.js +8 -9
package/bin/cli.js
CHANGED
|
@@ -112,10 +112,13 @@ const getBanner = () => {
|
|
|
112
112
|
try {
|
|
113
113
|
const fs = require('fs');
|
|
114
114
|
const bannerPath = path.join(__dirname, '../banner.txt');
|
|
115
|
+
const version = require('../package.json').version;
|
|
115
116
|
if (fs.existsSync(bannerPath)) {
|
|
116
117
|
const banner = fs.readFileSync(bannerPath, 'utf8');
|
|
117
|
-
return `\x1b[34m${banner}\x1b[0m\n`;
|
|
118
|
+
return `\x1b[34m${banner}\x1b[0m\n\x1b[1;36m zcrm v${version}\x1b[0m\n`;
|
|
118
119
|
}
|
|
120
|
+
// Banner art missing — still show the version line.
|
|
121
|
+
return `\x1b[1;36m zcrm v${version}\x1b[0m\n`;
|
|
119
122
|
} catch (err) {
|
|
120
123
|
// Fail silently
|
|
121
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wanas-zcrm-extractor",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Local Zoho CRM V8 Metadata Extractor CLI and Web Dashboard Utility",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node server.js",
|
|
11
|
-
"dev": "nodemon server.js"
|
|
11
|
+
"dev": "nodemon server.js",
|
|
12
|
+
"test": "node test/run.js",
|
|
13
|
+
"prepublishOnly": "node test/run.js"
|
|
12
14
|
},
|
|
13
15
|
"files": [
|
|
14
16
|
"bin",
|
|
@@ -11,11 +11,13 @@ async function delay(ms) {
|
|
|
11
11
|
|
|
12
12
|
async function exportAuditLog(filterFile) {
|
|
13
13
|
try {
|
|
14
|
-
// For a full export the request body is OPTIONAL
|
|
15
|
-
//
|
|
16
|
-
// (
|
|
17
|
-
// `
|
|
18
|
-
|
|
14
|
+
// For a full export the request body is OPTIONAL. Sending an object WITH an
|
|
15
|
+
// empty `criteria` is rejected (400), and sending NO body trips a 415
|
|
16
|
+
// (missing content type). So the default (no filter) sends an empty JSON
|
|
17
|
+
// object `{}` — which carries the JSON content type and contains no
|
|
18
|
+
// criteria, i.e. "export everything". A filter file (which must contain a
|
|
19
|
+
// valid `audit_log_export` criteria object) overrides it when supplied.
|
|
20
|
+
let requestBody = {};
|
|
19
21
|
|
|
20
22
|
if (filterFile) {
|
|
21
23
|
const filterPath = path.resolve(process.cwd(), filterFile);
|
package/src/utils/apiClient.js
CHANGED
|
@@ -73,15 +73,14 @@ async function request(method, endpoint, params = {}, data = null, retryCount =
|
|
|
73
73
|
|
|
74
74
|
logInfo(`${method.toUpperCase()} request to ${url} (Retry: ${retryCount})`, 'apiClient.request');
|
|
75
75
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
76
|
+
const headers = { 'Authorization': `Zoho-oauthtoken ${accessToken}` };
|
|
77
|
+
// Zoho requires an explicit JSON content type on write requests — even when
|
|
78
|
+
// the body is empty — otherwise it responds 415 MEDIA_TYPE_NOT_SUPPORTED.
|
|
79
|
+
if (method && method.toLowerCase() !== 'get') {
|
|
80
|
+
headers['Content-Type'] = 'application/json';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const response = await apiClient({ method, url, params, data, headers });
|
|
85
84
|
|
|
86
85
|
// Zoho API sometimes returns error statuses inside a 200 OK response, e.g. code: 'INVALID_TOKEN'
|
|
87
86
|
if (response.data && response.data.status === 'error') {
|