@optima-chat/commerce-cli 1.4.0 → 1.5.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 (84) hide show
  1. package/.claude/skills/commerce-storefront/SKILL.md +183 -3
  2. package/dist/api/rest/commerce.d.ts +170 -1
  3. package/dist/api/rest/commerce.d.ts.map +1 -1
  4. package/dist/api/rest/commerce.js +167 -0
  5. package/dist/api/rest/commerce.js.map +1 -1
  6. package/dist/commands/section/create.d.ts +3 -0
  7. package/dist/commands/section/create.d.ts.map +1 -0
  8. package/dist/commands/section/create.js +218 -0
  9. package/dist/commands/section/create.js.map +1 -0
  10. package/dist/commands/section/delete.d.ts +3 -0
  11. package/dist/commands/section/delete.d.ts.map +1 -0
  12. package/dist/commands/section/delete.js +86 -0
  13. package/dist/commands/section/delete.js.map +1 -0
  14. package/dist/commands/section/hide.d.ts +3 -0
  15. package/dist/commands/section/hide.d.ts.map +1 -0
  16. package/dist/commands/section/hide.js +82 -0
  17. package/dist/commands/section/hide.js.map +1 -0
  18. package/dist/commands/section/index.d.ts +4 -0
  19. package/dist/commands/section/index.d.ts.map +1 -0
  20. package/dist/commands/section/index.js +23 -0
  21. package/dist/commands/section/index.js.map +1 -0
  22. package/dist/commands/section/list.d.ts +3 -0
  23. package/dist/commands/section/list.d.ts.map +1 -0
  24. package/dist/commands/section/list.js +164 -0
  25. package/dist/commands/section/list.js.map +1 -0
  26. package/dist/commands/section/product/create.d.ts +3 -0
  27. package/dist/commands/section/product/create.d.ts.map +1 -0
  28. package/dist/commands/section/product/create.js +208 -0
  29. package/dist/commands/section/product/create.js.map +1 -0
  30. package/dist/commands/section/product/delete.d.ts +3 -0
  31. package/dist/commands/section/product/delete.d.ts.map +1 -0
  32. package/dist/commands/section/product/delete.js +85 -0
  33. package/dist/commands/section/product/delete.js.map +1 -0
  34. package/dist/commands/section/product/hide.d.ts +3 -0
  35. package/dist/commands/section/product/hide.d.ts.map +1 -0
  36. package/dist/commands/section/product/hide.js +78 -0
  37. package/dist/commands/section/product/hide.js.map +1 -0
  38. package/dist/commands/section/product/index.d.ts +4 -0
  39. package/dist/commands/section/product/index.d.ts.map +1 -0
  40. package/dist/commands/section/product/index.js +17 -0
  41. package/dist/commands/section/product/index.js.map +1 -0
  42. package/dist/commands/section/product/list.d.ts +3 -0
  43. package/dist/commands/section/product/list.d.ts.map +1 -0
  44. package/dist/commands/section/product/list.js +157 -0
  45. package/dist/commands/section/product/list.js.map +1 -0
  46. package/dist/commands/section/product/reorder.d.ts +3 -0
  47. package/dist/commands/section/product/reorder.d.ts.map +1 -0
  48. package/dist/commands/section/product/reorder.js +110 -0
  49. package/dist/commands/section/product/reorder.js.map +1 -0
  50. package/dist/commands/section/product/update.d.ts +3 -0
  51. package/dist/commands/section/product/update.d.ts.map +1 -0
  52. package/dist/commands/section/product/update.js +127 -0
  53. package/dist/commands/section/product/update.js.map +1 -0
  54. package/dist/commands/section/reorder.d.ts +3 -0
  55. package/dist/commands/section/reorder.d.ts.map +1 -0
  56. package/dist/commands/section/reorder.js +111 -0
  57. package/dist/commands/section/reorder.js.map +1 -0
  58. package/dist/commands/section/translation/delete.d.ts +3 -0
  59. package/dist/commands/section/translation/delete.d.ts.map +1 -0
  60. package/dist/commands/section/translation/delete.js +97 -0
  61. package/dist/commands/section/translation/delete.js.map +1 -0
  62. package/dist/commands/section/translation/index.d.ts +4 -0
  63. package/dist/commands/section/translation/index.d.ts.map +1 -0
  64. package/dist/commands/section/translation/index.js +11 -0
  65. package/dist/commands/section/translation/index.js.map +1 -0
  66. package/dist/commands/section/translation/list.d.ts +3 -0
  67. package/dist/commands/section/translation/list.d.ts.map +1 -0
  68. package/dist/commands/section/translation/list.js +104 -0
  69. package/dist/commands/section/translation/list.js.map +1 -0
  70. package/dist/commands/section/translation/set.d.ts +3 -0
  71. package/dist/commands/section/translation/set.d.ts.map +1 -0
  72. package/dist/commands/section/translation/set.js +151 -0
  73. package/dist/commands/section/translation/set.js.map +1 -0
  74. package/dist/commands/section/update.d.ts +3 -0
  75. package/dist/commands/section/update.d.ts.map +1 -0
  76. package/dist/commands/section/update.js +137 -0
  77. package/dist/commands/section/update.js.map +1 -0
  78. package/dist/index.js +8 -6
  79. package/dist/index.js.map +1 -1
  80. package/dist/utils/config.d.ts +4 -1
  81. package/dist/utils/config.d.ts.map +1 -1
  82. package/dist/utils/config.js +10 -2
  83. package/dist/utils/config.js.map +1 -1
  84. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/commands/section/product/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuEpC,eAAO,MAAM,0BAA0B,SAAM,CAAC"}
