@xbongbong/xbbcli 2.0.0 → 2.1.1

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.
Files changed (256) hide show
  1. package/README.md +71 -2
  2. package/ai-call-add-task.js +10 -1
  3. package/ai-word-list.js +10 -1
  4. package/bin/xbbcli.js +5 -0
  5. package/buyer-inquiry-detail.js +10 -1
  6. package/buyer-inquiry-list.js +10 -1
  7. package/clue-add-couser.js +10 -1
  8. package/clue-add.js +10 -1
  9. package/clue-back.js +10 -1
  10. package/clue-del.js +10 -1
  11. package/clue-delete-couser.js +10 -1
  12. package/clue-delete-mainuser.js +10 -1
  13. package/clue-detail.js +10 -1
  14. package/clue-distribution.js +10 -1
  15. package/clue-edit.js +10 -1
  16. package/clue-handover.js +10 -1
  17. package/clue-list.js +10 -1
  18. package/clue-thorough-delete.js +10 -1
  19. package/communicate-add.js +10 -1
  20. package/communicate-del.js +10 -1
  21. package/communicate-detail.js +10 -1
  22. package/communicate-edit.js +10 -1
  23. package/communicate-list.js +10 -1
  24. package/communicate-plan-add.js +10 -1
  25. package/communicate-plan-cancel.js +10 -1
  26. package/communicate-plan-del.js +10 -1
  27. package/communicate-plan-detail.js +10 -1
  28. package/communicate-plan-list.js +10 -1
  29. package/communicate-plan-single-operate.js +10 -1
  30. package/contact-add-couser.js +10 -1
  31. package/contact-add-mainuser.js +10 -1
  32. package/contact-add.js +10 -1
  33. package/contact-del.js +14 -1
  34. package/contact-delete-couser.js +10 -1
  35. package/contact-delete-mainuser.js +10 -1
  36. package/contact-detail.js +14 -1
  37. package/contact-edit.js +10 -1
  38. package/contact-handover.js +10 -1
  39. package/contact-list.js +10 -1
  40. package/contract-add-couser.js +10 -1
  41. package/contract-add-mainuser.js +10 -1
  42. package/contract-add.js +10 -1
  43. package/contract-del.js +10 -1
  44. package/contract-delete-couser.js +10 -1
  45. package/contract-delete-mainuser.js +10 -1
  46. package/contract-detail.js +10 -1
  47. package/contract-edit.js +10 -1
  48. package/contract-handover.js +10 -1
  49. package/contract-list.js +10 -1
  50. package/contract-outstock-add.js +10 -1
  51. package/contract-outstock-del.js +10 -1
  52. package/contract-outstock-detail.js +10 -1
  53. package/contract-outstock-edit.js +10 -1
  54. package/contract-outstock-list.js +10 -1
  55. package/customer-add-couser.js +10 -1
  56. package/customer-add.js +10 -1
  57. package/customer-back.js +10 -1
  58. package/customer-del.js +10 -1
  59. package/customer-delete-couser.js +10 -1
  60. package/customer-delete-mainuser.js +10 -1
  61. package/customer-detail.js +10 -1
  62. package/customer-distribution.js +10 -1
  63. package/customer-edit.js +10 -1
  64. package/customer-handover.js +10 -1
  65. package/customer-invoice-address-add.js +10 -1
  66. package/customer-invoice-address-edit.js +10 -1
  67. package/customer-invoice-address.js +10 -1
  68. package/customer-invoice-info-add.js +10 -1
  69. package/customer-invoice-info-edit.js +10 -1
  70. package/customer-invoice-info.js +10 -1
  71. package/customer-list.js +10 -1
  72. package/department-add.js +10 -1
  73. package/department-del.js +10 -1
  74. package/department-edit.js +10 -1
  75. package/department-list.js +10 -1
  76. package/form-data-add-couser.js +10 -1
  77. package/form-data-add-mainuser.js +10 -1
  78. package/form-data-add.js +10 -1
  79. package/form-data-del.js +10 -1
  80. package/form-data-delete-couser.js +10 -1
  81. package/form-data-delete-mainuser.js +10 -1
  82. package/form-data-detail.js +10 -1
  83. package/form-data-edit.js +10 -1
  84. package/form-data-handover.js +10 -1
  85. package/form-data-list.js +10 -1
  86. package/form-get.js +10 -1
  87. package/form-list.js +10 -1
  88. package/invoice-add.js +10 -1
  89. package/invoice-cancel.js +10 -1
  90. package/invoice-del.js +10 -1
  91. package/invoice-detail.js +10 -1
  92. package/invoice-edit.js +10 -1
  93. package/invoice-get-amount-detail.js +10 -1
  94. package/invoice-list.js +10 -1
  95. package/invoice-red.js +10 -1
  96. package/label-add.js +10 -1
  97. package/label-all-list.js +10 -1
  98. package/label-batch-add.js +10 -1
  99. package/label-batch-remove.js +10 -1
  100. package/label-del-completely.js +10 -1
  101. package/label-del.js +10 -1
  102. package/label-edit.js +10 -1
  103. package/label-group-add.js +10 -1
  104. package/label-group-del.js +10 -1
  105. package/label-group-list.js +10 -1
  106. package/label-group-update.js +10 -1
  107. package/label-list.js +10 -1
  108. package/label-reduction.js +10 -1
  109. package/label-repeat.js +10 -1
  110. package/market-activity-add.js +10 -1
  111. package/market-activity-del.js +10 -1
  112. package/market-activity-detail.js +10 -1
  113. package/market-activity-edit.js +10 -1
  114. package/market-activity-handover.js +10 -1
  115. package/market-activity-list.js +10 -1
  116. package/opportunity-add-couser.js +10 -1
  117. package/opportunity-add-mainuser.js +10 -1
  118. package/opportunity-add.js +10 -1
  119. package/opportunity-del.js +10 -1
  120. package/opportunity-delete-couser.js +10 -1
  121. package/opportunity-delete-mainuser.js +10 -1
  122. package/opportunity-detail.js +10 -1
  123. package/opportunity-edit.js +10 -1
  124. package/opportunity-handover.js +10 -1
  125. package/opportunity-list.js +10 -1
  126. package/package.json +1 -1
  127. package/pay-plan-add-couser.js +10 -1
  128. package/pay-plan-add-mainuser.js +10 -1
  129. package/pay-plan-add.js +10 -1
  130. package/pay-plan-delete-couser.js +10 -1
  131. package/pay-plan-delete-mainuser.js +10 -1
  132. package/pay-plan-handover.js +10 -1
  133. package/pay-sheet-add-bad.js +10 -1
  134. package/pay-sheet-add-couser.js +10 -1
  135. package/pay-sheet-add-mainuser.js +10 -1
  136. package/pay-sheet-add-red.js +10 -1
  137. package/pay-sheet-add-write-off.js +10 -1
  138. package/pay-sheet-del.js +10 -1
  139. package/pay-sheet-delete-couser.js +10 -1
  140. package/pay-sheet-delete-mainuser.js +10 -1
  141. package/pay-sheet-detail.js +10 -1
  142. package/pay-sheet-edit-bad.js +10 -1
  143. package/pay-sheet-edit-red.js +10 -1
  144. package/pay-sheet-edit-write-off.js +10 -1
  145. package/pay-sheet-get-amount-detail.js +10 -1
  146. package/pay-sheet-list.js +10 -1
  147. package/payment-add-couser.js +10 -1
  148. package/payment-add-mainuser.js +10 -1
  149. package/payment-add.js +10 -1
  150. package/payment-del.js +10 -1
  151. package/payment-delete-couser.js +10 -1
  152. package/payment-delete-mainuser.js +10 -1
  153. package/payment-detail.js +10 -1
  154. package/payment-edit.js +10 -1
  155. package/payment-handover.js +10 -1
  156. package/payment-list.js +10 -1
  157. package/payment-sheet-add-bad-debt.js +10 -1
  158. package/payment-sheet-add-pre.js +10 -1
  159. package/payment-sheet-add-red.js +10 -1
  160. package/payment-sheet-add-write-off.js +10 -1
  161. package/payment-sheet-del.js +10 -1
  162. package/payment-sheet-detail.js +10 -1
  163. package/payment-sheet-edit-bad-debt.js +10 -1
  164. package/payment-sheet-edit-red.js +10 -1
  165. package/payment-sheet-edit-write-off.js +10 -1
  166. package/payment-sheet-get-amount-detail.js +10 -1
  167. package/payment-sheet-handover.js +10 -1
  168. package/payment-sheet-list.js +10 -1
  169. package/product-add.js +10 -1
  170. package/product-category-add.js +10 -1
  171. package/product-category-del.js +10 -1
  172. package/product-category-list.js +10 -1
  173. package/product-category-update.js +10 -1
  174. package/product-del.js +10 -1
  175. package/product-detail.js +10 -1
  176. package/product-edit.js +10 -1
  177. package/product-list.js +10 -1
  178. package/product-online.js +10 -1
  179. package/quotation-add-couser.js +10 -1
  180. package/quotation-add-mainuser.js +10 -1
  181. package/quotation-add.js +10 -1
  182. package/quotation-del.js +10 -1
  183. package/quotation-delete-couser.js +10 -1
  184. package/quotation-delete-mainuser.js +10 -1
  185. package/quotation-detail.js +10 -1
  186. package/quotation-edit.js +10 -1
  187. package/quotation-handover.js +10 -1
  188. package/quotation-list.js +10 -1
  189. package/refund-add.js +16 -1
  190. package/refund-del.js +16 -1
  191. package/refund-detail.js +16 -1
  192. package/refund-edit.js +16 -1
  193. package/refund-list.js +10 -1
  194. package/role-list.js +10 -1
  195. package/sign-in-list.js +10 -1
  196. package/stage-get.js +10 -1
  197. package/stage-jump.js +10 -1
  198. package/supplier-add.js +10 -1
  199. package/token-del.js +101 -0
  200. package/token-generate.js +10 -1
  201. package/token-list.js +101 -0
  202. package/token-set.js +175 -10
  203. package/token-use.js +97 -0
  204. package/user-add.js +10 -1
  205. package/user-del.js +10 -1
  206. package/user-edit.js +10 -1
  207. package/user-handover.js +10 -1
  208. package/user-list.js +13 -4
  209. package/work-order-add.js +10 -1
  210. package/work-order-asset-add-couser.js +10 -1
  211. package/work-order-asset-add-mainuser.js +10 -1
  212. package/work-order-asset-add.js +10 -1
  213. package/work-order-asset-del-couser.js +10 -1
  214. package/work-order-asset-del-mainuser.js +10 -1
  215. package/work-order-asset-del.js +10 -1
  216. package/work-order-asset-detail.js +10 -1
  217. package/work-order-asset-edit.js +10 -1
  218. package/work-order-asset-handover.js +10 -1
  219. package/work-order-asset-list.js +10 -1
  220. package/work-order-del.js +10 -1
  221. package/work-order-detail.js +10 -1
  222. package/work-order-dynamic-list.js +10 -1
  223. package/work-order-edit.js +10 -1
  224. package/work-order-list.js +10 -1
  225. package/work-order-operate.js +10 -1
  226. package/work-order-template-detail.js +10 -1
  227. package/work-order-template-list.js +10 -1
  228. package/work-report-daily-add.js +10 -1
  229. package/work-report-daily-del.js +10 -1
  230. package/work-report-daily-detail.js +10 -1
  231. package/work-report-daily-edit.js +10 -1
  232. package/work-report-daily-get-work-plan.js +10 -1
  233. package/work-report-daily-list.js +10 -1
  234. package/work-report-monthly-add.js +10 -1
  235. package/work-report-monthly-del.js +10 -1
  236. package/work-report-monthly-detail.js +10 -1
  237. package/work-report-monthly-edit.js +10 -1
  238. package/work-report-monthly-list.js +10 -1
  239. package/work-report-weekly-add.js +10 -1
  240. package/work-report-weekly-del.js +10 -1
  241. package/work-report-weekly-detail.js +10 -1
  242. package/work-report-weekly-edit.js +10 -1
  243. package/work-report-weekly-list.js +10 -1
  244. package/work-task-add-couser.js +10 -1
  245. package/work-task-add.js +10 -1
  246. package/work-task-delete-couser.js +10 -1
  247. package/work-task-detail.js +10 -1
  248. package/work-task-edit.js +10 -1
  249. package/work-task-handover.js +10 -1
  250. package/workorder-add-couser.js +10 -1
  251. package/workorder-delete-couser.js +10 -1
  252. package/workorder-handover.js +10 -1
  253. package/workorderlist.js +10 -1
  254. package/workorderproductlist.js +10 -1
  255. package/worktimerecorddetail.js +10 -1
  256. package/worktimerecordlist.js +10 -1
