@xbongbong/xbbcli 2.1.1 → 2.2.0

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 (258) hide show
  1. package/README.md +32 -2
  2. package/ai-call-add-task.js +3 -15
  3. package/ai-word-list.js +3 -15
  4. package/bin/xbbcli.js +15 -2
  5. package/buyer-inquiry-detail.js +2 -14
  6. package/buyer-inquiry-list.js +2 -14
  7. package/clue-add-couser.js +2 -14
  8. package/clue-add.js +2 -14
  9. package/clue-back.js +2 -14
  10. package/clue-del.js +2 -14
  11. package/clue-delete-couser.js +2 -14
  12. package/clue-delete-mainuser.js +2 -14
  13. package/clue-detail.js +2 -14
  14. package/clue-distribution.js +2 -14
  15. package/clue-edit.js +2 -14
  16. package/clue-handover.js +3 -15
  17. package/clue-list.js +2 -14
  18. package/clue-thorough-delete.js +2 -14
  19. package/communicate-add.js +2 -14
  20. package/communicate-del.js +2 -14
  21. package/communicate-detail.js +2 -14
  22. package/communicate-edit.js +2 -14
  23. package/communicate-list.js +2 -14
  24. package/communicate-plan-add.js +2 -14
  25. package/communicate-plan-cancel.js +2 -14
  26. package/communicate-plan-del.js +2 -14
  27. package/communicate-plan-detail.js +2 -14
  28. package/communicate-plan-list.js +2 -14
  29. package/communicate-plan-single-operate.js +2 -14
  30. package/contact-add-couser.js +2 -14
  31. package/contact-add-mainuser.js +2 -14
  32. package/contact-add.js +2 -14
  33. package/contact-del.js +2 -14
  34. package/contact-delete-couser.js +2 -14
  35. package/contact-delete-mainuser.js +2 -14
  36. package/contact-detail.js +2 -14
  37. package/contact-edit.js +2 -14
  38. package/contact-handover.js +2 -14
  39. package/contact-list.js +2 -14
  40. package/contract-add-couser.js +2 -14
  41. package/contract-add-mainuser.js +2 -14
  42. package/contract-add.js +2 -14
  43. package/contract-del.js +2 -14
  44. package/contract-delete-couser.js +2 -14
  45. package/contract-delete-mainuser.js +2 -14
  46. package/contract-detail.js +2 -14
  47. package/contract-edit.js +2 -14
  48. package/contract-handover.js +2 -14
  49. package/contract-list.js +2 -14
  50. package/contract-outstock-add.js +2 -14
  51. package/contract-outstock-del.js +2 -14
  52. package/contract-outstock-detail.js +2 -14
  53. package/contract-outstock-edit.js +2 -14
  54. package/contract-outstock-list.js +2 -14
  55. package/customer-add-couser.js +2 -14
  56. package/customer-add.js +2 -14
  57. package/customer-back.js +2 -14
  58. package/customer-del.js +2 -14
  59. package/customer-delete-couser.js +2 -14
  60. package/customer-delete-mainuser.js +2 -14
  61. package/customer-detail.js +2 -14
  62. package/customer-distribution.js +2 -14
  63. package/customer-edit.js +2 -14
  64. package/customer-handover.js +2 -14
  65. package/customer-invoice-address-add.js +2 -14
  66. package/customer-invoice-address-edit.js +2 -14
  67. package/customer-invoice-address.js +2 -14
  68. package/customer-invoice-info-add.js +2 -14
  69. package/customer-invoice-info-edit.js +2 -14
  70. package/customer-invoice-info.js +2 -14
  71. package/customer-list.js +2 -14
  72. package/department-add.js +2 -14
  73. package/department-del.js +2 -14
  74. package/department-edit.js +2 -14
  75. package/department-list.js +2 -14
  76. package/form-data-add-couser.js +2 -14
  77. package/form-data-add-mainuser.js +2 -14
  78. package/form-data-add.js +2 -14
  79. package/form-data-del.js +2 -14
  80. package/form-data-delete-couser.js +2 -14
  81. package/form-data-delete-mainuser.js +2 -14
  82. package/form-data-detail.js +2 -14
  83. package/form-data-edit.js +2 -14
  84. package/form-data-handover.js +2 -14
  85. package/form-data-list.js +2 -14
  86. package/form-get.js +2 -14
  87. package/form-list.js +2 -14
  88. package/invoice-add.js +3 -15
  89. package/invoice-cancel.js +3 -15
  90. package/invoice-del.js +3 -15
  91. package/invoice-detail.js +3 -15
  92. package/invoice-edit.js +3 -15
  93. package/invoice-get-amount-detail.js +3 -15
  94. package/invoice-list.js +3 -15
  95. package/invoice-red.js +3 -15
  96. package/label-add.js +3 -15
  97. package/label-all-list.js +3 -15
  98. package/label-batch-add.js +3 -15
  99. package/label-batch-remove.js +3 -15
  100. package/label-del-completely.js +3 -15
  101. package/label-del.js +3 -15
  102. package/label-edit.js +3 -15
  103. package/label-group-add.js +3 -15
  104. package/label-group-del.js +3 -15
  105. package/label-group-list.js +3 -15
  106. package/label-group-update.js +3 -15
  107. package/label-list.js +3 -15
  108. package/label-reduction.js +3 -15
  109. package/label-repeat.js +3 -15
  110. package/market-activity-add.js +2 -14
  111. package/market-activity-del.js +2 -14
  112. package/market-activity-detail.js +2 -14
  113. package/market-activity-edit.js +2 -14
  114. package/market-activity-handover.js +2 -14
  115. package/market-activity-list.js +2 -14
  116. package/opportunity-add-couser.js +2 -14
  117. package/opportunity-add-mainuser.js +2 -14
  118. package/opportunity-add.js +2 -14
  119. package/opportunity-del.js +2 -14
  120. package/opportunity-delete-couser.js +2 -14
  121. package/opportunity-delete-mainuser.js +2 -14
  122. package/opportunity-detail.js +2 -14
  123. package/opportunity-edit.js +2 -14
  124. package/opportunity-handover.js +2 -14
  125. package/opportunity-list.js +2 -14
  126. package/package.json +1 -1
  127. package/pay-plan-add-couser.js +2 -14
  128. package/pay-plan-add-mainuser.js +2 -14
  129. package/pay-plan-add.js +2 -14
  130. package/pay-plan-delete-couser.js +2 -14
  131. package/pay-plan-delete-mainuser.js +2 -14
  132. package/pay-plan-handover.js +2 -14
  133. package/pay-sheet-add-bad.js +2 -14
  134. package/pay-sheet-add-couser.js +2 -14
  135. package/pay-sheet-add-mainuser.js +2 -14
  136. package/pay-sheet-add-red.js +2 -14
  137. package/pay-sheet-add-write-off.js +2 -14
  138. package/pay-sheet-del.js +2 -14
  139. package/pay-sheet-delete-couser.js +2 -14
  140. package/pay-sheet-delete-mainuser.js +2 -14
  141. package/pay-sheet-detail.js +2 -14
  142. package/pay-sheet-edit-bad.js +2 -14
  143. package/pay-sheet-edit-red.js +2 -14
  144. package/pay-sheet-edit-write-off.js +2 -14
  145. package/pay-sheet-get-amount-detail.js +2 -14
  146. package/pay-sheet-list.js +2 -14
  147. package/payment-add-couser.js +2 -14
  148. package/payment-add-mainuser.js +2 -14
  149. package/payment-add.js +2 -14
  150. package/payment-del.js +2 -14
  151. package/payment-delete-couser.js +2 -14
  152. package/payment-delete-mainuser.js +2 -14
  153. package/payment-detail.js +2 -14
  154. package/payment-edit.js +2 -14
  155. package/payment-handover.js +2 -14
  156. package/payment-list.js +2 -14
  157. package/payment-sheet-add-bad-debt.js +2 -14
  158. package/payment-sheet-add-pre.js +2 -14
  159. package/payment-sheet-add-red.js +2 -14
  160. package/payment-sheet-add-write-off.js +2 -14
  161. package/payment-sheet-del.js +2 -14
  162. package/payment-sheet-detail.js +2 -14
  163. package/payment-sheet-edit-bad-debt.js +2 -14
  164. package/payment-sheet-edit-red.js +2 -14
  165. package/payment-sheet-edit-write-off.js +2 -14
  166. package/payment-sheet-get-amount-detail.js +2 -14
  167. package/payment-sheet-handover.js +2 -14
  168. package/payment-sheet-list.js +2 -14
  169. package/product-add.js +2 -14
  170. package/product-category-add.js +2 -14
  171. package/product-category-del.js +2 -14
  172. package/product-category-list.js +2 -14
  173. package/product-category-update.js +2 -14
  174. package/product-del.js +2 -14
  175. package/product-detail.js +2 -14
  176. package/product-edit.js +2 -14
  177. package/product-list.js +2 -14
  178. package/product-online.js +2 -14
  179. package/quotation-add-couser.js +3 -15
  180. package/quotation-add-mainuser.js +3 -15
  181. package/quotation-add.js +3 -15
  182. package/quotation-del.js +3 -15
  183. package/quotation-delete-couser.js +3 -15
  184. package/quotation-delete-mainuser.js +3 -15
  185. package/quotation-detail.js +3 -15
  186. package/quotation-edit.js +3 -15
  187. package/quotation-handover.js +2 -14
  188. package/quotation-list.js +3 -15
  189. package/refund-add.js +2 -14
  190. package/refund-del.js +2 -14
  191. package/refund-detail.js +2 -14
  192. package/refund-edit.js +2 -14
  193. package/refund-list.js +2 -14
  194. package/role-list.js +2 -14
  195. package/sign-in-list.js +2 -14
  196. package/stage-get.js +2 -14
  197. package/stage-jump.js +2 -14
  198. package/supplier-add.js +2 -14
  199. package/token-del.js +5 -0
  200. package/token-generate.js +2 -14
  201. package/token-list.js +20 -2
  202. package/token-set.js +19 -3
  203. package/token-use.js +5 -0
  204. package/user-add.js +2 -14
  205. package/user-del.js +2 -14
  206. package/user-edit.js +2 -14
  207. package/user-handover.js +2 -14
  208. package/user-list.js +2 -14
  209. package/work-order-add.js +2 -14
  210. package/work-order-asset-add-couser.js +3 -15
  211. package/work-order-asset-add-mainuser.js +3 -15
  212. package/work-order-asset-add.js +3 -15
  213. package/work-order-asset-del-couser.js +3 -15
  214. package/work-order-asset-del-mainuser.js +3 -15
  215. package/work-order-asset-del.js +3 -15
  216. package/work-order-asset-detail.js +3 -15
  217. package/work-order-asset-edit.js +3 -15
  218. package/work-order-asset-handover.js +3 -15
  219. package/work-order-asset-list.js +3 -15
  220. package/work-order-del.js +2 -14
  221. package/work-order-detail.js +2 -14
  222. package/work-order-dynamic-list.js +2 -14
  223. package/work-order-edit.js +2 -14
  224. package/work-order-list.js +2 -14
  225. package/work-order-operate.js +2 -14
  226. package/work-order-template-detail.js +2 -14
  227. package/work-order-template-list.js +2 -14
  228. package/work-report-daily-add.js +2 -14
  229. package/work-report-daily-del.js +2 -14
  230. package/work-report-daily-detail.js +2 -14
  231. package/work-report-daily-edit.js +2 -14
  232. package/work-report-daily-get-work-plan.js +2 -14
  233. package/work-report-daily-list.js +2 -14
  234. package/work-report-monthly-add.js +2 -14
  235. package/work-report-monthly-del.js +2 -14
  236. package/work-report-monthly-detail.js +2 -14
  237. package/work-report-monthly-edit.js +2 -14
  238. package/work-report-monthly-list.js +2 -14
  239. package/work-report-weekly-add.js +2 -14
  240. package/work-report-weekly-del.js +2 -14
  241. package/work-report-weekly-detail.js +2 -14
  242. package/work-report-weekly-edit.js +2 -14
  243. package/work-report-weekly-list.js +2 -14
  244. package/work-task-add-couser.js +2 -14
  245. package/work-task-add.js +2 -14
  246. package/work-task-delete-couser.js +2 -14
  247. package/work-task-detail.js +2 -14
  248. package/work-task-edit.js +2 -14
  249. package/work-task-handover.js +2 -14
  250. package/workorder-add-couser.js +2 -14
  251. package/workorder-delete-couser.js +2 -14
  252. package/workorder-handover.js +2 -14
  253. package/workorderlist.js +2 -14
  254. package/workorderproductlist.js +2 -14
  255. package/worktimerecorddetail.js +2 -14
  256. package/worktimerecordlist.js +2 -14
  257. package/xbb-config.js +113 -0
  258. package/version.js +0 -18