@@ -0,0 +1,157 @@
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 product page sections (product-level)')
9
+ .argument('<product-id>', 'Product ID')
10
+ .option('--resolved', 'Show merged view with System + Merchant + Product layers (recommended)')
11
+ .action(async (productId, options) => {
12
+ try {
13
+ await listProductSections(productId, options);
14
+ }
15
+ catch (error) {
16
+ handleError(error);
17
+ }
18
+ });
19
+ addEnhancedHelp(cmd, {
20
+ examples: [
21
+ '# List product-level overrides only',
22
+ '$ commerce section product list prod-123',
23
+ '',
24
+ '# List merged view with all sections (recommended)',
25
+ '$ commerce section product list prod-123 --resolved',
26
+ ],
27
+ output: {
28
+ example: JSON.stringify({
29
+ success: true,
30
+ data: {
31
+ sections: [
32
+ {
33
+ handle: 'highlights',
34
+ source: 'system',
35
+ type: 'static',
36
+ position: 1,
37
+ is_hidden: false,
38
+ },
39
+ {
40
+ handle: 'care',
41
+ source: 'product',
42
+ type: 'collapsible',
43
+ position: 4,
44
+ is_hidden: false,
45
+ content: 'Special care for this product...',
46
+ },
47
+ ],
48
+ available_languages: ['en-US', 'zh-CN', 'ja-JP'],
49
+ },
50
+ }, null, 2),
51
+ },
52
+ relatedCommands: [
53
+ { command: 'section product create', description: 'Create product-level override' },
54
+ { command: 'section list --resolved', description: 'View merchant-level sections' },
55
+ ],
56
+ notes: [
57
+ 'Without --resolved: shows only product-level overrides',
58
+ 'With --resolved: shows System + Merchant + Product merged view',
59
+ 'source field: system | merchant | product (indicates origin)',
60
+ ],
61
+ });
62
+ export const listProductSectionsCommand = cmd;
63
+ async function listProductSections(productId, options) {
64
+ const spinner = output.spinner('正在获取商品区块配置...');
65
+ try {
66
+ if (options.resolved) {
67
+ const result = await commerceApi.productSections.product.listResolved(productId);
68
+ spinner.succeed('区块配置获取成功');
69
+ if (!result.sections || result.sections.length === 0) {
70
+ if (output.isJson()) {
71
+ output.success({ sections: [], available_languages: result.available_languages || [] }, '暂无区块配置');
72
+ }
73
+ else {
74
+ console.log(chalk.yellow('\n暂无区块配置\n'));
75
+ }
76
+ return;
77
+ }
78
+ if (output.isJson()) {
79
+ output.success(result);
80
+ }
81
+ else {
82
+ console.log();
83
+ console.log(chalk.bold(`商品 ${productId} 区块配置(合并视图):\n`));
84
+ result.sections.forEach((section, index) => {
85
+ const sourceColor = section.source === 'system' ? chalk.gray :
86
+ section.source === 'merchant' ? chalk.blue :
87
+ chalk.cyan;
88
+ const hiddenBadge = section.is_hidden ? chalk.red(' [已隐藏]') : '';
89
+ console.log(chalk.white(`${index + 1}. ${section.handle}`) + hiddenBadge);
90
+ console.log(chalk.gray(` 来源: `) + sourceColor(section.source));
91
+ console.log(chalk.gray(` 类型: ${section.type}`));
92
+ console.log(chalk.gray(` 位置: ${section.position}`));
93
+ if (section.tab_group) {
94
+ console.log(chalk.gray(` Tab分组: ${section.tab_group}`));
95
+ }
96
+ if (section.content) {
97
+ const preview = section.content.length > 50 ? section.content.substring(0, 50) + '...' : section.content;
98
+ console.log(chalk.gray(` 内容: ${preview}`));
99
+ }
100
+ const langCount = Object.keys(section.translations || {}).length;
101
+ if (langCount > 0) {
102
+ console.log(chalk.gray(` 翻译: ${langCount} 种语言`));
103
+ }
104
+ console.log();
105
+ });
106
+ console.log(chalk.gray(`共 ${result.sections.length} 个区块`));
107
+ if (result.available_languages && result.available_languages.length > 0) {
108
+ console.log(chalk.gray(`支持语言: ${result.available_languages.join(', ')}`));
109
+ }
110
+ console.log();
111
+ }
112
+ }
113
+ else {
114
+ const overrides = await commerceApi.productSections.product.list(productId);
115
+ spinner.succeed('商品级覆盖获取成功');
116
+ if (!overrides || overrides.length === 0) {
117
+ if (output.isJson()) {
118
+ output.success({ overrides: [] }, '暂无商品级覆盖(提示: 使用 --resolved 查看完整视图)');
119
+ }
120
+ else {
121
+ console.log(chalk.yellow('\n暂无商品级覆盖'));
122
+ console.log(chalk.gray('提示: 使用 --resolved 查看 System + Merchant + Product 合并后的完整视图\n'));
123
+ }
124
+ return;
125
+ }
126
+ if (output.isJson()) {
127
+ output.success({ overrides });
128
+ }
129
+ else {
130
+ console.log();
131
+ console.log(chalk.bold(`商品 ${productId} 的覆盖配置:\n`));
132
+ overrides.forEach((override, index) => {
133
+ console.log(chalk.cyan(`${index + 1}. ${override.handle}`));
134
+ console.log(chalk.gray(` ID: ${override.id}`));
135
+ console.log(chalk.gray(` 操作类型: ${override.operation_type}`));
136
+ console.log(chalk.gray(` 区块类型: ${override.type}`));
137
+ console.log(chalk.gray(` 位置: ${override.position}`));
138
+ if (override.tab_group) {
139
+ console.log(chalk.gray(` Tab分组: ${override.tab_group}`));
140
+ }
141
+ if (override.content) {
142
+ const preview = override.content.length > 50 ? override.content.substring(0, 50) + '...' : override.content;
143
+ console.log(chalk.gray(` 内容: ${preview}`));
144
+ }
145
+ console.log();
146
+ });
147
+ console.log(chalk.gray(`共 ${overrides.length} 个覆盖`));
148
+ console.log(chalk.gray('提示: 使用 --resolved 查看完整的合并视图\n'));
149
+ }
150
+ }
151
+ }
152
+ catch (error) {
153
+ spinner.fail('获取区块配置失败');
154
+ throw createApiError(error);
155
+ }
156
+ }
157
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/section/product/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,4CAA4C,CAAC;KACzD,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,YAAY,EAAE,wEAAwE,CAAC;KAC9F,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,OAAoB,EAAE,EAAE;IACxD,IAAI,CAAC;QACH,MAAM,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,eAAe,CAAC,GAAG,EAAE;IACnB,QAAQ,EAAE;QACR,qCAAqC;QACrC,0CAA0C;QAC1C,EAAE;QACF,oDAAoD;QACpD,qDAAqD;KACtD;IACD,MAAM,EAAE;QACN,OAAO,EAAE,IAAI,CAAC,SAAS,CACrB;YACE,OAAO,EAAE,IAAI;YACb,IAAI,EAAE;gBACJ,QAAQ,EAAE;oBACR;wBACE,MAAM,EAAE,YAAY;wBACpB,MAAM,EAAE,QAAQ;wBAChB,IAAI,EAAE,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CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const reorderProductSectionsCommand: Command;
3
+ //# sourceMappingURL=reorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.d.ts","sourceRoot":"","sources":["../../../../src/commands/section/product/reorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwDpC,eAAO,MAAM,6BAA6B,SAAM,CAAC"}
@@ -0,0 +1,110 @@
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 (product-level)')
10
+ .argument('<product-id>', 'Product ID')
11
+ .option('--sections <json>', 'JSON array of {handle, position} objects (required)')
12
+ .option('--tab-group <group>', 'Only reorder within this tab group (optional)')
13
+ .action(async (productId, options) => {
14
+ try {
15
+ await reorderProductSections(productId, options);
16
+ }
17
+ catch (error) {
18
+ handleError(error);
19
+ }
20
+ });
21
+ addEnhancedHelp(cmd, {
22
+ examples: [
23
+ '# Reorder sections for a specific product',
24
+ '$ commerce section product reorder prod-123 --sections \'[{"handle":"highlights","position":1},{"handle":"care","position":2}]\'',
25
+ '',
26
+ '# Reorder within a tab group',
27
+ '$ commerce section product reorder prod-123 --tab-group product-info --sections \'[...]\'',
28
+ ],
29
+ output: {
30
+ example: JSON.stringify({
31
+ success: true,
32
+ message: '商品区块顺序已更新',
33
+ }, null, 2),
34
+ },
35
+ relatedCommands: [
36
+ { command: 'section product list --resolved', description: 'View current section order' },
37
+ { command: 'section product update', description: 'Update individual section' },
38
+ { command: 'section reorder', description: 'Reorder for all products (merchant-level)' },
39
+ ],
40
+ notes: [
41
+ 'sections must be a valid JSON array',
42
+ 'Each item needs: handle (string), position (number)',
43
+ 'This only affects the specified product',
44
+ ],
45
+ });
46
+ export const reorderProductSectionsCommand = cmd;
47
+ async function reorderProductSections(productId, options) {
48
+ const { sections, tabGroup } = options;
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
+ let parsedSections;
60
+ try {
61
+ parsedSections = JSON.parse(sections);
62
+ }
63
+ catch (error) {
64
+ throw new ValidationError('--sections 必须是有效的 JSON 数组', 'sections');
65
+ }
66
+ if (!Array.isArray(parsedSections)) {
67
+ throw new ValidationError('--sections 必须是数组', 'sections');
68
+ }
69
+ for (const item of parsedSections) {
70
+ if (!item.handle || typeof item.handle !== 'string') {
71
+ throw new ValidationError('每个 section 必须有 handle 字段(字符串)', 'sections');
72
+ }
73
+ if (typeof item.position !== 'number' || item.position < 1) {
74
+ throw new ValidationError('每个 section 必须有 position 字段(正整数)', 'sections');
75
+ }
76
+ }
77
+ const spinner = output.spinner('正在更新商品区块顺序...');
78
+ try {
79
+ const data = {
80
+ sections: parsedSections,
81
+ };
82
+ if (tabGroup !== undefined) {
83
+ data.tab_group = tabGroup || null;
84
+ }
85
+ await commerceApi.productSections.product.reorder(productId, data);
86
+ spinner.succeed('商品区块顺序已更新!');
87
+ if (output.isJson()) {
88
+ output.success({ product_id: productId, sections: parsedSections, tab_group: tabGroup || null }, '商品区块顺序已更新');
89
+ }
90
+ else {
91
+ console.log();
92
+ console.log(chalk.green('✓ 商品区块顺序已更新!'));
93
+ console.log();
94
+ console.log(chalk.gray('商品ID: ') + chalk.white(productId));
95
+ if (tabGroup) {
96
+ console.log(chalk.gray('Tab分组: ') + chalk.white(tabGroup));
97
+ }
98
+ console.log(chalk.gray('新顺序:'));
99
+ parsedSections.forEach((item) => {
100
+ console.log(chalk.gray(` ${item.position}. `) + chalk.cyan(item.handle));
101
+ });
102
+ console.log();
103
+ }
104
+ }
105
+ catch (error) {
106
+ spinner.fail('更新商品区块顺序失败');
107
+ throw createApiError(error);
108
+ }
109
+ }
110
+ //# sourceMappingURL=reorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.js","sourceRoot":"","sources":["../../../../src/commands/section/product/reorder.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,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAOzE,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC;KAC/B,WAAW,CAAC,+CAA+C,CAAC;KAC5D,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,mBAAmB,EAAE,qDAAqD,CAAC;KAClF,MAAM,CAAC,qBAAqB,EAAE,+CAA+C,CAAC;KAC9E,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,OAAuB,EAAE,EAAE;IAC3D,IAAI,CAAC;QACH,MAAM,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,eAAe,CAAC,G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,EAAE,WAAW,CAAC,CAAC;QAChH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;YACzC,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3D,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAChC,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5E,CAAC,CAAC,CAAC;YACH,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const updateProductSectionCommand: Command;
3
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/commands/section/product/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsEpC,eAAO,MAAM,2BAA2B,SAAM,CAAC"}
@@ -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,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AASzE,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC9B,WAAW,CAAC,wDAAwD,CAAC;KACrE,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;KACtC,QAAQ,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAChD,MAAM,CAAC,eAAe,EAAE,oCAAoC,CAAC;KAC7D,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;KAC5C,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC;KACzD,MAAM,CAAC,qBAAqB,EAAE,4CAA4C,CAAC;KAC3E,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,MAAc,EAAE,OAAsB,EAAE,EAAE;IAC1E,IAAI,CAAC;QACH,MAAM,oBAAoB,CAAC,SAAS,EAA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AM,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YAC1E,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,IAAI,MAAM,CAAC,OAAO,EAAE,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":[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gBAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5E,CAAC,CAAC,CAAC;YACH,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 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"}