@newpeak/barista-cli 0.1.7 β†’ 0.1.9

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 (306) hide show
  1. package/README.md +10 -10
  2. package/dist/commands/liberica/calendar/index.d.ts +3 -0
  3. package/dist/commands/liberica/calendar/index.d.ts.map +1 -0
  4. package/dist/commands/liberica/calendar/index.js +11 -0
  5. package/dist/commands/liberica/calendar/index.js.map +1 -0
  6. package/dist/commands/liberica/calendar/list.d.ts +3 -0
  7. package/dist/commands/liberica/calendar/list.d.ts.map +1 -0
  8. package/dist/commands/liberica/calendar/list.js +181 -0
  9. package/dist/commands/liberica/calendar/list.js.map +1 -0
  10. package/dist/commands/liberica/calendar/set.d.ts +3 -0
  11. package/dist/commands/liberica/calendar/set.d.ts.map +1 -0
  12. package/dist/commands/liberica/calendar/set.js +120 -0
  13. package/dist/commands/liberica/calendar/set.js.map +1 -0
  14. package/dist/commands/liberica/client-contacts/create.d.ts +3 -0
  15. package/dist/commands/liberica/client-contacts/create.d.ts.map +1 -0
  16. package/dist/commands/liberica/client-contacts/create.js +132 -0
  17. package/dist/commands/liberica/client-contacts/create.js.map +1 -0
  18. package/dist/commands/liberica/client-contacts/delete.d.ts +3 -0
  19. package/dist/commands/liberica/client-contacts/delete.d.ts.map +1 -0
  20. package/dist/commands/liberica/client-contacts/delete.js +139 -0
  21. package/dist/commands/liberica/client-contacts/delete.js.map +1 -0
  22. package/dist/commands/liberica/client-contacts/get.d.ts +3 -0
  23. package/dist/commands/liberica/client-contacts/get.d.ts.map +1 -0
  24. package/dist/commands/liberica/client-contacts/get.js +92 -0
  25. package/dist/commands/liberica/client-contacts/get.js.map +1 -0
  26. package/dist/commands/liberica/client-contacts/index.d.ts +3 -0
  27. package/dist/commands/liberica/client-contacts/index.d.ts.map +1 -0
  28. package/dist/commands/liberica/client-contacts/index.js +17 -0
  29. package/dist/commands/liberica/client-contacts/index.js.map +1 -0
  30. package/dist/commands/liberica/client-contacts/list.d.ts +3 -0
  31. package/dist/commands/liberica/client-contacts/list.d.ts.map +1 -0
  32. package/dist/commands/liberica/client-contacts/list.js +92 -0
  33. package/dist/commands/liberica/client-contacts/list.js.map +1 -0
  34. package/dist/commands/liberica/client-contacts/update.d.ts +3 -0
  35. package/dist/commands/liberica/client-contacts/update.d.ts.map +1 -0
  36. package/dist/commands/liberica/client-contacts/update.js +156 -0
  37. package/dist/commands/liberica/client-contacts/update.js.map +1 -0
  38. package/dist/commands/liberica/dict-types/get.d.ts +3 -0
  39. package/dist/commands/liberica/dict-types/get.d.ts.map +1 -0
  40. package/dist/commands/liberica/dict-types/get.js +62 -0
  41. package/dist/commands/liberica/dict-types/get.js.map +1 -0
  42. package/dist/commands/liberica/dict-types/index.d.ts +3 -0
  43. package/dist/commands/liberica/dict-types/index.d.ts.map +1 -0
  44. package/dist/commands/liberica/dict-types/index.js +13 -0
  45. package/dist/commands/liberica/dict-types/index.js.map +1 -0
  46. package/dist/commands/liberica/dict-types/list.d.ts +3 -0
  47. package/dist/commands/liberica/dict-types/list.d.ts.map +1 -0
  48. package/dist/commands/liberica/dict-types/list.js +91 -0
  49. package/dist/commands/liberica/dict-types/list.js.map +1 -0
  50. package/dist/commands/liberica/dict-types/update.d.ts +3 -0
  51. package/dist/commands/liberica/dict-types/update.d.ts.map +1 -0
  52. package/dist/commands/liberica/dict-types/update.js +127 -0
  53. package/dist/commands/liberica/dict-types/update.js.map +1 -0
  54. package/dist/commands/liberica/dicts/create.d.ts +3 -0
  55. package/dist/commands/liberica/dicts/create.d.ts.map +1 -0
  56. package/dist/commands/liberica/dicts/create.js +157 -0
  57. package/dist/commands/liberica/dicts/create.js.map +1 -0
  58. package/dist/commands/liberica/dicts/delete.d.ts +3 -0
  59. package/dist/commands/liberica/dicts/delete.d.ts.map +1 -0
  60. package/dist/commands/liberica/dicts/delete.js +106 -0
  61. package/dist/commands/liberica/dicts/delete.js.map +1 -0
  62. package/dist/commands/liberica/dicts/get.d.ts +3 -0
  63. package/dist/commands/liberica/dicts/get.d.ts.map +1 -0
  64. package/dist/commands/liberica/dicts/get.js +69 -0
  65. package/dist/commands/liberica/dicts/get.js.map +1 -0
  66. package/dist/commands/liberica/dicts/index.d.ts +3 -0
  67. package/dist/commands/liberica/dicts/index.d.ts.map +1 -0
  68. package/dist/commands/liberica/dicts/index.js +17 -0
  69. package/dist/commands/liberica/dicts/index.js.map +1 -0
  70. package/dist/commands/liberica/dicts/list.d.ts +3 -0
  71. package/dist/commands/liberica/dicts/list.d.ts.map +1 -0
  72. package/dist/commands/liberica/dicts/list.js +88 -0
  73. package/dist/commands/liberica/dicts/list.js.map +1 -0
  74. package/dist/commands/liberica/dicts/update.d.ts +3 -0
  75. package/dist/commands/liberica/dicts/update.d.ts.map +1 -0
  76. package/dist/commands/liberica/dicts/update.js +112 -0
  77. package/dist/commands/liberica/dicts/update.js.map +1 -0
  78. package/dist/commands/liberica/index.d.ts.map +1 -1
  79. package/dist/commands/liberica/index.js +20 -0
  80. package/dist/commands/liberica/index.js.map +1 -1
  81. package/dist/commands/liberica/materials/create.d.ts.map +1 -1
  82. package/dist/commands/liberica/materials/create.js +13 -6
  83. package/dist/commands/liberica/materials/create.js.map +1 -1
  84. package/dist/commands/liberica/materials/update.js +1 -1
  85. package/dist/commands/liberica/materials/update.js.map +1 -1
  86. package/dist/commands/liberica/mould/get.d.ts +3 -0
  87. package/dist/commands/liberica/mould/get.d.ts.map +1 -0
  88. package/dist/commands/liberica/mould/get.js +90 -0
  89. package/dist/commands/liberica/mould/get.js.map +1 -0
  90. package/dist/commands/liberica/mould/index.d.ts +3 -0
  91. package/dist/commands/liberica/mould/index.d.ts.map +1 -0
  92. package/dist/commands/liberica/mould/index.js +15 -0
  93. package/dist/commands/liberica/mould/index.js.map +1 -0
  94. package/dist/commands/liberica/mould/list.d.ts +3 -0
  95. package/dist/commands/liberica/mould/list.d.ts.map +1 -0
  96. package/dist/commands/liberica/mould/list.js +114 -0
  97. package/dist/commands/liberica/mould/list.js.map +1 -0
  98. package/dist/commands/liberica/mould/set-status.d.ts +3 -0
  99. package/dist/commands/liberica/mould/set-status.d.ts.map +1 -0
  100. package/dist/commands/liberica/mould/set-status.js +84 -0
  101. package/dist/commands/liberica/mould/set-status.js.map +1 -0
  102. package/dist/commands/liberica/mould/stock-in.d.ts +3 -0
  103. package/dist/commands/liberica/mould/stock-in.d.ts.map +1 -0
  104. package/dist/commands/liberica/mould/stock-in.js +160 -0
  105. package/dist/commands/liberica/mould/stock-in.js.map +1 -0
  106. package/dist/commands/liberica/operations/active.d.ts +3 -0
  107. package/dist/commands/liberica/operations/active.d.ts.map +1 -0
  108. package/dist/commands/liberica/operations/active.js +152 -0
  109. package/dist/commands/liberica/operations/active.js.map +1 -0
  110. package/dist/commands/liberica/operations/batch-delete.d.ts +3 -0
  111. package/dist/commands/liberica/operations/batch-delete.d.ts.map +1 -0
  112. package/dist/commands/liberica/operations/batch-delete.js +130 -0
  113. package/dist/commands/liberica/operations/batch-delete.js.map +1 -0
  114. package/dist/commands/liberica/operations/copy.d.ts +3 -0
  115. package/dist/commands/liberica/operations/copy.d.ts.map +1 -0
  116. package/dist/commands/liberica/operations/copy.js +137 -0
  117. package/dist/commands/liberica/operations/copy.js.map +1 -0
  118. package/dist/commands/liberica/operations/create.d.ts +3 -0
  119. package/dist/commands/liberica/operations/create.d.ts.map +1 -0
  120. package/dist/commands/liberica/operations/create.js +212 -0
  121. package/dist/commands/liberica/operations/create.js.map +1 -0
  122. package/dist/commands/liberica/operations/deactive.d.ts +3 -0
  123. package/dist/commands/liberica/operations/deactive.d.ts.map +1 -0
  124. package/dist/commands/liberica/operations/deactive.js +152 -0
  125. package/dist/commands/liberica/operations/deactive.js.map +1 -0
  126. package/dist/commands/liberica/operations/delete.d.ts +3 -0
  127. package/dist/commands/liberica/operations/delete.d.ts.map +1 -0
  128. package/dist/commands/liberica/operations/delete.js +128 -0
  129. package/dist/commands/liberica/operations/delete.js.map +1 -0
  130. package/dist/commands/liberica/operations/get.d.ts +3 -0
  131. package/dist/commands/liberica/operations/get.d.ts.map +1 -0
  132. package/dist/commands/liberica/operations/get.js +93 -0
  133. package/dist/commands/liberica/operations/get.js.map +1 -0
  134. package/dist/commands/liberica/operations/index.d.ts +3 -0
  135. package/dist/commands/liberica/operations/index.d.ts.map +1 -0
  136. package/dist/commands/liberica/operations/index.js +25 -0
  137. package/dist/commands/liberica/operations/index.js.map +1 -0
  138. package/dist/commands/liberica/operations/list.d.ts +3 -0
  139. package/dist/commands/liberica/operations/list.d.ts.map +1 -0
  140. package/dist/commands/liberica/operations/list.js +141 -0
  141. package/dist/commands/liberica/operations/list.js.map +1 -0
  142. package/dist/commands/liberica/operations/update.d.ts +3 -0
  143. package/dist/commands/liberica/operations/update.d.ts.map +1 -0
  144. package/dist/commands/liberica/operations/update.js +208 -0
  145. package/dist/commands/liberica/operations/update.js.map +1 -0
  146. package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts +2 -0
  147. package/dist/commands/liberica/stock/__tests__/ledger.test.d.ts.map +1 -0
  148. package/dist/commands/liberica/stock/__tests__/ledger.test.js +41 -0
  149. package/dist/commands/liberica/stock/__tests__/ledger.test.js.map +1 -0
  150. package/dist/commands/liberica/stock/__tests__/list.test.d.ts +2 -0
  151. package/dist/commands/liberica/stock/__tests__/list.test.d.ts.map +1 -0
  152. package/dist/commands/liberica/stock/__tests__/list.test.js +39 -0
  153. package/dist/commands/liberica/stock/__tests__/list.test.js.map +1 -0
  154. package/dist/commands/liberica/stock/index.d.ts +3 -0
  155. package/dist/commands/liberica/stock/index.d.ts.map +1 -0
  156. package/dist/commands/liberica/stock/index.js +11 -0
  157. package/dist/commands/liberica/stock/index.js.map +1 -0
  158. package/dist/commands/liberica/stock/ledger.d.ts +3 -0
  159. package/dist/commands/liberica/stock/ledger.d.ts.map +1 -0
  160. package/dist/commands/liberica/stock/ledger.js +154 -0
  161. package/dist/commands/liberica/stock/ledger.js.map +1 -0
  162. package/dist/commands/liberica/stock/list.d.ts +3 -0
  163. package/dist/commands/liberica/stock/list.d.ts.map +1 -0
  164. package/dist/commands/liberica/stock/list.js +127 -0
  165. package/dist/commands/liberica/stock/list.js.map +1 -0
  166. package/dist/commands/liberica/supplier-contacts/create.d.ts +3 -0
  167. package/dist/commands/liberica/supplier-contacts/create.d.ts.map +1 -0
  168. package/dist/commands/liberica/supplier-contacts/create.js +129 -0
  169. package/dist/commands/liberica/supplier-contacts/create.js.map +1 -0
  170. package/dist/commands/liberica/supplier-contacts/delete.d.ts +3 -0
  171. package/dist/commands/liberica/supplier-contacts/delete.d.ts.map +1 -0
  172. package/dist/commands/liberica/supplier-contacts/delete.js +88 -0
  173. package/dist/commands/liberica/supplier-contacts/delete.js.map +1 -0
  174. package/dist/commands/liberica/supplier-contacts/get.d.ts +3 -0
  175. package/dist/commands/liberica/supplier-contacts/get.d.ts.map +1 -0
  176. package/dist/commands/liberica/supplier-contacts/get.js +84 -0
  177. package/dist/commands/liberica/supplier-contacts/get.js.map +1 -0
  178. package/dist/commands/liberica/supplier-contacts/index.d.ts +3 -0
  179. package/dist/commands/liberica/supplier-contacts/index.d.ts.map +1 -0
  180. package/dist/commands/liberica/supplier-contacts/index.js +17 -0
  181. package/dist/commands/liberica/supplier-contacts/index.js.map +1 -0
  182. package/dist/commands/liberica/supplier-contacts/list.d.ts +3 -0
  183. package/dist/commands/liberica/supplier-contacts/list.d.ts.map +1 -0
  184. package/dist/commands/liberica/supplier-contacts/list.js +98 -0
  185. package/dist/commands/liberica/supplier-contacts/list.js.map +1 -0
  186. package/dist/commands/liberica/supplier-contacts/update.d.ts +3 -0
  187. package/dist/commands/liberica/supplier-contacts/update.d.ts.map +1 -0
  188. package/dist/commands/liberica/supplier-contacts/update.js +136 -0
  189. package/dist/commands/liberica/supplier-contacts/update.js.map +1 -0
  190. package/dist/core/api/client.d.ts +63 -0
  191. package/dist/core/api/client.d.ts.map +1 -1
  192. package/dist/core/api/client.js +1050 -65
  193. package/dist/core/api/client.js.map +1 -1
  194. package/dist/index.js +1 -1
  195. package/dist/types/calendar.d.ts +28 -0
  196. package/dist/types/calendar.d.ts.map +1 -0
  197. package/dist/types/calendar.js +2 -0
  198. package/dist/types/calendar.js.map +1 -0
  199. package/dist/types/client-contact.d.ts +65 -0
  200. package/dist/types/client-contact.d.ts.map +1 -0
  201. package/dist/types/client-contact.js +4 -0
  202. package/dist/types/client-contact.js.map +1 -0
  203. package/dist/types/dict.d.ts +97 -0
  204. package/dist/types/dict.d.ts.map +1 -0
  205. package/dist/types/dict.js +2 -0
  206. package/dist/types/dict.js.map +1 -0
  207. package/dist/types/index.d.ts +7 -0
  208. package/dist/types/index.d.ts.map +1 -1
  209. package/dist/types/index.js +1 -0
  210. package/dist/types/index.js.map +1 -1
  211. package/dist/types/material.d.ts +1 -1
  212. package/dist/types/material.d.ts.map +1 -1
  213. package/dist/types/mould-stock-in.d.ts +70 -0
  214. package/dist/types/mould-stock-in.d.ts.map +1 -0
  215. package/dist/types/mould-stock-in.js +3 -0
  216. package/dist/types/mould-stock-in.js.map +1 -0
  217. package/dist/types/mould.d.ts +61 -0
  218. package/dist/types/mould.d.ts.map +1 -0
  219. package/dist/types/mould.js +2 -0
  220. package/dist/types/mould.js.map +1 -0
  221. package/dist/types/operation.d.ts +66 -0
  222. package/dist/types/operation.d.ts.map +1 -0
  223. package/dist/types/operation.js +2 -0
  224. package/dist/types/operation.js.map +1 -0
  225. package/dist/types/stock.d.ts +133 -0
  226. package/dist/types/stock.d.ts.map +1 -0
  227. package/dist/types/stock.js +3 -0
  228. package/dist/types/stock.js.map +1 -0
  229. package/dist/types/supplier-contact.d.ts +65 -0
  230. package/dist/types/supplier-contact.d.ts.map +1 -0
  231. package/dist/types/supplier-contact.js +4 -0
  232. package/dist/types/supplier-contact.js.map +1 -0
  233. package/docs/commands/REFERENCE.md +24 -4
  234. package/docs/commands/liberica/calendar/DESIGN.md +333 -0
  235. package/docs/commands/liberica/client-contacts/create.md +152 -0
  236. package/docs/commands/liberica/client-contacts/delete.md +123 -0
  237. package/docs/commands/liberica/client-contacts/get.md +133 -0
  238. package/docs/commands/liberica/client-contacts/list.md +143 -0
  239. package/docs/commands/liberica/client-contacts/update.md +158 -0
  240. package/docs/commands/liberica/stock/ledger.md +209 -0
  241. package/docs/commands/liberica/stock/list.md +165 -0
  242. package/docs/commands/liberica/supplier-contacts/create.md +152 -0
  243. package/docs/commands/liberica/supplier-contacts/delete.md +123 -0
  244. package/docs/commands/liberica/supplier-contacts/get.md +133 -0
  245. package/docs/commands/liberica/supplier-contacts/list.md +143 -0
  246. package/docs/commands/liberica/supplier-contacts/update.md +158 -0
  247. package/package.json +1 -1
  248. package/src/commands/liberica/calendar/index.ts +13 -0
  249. package/src/commands/liberica/calendar/list.ts +214 -0
  250. package/src/commands/liberica/calendar/set.ts +130 -0
  251. package/src/commands/liberica/client-contacts/create.ts +115 -0
  252. package/src/commands/liberica/client-contacts/delete.ts +140 -0
  253. package/src/commands/liberica/client-contacts/get.ts +103 -0
  254. package/src/commands/liberica/client-contacts/index.ts +19 -0
  255. package/src/commands/liberica/client-contacts/list.ts +118 -0
  256. package/src/commands/liberica/client-contacts/update.ts +137 -0
  257. package/src/commands/liberica/dict-types/get.ts +74 -0
  258. package/src/commands/liberica/dict-types/index.ts +15 -0
  259. package/src/commands/liberica/dict-types/list.ts +118 -0
  260. package/src/commands/liberica/dict-types/update.ts +134 -0
  261. package/src/commands/liberica/dicts/create.ts +175 -0
  262. package/src/commands/liberica/dicts/delete.ts +107 -0
  263. package/src/commands/liberica/dicts/get.ts +80 -0
  264. package/src/commands/liberica/dicts/index.ts +19 -0
  265. package/src/commands/liberica/dicts/list.ts +114 -0
  266. package/src/commands/liberica/dicts/update.ts +116 -0
  267. package/src/commands/liberica/index.ts +20 -0
  268. package/src/commands/liberica/materials/create.ts +13 -5
  269. package/src/commands/liberica/materials/update.ts +1 -1
  270. package/src/commands/liberica/mould/get.ts +111 -0
  271. package/src/commands/liberica/mould/index.ts +17 -0
  272. package/src/commands/liberica/mould/list.ts +157 -0
  273. package/src/commands/liberica/mould/set-status.ts +99 -0
  274. package/src/commands/liberica/mould/stock-in.ts +165 -0
  275. package/src/commands/liberica/operations/active.ts +153 -0
  276. package/src/commands/liberica/operations/batch-delete.ts +131 -0
  277. package/src/commands/liberica/operations/copy.ts +138 -0
  278. package/src/commands/liberica/operations/create.ts +223 -0
  279. package/src/commands/liberica/operations/deactive.ts +152 -0
  280. package/src/commands/liberica/operations/delete.ts +128 -0
  281. package/src/commands/liberica/operations/design.md +587 -0
  282. package/src/commands/liberica/operations/get.ts +112 -0
  283. package/src/commands/liberica/operations/index.ts +27 -0
  284. package/src/commands/liberica/operations/list.ts +180 -0
  285. package/src/commands/liberica/operations/update.ts +218 -0
  286. package/src/commands/liberica/stock/index.ts +13 -0
  287. package/src/commands/liberica/stock/ledger.ts +159 -0
  288. package/src/commands/liberica/stock/list.ts +128 -0
  289. package/src/commands/liberica/supplier-contacts/create.ts +120 -0
  290. package/src/commands/liberica/supplier-contacts/delete.ts +88 -0
  291. package/src/commands/liberica/supplier-contacts/get.ts +94 -0
  292. package/src/commands/liberica/supplier-contacts/index.ts +19 -0
  293. package/src/commands/liberica/supplier-contacts/list.ts +130 -0
  294. package/src/commands/liberica/supplier-contacts/update.ts +127 -0
  295. package/src/core/api/client.ts +1238 -17
  296. package/src/index.ts +1 -1
  297. package/src/types/calendar.ts +36 -0
  298. package/src/types/client-contact.ts +78 -0
  299. package/src/types/dict.ts +121 -0
  300. package/src/types/index.ts +7 -0
  301. package/src/types/material.ts +1 -1
  302. package/src/types/mould-stock-in.ts +82 -0
  303. package/src/types/mould.ts +74 -0
  304. package/src/types/operation.ts +72 -0
  305. package/src/types/stock.ts +161 -0
  306. package/src/types/supplier-contact.ts +78 -0
