@xbongbong/xbbcli 2.4.4 → 2.4.6
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/README.md +15 -4
- package/business-info-detail.js +126 -0
- package/business-info-search.js +95 -0
- package/buyer-inquiry-detail.js +16 -47
- package/buyer-inquiry-list.js +18 -56
- package/clue-add-couser.js +14 -39
- package/clue-add.js +15 -41
- package/clue-back.js +14 -39
- package/clue-del.js +14 -39
- package/clue-delete-couser.js +14 -39
- package/clue-delete-mainuser.js +14 -39
- package/clue-detail.js +15 -40
- package/clue-distribution.js +14 -43
- package/clue-edit.js +15 -41
- package/clue-handover.js +15 -45
- package/clue-list.js +18 -61
- package/clue-thorough-delete.js +14 -39
- package/communicate-add.js +15 -56
- package/communicate-del.js +17 -59
- package/communicate-detail.js +15 -56
- package/communicate-edit.js +15 -56
- package/communicate-list.js +18 -63
- package/communicate-plan-add.js +16 -42
- package/communicate-plan-cancel.js +14 -40
- package/communicate-plan-del.js +14 -40
- package/communicate-plan-detail.js +15 -41
- package/communicate-plan-list.js +18 -46
- package/communicate-plan-single-operate.js +14 -39
- package/contact-add-couser.js +14 -39
- package/contact-add-mainuser.js +14 -39
- package/contact-add.js +15 -51
- package/contact-del.js +15 -38
- package/contact-delete-couser.js +14 -39
- package/contact-delete-mainuser.js +14 -39
- package/contact-detail.js +15 -38
- package/contact-edit.js +14 -47
- package/contact-handover.js +14 -39
- package/contact-list.js +37 -61
- package/contract-add-couser.js +16 -58
- package/contract-add-mainuser.js +16 -58
- package/contract-add.js +15 -57
- package/contract-del.js +17 -58
- package/contract-delete-couser.js +16 -57
- package/contract-delete-mainuser.js +16 -58
- package/contract-detail.js +15 -57
- package/contract-edit.js +15 -57
- package/contract-handover.js +15 -56
- package/contract-list.js +18 -61
- package/contract-outstock-add.js +15 -46
- package/contract-outstock-del.js +15 -41
- package/contract-outstock-detail.js +15 -41
- package/contract-outstock-edit.js +15 -46
- package/contract-outstock-list.js +18 -46
- package/customer-add-couser.js +13 -54
- package/customer-add.js +15 -58
- package/customer-back.js +15 -57
- package/customer-del.js +17 -58
- package/customer-delete-couser.js +16 -57
- package/customer-delete-mainuser.js +16 -58
- package/customer-detail.js +13 -54
- package/customer-distribution.js +15 -57
- package/customer-edit.js +13 -53
- package/customer-handover.js +15 -56
- package/customer-invoice-address-add.js +15 -41
- package/customer-invoice-address-edit.js +15 -40
- package/customer-invoice-address.js +17 -42
- package/customer-invoice-info-add.js +15 -41
- package/customer-invoice-info-edit.js +15 -40
- package/customer-invoice-info.js +17 -42
- package/customer-list.js +18 -61
- package/department-add.js +14 -39
- package/department-del.js +14 -40
- package/department-edit.js +14 -39
- package/department-list.js +17 -59
- package/form-data-add-couser.js +14 -39
- package/form-data-add-mainuser.js +14 -39
- package/form-data-add.js +13 -54
- package/form-data-del.js +13 -53
- package/form-data-delete-couser.js +14 -40
- package/form-data-delete-mainuser.js +14 -39
- package/form-data-detail.js +13 -54
- package/form-data-edit.js +13 -54
- package/form-data-handover.js +14 -39
- package/form-data-list.js +37 -63
- package/form-get.js +13 -53
- package/form-list.js +19 -66
- package/hkh-call-add-task.js +14 -44
- package/hkh-word-list.js +16 -44
- package/invoice-add.js +15 -45
- package/invoice-cancel.js +14 -44
- package/invoice-del.js +15 -45
- package/invoice-detail.js +15 -45
- package/invoice-edit.js +15 -45
- package/invoice-get-amount-detail.js +14 -44
- package/invoice-list.js +18 -50
- package/invoice-red.js +15 -45
- package/label-add.js +14 -44
- package/label-all-list.js +16 -44
- package/label-batch-add.js +14 -44
- package/label-batch-remove.js +14 -44
- package/label-del-completely.js +14 -44
- package/label-del.js +15 -45
- package/label-edit.js +14 -44
- package/label-group-add.js +15 -45
- package/label-group-del.js +15 -45
- package/label-group-list.js +16 -44
- package/label-group-update.js +15 -45
- package/label-list.js +16 -44
- package/label-reduction.js +15 -45
- package/label-repeat.js +15 -45
- package/market-activity-add.js +14 -49
- package/market-activity-del.js +15 -46
- package/market-activity-detail.js +15 -45
- package/market-activity-edit.js +15 -46
- package/market-activity-handover.js +14 -40
- package/market-activity-list.js +18 -46
- package/opportunity-add-couser.js +16 -58
- package/opportunity-add-mainuser.js +16 -58
- package/opportunity-add.js +15 -56
- package/opportunity-del.js +17 -59
- package/opportunity-delete-couser.js +16 -58
- package/opportunity-delete-mainuser.js +16 -57
- package/opportunity-detail.js +15 -58
- package/opportunity-edit.js +15 -56
- package/opportunity-handover.js +15 -57
- package/opportunity-list.js +40 -65
- package/orginal-text-list.js +16 -61
- package/package.json +8 -1
- package/pay-plan-add-couser.js +14 -41
- package/pay-plan-add-mainuser.js +14 -41
- package/pay-plan-add.js +15 -46
- package/pay-plan-delete-couser.js +14 -40
- package/pay-plan-delete-mainuser.js +14 -40
- package/pay-plan-handover.js +14 -40
- package/pay-sheet-add-bad.js +15 -46
- package/pay-sheet-add-couser.js +14 -40
- package/pay-sheet-add-mainuser.js +14 -41
- package/pay-sheet-add-red.js +15 -46
- package/pay-sheet-add-write-off.js +15 -46
- package/pay-sheet-del.js +14 -48
- package/pay-sheet-delete-couser.js +14 -40
- package/pay-sheet-delete-mainuser.js +14 -41
- package/pay-sheet-detail.js +15 -46
- package/pay-sheet-edit-bad.js +14 -49
- package/pay-sheet-edit-red.js +14 -49
- package/pay-sheet-edit-write-off.js +15 -46
- package/pay-sheet-get-amount-detail.js +14 -44
- package/pay-sheet-list.js +18 -46
- package/payment-add-couser.js +16 -58
- package/payment-add-mainuser.js +16 -58
- package/payment-add.js +15 -56
- package/payment-del.js +17 -58
- package/payment-delete-couser.js +16 -57
- package/payment-delete-mainuser.js +16 -57
- package/payment-detail.js +15 -56
- package/payment-edit.js +15 -56
- package/payment-handover.js +15 -57
- package/payment-list.js +37 -61
- package/payment-sheet-add-bad-debt.js +15 -57
- package/payment-sheet-add-pre.js +15 -46
- package/payment-sheet-add-red.js +15 -57
- package/payment-sheet-add-write-off.js +15 -52
- package/payment-sheet-del.js +17 -53
- package/payment-sheet-detail.js +15 -52
- package/payment-sheet-edit-bad-debt.js +15 -51
- package/payment-sheet-edit-red.js +15 -56
- package/payment-sheet-edit-write-off.js +15 -56
- package/payment-sheet-get-amount-detail.js +14 -45
- package/payment-sheet-handover.js +14 -40
- package/payment-sheet-list.js +37 -60
- package/product-add.js +15 -51
- package/product-category-add.js +13 -48
- package/product-category-del.js +13 -53
- package/product-category-list.js +17 -60
- package/product-category-update.js +13 -54
- package/product-del.js +17 -53
- package/product-detail.js +13 -54
- package/product-edit.js +15 -51
- package/product-list.js +37 -63
- package/product-online.js +14 -44
- package/quotation-add-couser.js +15 -45
- package/quotation-add-mainuser.js +15 -45
- package/quotation-add.js +15 -45
- package/quotation-del.js +15 -45
- package/quotation-delete-couser.js +15 -45
- package/quotation-delete-mainuser.js +15 -45
- package/quotation-detail.js +15 -45
- package/quotation-edit.js +15 -45
- package/quotation-handover.js +14 -39
- package/quotation-list.js +18 -50
- package/refund-add.js +15 -39
- package/refund-del.js +15 -38
- package/refund-detail.js +15 -39
- package/refund-edit.js +15 -39
- package/refund-list.js +37 -61
- package/role-list.js +18 -46
- package/sign-in-list.js +21 -49
- package/stage-get.js +16 -42
- package/stage-jump.js +15 -49
- package/supplier-add.js +15 -57
- package/token-del.js +1 -1
- package/token-list.js +20 -1
- package/token-set.js +1 -1
- package/token-use.js +2 -35
- package/user-add.js +14 -39
- package/user-del.js +14 -40
- package/user-edit.js +14 -40
- package/user-handover.js +14 -40
- package/user-list.js +16 -62
- package/work-order-add.js +13 -54
- package/work-order-asset-add-couser.js +15 -45
- package/work-order-asset-add-mainuser.js +15 -45
- package/work-order-asset-add.js +15 -45
- package/work-order-asset-del-couser.js +15 -45
- package/work-order-asset-del-mainuser.js +15 -45
- package/work-order-asset-del.js +15 -45
- package/work-order-asset-detail.js +15 -45
- package/work-order-asset-edit.js +15 -45
- package/work-order-asset-handover.js +15 -45
- package/work-order-asset-list.js +18 -50
- package/work-order-del.js +13 -54
- package/work-order-detail.js +13 -53
- package/work-order-dynamic-list.js +18 -56
- package/work-order-edit.js +13 -54
- package/work-order-list.js +17 -59
- package/work-order-operate.js +13 -54
- package/work-order-template-detail.js +13 -54
- package/work-order-template-list.js +17 -60
- package/work-report-daily-add.js +14 -39
- package/work-report-daily-del.js +14 -39
- package/work-report-daily-detail.js +15 -40
- package/work-report-daily-edit.js +17 -52
- package/work-report-daily-get-work-plan.js +14 -40
- package/work-report-daily-list.js +18 -45
- package/work-report-monthly-add.js +14 -40
- package/work-report-monthly-del.js +14 -43
- package/work-report-monthly-detail.js +15 -40
- package/work-report-monthly-edit.js +15 -40
- package/work-report-monthly-list.js +18 -45
- package/work-report-weekly-add.js +14 -40
- package/work-report-weekly-del.js +14 -40
- package/work-report-weekly-detail.js +15 -41
- package/work-report-weekly-edit.js +15 -41
- package/work-report-weekly-list.js +18 -45
- package/work-task-add-couser.js +14 -43
- package/work-task-add.js +15 -41
- package/work-task-delete-couser.js +14 -40
- package/work-task-detail.js +15 -40
- package/work-task-edit.js +14 -39
- package/work-task-handover.js +14 -40
- package/workorder-add-couser.js +16 -57
- package/workorder-delete-couser.js +16 -58
- package/workorder-handover.js +17 -58
- package/workorderlist.js +38 -60
- package/workorderproductlist.js +18 -59
- package/worktimerecorddetail.js +13 -54
- package/worktimerecordlist.js +18 -59
- package/xbb-http.js +71 -0
package/contract-outstock-add.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/contractOutstock/add';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/contractOutstock/add';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{ dataId: '', resultCode: '', resultMsg: '', code, msg }];
|
|
@@ -73,29 +47,24 @@ cli({
|
|
|
73
47
|
const parsedDataList = parseDataList(kwargs.dataList);
|
|
74
48
|
if (parsedDataList) payload.dataList = parsedDataList;
|
|
75
49
|
|
|
76
|
-
const body = JSON.stringify(payload);
|
|
77
50
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
78
51
|
if (!token) return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
79
52
|
if (parsedDataList === null) return makeErrorRow('NO_DATALIST', '缺少 --dataList');
|
|
80
53
|
if (parsedDataList === undefined) return makeErrorRow('INVALID_DATALIST', '--dataList 必须是 JSON 对象字符串');
|
|
81
54
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
method: 'POST',
|
|
90
|
-
headers,
|
|
91
|
-
body,
|
|
55
|
+
const gateway = await requestGateway({
|
|
56
|
+
baseUrl,
|
|
57
|
+
apiPath: API_PATH,
|
|
58
|
+
payload,
|
|
59
|
+
token,
|
|
60
|
+
userId,
|
|
61
|
+
debug,
|
|
92
62
|
});
|
|
93
|
-
if (!
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: data.code ?? '', msg: data.msg || '' }];
|
|
63
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
64
|
+
if (gateway.data.code !== 1) {
|
|
65
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
66
|
+
}
|
|
67
|
+
const result = gateway.data.result || {};
|
|
68
|
+
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
100
69
|
},
|
|
101
70
|
});
|
package/contract-outstock-del.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/contractOutstock/del';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/contractOutstock/del';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{ resultCode: '', resultMsg: '', errorDataMemo: '', code, msg }];
|
|
@@ -53,23 +27,23 @@ cli({
|
|
|
53
27
|
const payload = { corpid, dataId: Number(kwargs.dataId || 0) };
|
|
54
28
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
55
29
|
|
|
56
|
-
const body = JSON.stringify(payload);
|
|
57
30
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
58
31
|
if (!payload.dataId) return makeErrorRow('NO_DATAID', '缺少 --dataId');
|
|
59
32
|
if (!token) return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
60
33
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
const gateway = await requestGateway({
|
|
35
|
+
baseUrl,
|
|
36
|
+
apiPath: API_PATH,
|
|
37
|
+
payload,
|
|
38
|
+
token,
|
|
39
|
+
userId,
|
|
40
|
+
debug,
|
|
41
|
+
});
|
|
42
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
43
|
+
if (gateway.data.code !== 1) {
|
|
44
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
65
45
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const data = await resp.json();
|
|
69
|
-
const responseBody = JSON.stringify(data);
|
|
70
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
71
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
72
|
-
const result = data.result || {};
|
|
73
|
-
return [{ resultCode: data.code ?? '', resultMsg: data.msg || '', errorDataMemo: result.errorDataMemo || '', code: data.code ?? '', msg: data.msg || '' }];
|
|
46
|
+
const result = gateway.data.result || {};
|
|
47
|
+
return [{ resultCode: gateway.data.code ?? '', resultMsg: gateway.data.msg || '', errorDataMemo: result.errorDataMemo || '', code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
74
48
|
},
|
|
75
49
|
});
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/contractOutstock/detail';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/contractOutstock/detail';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{ dataId: '', formId: '', addTime: '', updateTime: '', data: '', code, msg }];
|
|
@@ -55,23 +29,23 @@ cli({
|
|
|
55
29
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
56
30
|
if (String(kwargs.queryFlag ?? '') !== '') payload.queryFlag = Number(kwargs.queryFlag);
|
|
57
31
|
|
|
58
|
-
const body = JSON.stringify(payload);
|
|
59
32
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
60
33
|
if (!payload.dataId) return makeErrorRow('NO_DATAID', '缺少 --dataId');
|
|
61
34
|
if (!token) return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
62
35
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
36
|
+
const gateway = await requestGateway({
|
|
37
|
+
baseUrl,
|
|
38
|
+
apiPath: API_PATH,
|
|
39
|
+
payload,
|
|
40
|
+
token,
|
|
41
|
+
userId,
|
|
42
|
+
debug,
|
|
43
|
+
});
|
|
44
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
45
|
+
if (gateway.data.code !== 1) {
|
|
46
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
67
47
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const data = await resp.json();
|
|
71
|
-
const responseBody = JSON.stringify(data);
|
|
72
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
73
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
74
|
-
const result = data.result || {};
|
|
75
|
-
return [{ dataId: result.dataId || '', formId: result.formId || '', addTime: result.addTime || '', updateTime: result.updateTime || '', data: JSON.stringify(result.data || {}), code: data.code ?? '', msg: data.msg || '' }];
|
|
48
|
+
const result = gateway.data.result || {};
|
|
49
|
+
return [{ dataId: result.dataId || '', formId: result.formId || '', addTime: result.addTime || '', updateTime: result.updateTime || '', data: JSON.stringify(result.data || {}), code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
76
50
|
},
|
|
77
51
|
});
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/contractOutstock/edit';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const API_PATH = '/pro/v2/api/contractOutstock/edit';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{ dataId: '', resultCode: '', resultMsg: '', code, msg }];
|
|
@@ -74,30 +48,25 @@ cli({
|
|
|
74
48
|
const parsedDataList = parseDataList(kwargs.dataList);
|
|
75
49
|
if (parsedDataList) payload.dataList = parsedDataList;
|
|
76
50
|
|
|
77
|
-
const body = JSON.stringify(payload);
|
|
78
51
|
if (!payload.dataId) return makeErrorRow('NO_DATAID', '缺少 --dataId');
|
|
79
52
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
80
53
|
if (!token) return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
81
54
|
if (parsedDataList === null) return makeErrorRow('NO_DATALIST', '缺少 --dataList');
|
|
82
55
|
if (parsedDataList === undefined) return makeErrorRow('INVALID_DATALIST', '--dataList 必须是 JSON 对象字符串');
|
|
83
56
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
method: 'POST',
|
|
92
|
-
headers,
|
|
93
|
-
body,
|
|
57
|
+
const gateway = await requestGateway({
|
|
58
|
+
baseUrl,
|
|
59
|
+
apiPath: API_PATH,
|
|
60
|
+
payload,
|
|
61
|
+
token,
|
|
62
|
+
userId,
|
|
63
|
+
debug,
|
|
94
64
|
});
|
|
95
|
-
if (!
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: data.code ?? '', msg: data.msg || '' }];
|
|
65
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
66
|
+
if (gateway.data.code !== 1) {
|
|
67
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
68
|
+
}
|
|
69
|
+
const result = gateway.data.result || {};
|
|
70
|
+
return [{ dataId: result.dataId || '', resultCode: result.code ?? '', resultMsg: result.msg || '', code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
102
71
|
},
|
|
103
72
|
});
|
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway, createPagination } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/contractOutstock/list';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const API_PATH = '/pro/v2/api/contractOutstock/list';
|
|
11
5
|
const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function readConfig() {
|
|
15
|
-
return readActiveConfig();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getRuntimeConfig() {
|
|
19
|
-
const config = readConfig();
|
|
20
|
-
return {
|
|
21
|
-
corpid: String(config.corpid || '').trim(),
|
|
22
|
-
token: String(config.token || '').trim(),
|
|
23
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
24
|
-
userId: String(config.userId || '').trim(),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function buildApiUrl(baseUrl, apiUrl) {
|
|
29
|
-
const apiPath = new URL(apiUrl).pathname;
|
|
30
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
31
|
-
}
|
|
6
|
+
const pagination = createPagination();
|
|
32
7
|
|
|
33
8
|
function buildConditions(kwargs) {
|
|
34
9
|
if (String(kwargs.conditions ?? '').trim()) {
|
|
@@ -69,7 +44,7 @@ cli({
|
|
|
69
44
|
{ name: 'raw', type: 'bool', default: false, help: '输出接口返回的原文' },
|
|
70
45
|
],
|
|
71
46
|
columns: ['rank', 'dataId', 'formId', 'addTime', 'updateTime', 'data', 'code', 'msg'],
|
|
72
|
-
footerExtra:
|
|
47
|
+
footerExtra: pagination.footerExtra,
|
|
73
48
|
func: async function (kwargs) {
|
|
74
49
|
const debug = Boolean(kwargs.debug);
|
|
75
50
|
let conditions;
|
|
@@ -91,27 +66,24 @@ cli({
|
|
|
91
66
|
if (conditions.length) payload.conditions = conditions;
|
|
92
67
|
if (String(kwargs.viewApproval ?? '') !== '') payload.viewApproval = String(kwargs.viewApproval);
|
|
93
68
|
|
|
94
|
-
const requestBody = JSON.stringify(payload);
|
|
95
69
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
96
70
|
if (!token) return makeErrorRow('NO_TOKEN', MISSING_TOKEN_MESSAGE);
|
|
97
71
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
72
|
+
const gateway = await requestGateway({
|
|
73
|
+
baseUrl,
|
|
74
|
+
apiPath: API_PATH,
|
|
75
|
+
payload,
|
|
76
|
+
token,
|
|
77
|
+
userId,
|
|
78
|
+
debug,
|
|
79
|
+
});
|
|
80
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
81
|
+
pagination.update(gateway.data);
|
|
82
|
+
if (kwargs.raw) return [{ raw: gateway.responseBody }];
|
|
83
|
+
if (gateway.data.code !== 1) {
|
|
84
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
103
85
|
}
|
|
104
|
-
const
|
|
105
|
-
if (!resp.ok) return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
106
|
-
const data = await resp.json();
|
|
107
|
-
lastPagination = data?.code === 1 && data?.result?.totalCount != null && data?.result?.totalPage != null
|
|
108
|
-
? { totalCount: data.result.totalCount, totalPage: data.result.totalPage }
|
|
109
|
-
: null;
|
|
110
|
-
const responseBody = JSON.stringify(data);
|
|
111
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
112
|
-
if (kwargs.raw) return [{ raw: responseBody }];
|
|
113
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
114
|
-
const list = Array.isArray(data.result?.list) ? data.result.list : [];
|
|
86
|
+
const list = Array.isArray(gateway.data.result?.list) ? gateway.data.result.list : [];
|
|
115
87
|
if (!list.length) return makeErrorRow('NO_DATA', '接口成功,但 list 为空');
|
|
116
88
|
return list.map((item, index) => ({ rank: index + 1, dataId: item.dataId || '', formId: item.formId || '', addTime: item.addTime || '', updateTime: item.updateTime || '', data: JSON.stringify(item.data || {}), code: '', msg: '' }));
|
|
117
89
|
},
|
package/customer-add-couser.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const ADD_COUSER_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/addCoUser';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const ADD_COUSER_API_PATH = '/pro/v2/api/customer/addCoUser';
|
|
11
5
|
const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
|
|
12
6
|
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
7
|
function parseBusinessUserIdList(raw) {
|
|
33
8
|
if (Array.isArray(raw)) {
|
|
34
9
|
const cleaned = raw.map(function (item) {
|
|
@@ -143,41 +118,25 @@ cli({
|
|
|
143
118
|
const debug = Boolean(kwargs.debug);
|
|
144
119
|
const { corpid, token, baseUrl, userId } = getRuntimeConfig();
|
|
145
120
|
const { payload, businessUserIdList } = buildPayload(kwargs, corpid);
|
|
146
|
-
const body = JSON.stringify(payload);
|
|
147
121
|
|
|
148
122
|
const validationError = getValidationError(payload, token, businessUserIdList);
|
|
149
123
|
if (validationError) {
|
|
150
124
|
return makeErrorRow(validationError.code, validationError.msg);
|
|
151
125
|
}
|
|
152
126
|
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
161
|
-
}
|
|
162
|
-
const resp = await fetch(apiUrl, {
|
|
163
|
-
method: 'POST',
|
|
164
|
-
headers,
|
|
165
|
-
body,
|
|
127
|
+
const gateway = await requestGateway({
|
|
128
|
+
baseUrl,
|
|
129
|
+
apiPath: ADD_COUSER_API_PATH,
|
|
130
|
+
payload,
|
|
131
|
+
token,
|
|
132
|
+
userId,
|
|
133
|
+
debug,
|
|
166
134
|
});
|
|
167
|
-
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
171
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const data = await resp.json();
|
|
175
|
-
const responseBody = JSON.stringify(data);
|
|
176
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
177
|
-
if (data.code !== 1) {
|
|
178
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
135
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
136
|
+
if (gateway.data.code !== 1) {
|
|
137
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
179
138
|
}
|
|
180
139
|
|
|
181
|
-
return makeSuccessRow(data);
|
|
140
|
+
return makeSuccessRow(gateway.data);
|
|
182
141
|
},
|
|
183
142
|
});
|
package/customer-add.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
1
|
import { cli, Strategy } from './xbb-registry.js';
|
|
6
|
-
import {
|
|
2
|
+
import { getRuntimeConfig, requestGateway } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
|
|
10
|
-
const CUSTOMER_ADD_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/customer/add';
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
12
|
-
|
|
13
|
-
function readConfig() {
|
|
14
|
-
return readActiveConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getRuntimeConfig() {
|
|
18
|
-
const config = readConfig();
|
|
19
|
-
return {
|
|
20
|
-
corpid: String(config.corpid || '').trim(),
|
|
21
|
-
token: String(config.token || '').trim(),
|
|
22
|
-
baseUrl: String(config.baseurl || DEFAULT_BASE_URL).trim(),
|
|
23
|
-
userId: String(config.userId || '').trim(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function buildApiUrl(baseUrl, defaultUrl) {
|
|
28
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
4
|
+
const CUSTOMER_ADD_API_PATH = '/pro/v2/api/customer/add';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -91,8 +65,6 @@ cli({
|
|
|
91
65
|
payload.dataList = parsedDataList;
|
|
92
66
|
}
|
|
93
67
|
|
|
94
|
-
const body = JSON.stringify(payload);
|
|
95
|
-
|
|
96
68
|
if (!payload.corpid) {
|
|
97
69
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
98
70
|
}
|
|
@@ -109,41 +81,26 @@ cli({
|
|
|
109
81
|
return makeErrorRow('INVALID_DATALIST', '--dataList 必须是 JSON 对象字符串');
|
|
110
82
|
}
|
|
111
83
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
120
|
-
}
|
|
121
|
-
const resp = await fetch(apiUrl, {
|
|
122
|
-
method: 'POST',
|
|
123
|
-
headers,
|
|
124
|
-
body,
|
|
84
|
+
const gateway = await requestGateway({
|
|
85
|
+
baseUrl,
|
|
86
|
+
apiPath: CUSTOMER_ADD_API_PATH,
|
|
87
|
+
payload,
|
|
88
|
+
token,
|
|
89
|
+
userId: runtimeUserId,
|
|
90
|
+
debug,
|
|
125
91
|
});
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
130
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const data = await resp.json();
|
|
134
|
-
const responseBody = JSON.stringify(data);
|
|
135
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
136
|
-
if (data.code !== 1) {
|
|
137
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
92
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
93
|
+
if (gateway.data.code !== 1) {
|
|
94
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
138
95
|
}
|
|
139
96
|
|
|
140
|
-
const result = data.result || {};
|
|
97
|
+
const result = gateway.data.result || {};
|
|
141
98
|
return [{
|
|
142
99
|
dataId: result.dataId || '',
|
|
143
100
|
resultCode: result.code ?? '',
|
|
144
101
|
resultMsg: result.msg || '',
|
|
145
|
-
code: data.code ?? '',
|
|
146
|
-
msg: data.msg || '',
|
|
102
|
+
code: gateway.data.code ?? '',
|
|
103
|
+
msg: gateway.data.msg || '',
|
|
147
104
|
}];
|
|
148
105
|
},
|
|
149
106
|
});
|