@optima-chat/commerce-cli 1.17.1 → 1.18.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 (118) hide show
  1. package/.claude/skills/commerce-storefront/SKILL.md +54 -132
  2. package/dist/commands/homepage/patch-settings.d.ts.map +1 -1
  3. package/dist/commands/homepage/patch-settings.js +3 -0
  4. package/dist/commands/homepage/patch-settings.js.map +1 -1
  5. package/dist/commands/order/ship.d.ts.map +1 -1
  6. package/dist/commands/order/ship.js +59 -21
  7. package/dist/commands/order/ship.js.map +1 -1
  8. package/dist/commands/pdp/add.d.ts +3 -0
  9. package/dist/commands/pdp/add.d.ts.map +1 -0
  10. package/dist/commands/pdp/add.js +234 -0
  11. package/dist/commands/pdp/add.js.map +1 -0
  12. package/dist/commands/pdp/edit.d.ts +3 -0
  13. package/dist/commands/pdp/edit.d.ts.map +1 -0
  14. package/dist/commands/pdp/edit.js +258 -0
  15. package/dist/commands/pdp/edit.js.map +1 -0
  16. package/dist/commands/pdp/hide.d.ts +3 -0
  17. package/dist/commands/pdp/hide.d.ts.map +1 -0
  18. package/dist/commands/pdp/hide.js +191 -0
  19. package/dist/commands/pdp/hide.js.map +1 -0
  20. package/dist/commands/pdp/index.d.ts +4 -0
  21. package/dist/commands/pdp/index.d.ts.map +1 -0
  22. package/dist/commands/pdp/index.js +19 -0
  23. package/dist/commands/pdp/index.js.map +1 -0
  24. package/dist/commands/pdp/reorder.d.ts +3 -0
  25. package/dist/commands/pdp/reorder.d.ts.map +1 -0
  26. package/dist/commands/pdp/reorder.js +117 -0
  27. package/dist/commands/pdp/reorder.js.map +1 -0
  28. package/dist/commands/pdp/reset.d.ts +3 -0
  29. package/dist/commands/pdp/reset.d.ts.map +1 -0
  30. package/dist/commands/pdp/reset.js +123 -0
  31. package/dist/commands/pdp/reset.js.map +1 -0
  32. package/dist/commands/pdp/show.d.ts +3 -0
  33. package/dist/commands/pdp/show.d.ts.map +1 -0
  34. package/dist/commands/pdp/show.js +225 -0
  35. package/dist/commands/pdp/show.js.map +1 -0
  36. package/dist/commands/pdp/translate.d.ts +3 -0
  37. package/dist/commands/pdp/translate.d.ts.map +1 -0
  38. package/dist/commands/pdp/translate.js +258 -0
  39. package/dist/commands/pdp/translate.js.map +1 -0
  40. package/dist/commands/pdp/utils.d.ts +34 -0
  41. package/dist/commands/pdp/utils.d.ts.map +1 -0
  42. package/dist/commands/pdp/utils.js +85 -0
  43. package/dist/commands/pdp/utils.js.map +1 -0
  44. package/dist/index.js +2 -2
  45. package/dist/index.js.map +1 -1
  46. package/package.json +1 -1
  47. package/dist/commands/product-page/create.d.ts +0 -3
  48. package/dist/commands/product-page/create.d.ts.map +0 -1
  49. package/dist/commands/product-page/create.js +0 -218
  50. package/dist/commands/product-page/create.js.map +0 -1
  51. package/dist/commands/product-page/delete.d.ts +0 -3
  52. package/dist/commands/product-page/delete.d.ts.map +0 -1
  53. package/dist/commands/product-page/delete.js +0 -86
  54. package/dist/commands/product-page/delete.js.map +0 -1
  55. package/dist/commands/product-page/hide.d.ts +0 -3
  56. package/dist/commands/product-page/hide.d.ts.map +0 -1
  57. package/dist/commands/product-page/hide.js +0 -82
  58. package/dist/commands/product-page/hide.js.map +0 -1
  59. package/dist/commands/product-page/index.d.ts +0 -4
  60. package/dist/commands/product-page/index.d.ts.map +0 -1
  61. package/dist/commands/product-page/index.js +0 -23
  62. package/dist/commands/product-page/index.js.map +0 -1
  63. package/dist/commands/product-page/list.d.ts +0 -3
  64. package/dist/commands/product-page/list.d.ts.map +0 -1
  65. package/dist/commands/product-page/list.js +0 -164
  66. package/dist/commands/product-page/list.js.map +0 -1
  67. package/dist/commands/product-page/product/create.d.ts +0 -3
  68. package/dist/commands/product-page/product/create.d.ts.map +0 -1
  69. package/dist/commands/product-page/product/create.js +0 -208
  70. package/dist/commands/product-page/product/create.js.map +0 -1
  71. package/dist/commands/product-page/product/delete.d.ts +0 -3
  72. package/dist/commands/product-page/product/delete.d.ts.map +0 -1
  73. package/dist/commands/product-page/product/delete.js +0 -85
  74. package/dist/commands/product-page/product/delete.js.map +0 -1
  75. package/dist/commands/product-page/product/hide.d.ts +0 -3
  76. package/dist/commands/product-page/product/hide.d.ts.map +0 -1
  77. package/dist/commands/product-page/product/hide.js +0 -78
  78. package/dist/commands/product-page/product/hide.js.map +0 -1
  79. package/dist/commands/product-page/product/index.d.ts +0 -4
  80. package/dist/commands/product-page/product/index.d.ts.map +0 -1
  81. package/dist/commands/product-page/product/index.js +0 -17
  82. package/dist/commands/product-page/product/index.js.map +0 -1
  83. package/dist/commands/product-page/product/list.d.ts +0 -3
  84. package/dist/commands/product-page/product/list.d.ts.map +0 -1
  85. package/dist/commands/product-page/product/list.js +0 -157
  86. package/dist/commands/product-page/product/list.js.map +0 -1
  87. package/dist/commands/product-page/product/reorder.d.ts +0 -3
  88. package/dist/commands/product-page/product/reorder.d.ts.map +0 -1
  89. package/dist/commands/product-page/product/reorder.js +0 -110
  90. package/dist/commands/product-page/product/reorder.js.map +0 -1
  91. package/dist/commands/product-page/product/update.d.ts +0 -3
  92. package/dist/commands/product-page/product/update.d.ts.map +0 -1
  93. package/dist/commands/product-page/product/update.js +0 -127
  94. package/dist/commands/product-page/product/update.js.map +0 -1
  95. package/dist/commands/product-page/reorder.d.ts +0 -3
  96. package/dist/commands/product-page/reorder.d.ts.map +0 -1
  97. package/dist/commands/product-page/reorder.js +0 -111
  98. package/dist/commands/product-page/reorder.js.map +0 -1
  99. package/dist/commands/product-page/translation/delete.d.ts +0 -3
  100. package/dist/commands/product-page/translation/delete.d.ts.map +0 -1
  101. package/dist/commands/product-page/translation/delete.js +0 -97
  102. package/dist/commands/product-page/translation/delete.js.map +0 -1
  103. package/dist/commands/product-page/translation/index.d.ts +0 -4
  104. package/dist/commands/product-page/translation/index.d.ts.map +0 -1
  105. package/dist/commands/product-page/translation/index.js +0 -11
  106. package/dist/commands/product-page/translation/index.js.map +0 -1
  107. package/dist/commands/product-page/translation/list.d.ts +0 -3
  108. package/dist/commands/product-page/translation/list.d.ts.map +0 -1
  109. package/dist/commands/product-page/translation/list.js +0 -104
  110. package/dist/commands/product-page/translation/list.js.map +0 -1
  111. package/dist/commands/product-page/translation/set.d.ts +0 -3
  112. package/dist/commands/product-page/translation/set.d.ts.map +0 -1
  113. package/dist/commands/product-page/translation/set.js +0 -151
  114. package/dist/commands/product-page/translation/set.js.map +0 -1
  115. package/dist/commands/product-page/update.d.ts +0 -3
  116. package/dist/commands/product-page/update.d.ts.map +0 -1
  117. package/dist/commands/product-page/update.js +0 -137
  118. package/dist/commands/product-page/update.js.map +0 -1