package/README.md CHANGED
@@ -13,6 +13,21 @@ xbbcli --help
13
13
 
14
14
  需要升级时运行 `npm update -g @xbongbong/xbbcli`。
15
15
 
16
+
17
+
18
+ 首次使用时配置销帮帮凭证:
19
+
20
+ ```bash
21
+ xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>
22
+ ```
23
+
24
+ 配置完成后即可运行各业务命令,例如:
25
+
26
+ ```bash
27
+ xbbcli user-list
28
+ xbbcli form-list --saasMark 1 -f json
29
+ ```
30
+
16
31
  ## 初始化配置
17
32
 
18
33
  首次使用先保存 `corpid`、`token` 和 `userId`:
@@ -27,12 +42,40 @@ xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>
27
42
  ~/.xbbcli/config.env
28
43
  ```
29
44
 
30
- 文件内容包含:
45
+ `config.env` 是一个 JSON 文件,可同时保存多家公司,每个公司包含:
31
46
 
32
47
  - `corpid`
33
48
  - `token`
34
49
  - `baseurl`
35
50
  - `userId`
51
+ - `enable`:是否启用;任何时刻**仅且只有一个**公司的 `enable` 为 `true`
52
+ - `corpName`:公司名称,取部门列表中 `id` 为 `1` 的部门名称(`token-set` 自动写入)
53
+ - `userName`:当前 `userId` 对应的员工姓名,从员工列表中按 `userId` 匹配(`token-set` 自动写入)
54
+
55
+ 示例:
56
+
57
+ ```json
58
+ [
59
+ {
60
+ "corpid": "<CORPID_A>",
61
+ "token": "<TOKEN_A>",
62
+ "baseurl": "https://proapi.xbongbong.com",
63
+ "userId": "<USERID_A>",
64
+ "corpName": "<CORP_NAME_A>",
65
+ "userName": "<USER_NAME_A>",
66
+ "enable": true
67
+ },
68
+ {
69
+ "corpid": "<CORPID_B>",
70
+ "token": "<TOKEN_B>",
71
+ "baseurl": "https://appapi.xbongbong.com",
72
+ "userId": "<USERID_B>",
73
+ "enable": false
74
+ }
75
+ ]
76
+ ```
77
+
78
+ `token-set` 会按 `corpid` 新增或覆盖一家公司,并把该公司置为 `enable=true`(其余公司自动置为 `false`),同时写入公司名称 `corpName`(取部门 `id` 为 `1` 的部门名称)和操作人姓名 `userName`(从员工列表中按 `userId` 匹配)。除 `token-set`、`token-list`、`token-use`、`token-del` 外,其余命令都使用 `enable` 为 `true` 的公司配置。
36
79
 
37
80
  同时会自动拉取两份表单清单并合并缓存到:
38
81
 
@@ -47,6 +90,27 @@ xbbcli form-list --saasMark 2 -f json
47
90
  xbbcli form-list --saasMark 1 -f json
48
91
  ```