@@ -2,7 +2,8 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
- import { cli, Strategy } from './xbb-registry.js';
5
+ import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.opencli', 'xbb', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/asset/delMinUser';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -2,7 +2,8 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
- import { cli, Strategy } from './xbb-registry.js';
5
+ import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.opencli', 'xbb', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/asset/del';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -2,7 +2,8 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
- import { cli, Strategy } from './xbb-registry.js';
5
+ import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.opencli', 'xbb', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/asset/detail';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -2,7 +2,8 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
- import { cli, Strategy } from './xbb-registry.js';
5
+ import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.opencli', 'xbb', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/asset/edit';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -2,7 +2,8 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
- import { cli, Strategy } from './xbb-registry.js';
5
+ import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.opencli', 'xbb', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/asset/handover';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -2,7 +2,8 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
- import { cli, Strategy } from './xbb-registry.js';
5
+ import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.opencli', 'xbb', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/asset/list';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 opencli xbb token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
package/work-order-del.js CHANGED
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const WORK_ORDER_DELETE_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/del';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const WORK_ORDER_DETAIL_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/detail';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const WORK_ORDER_DYNAMIC_LIST_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/dynamic/list';
@@ -11,20 +12,7 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
12
  let lastPagination = null;
12
13
 
13
14
  function readConfig() {
14
- try {
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 || {};
25
- } catch {
26
- return {};
27
- }
15
+ return readActiveConfig();
28
16
  }