@@ -0,0 +1,191 @@
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
+ import { resolveProductId } from './utils.js';
10
+ const cmd = new Command('hide')
11
+ .description('Hide a section on the product detail page')
12
+ .requiredOption('--handle <handle>', 'Section handle (required)')
13
+ .option('--product <identifier>', 'Product ID or handle (product-level if specified)')
14
+ .option('-y, --yes', 'Skip confirmation when existing customization must be replaced')
15
+ .action(async (options) => {
16
+ try {
17
+ await hideSection(options);
18
+ }
19
+ catch (error) {
20
+ handleError(error);
21
+ }
22
+ });
23
+ addEnhancedHelp(cmd, {
24
+ examples: [
25
+ '# Hide a merchant-level section',
26
+ '$ commerce pdp hide --handle reviews',
27
+ '',
28
+ '# Hide a product-level section',
29
+ '$ commerce pdp hide --handle specs --product my-product',
30
+ '',
31
+ '# Skip confirmation when replacing existing customization',
32
+ '$ commerce pdp hide --handle care --yes',
33
+ ],
34
+ output: {
35
+ example: JSON.stringify({
36
+ success: true,
37
+ data: {
38
+ id: 'customization-uuid',
39
+ merchant_id: 'merchant-uuid',
40
+ handle: 'reviews',
41
+ operation_type: 'hidden',
42
+ created_at: '2025-11-27T00:00:00Z',
43
+ updated_at: '2025-11-27T00:00:00Z',
44
+ },
45
+ message: 'Section hidden',
46
+ }, null, 2),
47
+ },
48
+ relatedCommands: [
49
+ { command: 'pdp show', description: 'View all sections' },
50
+ { command: 'pdp reset', description: 'Remove customization (unhide)' },
51
+ { command: 'pdp add', description: 'Add a new section' },
52
+ { command: 'pdp edit', description: 'Edit an existing section' },
53
+ ],
54
+ notes: [
55
+ '--handle is required to identify the section to hide',
56
+ 'If the section already has a customization (override or new), you will be prompted to confirm replacement',
57
+ 'Use --yes to skip confirmation in non-interactive environments',
58
+ "To unhide, use 'commerce pdp reset --handle <handle>'",
59
+ '--product accepts a product ID (UUID) or handle for product-level hiding',
60
+ ],
61
+ });
62
+ export const hideCommand = cmd;
63
+ async function hideSection(options) {
64
+ const { handle, product, yes } = options;
65
+ // Resolve product ID if provided
66
+ let productId;
67
+ if (product) {
68
+ productId = await resolveProductId(product);
69
+ }
70
+ const isProductLevel = !!productId;
71
+ const spinnerMsg = isProductLevel ? '正在隐藏商品级区块...' : '正在隐藏商户级区块...';
72
+ const spinner = output.spinner(spinnerMsg);
73
+ try {
74
+ let result;
75
+ if (isProductLevel) {
76
+ result = await commerceApi.productSections.product.hide(productId, handle);
77
+ }
78
+ else {
79
+ result = await commerceApi.productSections.merchant.hide(handle);
80
+ }
81
+ spinner.succeed('区块已隐藏!');
82
+ outputSuccess(result, handle, isProductLevel);
83
+ }
84
+ catch (error) {
85
+ // Check for 409 Conflict — section already has a customization
86
+ const status = error?.response?.status || error?.statusCode;
87
+ if (status === 409) {
88
+ spinner.stop();
89
+ await handle409Conflict(handle, productId, isProductLevel, yes);
90
+ }
91
+ else {
92
+ spinner.fail('隐藏区块失败');
93
+ throw createApiError(error);
94
+ }
95
+ }
96
+ }
97
+ async function handle409Conflict(handle, productId, isProductLevel, yes) {
98
+ // Fetch resolved view to check what kind of customization exists
99
+ let resolved;
100
+ if (isProductLevel) {
101
+ resolved = await commerceApi.productSections.product.listResolved(productId);
102
+ }
103
+ else {
104
+ resolved = await commerceApi.productSections.merchant.listResolved();
105
+ }
106
+ const section = resolved.sections.find((s) => s.handle === handle);
107
+ // If already hidden, just inform and exit
108
+ if (section && section.operation_type === 'hidden') {
109
+ if (output.isJson()) {
110
+ output.success(section, `Section "${handle}" is already hidden.`);
111
+ }
112
+ else {
113
+ console.log();
114
+ console.log(chalk.yellow(`Section "${handle}" is already hidden.`));
115
+ console.log();
116
+ }
117
+ return;
118
+ }
119
+ // Section has an existing customization (override or new)
120
+ const operationType = section?.operation_type || 'unknown';
121
+ if (!isInteractiveEnvironment() && !yes) {
122
+ throw new ValidationError(`Section "${handle}" has an existing ${operationType} customization. Use --yes to confirm replacement.`, 'handle');
123
+ }
124
+ if (!yes) {
125
+ const { confirm } = await inquirer.prompt([
126
+ {
127
+ type: 'confirm',
128
+ name: 'confirm',
129
+ message: `Section "${handle}" has an existing ${operationType} customization. Hiding will remove it. Continue?`,
130
+ default: false,
131
+ },
132
+ ]);
133
+ if (!confirm) {
134
+ console.log(chalk.yellow('Operation cancelled.'));
135
+ return;
136
+ }
137
+ }
138
+ // Delete existing customization, then retry hide
139
+ const deleteSpinner = output.spinner('正在删除现有自定义...');
140
+ try {
141
+ if (isProductLevel) {
142
+ await commerceApi.productSections.product.delete(productId, handle);
143
+ }
144
+ else {
145
+ await commerceApi.productSections.merchant.delete(handle);
146
+ }
147
+ deleteSpinner.succeed('现有自定义已删除');
148
+ }
149
+ catch (deleteError) {
150
+ deleteSpinner.fail('删除现有自定义失败');
151
+ throw createApiError(deleteError);
152
+ }
153
+ // Retry hide
154
+ const retrySpinner = output.spinner('正在隐藏区块...');
155
+ try {
156
+ let result;
157
+ if (isProductLevel) {
158
+ result = await commerceApi.productSections.product.hide(productId, handle);
159
+ }
160
+ else {
161
+ result = await commerceApi.productSections.merchant.hide(handle);
162
+ }
163
+ retrySpinner.succeed('区块已隐藏!');
164
+ outputSuccess(result, handle, isProductLevel);
165
+ }
166
+ catch (retryError) {
167
+ retrySpinner.fail('隐藏区块失败');
168
+ throw createApiError(retryError);
169
+ }
170
+ }
171
+ function outputSuccess(result, handle, isProductLevel) {
172
+ if (output.isJson()) {
173
+ output.success(result, 'Section hidden');
174
+ }
175
+ else {
176
+ console.log();
177
+ console.log(chalk.green(`✓ Section "${handle}" is now hidden.`));
178
+ if (result.id) {
179
+ console.log(chalk.gray('ID: ') + chalk.cyan(result.id));
180
+ }
181
+ console.log(chalk.gray('Handle: ') + chalk.white(result.handle || handle));
182
+ console.log(chalk.gray('操作类型: ') + chalk.white(result.operation_type || 'hidden'));
183
+ if (isProductLevel) {
184
+ console.log(chalk.gray('级别: ') + chalk.white('商品级'));
185
+ }
186
+ console.log();
187
+ console.log(chalk.gray(`Hint: To unhide, use 'commerce pdp reset --handle ${handle}'`));
188
+ console.log();
189
+ }
190
+ }
191
+ //# sourceMappingURL=hide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hide.js","sourceRoot":"","sources":["../../../src/commands/pdp/hide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,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;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAQ9C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC5B,WAAW,CAAC,2CAA2C,CAAC;KACxD,cAAc,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AAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,qDAAqD,MAAM,GAAG,CAAC,CAAC,CAAC;QACxF,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ declare const pdpCommand: Command;
3
+ export { pdpCommand };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/pdp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,QAAA,MAAM,UAAU,SACgG,CAAC;AAUjH,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Command } from 'commander';
2
+ import { showCommand } from './show.js';
3
+ import { addCommand } from './add.js';
4
+ import { editCommand } from './edit.js';
5
+ import { hideCommand } from './hide.js';
6
+ import { resetCommand } from './reset.js';
7
+ import { reorderCommand } from './reorder.js';
8
+ import { translateCommand } from './translate.js';
9
+ const pdpCommand = new Command('pdp')
10
+ .description('Product Detail Page sections — manage content blocks on product pages (NOT product attributes)');
11
+ pdpCommand.addCommand(showCommand);
12
+ pdpCommand.addCommand(addCommand);
13
+ pdpCommand.addCommand(editCommand);
14
+ pdpCommand.addCommand(hideCommand);
15
+ pdpCommand.addCommand(resetCommand);
16
+ pdpCommand.addCommand(reorderCommand);
17
+ pdpCommand.addCommand(translateCommand);
18
+ export { pdpCommand };
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/pdp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;KAClC,WAAW,CAAC,gGAAgG,CAAC,CAAC;AAEjH,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACnC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAClC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACnC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACnC,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACpC,UAAU,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACtC,UAAU,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const reorderCommand: Command;
3
+ //# sourceMappingURL=reorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.d.ts","sourceRoot":"","sources":["../../../src/commands/pdp/reorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyEpC,eAAO,MAAM,cAAc,SAAM,CAAC"}
@@ -0,0 +1,117 @@
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
+ import { resolveProductId, parseReorderArgs } from './utils.js';
8
+ const cmd = new Command('reorder')
9
+ .description('Reorder PDP sections using handle:position pairs')
10
+ .argument('<pairs...>', 'One or more handle:position pairs (e.g., highlights:1 details:2 care:3)')
11
+ .option('--tab-group <group>', 'Scope reorder to a tab group and assign listed sections to that group')
12
+ .option('--product <identifier>', 'Product ID or handle (product-level reorder)')
13
+ .action(async (pairs, options) => {
14
+ try {
15
+ await reorderSections(pairs, options);
16
+ }
17
+ catch (error) {
18
+ handleError(error);
19
+ }
20
+ });
21
+ addEnhancedHelp(cmd, {
22
+ examples: [
23
+ '# Reorder merchant-level sections',
24
+ '$ commerce pdp reorder highlights:1 details:2 care:3',
25
+ '',
26
+ '# Reorder within a tab group',
27
+ '$ commerce pdp reorder specs:1 materials:2 --tab-group product-info',
28
+ '',
29
+ '# Reorder product-level sections',
30
+ '$ commerce pdp reorder highlights:1 care:2 --product my-product',
31
+ '',
32
+ '# Reorder product-level sections within a tab group',
33
+ '$ commerce pdp reorder specs:1 care:2 --tab-group info --product my-product',
34
+ ],
35
+ output: {
36
+ example: JSON.stringify({
37
+ success: true,
38
+ data: {
39
+ sections: [
40
+ { handle: 'highlights', position: 1 },
41
+ { handle: 'details', position: 2 },
42
+ { handle: 'care', position: 3 },
43
+ ],
44
+ tab_group: null,
45
+ },
46
+ message: 'Sections reordered',
47
+ }, null, 2),
48
+ },
49
+ relatedCommands: [
50
+ { command: 'pdp show', description: 'View all sections' },
51
+ { command: 'pdp add', description: 'Add a new section' },
52
+ { command: 'pdp edit', description: 'Edit an existing section' },
53
+ { command: 'pdp hide', description: 'Hide a section' },
54
+ ],
55
+ notes: [
56
+ 'Each pair must be in handle:position format (e.g., care:3)',
57
+ 'Position must be >= 1',
58
+ 'Handle must match ^[a-z0-9-]+$ (lowercase letters, digits, hyphens)',
59
+ '--tab-group scopes the reorder to that group and assigns listed sections to it',
60
+ '--product accepts a product ID (UUID) or handle for product-level reorder',
61
+ ],
62
+ });
63
+ export const reorderCommand = cmd;
64
+ async function reorderSections(pairs, options) {
65
+ const { tabGroup, product } = options;
66
+ // Parse handle:position pairs
67
+ const sections = parseReorderArgs(pairs);
68
+ // Resolve product ID if provided
69
+ let productId;
70
+ if (product) {
71
+ productId = await resolveProductId(product);
72
+ }
73
+ const isProductLevel = !!productId;
74
+ const spinnerMsg = isProductLevel ? '正在重新排序商品级区块...' : '正在重新排序商户级区块...';
75
+ const spinner = output.spinner(spinnerMsg);
76
+ try {
77
+ const requestData = {
78
+ tab_group: tabGroup || null,
79
+ sections,
80
+ };
81
+ if (isProductLevel) {
82
+ await commerceApi.productSections.product.reorder(productId, requestData);
83
+ }
84
+ else {
85
+ await commerceApi.productSections.merchant.reorder(requestData);
86
+ }
87
+ spinner.succeed('区块排序成功!');
88
+ const resultData = {
89
+ sections,
90
+ tab_group: tabGroup || null,
91
+ };
92
+ if (output.isJson()) {
93
+ output.success(resultData, 'Sections reordered');
94
+ }
95
+ else {
96
+ console.log();
97
+ console.log(chalk.green('✓ 区块排序成功!'));
98
+ console.log();
99
+ for (const s of sections) {
100
+ console.log(` ${chalk.cyan(s.position.toString())} ${chalk.white(s.handle)}`);
101
+ }
102
+ if (tabGroup) {
103
+ console.log();
104
+ console.log(chalk.gray('Tab分组: ') + chalk.white(tabGroup));
105
+ }
106
+ if (isProductLevel) {
107
+ console.log(chalk.gray('级别: ') + chalk.white('商品级'));
108
+ }
109
+ console.log();
110
+ }
111
+ }
112
+ catch (error) {
113
+ spinner.fail('区块排序失败');
114
+ throw createApiError(error);
115
+ }
116
+ }
117
+ //# sourceMappingURL=reorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.js","sourceRoot":"","sources":["../../../src/commands/pdp/reorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAA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;YACvD,CAAC;YACD,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 resetCommand: Command;
3
+ //# sourceMappingURL=reset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../../../src/commands/pdp/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiEpC,eAAO,MAAM,YAAY,SAAM,CAAC"}
@@ -0,0 +1,123 @@
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
+ import { resolveProductId } from './utils.js';
10
+ const cmd = new Command('reset')
11
+ .description('Remove a section customization and restore the inherited version')
12
+ .requiredOption('--handle <handle>', 'Section handle (required)')
13
+ .option('--product <identifier>', 'Product ID or handle (product-level if specified)')
14
+ .option('-y, --yes', 'Skip confirmation')
15
+ .action(async (options) => {
16
+ try {
17
+ await resetSection(options);
18
+ }
19
+ catch (error) {
20
+ handleError(error);
21
+ }
22
+ });
23
+ addEnhancedHelp(cmd, {
24
+ examples: [
25
+ '# Reset a merchant-level section',
26
+ '$ commerce pdp reset --handle care',
27
+ '',
28
+ '# Reset a product-level section',
29
+ '$ commerce pdp reset --handle specs --product my-product',
30
+ '',
31
+ '# Skip confirmation prompt',
32
+ '$ commerce pdp reset --handle care --yes',
33
+ ],
34
+ output: {
35
+ example: JSON.stringify({
36
+ success: true,
37
+ message: 'Section "care" customization removed',
38
+ }, null, 2),
39
+ },
40
+ relatedCommands: [
41
+ { command: 'pdp show', description: 'View all sections' },
42
+ { command: 'pdp hide', description: 'Hide a section' },
43
+ { command: 'pdp add', description: 'Add a new section' },
44
+ { command: 'pdp edit', description: 'Edit an existing section' },
45
+ ],
46
+ notes: [
47
+ '--handle is required to identify the section to reset',
48
+ 'This removes any customization (override, new, hidden) at the current level',
49
+ 'After reset, the section reverts to the inherited version from the layer above',
50
+ 'If the section has no customization at this level, nothing happens (not an error)',
51
+ '--product accepts a product ID (UUID) or handle for product-level reset',
52
+ ],
53
+ });
54
+ export const resetCommand = cmd;
55
+ async function resetSection(options) {
56
+ const { handle, product, yes } = options;
57
+ // Resolve product ID if provided
58
+ let productId;
59
+ if (product) {
60
+ productId = await resolveProductId(product);
61
+ }
62
+ const isProductLevel = !!productId;
63
+ // Confirmation required
64
+ if (!isInteractiveEnvironment() && !yes) {
65
+ throw new ValidationError(`Confirmation required. Use --yes to confirm reset of section "${handle}".`, 'yes');
66
+ }
67
+ if (!yes) {
68
+ const { confirm } = await inquirer.prompt([
69
+ {
70
+ type: 'confirm',
71
+ name: 'confirm',
72
+ message: `Reset section "${handle}"? This removes your customization and restores the inherited version.`,
73
+ default: false,
74
+ },
75
+ ]);
76
+ if (!confirm) {
77
+ console.log(chalk.yellow('Operation cancelled.'));
78
+ return;
79
+ }
80
+ }
81
+ const spinnerMsg = isProductLevel ? '正在重置商品级区块...' : '正在重置商户级区块...';
82
+ const spinner = output.spinner(spinnerMsg);
83
+ try {
84
+ if (isProductLevel) {
85
+ await commerceApi.productSections.product.delete(productId, handle);
86
+ }
87
+ else {
88
+ await commerceApi.productSections.merchant.delete(handle);
89
+ }
90
+ spinner.succeed('区块自定义已移除');
91
+ if (output.isJson()) {
92
+ output.success({}, `Section "${handle}" customization removed`);
93
+ }
94
+ else {
95
+ console.log();
96
+ console.log(chalk.green(`✓ Section "${handle}" customization removed`));
97
+ console.log(chalk.gray('The inherited version from the layer above is now active.'));
98
+ if (isProductLevel) {
99
+ console.log(chalk.gray('级别: ') + chalk.white('商品级'));
100
+ }
101
+ console.log();
102
+ }
103
+ }
104
+ catch (error) {
105
+ // 404 means no customization exists — not an error
106
+ const status = error?.response?.status || error?.statusCode;
107
+ if (status === 404) {
108
+ spinner.stop();
109
+ if (output.isJson()) {
110
+ output.success({}, `Section "${handle}" has no customization at this level. Nothing to reset.`);
111
+ }
112
+ else {
113
+ console.log();
114
+ console.log(chalk.yellow(`Section "${handle}" has no customization at this level. Nothing to reset.`));
115
+ console.log();
116
+ }
117
+ return;
118
+ }
119
+ spinner.fail('重置区块失败');
120
+ throw createApiError(error);
121
+ }
122
+ }
123
+ //# sourceMappingURL=reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../src/commands/pdp/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,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;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAQ9C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7B,WAAW,CAAC,kEAAkE,CAAC;KAC/E,cAAc,CAAC,mBAAmB,EAAE,2BAA2B,CAAC;KAChE,MAAM,CAAC,wBAAwB,EAAE,mDAAmD,CAAC;KACrF,MAA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,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,MAAM,yBAAyB,CAAC,CAAC,CAAC;YACxE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC,CAAC;YACrF,IAAI,cAAc,EAAE,CAAC;gBACnB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACvD,CAAC;YACD,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,mDAAmD;QACnD,MAAM,MAAM,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,EAAE,UAAU,CAAC;QAC5D,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;gBACpB,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,MAAM,yDAAyD,CAAC,CAAC;YAClG,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CAAC,YAAY,MAAM,yDAAyD,CAAC,CAC1F,CAAC;gBACF,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,CAAC;YACD,OAAO;QACT,CAAC;QAED,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 showCommand: Command;
3
+ //# sourceMappingURL=show.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/commands/pdp/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8FpC,eAAO,MAAM,WAAW,SAAM,CAAC"}