49
92
 
93
+ 同时会自动分页拉取所有部门与员工并缓存到:
94
+
95
+ ```text
96
+ ~/.xbbcli/<corpid>.department-user.json
97
+ ```
98
+
99
+ 初始化过程调用:
100
+
101
+ ```bash
102
+ xbbcli department-list --pageSize 200 -f json
103
+ xbbcli user-list --pageSize 200 -f json
104
+ ```
105
+
106
+ 缓存文件内容:
107
+
108
+ - `departments`:部门清单(`id`、`name`、`parentId`、`depIdRouter`)
109
+ - `users`:员工清单(`userId`、`name`、`position`、`jobnumber`、`departmentList`)
110
+ - `departmentCount`、`userCount`、`pageSize`、`updatedAt`
111
+
112
+ 以后需要查询部门或员工信息时,可以先查这个文件,避免重复调用接口。
113
+
50
114
  `baseurl` 路由规则:
51
115
 
52
116
  - `corpid` 以 `ding` 开头,或包含 `$$ding` 时,使用 `https://proapi.xbongbong.com`
@@ -56,7 +120,10 @@ xbbcli form-list --saasMark 1 -f json
56
120
 
57
121
  ### 配置
58
122
 
59
- - `token-set`:保存个人 token、`corpid`、`userId`、`baseurl`,并刷新本地表单缓存;传入的 token 不以 `user_` 开头时,会先为该 `userId` 刷新并保存个人 token
123
+ - `token-set`:保存个人 token、`corpid`、`userId`、`baseurl`,并刷新本地表单缓存、命令映射文件与部门/员工缓存;传入的 token 不以 `user_` 开头时,会先为该 `userId` 刷新并保存个人 token
124
+ - `token-list`:列出本地保存的所有公司配置和唯一启用的公司(含 `corpName` 公司名称与 `userName` 操作人姓名);`--showToken` 显示完整 token(默认脱敏)
125
+ - `token-use`:切换当前启用的公司(`xbbcli token-use --corpid <CORPID>`),保证仅且只有一个公司被启用
126
+ - `token-del`:删除指定公司的本地配置(`xbbcli token-del --corpid <CORPID>`),并保证剩余配置中仅且只有一个公司被启用
60
127
  - `token-generate`:生成/获取个人 token,`--resetToken 0` 获取(默认)、`1` 刷新;`--checkUserId` 未传则用配置中的 `userId`