29
17
 
30
18
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const WORK_ORDER_EDIT_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/edit';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const WORK_ORDER_LIST_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/list';
@@ -11,20 +12,7 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
12
  let lastPagination = null;
12
13
 
13
14
  function readConfig() {
14
- try {
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 || {};
25
- } catch {
26
- return {};
27
- }
15
+ return readActiveConfig();
28
16
  }
29
17
 
30
18
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const WORK_ORDER_OPERATE_API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrderV2/operate';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,26 +3,14 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workOrder/templateDetail';
9
10
  const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
 
11
12
  function readConfig() {
12
- try {
13
- const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
14
- const companies = Array.isArray(parsed)
15
- ? parsed
16
- : Array.isArray(parsed?.companies)
17
- ? parsed.companies
18
- : null;
19
- if (companies) {
20
- return companies.find((item) => item && item.enable) || {};
21
- }
22
- return parsed || {};
23
- } catch {
24
- return {};
25
- }
13
+ return readActiveConfig();
26
14
  }
27
15
 
28
16
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import crypto from 'node:crypto';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_DIR = path.join(os.homedir(), '.xbbcli');
8
9
  const CONFIG_FILE = path.join(CONFIG_DIR, 'config.env');
@@ -11,20 +12,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
11
12
  let lastPagination = null;
