@optima-chat/commerce-cli 1.7.2 → 1.7.4

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 (181) hide show
  1. package/.claude/settings.local.json +70 -0
  2. package/README.md +7 -7
  3. package/dist/commands/address/create.d.ts +3 -0
  4. package/dist/commands/address/create.d.ts.map +1 -0
  5. package/dist/commands/address/create.js +122 -0
  6. package/dist/commands/address/create.js.map +1 -0
  7. package/dist/commands/address/delete.d.ts +3 -0
  8. package/dist/commands/address/delete.d.ts.map +1 -0
  9. package/dist/commands/address/delete.js +50 -0
  10. package/dist/commands/address/delete.js.map +1 -0
  11. package/dist/commands/address/get.d.ts +3 -0
  12. package/dist/commands/address/get.d.ts.map +1 -0
  13. package/dist/commands/address/get.js +50 -0
  14. package/dist/commands/address/get.js.map +1 -0
  15. package/dist/commands/address/index.d.ts +3 -0
  16. package/dist/commands/address/index.d.ts.map +1 -0
  17. package/dist/commands/address/index.js +16 -0
  18. package/dist/commands/address/index.js.map +1 -0
  19. package/dist/commands/address/list.d.ts +3 -0
  20. package/dist/commands/address/list.d.ts.map +1 -0
  21. package/dist/commands/address/list.js +34 -0
  22. package/dist/commands/address/list.js.map +1 -0
  23. package/dist/commands/address/set-default.d.ts +3 -0
  24. package/dist/commands/address/set-default.d.ts.map +1 -0
  25. package/dist/commands/address/set-default.js +34 -0
  26. package/dist/commands/address/set-default.js.map +1 -0
  27. package/dist/commands/address/update.d.ts +3 -0
  28. package/dist/commands/address/update.d.ts.map +1 -0
  29. package/dist/commands/address/update.js +120 -0
  30. package/dist/commands/address/update.js.map +1 -0
  31. package/dist/commands/auth/login.js +1 -1
  32. package/dist/commands/auth/login.js.map +1 -1
  33. package/dist/commands/auth/switch.d.ts +3 -0
  34. package/dist/commands/auth/switch.d.ts.map +1 -0
  35. package/dist/commands/auth/switch.js +111 -0
  36. package/dist/commands/auth/switch.js.map +1 -0
  37. package/dist/commands/auth/test-refresh.d.ts +3 -0
  38. package/dist/commands/auth/test-refresh.d.ts.map +1 -0
  39. package/dist/commands/auth/test-refresh.js +43 -0
  40. package/dist/commands/auth/test-refresh.js.map +1 -0
  41. package/dist/commands/auth/whoami.d.ts.map +1 -1
  42. package/dist/commands/auth/whoami.js +5 -5
  43. package/dist/commands/auth/whoami.js.map +1 -1
  44. package/dist/commands/category/create.d.ts +3 -0
  45. package/dist/commands/category/create.d.ts.map +1 -0
  46. package/dist/commands/category/create.js +142 -0
  47. package/dist/commands/category/create.js.map +1 -0
  48. package/dist/commands/category/delete.d.ts +3 -0
  49. package/dist/commands/category/delete.d.ts.map +1 -0
  50. package/dist/commands/category/delete.js +98 -0
  51. package/dist/commands/category/delete.js.map +1 -0
  52. package/dist/commands/category/get.d.ts +3 -0
  53. package/dist/commands/category/get.d.ts.map +1 -0
  54. package/dist/commands/category/get.js +74 -0
  55. package/dist/commands/category/get.js.map +1 -0
  56. package/dist/commands/category/index.d.ts +3 -0
  57. package/dist/commands/category/index.d.ts.map +1 -0
  58. package/dist/commands/category/index.js +14 -0
  59. package/dist/commands/category/index.js.map +1 -0
  60. package/dist/commands/category/list.d.ts +3 -0
  61. package/dist/commands/category/list.d.ts.map +1 -0
  62. package/dist/commands/category/list.js +77 -0
  63. package/dist/commands/category/list.js.map +1 -0
  64. package/dist/commands/category/update.d.ts +3 -0
  65. package/dist/commands/category/update.d.ts.map +1 -0
  66. package/dist/commands/category/update.js +104 -0
  67. package/dist/commands/category/update.js.map +1 -0
  68. package/dist/commands/cleanup.d.ts +3 -0
  69. package/dist/commands/cleanup.d.ts.map +1 -0
  70. package/dist/commands/cleanup.js +100 -0
  71. package/dist/commands/cleanup.js.map +1 -0
  72. package/dist/commands/i18n/category/create.d.ts +3 -0
  73. package/dist/commands/i18n/category/create.d.ts.map +1 -0
  74. package/dist/commands/i18n/category/create.js +113 -0
  75. package/dist/commands/i18n/category/create.js.map +1 -0
  76. package/dist/commands/i18n/category/delete.d.ts +3 -0
  77. package/dist/commands/i18n/category/delete.d.ts.map +1 -0
  78. package/dist/commands/i18n/category/delete.js +63 -0
  79. package/dist/commands/i18n/category/delete.js.map +1 -0
  80. package/dist/commands/i18n/category/get.d.ts +3 -0
  81. package/dist/commands/i18n/category/get.d.ts.map +1 -0
  82. package/dist/commands/i18n/category/get.js +56 -0
  83. package/dist/commands/i18n/category/get.js.map +1 -0
  84. package/dist/commands/i18n/category/index.d.ts +3 -0
  85. package/dist/commands/i18n/category/index.d.ts.map +1 -0
  86. package/dist/commands/i18n/category/index.js +14 -0
  87. package/dist/commands/i18n/category/index.js.map +1 -0
  88. package/dist/commands/i18n/category/list.d.ts +3 -0
  89. package/dist/commands/i18n/category/list.d.ts.map +1 -0
  90. package/dist/commands/i18n/category/list.js +72 -0
  91. package/dist/commands/i18n/category/list.js.map +1 -0
  92. package/dist/commands/i18n/category/update.d.ts +3 -0
  93. package/dist/commands/i18n/category/update.d.ts.map +1 -0
  94. package/dist/commands/i18n/category/update.js +68 -0
  95. package/dist/commands/i18n/category/update.js.map +1 -0
  96. package/dist/commands/i18n/merchant/get.d.ts +3 -0
  97. package/dist/commands/i18n/merchant/get.d.ts.map +1 -0
  98. package/dist/commands/i18n/merchant/get.js +30 -0
  99. package/dist/commands/i18n/merchant/get.js.map +1 -0
  100. package/dist/commands/section/create.d.ts +3 -0
  101. package/dist/commands/section/create.d.ts.map +1 -0
  102. package/dist/commands/section/create.js +218 -0
  103. package/dist/commands/section/create.js.map +1 -0
  104. package/dist/commands/section/delete.d.ts +3 -0
  105. package/dist/commands/section/delete.d.ts.map +1 -0
  106. package/dist/commands/section/delete.js +86 -0
  107. package/dist/commands/section/delete.js.map +1 -0
  108. package/dist/commands/section/hide.d.ts +3 -0
  109. package/dist/commands/section/hide.d.ts.map +1 -0
  110. package/dist/commands/section/hide.js +82 -0
  111. package/dist/commands/section/hide.js.map +1 -0
  112. package/dist/commands/section/index.d.ts +4 -0
  113. package/dist/commands/section/index.d.ts.map +1 -0
  114. package/dist/commands/section/index.js +23 -0
  115. package/dist/commands/section/index.js.map +1 -0
  116. package/dist/commands/section/list.d.ts +3 -0
  117. package/dist/commands/section/list.d.ts.map +1 -0
  118. package/dist/commands/section/list.js +164 -0
  119. package/dist/commands/section/list.js.map +1 -0
  120. package/dist/commands/section/product/create.d.ts +3 -0
  121. package/dist/commands/section/product/create.d.ts.map +1 -0
  122. package/dist/commands/section/product/create.js +208 -0
  123. package/dist/commands/section/product/create.js.map +1 -0
  124. package/dist/commands/section/product/delete.d.ts +3 -0
  125. package/dist/commands/section/product/delete.d.ts.map +1 -0
  126. package/dist/commands/section/product/delete.js +85 -0
  127. package/dist/commands/section/product/delete.js.map +1 -0
  128. package/dist/commands/section/product/hide.d.ts +3 -0
  129. package/dist/commands/section/product/hide.d.ts.map +1 -0
  130. package/dist/commands/section/product/hide.js +78 -0
  131. package/dist/commands/section/product/hide.js.map +1 -0
  132. package/dist/commands/section/product/index.d.ts +4 -0
  133. package/dist/commands/section/product/index.d.ts.map +1 -0
  134. package/dist/commands/section/product/index.js +17 -0
  135. package/dist/commands/section/product/index.js.map +1 -0
  136. package/dist/commands/section/product/list.d.ts +3 -0
  137. package/dist/commands/section/product/list.d.ts.map +1 -0
  138. package/dist/commands/section/product/list.js +157 -0
  139. package/dist/commands/section/product/list.js.map +1 -0
  140. package/dist/commands/section/product/reorder.d.ts +3 -0
  141. package/dist/commands/section/product/reorder.d.ts.map +1 -0
  142. package/dist/commands/section/product/reorder.js +110 -0
  143. package/dist/commands/section/product/reorder.js.map +1 -0
  144. package/dist/commands/section/product/update.d.ts +3 -0
  145. package/dist/commands/section/product/update.d.ts.map +1 -0
  146. package/dist/commands/section/product/update.js +127 -0
  147. package/dist/commands/section/product/update.js.map +1 -0
  148. package/dist/commands/section/reorder.d.ts +3 -0
  149. package/dist/commands/section/reorder.d.ts.map +1 -0
  150. package/dist/commands/section/reorder.js +111 -0
  151. package/dist/commands/section/reorder.js.map +1 -0
  152. package/dist/commands/section/translation/delete.d.ts +3 -0
  153. package/dist/commands/section/translation/delete.d.ts.map +1 -0
  154. package/dist/commands/section/translation/delete.js +97 -0
  155. package/dist/commands/section/translation/delete.js.map +1 -0
  156. package/dist/commands/section/translation/index.d.ts +4 -0
  157. package/dist/commands/section/translation/index.d.ts.map +1 -0
  158. package/dist/commands/section/translation/index.js +11 -0
  159. package/dist/commands/section/translation/index.js.map +1 -0
  160. package/dist/commands/section/translation/list.d.ts +3 -0
  161. package/dist/commands/section/translation/list.d.ts.map +1 -0
  162. package/dist/commands/section/translation/list.js +104 -0
  163. package/dist/commands/section/translation/list.js.map +1 -0
  164. package/dist/commands/section/translation/set.d.ts +3 -0
  165. package/dist/commands/section/translation/set.d.ts.map +1 -0
  166. package/dist/commands/section/translation/set.js +151 -0
  167. package/dist/commands/section/translation/set.js.map +1 -0
  168. package/dist/commands/section/update.d.ts +3 -0
  169. package/dist/commands/section/update.d.ts.map +1 -0
  170. package/dist/commands/section/update.js +137 -0
  171. package/dist/commands/section/update.js.map +1 -0
  172. package/dist/commands/test/health.js +2 -2
  173. package/dist/commands/test/health.js.map +1 -1
  174. package/dist/commands/variant/get.d.ts +3 -0
  175. package/dist/commands/variant/get.d.ts.map +1 -0
  176. package/dist/commands/variant/get.js +41 -0
  177. package/dist/commands/variant/get.js.map +1 -0
  178. package/dist/index.js +0 -0
  179. package/dist/utils/config.js +3 -3
  180. package/dist/utils/config.js.map +1 -1
  181. package/package.json +1 -1