61
128
 
62
129
  ### 组织与人员
@@ -304,6 +371,8 @@ xbbcli form-list --saasMark 1 -f json
304
371
  - 大部分命令会从 `~/.xbbcli/config.env` 读取 `token`
305
372
  - 所有命令会从配置中读取 `userId` 并附加到请求 header 中
306
373
  - 大部分命令需要 formId 参数,可以根据业务名称或 businessType 从 `~/.xbbcli/<corpid>.formlist.json` 中获取 formId
374
+ - 需要查询部门 id/名称,或员工 userId/所属部门时,可以先查 `~/.xbbcli/<corpid>.department-user.json`(由 `token-set` 分页抓取并缓存全部部门与员工)
375
+ - 当前公司名称存在 `~/.xbbcli/config.env` 的 `corpName` 字段(取部门 `id` 为 `1` 的部门名称),操作人姓名存在 `userName` 字段(按 `userId` 匹配员工列表)
307
376
  - 未传入的可选参数不会进入请求体
308
377
  - `--attr` 和 `--value` 只有同时提供时才会拼入查询条件
309
378
  - `--limit` 是在响应映射之后截断结果
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/ai-word-list.js CHANGED
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/bin/xbbcli.js CHANGED
@@ -91,6 +91,11 @@ function outputRows(rows, command, format) {
91
91
  }
