@xbongbong/xbbcli 2.4.5 → 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 +17 -62
- 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/clue-list.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, createPagination } from './xbb-http.js';
|
|
7
3
|
|
|
8
|
-
const
|
|
9
|
-
const CLUE_LIST_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/clue/list';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const CLUE_LIST_API_PATH = '/pro/v2/api/clue/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, defaultUrl) {
|
|
29
|
-
const apiPath = new URL(defaultUrl).pathname;
|
|
30
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
31
|
-
}
|
|
6
|
+
const pagination = createPagination();
|
|
32
7
|
|
|
33
8
|
function buildConditions(kwargs) {
|
|
34
9
|
const conditions = kwargs.conditions;
|
|
@@ -147,7 +122,7 @@ cli({
|
|
|
147
122
|
{ name: 'formId', type: 'int', help: '表单id(必填)' },
|
|
148
123
|
{ name: 'del', type: 'int', default: 0, help: '0线索列表,1回收站数据' },
|
|
149
124
|
{ name: 'userId', type: 'str', default: '', help: '操作人id(可选)' },
|
|
150
|
-
{ name: 'isPublic', type: '
|
|
125
|
+
{ name: 'isPublic', type: 'str', default: '', help: '是否公海线索:0非公海,1公海,不传表示全部' },
|
|
151
126
|
{ name: 'viewApproval', type: 'str', default: '', help: '是否查询审批中数据,1是,0否' },
|
|
152
127
|
{ name: 'conditions', type: 'str', default: '', help: '条件集合 JSON 字符串,例如 [{"attr":"subForm_1","subAttr":"text_2","value":["133***"],"symbol":"equal"}]' },
|
|
153
128
|
{ name: 'attr', type: 'str', default: '', help: '筛选字段 attr,例如 text_1' },
|
|
@@ -159,7 +134,7 @@ cli({
|
|
|
159
134
|
{ name: 'raw', type: 'bool', default: false, help: '输出接口返回的原文' },
|
|
160
135
|
],
|
|
161
136
|
columns: ['rank', 'dataId', 'formId', 'name', 'contact', 'mobile', 'customerName', 'creatorId', 'addTime', 'updateTime', 'data', 'code', 'msg'],
|
|
162
|
-
footerExtra:
|
|
137
|
+
footerExtra: pagination.footerExtra,
|
|
163
138
|
func: async function (kwargs) {
|
|
164
139
|
const debug = Boolean(kwargs.debug);
|
|
165
140
|
const { corpid, token, baseUrl, userId } = getRuntimeConfig();
|
|
@@ -173,45 +148,27 @@ cli({
|
|
|
173
148
|
const detail = separatorIndex > 0 ? message.slice(separatorIndex + 1) : message;
|
|
174
149
|
return makeErrorRow(code, detail);
|
|
175
150
|
}
|
|
176
|
-
const body = JSON.stringify(payload);
|
|
177
|
-
|
|
178
151
|
const validationError = getValidationError(payload, token);
|
|
179
152
|
if (validationError) {
|
|
180
153
|
return makeErrorRow(validationError.code, validationError.msg);
|
|
181
154
|
}
|
|
182
155
|
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
const resp = await fetch(buildApiUrl(baseUrl, CLUE_LIST_API_URL), {
|
|
192
|
-
method: 'POST',
|
|
193
|
-
headers,
|
|
194
|
-
body,
|
|
156
|
+
const gateway = await requestGateway({
|
|
157
|
+
baseUrl,
|
|
158
|
+
apiPath: CLUE_LIST_API_PATH,
|
|
159
|
+
payload,
|
|
160
|
+
token,
|
|
161
|
+
userId,
|
|
162
|
+
debug,
|
|
195
163
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return makeErrorRow(
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const data = await resp.json();
|
|
204
|
-
lastPagination = data?.code === 1 && data?.result?.totalCount != null && data?.result?.totalPage != null
|
|
205
|
-
? { totalCount: data.result.totalCount, totalPage: data.result.totalPage }
|
|
206
|
-
: null;
|
|
207
|
-
const responseBody = JSON.stringify(data);
|
|
208
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
209
|
-
if (kwargs.raw) return [{ raw: responseBody }];
|
|
210
|
-
if (data.code !== 1) {
|
|
211
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
164
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
165
|
+
pagination.update(gateway.data);
|
|
166
|
+
if (kwargs.raw) return [{ raw: gateway.responseBody }];
|
|
167
|
+
if (gateway.data.code !== 1) {
|
|
168
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
212
169
|
}
|
|
213
170
|
|
|
214
|
-
const list = Array.isArray(data.result?.list) ? data.result.list : [];
|
|
171
|
+
const list = Array.isArray(gateway.data.result?.list) ? gateway.data.result.list : [];
|
|
215
172
|
if (!list.length) {
|
|
216
173
|
return makeErrorRow('NO_DATA', '接口成功,但 list 为空');
|
|
217
174
|
}
|
package/clue-thorough-delete.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
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 API_URL = 'https://proapi.xbongbong.com/pro/v2/api/clue/thorough/delete';
|
|
10
|
-
const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
|
|
4
|
+
const API_PATH = '/pro/v2/api/clue/thorough/delete';
|
|
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, apiUrl) {
|
|
28
|
-
const apiPath = new URL(apiUrl).pathname;
|
|
29
|
-
return `${baseUrl.replace(/\/+$/, '')}${apiPath}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
7
|
function makeErrorRow(code, msg) {
|
|
33
8
|
return [{ code, msg }];
|
|
34
9
|
}
|
|
@@ -59,21 +34,21 @@ cli({
|
|
|
59
34
|
dataIdList = null;
|
|
60
35
|
}
|
|
61
36
|
if (Array.isArray(dataIdList)) payload.dataIdList = dataIdList;
|
|
62
|
-
const requestBody = JSON.stringify(payload);
|
|
63
37
|
if (!payload.corpid) return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
64
38
|
if (!Array.isArray(dataIdList) || !dataIdList.length) return makeErrorRow('NO_DATAIDLIST', '缺少 --dataIdList 或格式不正确,需为JSON数组');
|
|
65
39
|
if (!token) return makeErrorRow('NO_TOKEN', MISSING_TOKEN_MESSAGE);
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
40
|
+
const gateway = await requestGateway({
|
|
41
|
+
baseUrl,
|
|
42
|
+
apiPath: API_PATH,
|
|
43
|
+
payload,
|
|
44
|
+
token,
|
|
45
|
+
userId,
|
|
46
|
+
debug,
|
|
47
|
+
});
|
|
48
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
49
|
+
if (gateway.data.code !== 1) {
|
|
50
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
70
51
|
}
|
|
71
|
-
|
|
72
|
-
if (!resp.ok) return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
73
|
-
const data = await resp.json();
|
|
74
|
-
const responseBody = JSON.stringify(data);
|
|
75
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
76
|
-
if (data.code !== 1) return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
77
|
-
return [{ code: data.code ?? '', msg: data.msg || '' }];
|
|
52
|
+
return [{ code: gateway.data.code ?? '', msg: gateway.data.msg || '' }];
|
|
78
53
|
},
|
|
79
54
|
});
|
package/communicate-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/communicate/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/communicate/add';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -87,7 +61,6 @@ cli({
|
|
|
87
61
|
payload.dataList = parsedDataList;
|
|
88
62
|
}
|
|
89
63
|
|
|
90
|
-
const body = JSON.stringify(payload);
|
|
91
64
|
|
|
92
65
|
if (!payload.corpid) {
|
|
93
66
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -102,40 +75,26 @@ cli({
|
|
|
102
75
|
return makeErrorRow('INVALID_DATALIST', '--dataList 必须是 JSON 对象字符串');
|
|
103
76
|
}
|
|
104
77
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
const resp = await fetch(buildApiUrl(baseUrl, API_URL), {
|
|
114
|
-
method: 'POST',
|
|
115
|
-
headers,
|
|
116
|
-
body,
|
|
78
|
+
const gateway = await requestGateway({
|
|
79
|
+
baseUrl,
|
|
80
|
+
apiPath: API_PATH,
|
|
81
|
+
payload,
|
|
82
|
+
token,
|
|
83
|
+
userId: runtimeUserId,
|
|
84
|
+
debug,
|
|
117
85
|
});
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
122
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const data = await resp.json();
|
|
126
|
-
const responseBody = JSON.stringify(data);
|
|
127
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
128
|
-
if (data.code !== 1) {
|
|
129
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
86
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
87
|
+
if (gateway.data.code !== 1) {
|
|
88
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
130
89
|
}
|
|
131
90
|
|
|
132
|
-
const result = data.result || {};
|
|
91
|
+
const result = gateway.data.result || {};
|
|
133
92
|
return [{
|
|
134
93
|
dataId: result.dataId || '',
|
|
135
94
|
resultCode: result.code ?? '',
|
|
136
95
|
resultMsg: result.msg || '',
|
|
137
|
-
code: data.code ?? '',
|
|
138
|
-
msg: data.msg || '',
|
|
96
|
+
code: gateway.data.code ?? '',
|
|
97
|
+
msg: gateway.data.msg || '',
|
|
139
98
|
}];
|
|
140
99
|
},
|
|
141
100
|
});
|
package/communicate-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/communicate/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/communicate/del';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -63,7 +37,6 @@ cli({
|
|
|
63
37
|
};
|
|
64
38
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
65
39
|
|
|
66
|
-
const body = JSON.stringify(payload);
|
|
67
40
|
|
|
68
41
|
if (!payload.corpid) {
|
|
69
42
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -75,41 +48,26 @@ cli({
|
|
|
75
48
|
return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
76
49
|
}
|
|
77
50
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
process.stderr.write(`[debug] URL: ${apiUrl}\n[debug] Headers: ${JSON.stringify(headers)}\n[debug] RequestBody: ${body}\n`);
|
|
86
|
-
}
|
|
87
|
-
const resp = await fetch(apiUrl, {
|
|
88
|
-
method: 'POST',
|
|
89
|
-
headers,
|
|
90
|
-
body,
|
|
51
|
+
const gateway = await requestGateway({
|
|
52
|
+
baseUrl,
|
|
53
|
+
apiPath: API_PATH,
|
|
54
|
+
payload,
|
|
55
|
+
token,
|
|
56
|
+
userId,
|
|
57
|
+
debug,
|
|
91
58
|
});
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
96
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const data = await resp.json();
|
|
100
|
-
const responseBody = JSON.stringify(data);
|
|
101
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
102
|
-
if (data.code !== 1) {
|
|
103
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
59
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
60
|
+
if (gateway.data.code !== 1) {
|
|
61
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
104
62
|
}
|
|
105
63
|
|
|
106
|
-
const result = data.result || {};
|
|
64
|
+
const result = gateway.data.result || {};
|
|
107
65
|
return [{
|
|
108
|
-
resultCode: data.code ?? '',
|
|
109
|
-
resultMsg: data.msg || '',
|
|
66
|
+
resultCode: gateway.data.code ?? '',
|
|
67
|
+
resultMsg: gateway.data.msg || '',
|
|
110
68
|
errorDataMemo: result.errorDataMemo || '',
|
|
111
|
-
code: data.code ?? '',
|
|
112
|
-
msg: data.msg || '',
|
|
69
|
+
code: gateway.data.code ?? '',
|
|
70
|
+
msg: gateway.data.msg || '',
|
|
113
71
|
}];
|
|
114
72
|
},
|
|
115
73
|
});
|
package/communicate-detail.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/communicate/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/communicate/detail';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -67,7 +41,6 @@ cli({
|
|
|
67
41
|
if (kwargs.userId) payload.userId = String(kwargs.userId);
|
|
68
42
|
if (String(kwargs.queryFlag ?? '') !== '') payload.queryFlag = Number(kwargs.queryFlag);
|
|
69
43
|
|
|
70
|
-
const body = JSON.stringify(payload);
|
|
71
44
|
|
|
72
45
|
if (!payload.corpid) {
|
|
73
46
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -79,42 +52,28 @@ cli({
|
|
|
79
52
|
return makeErrorRow('NO_TOKEN', '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
80
53
|
}
|
|
81
54
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
const resp = await fetch(buildApiUrl(baseUrl, API_URL), {
|
|
91
|
-
method: 'POST',
|
|
92
|
-
headers,
|
|
93
|
-
body,
|
|
55
|
+
const gateway = await requestGateway({
|
|
56
|
+
baseUrl,
|
|
57
|
+
apiPath: API_PATH,
|
|
58
|
+
payload,
|
|
59
|
+
token,
|
|
60
|
+
userId,
|
|
61
|
+
debug,
|
|
94
62
|
});
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
99
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const data = await resp.json();
|
|
103
|
-
const responseBody = JSON.stringify(data);
|
|
104
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
105
|
-
if (data.code !== 1) {
|
|
106
|
-
return makeErrorRow(data.code ?? '', 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 ?? '未知错误');
|
|
107
66
|
}
|
|
108
67
|
|
|
109
|
-
const result = data.result || {};
|
|
68
|
+
const result = gateway.data.result || {};
|
|
110
69
|
return [{
|
|
111
70
|
dataId: result.dataId || '',
|
|
112
71
|
formId: result.formId || '',
|
|
113
72
|
addTime: result.addTime || '',
|
|
114
73
|
updateTime: result.updateTime || '',
|
|
115
74
|
data: JSON.stringify(result.data || {}),
|
|
116
|
-
code: data.code ?? '',
|
|
117
|
-
msg: data.msg || '',
|
|
75
|
+
code: gateway.data.code ?? '',
|
|
76
|
+
msg: gateway.data.msg || '',
|
|
118
77
|
}];
|
|
119
78
|
},
|
|
120
79
|
});
|
package/communicate-edit.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/communicate/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/communicate/edit';
|
|
31
5
|
|
|
32
6
|
function makeErrorRow(code, msg) {
|
|
33
7
|
return [{
|
|
@@ -86,7 +60,6 @@ cli({
|
|
|
86
60
|
payload.dataList = parsedDataList;
|
|
87
61
|
}
|
|
88
62
|
|
|
89
|
-
const body = JSON.stringify(payload);
|
|
90
63
|
|
|
91
64
|
if (!payload.corpid) {
|
|
92
65
|
return makeErrorRow('NO_CORPID', '缺少本地 corpid;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>');
|
|
@@ -104,40 +77,26 @@ cli({
|
|
|
104
77
|
return makeErrorRow('INVALID_DATALIST', '--dataList 必须是 JSON 对象字符串');
|
|
105
78
|
}
|
|
106
79
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
const resp = await fetch(buildApiUrl(baseUrl, API_URL), {
|
|
116
|
-
method: 'POST',
|
|
117
|
-
headers,
|
|
118
|
-
body,
|
|
80
|
+
const gateway = await requestGateway({
|
|
81
|
+
baseUrl,
|
|
82
|
+
apiPath: API_PATH,
|
|
83
|
+
payload,
|
|
84
|
+
token,
|
|
85
|
+
userId,
|
|
86
|
+
debug,
|
|
119
87
|
});
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseText}\n`);
|
|
124
|
-
return makeErrorRow(resp.status, `HTTP ${resp.status} ${resp.statusText}`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const data = await resp.json();
|
|
128
|
-
const responseBody = JSON.stringify(data);
|
|
129
|
-
if (debug) process.stderr.write(`[debug] ResponseBody: ${responseBody}\n`);
|
|
130
|
-
if (data.code !== 1) {
|
|
131
|
-
return makeErrorRow(data.code ?? '', data.msg ?? '未知错误');
|
|
88
|
+
if (!gateway.ok) return makeErrorRow(gateway.code, gateway.msg);
|
|
89
|
+
if (gateway.data.code !== 1) {
|
|
90
|
+
return makeErrorRow(gateway.data.code ?? '', gateway.data.msg ?? '未知错误');
|
|
132
91
|
}
|
|
133
92
|
|
|
134
|
-
const result = data.result || {};
|
|
93
|
+
const result = gateway.data.result || {};
|
|
135
94
|
return [{
|
|
136
95
|
dataId: result.dataId || '',
|
|
137
96
|
resultCode: result.code ?? '',
|
|
138
97
|
resultMsg: result.msg || '',
|
|
139
|
-
code: data.code ?? '',
|
|
140
|
-
msg: data.msg || '',
|
|
98
|
+
code: gateway.data.code ?? '',
|
|
99
|
+
msg: gateway.data.msg || '',
|
|
141
100
|
}];
|
|
142
101
|
},
|
|
143
102
|
});
|