@@ -0,0 +1,80 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { configManager } from '../../../core/config/manager.js';
4
+ import { apiClient } from '../../../core/api/client.js';
5
+ import { Environment } from '../../../types/index.js';
6
+ import { DictItem } from '../../../types/dict.js';
7
+
8
+ export function createDictGetCommand(): Command {
9
+ const getCommand = new Command('get');
10
+ getCommand.description('Get dictionary item details by ID');
11
+ getCommand.arguments('<dictId>');
12
+ getCommand.option('--json', 'Output as JSON');
13
+
14
+ getCommand.action(async (dictId: string, options: Record<string, unknown>) => {
15
+ const context = configManager.getCurrentContext();
16
+ const environment = (options.env as Environment) || context.environment;
17
+ const tenant = (options.tenant as string) || context.tenant;
18
+
19
+ if (!dictId) {
20
+ console.error(chalk.red('\nβœ— Dict ID is required\n'));
21
+ process.exit(1);
22
+ }
23
+
24
+ if (!dictId || dictId.trim() === '') {
25
+ console.error(chalk.red('\nβœ— Invalid dict ID.\n'));
26
+ process.exit(1);
27
+ }
28
+
29
+ try {
30
+ const response = await apiClient.getDictItem(environment, tenant, dictId);
31
+
32
+ if (!response.success) {
33
+ const errorCode = response.error?.code || 'UNKNOWN_ERROR';
34
+ const errorMessage = response.error?.message || 'Unknown error';
35
+
36
+ // Handle "dict item not found" case
37
+ if (errorCode === '01001150001' || errorMessage.includes('不存在')) {
38
+ console.error(chalk.red(`\nβœ— Dictionary item not found: ${dictId}\n`));
39
+ } else {
40
+ console.error(chalk.red(`\nβœ— Error: ${errorMessage} (${errorCode})\n`));
41
+ }
42
+ process.exit(1);
43
+ }
44
+
45
+ const dictItem = response.data as DictItem | null;
46
+
47
+ if (!dictItem) {
48
+ console.error(chalk.red('\nβœ— Dictionary item not found\n'));
49
+ process.exit(1);
50
+ }
51
+
52
+ if (options.json) {
53
+ console.log(JSON.stringify({
54
+ success: true,
55
+ data: dictItem,
56
+ }, null, 2));
57
+ return;
58
+ }
59
+
60
+ // Table output
61
+ console.log(chalk.bold('\nπŸ“– Dictionary Item Details\n'));
62
+ console.log(` ${chalk.gray('ID:')} ${dictItem.dictId}`);
63
+ console.log(` ${chalk.gray('Type ID:')} ${dictItem.dictTypeId}`);
64
+ console.log(` ${chalk.gray('Code:')} ${dictItem.dictCode}`);
65
+ console.log(` ${chalk.gray('Name:')} ${dictItem.dictName}`);
66
+ console.log(` ${chalk.gray('Value:')} ${dictItem.dictValue}`);
67
+ console.log(` ${chalk.gray('Sort Order:')} ${dictItem.sortOrder}`);
68
+ console.log(` ${chalk.gray('Status:')} ${dictItem.statusFlag === 1 ? 'Enable' : 'Disable'}`);
69
+ if (dictItem.remark) {
70
+ console.log(` ${chalk.gray('Remark:')} ${dictItem.remark}`);
71
+ }
72
+ console.log();
73
+ } catch (error) {
74
+ console.error(chalk.red(`\nβœ— Unexpected error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
75
+ process.exit(1);
76
+ }
77
+ });
78
+
79
+ return getCommand;
80
+ }
@@ -0,0 +1,19 @@
1
+ import { Command } from 'commander';
2
+ import { createDictListCommand } from './list.js';
3
+ import { createDictGetCommand } from './get.js';
4
+ import { createDictDeleteCommand } from './delete.js';
5
+ import { createDictCreateCommand } from './create.js';
6
+ import { createDictUpdateCommand } from './update.js';
7
+
8
+ export function createDictsCommand(): Command {
9
+ const dictsCommand = new Command('dicts');
10
+ dictsCommand.description('Manage dictionary items');
11
+
12
+ dictsCommand.addCommand(createDictListCommand());
13
+ dictsCommand.addCommand(createDictGetCommand());
14
+ dictsCommand.addCommand(createDictDeleteCommand());
15
+ dictsCommand.addCommand(createDictCreateCommand());
16
+ dictsCommand.addCommand(createDictUpdateCommand());
17
+
18
+ return dictsCommand;
19
+ }
@@ -0,0 +1,114 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import Table from 'cli-table3';
4
+ import { configManager } from '../../../core/config/manager.js';
5
+ import { apiClient } from '../../../core/api/client.js';
6
+ import { DictItem, DictStatusFlag } from '../../../types/dict.js';
7
+ import { Environment } from '../../../types/index.js';
8
+
9
+ export function createDictListCommand(): Command {
10
+ const listCommand = new Command('list');
11
+ listCommand.description('List dictionary items by type');
12
+
13
+ listCommand
14
+ .requiredOption('-t, --type-code <string>', 'Dict type code (e.g., ID_TYPE, sex)')
15
+ .option('-p, --page <number>', 'Page number', '1')
16
+ .option('-s, --size <number>', 'Page size', '20')
17
+ .option('--status <string>', 'Status filter (enable/disable)')
18
+ .option('--json', 'Output as JSON')
19
+ .action(async (options) => {
20
+ const outputJson = options.json === true || process.argv.includes('--json');
21
+
22
+ const context = configManager.getCurrentContext();
23
+ const environment = (options.env as Environment) || context.environment;
24
+ const tenant = options.tenant || context.tenant;
25
+
26
+ const typeCode = options.typeCode as string;
27
+ const page = parseInt(options.page as string, 10) - 1;
28
+ const size = parseInt(options.size as string, 10);
29
+
30
+ const params: {
31
+ dictTypeCode: string;
32
+ pageNo: number;
33
+ pageSize: number;
34
+ status?: DictStatusFlag;
35
+ } = { dictTypeCode: typeCode, pageNo: page, pageSize: size };
36
+
37
+ if (options.status !== undefined) {
38
+ const statusVal = (options.status as string).toLowerCase();
39
+ if (statusVal === 'enable' || statusVal === '1') {
40
+ params.status = 1;
41
+ } else if (statusVal === 'disable' || statusVal === '2') {
42
+ params.status = 2;
43
+ }
44
+ }
45
+
46
+ const response = await apiClient.listDictItems(environment, tenant, params);
47
+
48
+ if (!response.success) {
49
+ console.error(chalk.red(`\nβœ— Failed to list dict items: ${response.error?.message || 'Unknown error'}`));
50
+ if (response.error?.code) {
51
+ console.error(chalk.gray(` Error code: ${response.error.code}`));
52
+ }
53
+ console.error();
54
+ process.exit(1);
55
+ }
56
+
57
+ const records = (response.data as unknown as DictItem[]) || [];
58
+
59
+ if (!records || records.length === 0) {
60
+ if (outputJson) {
61
+ console.log(JSON.stringify({ success: true, data: { items: [] } }, null, 2));
62
+ } else {
63
+ console.log(chalk.bold('\nπŸ“– Dict Items\n'));
64
+ console.log(chalk.gray(' No dict items found\n'));
65
+ }
66
+ return;
67
+ }
68
+
69
+ if (outputJson) {
70
+ console.log(
71
+ JSON.stringify(
72
+ {
73
+ success: true,
74
+ data: {
75
+ items: records,
76
+ },
77
+ },
78
+ null,
79
+ 2
80
+ )
81
+ );
82
+ return;
83
+ }
84
+
85
+ console.log(chalk.bold('\nπŸ“– Dict Items\n'));
86
+
87
+ const table = new Table({
88
+ head: [chalk.bold('ID'), chalk.bold('Code'), chalk.bold('Name'), chalk.bold('Sort'), chalk.bold('Status')],
89
+ colWidths: [14, 20, 30, 10, 10],
90
+ style: {
91
+ head: [],
92
+ border: [],
93
+ },
94
+ });
95
+
96
+ for (const item of records) {
97
+ const statusText = item.statusFlag === 1 ? chalk.green('Enable') : chalk.red('Disable');
98
+ table.push([
99
+ item.dictId,
100
+ item.dictCode || '-',
101
+ item.dictName || '-',
102
+ item.sortOrder?.toString() || '-',
103
+ statusText,
104
+ ]);
105
+ }
106
+
107
+ console.log(table.toString());
108
+ console.log();
109
+ console.log(chalk.gray(` Total: ${records.length}`));
110
+ console.log();
111
+ });
112
+
113
+ return listCommand;
114
+ }
@@ -0,0 +1,116 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { configManager } from '../../../core/config/manager.js';
4
+ import { apiClient } from '../../../core/api/client.js';
5
+ import { Environment } from '../../../types/index.js';
6
+ import { DictItem, UpdateDictItemRequest } from '../../../types/dict.js';
7
+
8
+ export function createDictUpdateCommand(): Command {
9
+ const updateCommand = new Command('update');
10
+ updateCommand
11
+ .description('Update dictionary item')
12
+ .argument('<dictId>', 'Dictionary item ID')
13
+ .option('--code <code>', 'Dictionary code')
14
+ .option('--name <name>', 'Dictionary name')
15
+ .option('--parent <id>', 'Parent dict type ID')
16
+ .option('--status <status>', 'Status (1=enable, 2=disable)', (val) => {
17
+ const num = parseInt(val, 10);
18
+ if (num !== 1 && num !== 2) {
19
+ throw new Error('Status must be 1 or 2');
20
+ }
21
+ return num;
22
+ })
23
+ .option('--sort <sort>', 'Sort order', (val) => parseInt(val, 10))
24
+ .option('--json', 'Output as JSON')
25
+ .action(async (dictId: string, options: Record<string, unknown>) => {
26
+ const context = configManager.getCurrentContext();
27
+ const environment = context.environment as Environment;
28
+ const tenant = context.tenant;
29
+
30
+ const fields: Partial<UpdateDictItemRequest> = {};
31
+ if (options.code) fields.dictCode = options.code as string;
32
+ if (options.name) fields.dictName = options.name as string;
33
+ if (options.parent) fields.dictTypeId = options.parent as string;
34
+ if (options.status) fields.statusFlag = options.status as 1 | 2;
35
+ if (options.sort) fields.sortOrder = options.sort as number;
36
+
37
+ const providedFields = Object.keys(fields).filter(
38
+ (k) => fields[k as keyof UpdateDictItemRequest] !== undefined
39
+ );
40
+ if (providedFields.length === 0) {
41
+ console.error(
42
+ chalk.red('\nβœ— No fields to update. Provide at least one of: --code, --name, --parent, --status, --sort\n')
43
+ );
44
+ process.exit(1);
45
+ }
46
+
47
+ let currentItem: DictItem | undefined;
48
+ try {
49
+ const itemResponse = await apiClient.getDictItem(environment, tenant, dictId);
50
+ if (!itemResponse.success || !itemResponse.data) {
51
+ console.error(chalk.red(`\nβœ— Dictionary item not found: ${dictId}`));
52
+ if (itemResponse.error?.message) {
53
+ console.error(chalk.gray(` ${itemResponse.error.message}`));
54
+ }
55
+ if (itemResponse.error?.code) {
56
+ console.error(chalk.gray(` Error code: ${itemResponse.error.code}`));
57
+ }
58
+ console.error();
59
+ process.exit(1);
60
+ }
61
+ currentItem = itemResponse.data as DictItem;
62
+ } catch (error) {
63
+ console.error(chalk.red(`\nβœ— Failed to fetch dictionary item: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
64
+ process.exit(1);
65
+ }
66
+
67
+ console.log(chalk.bold(`\nπŸ“– Update Dictionary Item (${environment})\n`));
68
+ console.log(chalk.gray(` Dict ID: ${dictId}`));
69
+ console.log(chalk.gray(` Current Name: ${currentItem.dictName}`));
70
+ console.log(chalk.gray('\n Changes:'));
71
+ for (const field of providedFields) {
72
+ const label = field.replace(/([A-Z])/g, (m) => ` ${m.toLowerCase()}`).trim();
73
+ const currentVal = (currentItem as unknown as Record<string, unknown>)[field] ?? '(not set)';
74
+ const newVal = fields[field as keyof UpdateDictItemRequest];
75
+ console.log(chalk.cyan(` ${label}: "${currentVal}" -> "${newVal}"`));
76
+ }
77
+
78
+ const updateData: UpdateDictItemRequest = { dictId, dictTypeId: currentItem.dictTypeId, ...fields };
79
+ try {
80
+ const response = await apiClient.updateDictItem(environment, tenant, updateData);
81
+
82
+ if (response.success) {
83
+ if (options.json) {
84
+ console.log(JSON.stringify({ success: true, data: response.data }, null, 2));
85
+ } else {
86
+ console.log(chalk.green(`\nβœ“ Dictionary item updated successfully\n`));
87
+ }
88
+ } else {
89
+ if (options.json) {
90
+ console.log(JSON.stringify({ success: false, error: response.error }, null, 2));
91
+ } else {
92
+ console.error(chalk.red(`\nβœ— Update failed: ${response.error?.message || 'Unknown error'}`));
93
+ if (response.error?.code) {
94
+ console.error(chalk.gray(` Error code: ${response.error.code}`));
95
+ }
96
+ console.error();
97
+ }
98
+ process.exit(1);
99
+ }
100
+ } catch (error) {
101
+ if (options.json) {
102
+ console.log(
103
+ JSON.stringify({
104
+ success: false,
105
+ error: { message: error instanceof Error ? error.message : 'Unknown error' },
106
+ })
107
+ );
108
+ } else {
109
+ console.error(chalk.red(`\nβœ— Error: ${error instanceof Error ? error.message : 'Unknown error'}\n`));
110
+ }
111
+ process.exit(1);
112
+ }
113
+ });
114
+
115
+ return updateCommand;
116
+ }
@@ -13,6 +13,14 @@ import { createMaterialsCommand } from './materials/index.js';
13
13
  import { createUomsCommand } from './uoms/index.js';
14
14
  import { createCurrencyCommand } from './currency/index.js';
15
15
  import { createWarehousesCommand } from './warehouses/index.js';
16
+ import { createDictTypesCommand } from './dict-types/index.js';
17
+ import { createDictsCommand } from './dicts/index.js';
18
+ import { createOperationsCommand } from './operations/index.js';
19
+ import { createStockCommand } from './stock/index.js';
20
+ import { createCalendarCommand } from './calendar/index.js';
21
+ import { createClientContactsCommand } from './client-contacts/index.js';
22
+ import { createSupplierContactsCommand } from './supplier-contacts/index.js';
23
+ import { createMouldCommand } from './mould/index.js';
16
24
 
17
25
  export function createLibericaCommand(): Command {
18
26
  const libericaCommand = new Command('liberica');
@@ -31,6 +39,14 @@ export function createLibericaCommand(): Command {
31
39
  libericaCommand.addCommand(createUomsCommand());
32
40
  libericaCommand.addCommand(createCurrencyCommand());
33
41
  libericaCommand.addCommand(createWarehousesCommand());
42
+ libericaCommand.addCommand(createDictTypesCommand());
43
+ libericaCommand.addCommand(createDictsCommand());
44
+ libericaCommand.addCommand(createOperationsCommand());
45
+ libericaCommand.addCommand(createStockCommand());
46
+ libericaCommand.addCommand(createCalendarCommand());
47
+ libericaCommand.addCommand(createClientContactsCommand());
48
+ libericaCommand.addCommand(createSupplierContactsCommand());
49
+ libericaCommand.addCommand(createMouldCommand());
34
50
 
35
51
  libericaCommand.action(() => {
36
52
  console.log(chalk.bold('\nβ˜• Liberica Commands\n'));
@@ -47,6 +63,10 @@ export function createLibericaCommand(): Command {
47
63
  console.log(' Use "barista liberica currencies <command>" for currency management');
48
64
  console.log(' Use "barista liberica warehouses <command>" for warehouse management');
49
65
  console.log(' Use "barista liberica warehouses locations <command>" for warehouse location management');
66
+ console.log(' Use "barista liberica dict-types <command>" for dictionary type management');
67
+ console.log(' Use "barista liberica dicts <command>" for dictionary item management');
68
+ console.log(' Use "barista liberica operations <command>" for operation management');
69
+ console.log(' Use "barista liberica stock <command>" for stock management');
50
70
  console.log('\n Run "barista liberica <command> --help" for more details\n');
51
71
  });
52
72
 
@@ -12,7 +12,7 @@ function formatTable(data: MaterialRequest): string {
12
12
  lines.push(` ${chalk.gray('Code:')} ${data.materialCode}`);
13
13
  lines.push(` ${chalk.gray('Class:')} ${data.materialClass || '(not set)'}`);
14
14
  if (data.materialType) lines.push(` ${chalk.gray('Type:')} ${data.materialType}`);
15
- if (data.materialUnit) lines.push(` ${chalk.gray('Unit:')} ${data.materialUnit}`);
15
+ if (data.materialUomCode) lines.push(` ${chalk.gray('Unit:')} ${data.materialUomCode}`);
16
16
  return lines.join('\n');
17
17
  }
18
18
 
@@ -36,7 +36,7 @@ export function createMaterialsCreateCommand(): Command {
36
36
  let materialNo = (options.no as string | undefined) || (options['no'] as string | undefined);
37
37
  let materialClass = options.class as string | undefined;
38
38
  const materialType = options.type as string | undefined;
39
- const materialUnit = options.unit as string | undefined;
39
+ const materialUomCode = options.unit as string | undefined;
40
40
  const dryRun = options.dryRun === true;
41
41
  const outputJson = options.json === true;
42
42
 
@@ -100,6 +100,14 @@ export function createMaterialsCreateCommand(): Command {
100
100
  materialNo = inputNo;
101
101
  }
102
102
 
103
+ const dictResponse = await apiClient.getDictItems(context.environment, context.tenant, 'MATERIAL_CLASS');
104
+ if (dictResponse.success && dictResponse.data) {
105
+ const matchedItem = dictResponse.data.find(item => item.dictName === materialClass);
106
+ if (matchedItem) {
107
+ materialClass = matchedItem.dictCode;
108
+ }
109
+ }
110
+
103
111
  const codeResponse = await apiClient.getCodeByType(context.environment, context.tenant, 'TenantMaterialCode');
104
112
  if (!codeResponse.success || !codeResponse.data) {
105
113
  const errMsg = codeResponse.error?.message || 'Failed to generate material code';
@@ -118,7 +126,7 @@ export function createMaterialsCreateCommand(): Command {
118
126
  materialCode: materialCode,
119
127
  materialClass: materialClass!,
120
128
  materialType: materialType,
121
- materialUnit: materialUnit,
129
+ materialUomCode: materialUomCode,
122
130
  };
123
131
 
124
132
  if (dryRun) {
@@ -162,7 +170,7 @@ export function createMaterialsCreateCommand(): Command {
162
170
  materialName?: string;
163
171
  materialClass?: string;
164
172
  materialType?: string;
165
- materialUnit?: string;
173
+ materialUomCode?: string;
166
174
  statusFlag?: number;
167
175
  createTime?: string;
168
176
  } | undefined;
@@ -177,7 +185,7 @@ export function createMaterialsCreateCommand(): Command {
177
185
  if (material?.materialCode) console.log(` ${chalk.gray('Code:')} ${material.materialCode}`);
178
186
  if (material?.materialClass) console.log(` ${chalk.gray('Class:')} ${material.materialClass}`);
179
187
  if (material?.materialType) console.log(` ${chalk.gray('Type:')} ${material.materialType}`);
180
- if (material?.materialUnit) console.log(` ${chalk.gray('Unit:')} ${material.materialUnit}`);
188
+ if (material?.materialUomCode) console.log(` ${chalk.gray('Unit:')} ${material.materialUomCode}`);
181
189
  if (material?.statusFlag !== undefined) {
182
190
  const statusText = material.statusFlag === 1 ? 'Enabled' : 'Disabled';
183
191
  console.log(` ${chalk.gray('Status:')} ${chalk.green(statusText)}`);
@@ -25,7 +25,7 @@ export function createMaterialUpdateCommand(): Command {
25
25
  if (options.name) fields.materialName = options.name as string;
26
26
  if (options.class) fields.materialClass = options.class as string;
27
27
  if (options.type) fields.materialType = options.type as string;
28
- if (options.unit) fields.materialUnit = options.unit as string;
28
+ if (options.unit) fields.materialUomCode = options.unit as string;
29
29
 
30
30
  const providedFields = Object.keys(fields).filter(
31
31
  (k) => fields[k as keyof MaterialRequest] !== undefined
@@ -0,0 +1,111 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { configManager } from '../../../core/config/manager.js';
4
+ import { apiClient } from '../../../core/api/client.js';
5
+ import { MouldEntityApiResponse, MouldEntity } from '../../../types/mould.js';
6
+
7
+ function formatMouldStatus(status?: string): string {
8
+ if (!status) return chalk.gray('-');
9
+ switch (status) {
10
+ case 'FINE':
11
+ return chalk.green('FINE');
12
+ case 'REPAIR':
13
+ return chalk.yellow('REPAIR');
14
+ case 'SCRAP':
15
+ return chalk.red('SCRAP');
16
+ default:
17
+ return status;
18
+ }
19
+ }
20
+
21
+ function outputMouldDetails(mould: MouldEntity): void {
22
+ console.log(chalk.bold('\nπŸ”§ Mould Details\n'));
23
+
24
+ console.log(chalk.gray(' ID: ') + mould.mouldEntityId);
25
+ console.log(chalk.gray(' Code: ') + (mould.mouldEntityCode || chalk.gray('-')));
26
+ console.log(chalk.gray(' Material Code: ') + (mould.materialCode || chalk.gray('-')));
27
+ console.log(chalk.gray(' Material Name: ') + (mould.materialName || chalk.gray('-')));
28
+ console.log(chalk.gray(' Material No: ') + (mould.materialNo || chalk.gray('-')));
29
+ console.log(chalk.gray(' Type: ') + (mould.mouldType || chalk.gray('-')));
30
+ console.log(chalk.gray(' Status: ') + formatMouldStatus(mould.mouldStatus));
31
+ console.log(chalk.gray(' Warehouse Code: ') + (mould.currentWarehouseCode || chalk.gray('-')));
32
+ console.log(chalk.gray(' Seq No: ') + (mould.seqNo || chalk.gray('-')));
33
+ console.log(chalk.gray(' Lot No: ') + (mould.lotNo || chalk.gray('-')));
34
+ console.log(chalk.gray(' Face Number: ') + (mould.mouldFaceNumber !== undefined ? String(mould.mouldFaceNumber) : chalk.gray('-')));
35
+ console.log(chalk.gray(' Unit Price: ') + (mould.unitPrice !== undefined ? `${mould.unitPrice} ${mould.currency || ''}` : chalk.gray('-')));
36
+ console.log(chalk.gray(' Produced Date: ') + (mould.producedDate || chalk.gray('-')));
37
+ console.log(chalk.gray(' Last Stock Out: ') + (mould.lastStockOutTime || chalk.gray('-')));
38
+ console.log(chalk.gray(' Remark: ') + (mould.remark || chalk.gray('-')));
39
+ console.log();
40
+ }
41
+
42
+ export function createMouldGetCommand(): Command {
43
+ const getCommand = new Command('get');
44
+ getCommand.description('Get mould entity details by ID');
45
+
46
+ getCommand
47
+ .argument('<mouldEntityId>', 'Mould entity ID (BigInteger string)')
48
+ .option('--json', 'Output as JSON')
49
+ .action(async (mouldEntityId: string, options: { json?: boolean }) => {
50
+ if (!mouldEntityId) {
51
+ console.error(chalk.red('\nβœ— Mould ID is required\n'));
52
+ process.exit(1);
53
+ }
54
+
55
+ const context = configManager.getCurrentContext();
56
+ const environment = context.environment;
57
+ const tenant = context.tenant;
58
+
59
+ const response: MouldEntityApiResponse = await apiClient.getMouldEntity(
60
+ environment,
61
+ tenant,
62
+ mouldEntityId
63
+ );
64
+
65
+ if (!response.success) {
66
+ const errorMessage = response.error?.message || 'Unknown error';
67
+ const errorCode = response.error?.code;
68
+
69
+ if (errorMessage.includes('不存在') || errorMessage.includes('not exist')) {
70
+ console.error(chalk.red(`\nβœ— Mould not found: ${mouldEntityId}\n`));
71
+ } else {
72
+ console.error(chalk.red(`\nβœ— Failed to get mould: ${errorMessage}`));
73
+ if (errorCode) {
74
+ console.error(chalk.gray(` Error code: ${errorCode}`));
75
+ }
76
+ console.error();
77
+ }
78
+ process.exit(1);
79
+ }
80
+
81
+ const data = response.data as MouldEntity | null;
82
+
83
+ if (!data) {
84
+ if (options.json) {
85
+ console.log(JSON.stringify({ success: true, data: null }, null, 2));
86
+ } else {
87
+ console.log(chalk.bold('\nπŸ”§ Mould Details\n'));
88
+ console.log(chalk.gray(' Not found\n'));
89
+ }
90
+ return;
91
+ }
92
+
93
+ if (options.json) {
94
+ console.log(
95
+ JSON.stringify(
96
+ {
97
+ success: true,
98
+ data,
99
+ },
100
+ null,
101
+ 2
102
+ )
103
+ );
104
+ return;
105
+ }
106
+
107
+ outputMouldDetails(data);
108
+ });
109
+
110
+ return getCommand;
111
+ }
@@ -0,0 +1,17 @@
1
+ import { Command } from 'commander';
2
+ import { createMouldListCommand } from './list.js';
3
+ import { createMouldGetCommand } from './get.js';
4
+ import { createMouldSetStatusCommand } from './set-status.js';
5
+ import { createMouldStockInCommand } from './stock-in.js';
6
+
7
+ export function createMouldCommand(): Command {
8
+ const mouldCommand = new Command('mould');
9
+ mouldCommand.description('Manage mould entities');
10
+
11
+ mouldCommand.addCommand(createMouldListCommand());
12
+ mouldCommand.addCommand(createMouldGetCommand());
13
+ mouldCommand.addCommand(createMouldSetStatusCommand());
14
+ mouldCommand.addCommand(createMouldStockInCommand());
15
+
16
+ return mouldCommand;
17
+ }