92
92
  process.stdout.write(`${columns.join('\t')}\n`);
93
93
  for (const row of rows) process.stdout.write(`${columns.map((column) => String(row[column] ?? '')).join('\t')}\n`);
94
+
95
+ const footer = typeof command.footerExtra === "function"
96
+ ? command.footerExtra()
97
+ : command.footerExtra;
98
+ if (footer) process.stdout.write(`${footer}\n`);
94
99
  }
95
100
 
96
101
  await loadCommands();
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -12,7 +12,16 @@ let lastPagination = null;
12
12
 
13
13
  function readConfig() {
14
14
  try {
15
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
16
+ const companies = Array.isArray(parsed)
17
+ ? parsed
18
+ : Array.isArray(parsed?.companies)
19
+ ? parsed.companies
20
+ : null;
21
+ if (companies) {
22
+ return companies.find((item) => item && item.enable) || {};
23
+ }
24
+ return parsed || {};
16
25
  } catch {
17
26
  return {};
18
27
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/clue-add.js CHANGED
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/clue-back.js CHANGED
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/clue-del.js CHANGED
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/clue-detail.js CHANGED
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/clue-edit.js CHANGED
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/clue-handover.js CHANGED
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
package/clue-list.js CHANGED
@@ -12,7 +12,16 @@ let lastPagination = null;
12
12
 
13
13
  function readConfig() {
14
14
  try {
15
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
16
+ const companies = Array.isArray(parsed)
17
+ ? parsed
18
+ : Array.isArray(parsed?.companies)
19
+ ? parsed.companies
20
+ : null;
21
+ if (companies) {
22
+ return companies.find((item) => item && item.enable) || {};
23
+ }
24
+ return parsed || {};
16
25
  } catch {
17
26
  return {};
18
27
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -12,7 +12,16 @@ let lastPagination = null;
12
12
 
13
13
  function readConfig() {
14
14
  try {
15
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
16
+ const companies = Array.isArray(parsed)
17
+ ? parsed
18
+ : Array.isArray(parsed?.companies)
19
+ ? parsed.companies
20
+ : null;
21
+ if (companies) {
22
+ return companies.find((item) => item && item.enable) || {};
23
+ }
24
+ return parsed || {};
16
25
  } catch {
17
26
  return {};
18
27
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -12,7 +12,16 @@ let lastPagination = null;
12
12
 
13
13
  function readConfig() {
14
14
  try {
15
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
16
+ const companies = Array.isArray(parsed)
17
+ ? parsed
18
+ : Array.isArray(parsed?.companies)
19
+ ? parsed.companies
20
+ : null;
21
+ if (companies) {
22
+ return companies.find((item) => item && item.enable) || {};
23
+ }
24
+ return parsed || {};
16
25
  } catch {
17
26
  return {};
18
27
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }
@@ -11,7 +11,16 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
11
 
12
12
  function readConfig() {
13
13
  try {
14
- return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
+ const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
15
+ const companies = Array.isArray(parsed)
16
+ ? parsed
17
+ : Array.isArray(parsed?.companies)
18
+ ? parsed.companies
19
+ : null;
20
+ if (companies) {
21
+ return companies.find((item) => item && item.enable) || {};
22
+ }
23
+ return parsed || {};
15
24
  } catch {
16
25
  return {};
17
26
  }