@@ -0,0 +1,127 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { commerceApi } from '../../../api/rest/commerce.js';
4
+ import { handleError, createApiError, ValidationError } from '../../../utils/error.js';
5
+ import { output } from '../../../utils/output.js';
6
+ import { addEnhancedHelp } from '../../../utils/helpText.js';
7
+ import { isInteractiveEnvironment } from '../../../utils/interactive.js';
8
+ const cmd = new Command('update')
9
+ .description('Update a product page section override (product-level)')
10
+ .argument('<product-id>', 'Product ID')
11
+ .argument('<handle>', 'Section handle to update')
12
+ .option('--type <type>', 'Section type: collapsible | static')
13
+ .option('--position <n>', 'Display position')
14
+ .option('--content <text>', 'Section content in Markdown')
15
+ .option('--tab-group <group>', 'Tab group name (use empty string to clear)')
16
+ .action(async (productId, handle, options) => {
17
+ try {
18
+ await updateProductSection(productId, handle, options);
19
+ }
20
+ catch (error) {
21
+ handleError(error);
22
+ }
23
+ });
24
+ addEnhancedHelp(cmd, {
25
+ examples: [
26
+ '# Update section content for a product',
27
+ '$ commerce section product update prod-123 care --content "Special care instructions for this product"',
28
+ '',
29
+ '# Update position',
30
+ '$ commerce section product update prod-123 care --position 5',
31
+ ],
32
+ output: {
33
+ example: JSON.stringify({
34
+ success: true,
35
+ data: {
36
+ id: 'override-uuid',
37
+ product_id: 'prod-123',
38
+ handle: 'care',
39
+ operation_type: 'override',
40
+ type: 'collapsible',
41
+ position: 5,
42
+ content: 'Special care instructions...',
43
+ },
44
+ message: '商品区块更新成功',
45
+ }, null, 2),
46
+ },
47
+ relatedCommands: [
48
+ { command: 'section product list --resolved', description: 'View product sections' },
49
+ { command: 'section product create', description: 'Create product override' },
50
+ { command: 'section product delete', description: 'Delete product override' },
51
+ ],
52
+ notes: [
53
+ 'Only updates the fields you specify',
54
+ 'The product must have an existing override for this section',
55
+ 'Use section product create first if no override exists',
56
+ ],
57
+ });
58
+ export const updateProductSectionCommand = cmd;
59
+ async function updateProductSection(productId, handle, options) {
60
+ const { type, position, content, tabGroup } = options;
61
+ // 验证至少有一个更新字段
62
+ if (!type && !position && !content && tabGroup === undefined) {
63
+ if (!isInteractiveEnvironment()) {
64
+ throw new ValidationError('至少需要一个更新字段: --type, --position, --content, 或 --tab-group', 'options');
65
+ }
66
+ else {
67
+ console.log(chalk.yellow('提示: 请指定要更新的字段'));
68
+ console.log(chalk.gray(' --type <type> 区块类型'));
69
+ console.log(chalk.gray(' --position <n> 显示位置'));
70
+ console.log(chalk.gray(' --content <text> 区块内容'));
71
+ console.log(chalk.gray(' --tab-group <group> Tab分组'));
72
+ return;
73
+ }
74
+ }
75
+ // 验证 type
76
+ if (type) {
77
+ const validTypes = ['collapsible', 'static'];
78
+ if (!validTypes.includes(type)) {
79
+ throw new ValidationError(`无效的区块类型: ${type}。有效值: ${validTypes.join(', ')}`, 'type');
80
+ }
81
+ }
82
+ const spinner = output.spinner('正在更新商品区块...');
83
+ try {
84
+ const data = {};
85
+ if (type) {
86
+ data.type = type;
87
+ }
88
+ if (position) {
89
+ data.position = parseInt(position, 10);
90
+ }
91
+ if (content) {
92
+ data.content = content;
93
+ }
94
+ if (tabGroup !== undefined) {
95
+ data.tab_group = tabGroup || null;
96
+ }
97
+ const result = await commerceApi.productSections.product.update(productId, handle, data);
98
+ spinner.succeed('商品区块更新成功!');
99
+ if (output.isJson()) {
100
+ output.success(result, '商品区块更新成功');
101
+ }
102
+ else {
103
+ console.log();
104
+ console.log(chalk.green('✓ 商品区块更新成功!'));
105
+ console.log();
106
+ console.log(chalk.gray('ID: ') + chalk.cyan(result.id));
107
+ console.log(chalk.gray('商品ID: ') + chalk.white(result.product_id));
108
+ console.log(chalk.gray('Handle: ') + chalk.white(result.handle));
109
+ console.log(chalk.gray('操作类型: ') + chalk.white(result.operation_type));
110
+ console.log(chalk.gray('区块类型: ') + chalk.white(result.type));
111
+ console.log(chalk.gray('位置: ') + chalk.white(result.position.toString()));
112
+ if (result.tab_group) {
113
+ console.log(chalk.gray('Tab分组: ') + chalk.white(result.tab_group));
114
+ }
115
+ if (result.content) {
116
+ const preview = result.content.length > 100 ? result.content.substring(0, 100) + '...' : result.content;
117
+ console.log(chalk.gray('内容: ') + chalk.white(preview));
118
+ }
119
+ console.log();
120
+ }
121
+ }
122
+ catch (error) {
123
+ spinner.fail('更新商品区块失败');
124
+ throw createApiError(error);
125
+ }
126
+ }
127
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/section/product/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,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CAAC;gBACnB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gBACxG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzB,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const reorderSectionsCommand: Command;
3
+ //# sourceMappingURL=reorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.d.ts","sourceRoot":"","sources":["../../../src/commands/section/reorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuDpC,eAAO,MAAM,sBAAsB,SAAM,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { commerceApi } from '../../api/rest/commerce.js';
4
+ import { handleError, createApiError, ValidationError } from '../../utils/error.js';
5
+ import { output } from '../../utils/output.js';
6
+ import { addEnhancedHelp } from '../../utils/helpText.js';
7
+ import { isInteractiveEnvironment } from '../../utils/interactive.js';
8
+ const cmd = new Command('reorder')
9
+ .description('Reorder product page sections (merchant-level)')
10
+ .option('--sections <json>', 'JSON array of {handle, position} objects (required)')
11
+ .option('--tab-group <group>', 'Only reorder within this tab group (optional)')
12
+ .action(async (options) => {
13
+ try {
14
+ await reorderSections(options);
15
+ }
16
+ catch (error) {
17
+ handleError(error);
18
+ }
19
+ });
20
+ addEnhancedHelp(cmd, {
21
+ examples: [
22
+ '# Reorder sections globally',
23
+ '$ commerce section reorder --sections \'[{"handle":"highlights","position":1},{"handle":"details","position":2},{"handle":"care","position":3}]\'',
24
+ '',
25
+ '# Reorder within a tab group',
26
+ '$ commerce section reorder --tab-group product-info --sections \'[{"handle":"highlights","position":1},{"handle":"care","position":2}]\'',
27
+ ],
28
+ output: {
29
+ example: JSON.stringify({
30
+ success: true,
31
+ message: '区块顺序已更新',
32
+ }, null, 2),
33
+ },
34
+ relatedCommands: [
35
+ { command: 'section list --resolved', description: 'View current section order' },
36
+ { command: 'section update', description: 'Update individual section position' },
37
+ ],
38
+ notes: [
39
+ 'sections must be a valid JSON array',
40
+ 'Each item needs: handle (string), position (number)',
41
+ 'If a section has no customization, one will be auto-created',
42
+ 'Use --tab-group to only reorder sections within a specific tab',
43
+ ],
44
+ });
45
+ export const reorderSectionsCommand = cmd;
46
+ async function reorderSections(options) {
47
+ const { sections, tabGroup } = options;
48
+ // 验证必需参数
49
+ if (!sections || sections.trim().length === 0) {
50
+ if (!isInteractiveEnvironment()) {
51
+ throw new ValidationError('缺少必需参数: --sections (JSON数组)', 'sections');
52
+ }
53
+ else {
54
+ console.log(chalk.yellow('请指定 --sections 参数'));
55
+ console.log(chalk.gray('格式: \'[{"handle":"highlights","position":1},{"handle":"details","position":2}]\''));
56
+ return;
57
+ }
58
+ }
59
+ // 解析 sections JSON
60
+ let parsedSections;
61
+ try {
62
+ parsedSections = JSON.parse(sections);
63
+ }
64
+ catch (error) {
65
+ throw new ValidationError('--sections 必须是有效的 JSON 数组', 'sections');
66
+ }
67
+ // 验证 sections 格式
68
+ if (!Array.isArray(parsedSections)) {
69
+ throw new ValidationError('--sections 必须是数组', 'sections');
70
+ }
71
+ for (const item of parsedSections) {
72
+ if (!item.handle || typeof item.handle !== 'string') {
73
+ throw new ValidationError('每个 section 必须有 handle 字段(字符串)', 'sections');
74
+ }
75
+ if (typeof item.position !== 'number' || item.position < 1) {
76
+ throw new ValidationError('每个 section 必须有 position 字段(正整数)', 'sections');
77
+ }
78
+ }
79
+ const spinner = output.spinner('正在更新区块顺序...');
80
+ try {
81
+ const data = {
82
+ sections: parsedSections,
83
+ };
84
+ if (tabGroup !== undefined) {
85
+ data.tab_group = tabGroup || null;
86
+ }
87
+ await commerceApi.productSections.merchant.reorder(data);
88
+ spinner.succeed('区块顺序已更新!');
89
+ if (output.isJson()) {
90
+ output.success({ sections: parsedSections, tab_group: tabGroup || null }, '区块顺序已更新');
91
+ }
92
+ else {
93
+ console.log();
94
+ console.log(chalk.green('✓ 区块顺序已更新!'));
95
+ console.log();
96
+ if (tabGroup) {
97
+ console.log(chalk.gray('Tab分组: ') + chalk.white(tabGroup));
98
+ }
99
+ console.log(chalk.gray('新顺序:'));
100
+ parsedSections.forEach((item) => {
101
+ console.log(chalk.gray(` ${item.position}. `) + chalk.cyan(item.handle));
102
+ });
103
+ console.log();
104
+ }
105
+ }
106
+ catch (error) {
107
+ spinner.fail('更新区块顺序失败');
108
+ throw createApiError(error);
109
+ }
110
+ }
111
+ //# sourceMappingURL=reorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.js","sourceRoot":"","sources":["../../../src/commands/section/reorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAOtE,MAAM,GAAG,GAAG,IAAI,OAAO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+ import { Command } from 'commander';
2
+ export declare const deleteTranslationCommand: Command;
3
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/commands/section/translation/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6DpC,eAAO,MAAM,wBAAwB,SAAM,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import inquirer from 'inquirer';
4
+ import { commerceApi } from '../../../api/rest/commerce.js';
5
+ import { handleError, createApiError, ValidationError } from '../../../utils/error.js';
6
+ import { output } from '../../../utils/output.js';
7
+ import { addEnhancedHelp } from '../../../utils/helpText.js';
8
+ import { isInteractiveEnvironment } from '../../../utils/interactive.js';
9
+ const cmd = new Command('delete')
10
+ .description('Delete translation for a section')
11
+ .argument('<handle>', 'Section handle')
12
+ .option('--lang <code>', 'Language code to delete (required)')
13
+ .option('--product-id <id>', 'Product ID (for product-level translation)')
14
+ .option('-y, --yes', 'Skip confirmation prompt')
15
+ .action(async (handle, options) => {
16
+ try {
17
+ await deleteTranslation(handle, options);
18
+ }
19
+ catch (error) {
20
+ handleError(error);
21
+ }
22
+ });
23
+ addEnhancedHelp(cmd, {
24
+ examples: [
25
+ '# Delete merchant-level Chinese translation',
26
+ '$ commerce section translation delete care --lang zh-CN',
27
+ '',
28
+ '# Delete with confirmation skip',
29
+ '$ commerce section translation delete care --lang zh-CN --yes',
30
+ '',
31
+ '# Delete product-level translation',
32
+ '$ commerce section translation delete care --lang ja-JP --product-id prod-123 --yes',
33
+ ],
34
+ output: {
35
+ example: JSON.stringify({
36
+ success: true,
37
+ message: '翻译已删除',
38
+ }, null, 2),
39
+ },
40
+ relatedCommands: [
41
+ { command: 'section translation list', description: 'View translations' },
42
+ { command: 'section translation set', description: 'Add translation' },
43
+ ],
44
+ notes: [
45
+ 'Use --yes to skip confirmation in non-interactive environments',
46
+ 'Without --product-id: deletes merchant-level translation',
47
+ 'With --product-id: deletes product-level translation',
48
+ ],
49
+ });
50
+ export const deleteTranslationCommand = cmd;
51
+ async function deleteTranslation(handle, options) {
52
+ const { lang, productId, yes } = options;
53
+ if (!lang || lang.trim().length === 0) {
54
+ throw new ValidationError('缺少必需参数: --lang (语言代码)', 'lang');
55
+ }
56
+ if (!isInteractiveEnvironment() && !yes) {
57
+ throw new ValidationError('非交互模式下需要 --yes 确认删除操作', 'yes');
58
+ }
59
+ if (isInteractiveEnvironment() && !yes) {
60
+ const { confirm } = await inquirer.prompt([
61
+ {
62
+ type: 'confirm',
63
+ name: 'confirm',
64
+ message: `确定要删除区块 "${handle}" 的 ${lang} 翻译吗?`,
65
+ default: false,
66
+ },
67
+ ]);
68
+ if (!confirm) {
69
+ console.log(chalk.yellow('已取消删除操作'));
70
+ return;
71
+ }
72
+ }
73
+ const level = productId ? '商品级' : '商户级';
74
+ const spinner = output.spinner(`正在删除${level}翻译...`);
75
+ try {
76
+ if (productId) {
77
+ await commerceApi.productSections.product.translations.delete(productId, handle, lang);
78
+ }
79
+ else {
80
+ await commerceApi.productSections.merchant.translations.delete(handle, lang);
81
+ }
82
+ spinner.succeed('翻译已删除!');
83
+ if (output.isJson()) {
84
+ output.success({ handle, language_code: lang, product_id: productId || null }, '翻译已删除');
85
+ }
86
+ else {
87
+ console.log();
88
+ console.log(chalk.green(`✓ 区块 "${handle}" 的 ${lang} 翻译已删除`));
89
+ console.log();
90
+ }
91
+ }
92
+ catch (error) {
93
+ spinner.fail('删除翻译失败');
94
+ throw createApiError(error);
95
+ }
96
+ }
97
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/commands/section/translation/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,M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E,CAAC;YACd,MAAM,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACzF,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE1B,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,IAAI,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAC1F,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,MAAM,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ declare const translationCommand: Command;
3
+ export { translationCommand };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/section/translation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,QAAA,MAAM,kBAAkB,SACwB,CAAC;AAMjD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Command } from 'commander';
2
+ import { listTranslationsCommand } from './list.js';
3
+ import { setTranslationCommand } from './set.js';
4
+ import { deleteTranslationCommand } from './delete.js';
5
+ const translationCommand = new Command('translation')
6
+ .description('Section translation management');
7
+ translationCommand.addCommand(listTranslationsCommand);
8
+ translationCommand.addCommand(setTranslationCommand);
9
+ translationCommand.addCommand(deleteTranslationCommand);
10
+ export { translationCommand };
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/section/translation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;KAClD,WAAW,CAAC,gCAAgC,CAAC,CAAC;AAEjD,kBAAkB,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;AACvD,kBAAkB,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;AACrD,kBAAkB,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const listTranslationsCommand: Command;
3
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/commands/section/translation/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkEpC,eAAO,MAAM,uBAAuB,SAAM,CAAC"}
@@ -0,0 +1,104 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { commerceApi } from '../../../api/rest/commerce.js';
4
+ import { handleError, createApiError } from '../../../utils/error.js';
5
+ import { output } from '../../../utils/output.js';
6
+ import { addEnhancedHelp } from '../../../utils/helpText.js';
7
+ const cmd = new Command('list')
8
+ .description('List translations for a section')
9
+ .argument('<handle>', 'Section handle')
10
+ .option('--product-id <id>', 'Product ID (for product-level translations)')
11
+ .action(async (handle, options) => {
12
+ try {
13
+ await listTranslations(handle, options);
14
+ }
15
+ catch (error) {
16
+ handleError(error);
17
+ }
18
+ });
19
+ addEnhancedHelp(cmd, {
20
+ examples: [
21
+ '# List merchant-level translations for care section',
22
+ '$ commerce section translation list care',
23
+ '',
24
+ '# List product-level translations',
25
+ '$ commerce section translation list care --product-id prod-123',
26
+ ],
27
+ output: {
28
+ example: JSON.stringify({
29
+ success: true,
30
+ data: {
31
+ translations: [
32
+ {
33
+ language_code: 'en-US',
34
+ title: 'Care Instructions',
35
+ content: 'Machine washable, cold water.',
36
+ },
37
+ {
38
+ language_code: 'zh-CN',
39
+ title: '护理说明',
40
+ content: '机洗,冷水。',
41
+ },
42
+ ],
43
+ },
44
+ }, null, 2),
45
+ },
46
+ relatedCommands: [
47
+ { command: 'section translation set', description: 'Add or update translation' },
48
+ { command: 'section translation delete', description: 'Delete translation' },
49
+ { command: 'section list --resolved', description: 'View all sections with translations' },
50
+ ],
51
+ notes: [
52
+ 'Without --product-id: lists merchant-level translations',
53
+ 'With --product-id: lists product-level translations',
54
+ 'The section must have a customization/override to have translations',
55
+ ],
56
+ });
57
+ export const listTranslationsCommand = cmd;
58
+ async function listTranslations(handle, options) {
59
+ const { productId } = options;
60
+ const level = productId ? '商品级' : '商户级';
61
+ const spinner = output.spinner(`正在获取${level}翻译...`);
62
+ try {
63
+ let translations;
64
+ if (productId) {
65
+ translations = await commerceApi.productSections.product.translations.list(productId, handle);
66
+ }
67
+ else {
68
+ translations = await commerceApi.productSections.merchant.translations.list(handle);
69
+ }
70
+ spinner.succeed(`${level}翻译获取成功`);
71
+ if (!translations || translations.length === 0) {
72
+ if (output.isJson()) {
73
+ output.success({ translations: [] }, '暂无翻译');
74
+ }
75
+ else {
76
+ console.log(chalk.yellow(`\n区块 "${handle}" 暂无翻译\n`));
77
+ }
78
+ return;
79
+ }
80
+ if (output.isJson()) {
81
+ output.success({ translations });
82
+ }
83
+ else {
84
+ console.log();
85
+ console.log(chalk.bold(`区块 "${handle}" 的翻译(${level}):\n`));
86
+ translations.forEach((trans, index) => {
87
+ console.log(chalk.cyan(`${index + 1}. ${trans.language_code}`));
88
+ console.log(chalk.gray(` 标题: ${trans.title || '(无)'}`));
89
+ if (trans.content) {
90
+ const preview = trans.content.length > 80 ? trans.content.substring(0, 80) + '...' : trans.content;
91
+ console.log(chalk.gray(` 内容: ${preview}`));
92
+ }
93
+ console.log();
94
+ });
95
+ console.log(chalk.gray(`共 ${translations.length} 种语言`));
96
+ console.log();
97
+ }
98
+ }
99
+ catch (error) {
100
+ spinner.fail('获取翻译失败');
101
+ throw createApiError(error);
102
+ }
103
+ }
104
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/section/translation/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAM7D,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC5B,WAAW,CAAC,iCAAiC,CAAC;KAC9C,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;KACtC,MAAM,CAAC,mBAAmB,EAAE,6CAA6C,CAAC;KAC1E,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,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C,aAAa,EAAE,CAAC,CAAC,CAAC;gBAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;gBAC1D,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;oBAClB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;oBACnG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC;gBAC/C,CAAC;gBACD,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const setTranslationCommand: Command;
3
+ //# sourceMappingURL=set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../../src/commands/section/translation/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsEpC,eAAO,MAAM,qBAAqB,SAAM,CAAC"}