12
13
 
13
14
  function readConfig() {
14
- try {
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 || {};
25
- } catch {
26
- return {};
27
- }
15
+ return readActiveConfig();
28
16
  }
29
17
 
30
18
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workReportDaily/add';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workReportDaily/del';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workReportDaily/detail';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workReportDaily/edit';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workReportDaily/getWorkPlan';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workReportDaily/list';
@@ -11,20 +12,7 @@ const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --co
11
12
  let lastPagination = null;
12
13
 
13
14
  function readConfig() {
14
- try {
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 || {};
25
- } catch {
26
- return {};
27
- }
15
+ return readActiveConfig();
28
16
  }
29
17
 
30
18
  function getRuntimeConfig() {
@@ -3,6 +3,7 @@ import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { cli, Strategy } from './xbb-registry.js';
6
+ import { readActiveConfig } from './xbb-config.js';
6
7
 
7
8
  const CONFIG_FILE = path.join(os.homedir(), '.xbbcli', 'config.env');
8
9
  const API_URL = 'https://proapi.xbongbong.com/pro/v2/api/workReportMonthly/add';
@@ -10,20 +11,7 @@ const DEFAULT_BASE_URL = 'https://proapi.xbongbong.com';
10
11
  const MISSING_TOKEN_MESSAGE = '缺少 token;请先执行 xbbcli token-set --corpid <CORPID> --token <TOKEN> --userId <USERID>';
11
12
 
12
13
  function readConfig() {
13
- try {
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 || {};
24
- } catch {
25
- return {};
26
- }
14
+ return readActiveConfig();
27
15
  }
28
16
 
29
17
  function getRuntimeConfig() {