@optima-chat/commerce-cli 1.7.4 → 1.7.6
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.
- package/dist/api/rest/commerce.d.ts +6 -2
- package/dist/api/rest/commerce.d.ts.map +1 -1
- package/dist/api/rest/commerce.js +5 -1
- package/dist/api/rest/commerce.js.map +1 -1
- package/dist/commands/product/list.js +24 -21
- package/dist/commands/product/list.js.map +1 -1
- package/dist/commands/test/smoke.js +1 -1
- package/dist/commands/test/smoke.js.map +1 -1
- package/dist/index.js +0 -0
- package/package.json +1 -1
- package/.claude/settings.local.json +0 -70
- package/dist/commands/address/create.d.ts +0 -3
- package/dist/commands/address/create.d.ts.map +0 -1
- package/dist/commands/address/create.js +0 -122
- package/dist/commands/address/create.js.map +0 -1
- package/dist/commands/address/delete.d.ts +0 -3
- package/dist/commands/address/delete.d.ts.map +0 -1
- package/dist/commands/address/delete.js +0 -50
- package/dist/commands/address/delete.js.map +0 -1
- package/dist/commands/address/get.d.ts +0 -3
- package/dist/commands/address/get.d.ts.map +0 -1
- package/dist/commands/address/get.js +0 -50
- package/dist/commands/address/get.js.map +0 -1
- package/dist/commands/address/index.d.ts +0 -3
- package/dist/commands/address/index.d.ts.map +0 -1
- package/dist/commands/address/index.js +0 -16
- package/dist/commands/address/index.js.map +0 -1
- package/dist/commands/address/list.d.ts +0 -3
- package/dist/commands/address/list.d.ts.map +0 -1
- package/dist/commands/address/list.js +0 -34
- package/dist/commands/address/list.js.map +0 -1
- package/dist/commands/address/set-default.d.ts +0 -3
- package/dist/commands/address/set-default.d.ts.map +0 -1
- package/dist/commands/address/set-default.js +0 -34
- package/dist/commands/address/set-default.js.map +0 -1
- package/dist/commands/address/update.d.ts +0 -3
- package/dist/commands/address/update.d.ts.map +0 -1
- package/dist/commands/address/update.js +0 -120
- package/dist/commands/address/update.js.map +0 -1
- package/dist/commands/auth/switch.d.ts +0 -3
- package/dist/commands/auth/switch.d.ts.map +0 -1
- package/dist/commands/auth/switch.js +0 -111
- package/dist/commands/auth/switch.js.map +0 -1
- package/dist/commands/auth/test-refresh.d.ts +0 -3
- package/dist/commands/auth/test-refresh.d.ts.map +0 -1
- package/dist/commands/auth/test-refresh.js +0 -43
- package/dist/commands/auth/test-refresh.js.map +0 -1
- package/dist/commands/category/create.d.ts +0 -3
- package/dist/commands/category/create.d.ts.map +0 -1
- package/dist/commands/category/create.js +0 -142
- package/dist/commands/category/create.js.map +0 -1
- package/dist/commands/category/delete.d.ts +0 -3
- package/dist/commands/category/delete.d.ts.map +0 -1
- package/dist/commands/category/delete.js +0 -98
- package/dist/commands/category/delete.js.map +0 -1
- package/dist/commands/category/get.d.ts +0 -3
- package/dist/commands/category/get.d.ts.map +0 -1
- package/dist/commands/category/get.js +0 -74
- package/dist/commands/category/get.js.map +0 -1
- package/dist/commands/category/index.d.ts +0 -3
- package/dist/commands/category/index.d.ts.map +0 -1
- package/dist/commands/category/index.js +0 -14
- package/dist/commands/category/index.js.map +0 -1
- package/dist/commands/category/list.d.ts +0 -3
- package/dist/commands/category/list.d.ts.map +0 -1
- package/dist/commands/category/list.js +0 -77
- package/dist/commands/category/list.js.map +0 -1
- package/dist/commands/category/update.d.ts +0 -3
- package/dist/commands/category/update.d.ts.map +0 -1
- package/dist/commands/category/update.js +0 -104
- package/dist/commands/category/update.js.map +0 -1
- package/dist/commands/cleanup.d.ts +0 -3
- package/dist/commands/cleanup.d.ts.map +0 -1
- package/dist/commands/cleanup.js +0 -100
- package/dist/commands/cleanup.js.map +0 -1
- package/dist/commands/i18n/category/create.d.ts +0 -3
- package/dist/commands/i18n/category/create.d.ts.map +0 -1
- package/dist/commands/i18n/category/create.js +0 -113
- package/dist/commands/i18n/category/create.js.map +0 -1
- package/dist/commands/i18n/category/delete.d.ts +0 -3
- package/dist/commands/i18n/category/delete.d.ts.map +0 -1
- package/dist/commands/i18n/category/delete.js +0 -63
- package/dist/commands/i18n/category/delete.js.map +0 -1
- package/dist/commands/i18n/category/get.d.ts +0 -3
- package/dist/commands/i18n/category/get.d.ts.map +0 -1
- package/dist/commands/i18n/category/get.js +0 -56
- package/dist/commands/i18n/category/get.js.map +0 -1
- package/dist/commands/i18n/category/index.d.ts +0 -3
- package/dist/commands/i18n/category/index.d.ts.map +0 -1
- package/dist/commands/i18n/category/index.js +0 -14
- package/dist/commands/i18n/category/index.js.map +0 -1
- package/dist/commands/i18n/category/list.d.ts +0 -3
- package/dist/commands/i18n/category/list.d.ts.map +0 -1
- package/dist/commands/i18n/category/list.js +0 -72
- package/dist/commands/i18n/category/list.js.map +0 -1
- package/dist/commands/i18n/category/update.d.ts +0 -3
- package/dist/commands/i18n/category/update.d.ts.map +0 -1
- package/dist/commands/i18n/category/update.js +0 -68
- package/dist/commands/i18n/category/update.js.map +0 -1
- package/dist/commands/i18n/merchant/get.d.ts +0 -3
- package/dist/commands/i18n/merchant/get.d.ts.map +0 -1
- package/dist/commands/i18n/merchant/get.js +0 -30
- package/dist/commands/i18n/merchant/get.js.map +0 -1
- package/dist/commands/section/create.d.ts +0 -3
- package/dist/commands/section/create.d.ts.map +0 -1
- package/dist/commands/section/create.js +0 -218
- package/dist/commands/section/create.js.map +0 -1
- package/dist/commands/section/delete.d.ts +0 -3
- package/dist/commands/section/delete.d.ts.map +0 -1
- package/dist/commands/section/delete.js +0 -86
- package/dist/commands/section/delete.js.map +0 -1
- package/dist/commands/section/hide.d.ts +0 -3
- package/dist/commands/section/hide.d.ts.map +0 -1
- package/dist/commands/section/hide.js +0 -82
- package/dist/commands/section/hide.js.map +0 -1
- package/dist/commands/section/index.d.ts +0 -4
- package/dist/commands/section/index.d.ts.map +0 -1
- package/dist/commands/section/index.js +0 -23
- package/dist/commands/section/index.js.map +0 -1
- package/dist/commands/section/list.d.ts +0 -3
- package/dist/commands/section/list.d.ts.map +0 -1
- package/dist/commands/section/list.js +0 -164
- package/dist/commands/section/list.js.map +0 -1
- package/dist/commands/section/product/create.d.ts +0 -3
- package/dist/commands/section/product/create.d.ts.map +0 -1
- package/dist/commands/section/product/create.js +0 -208
- package/dist/commands/section/product/create.js.map +0 -1
- package/dist/commands/section/product/delete.d.ts +0 -3
- package/dist/commands/section/product/delete.d.ts.map +0 -1
- package/dist/commands/section/product/delete.js +0 -85
- package/dist/commands/section/product/delete.js.map +0 -1
- package/dist/commands/section/product/hide.d.ts +0 -3
- package/dist/commands/section/product/hide.d.ts.map +0 -1
- package/dist/commands/section/product/hide.js +0 -78
- package/dist/commands/section/product/hide.js.map +0 -1
- package/dist/commands/section/product/index.d.ts +0 -4
- package/dist/commands/section/product/index.d.ts.map +0 -1
- package/dist/commands/section/product/index.js +0 -17
- package/dist/commands/section/product/index.js.map +0 -1
- package/dist/commands/section/product/list.d.ts +0 -3
- package/dist/commands/section/product/list.d.ts.map +0 -1
- package/dist/commands/section/product/list.js +0 -157
- package/dist/commands/section/product/list.js.map +0 -1
- package/dist/commands/section/product/reorder.d.ts +0 -3
- package/dist/commands/section/product/reorder.d.ts.map +0 -1
- package/dist/commands/section/product/reorder.js +0 -110
- package/dist/commands/section/product/reorder.js.map +0 -1
- package/dist/commands/section/product/update.d.ts +0 -3
- package/dist/commands/section/product/update.d.ts.map +0 -1
- package/dist/commands/section/product/update.js +0 -127
- package/dist/commands/section/product/update.js.map +0 -1
- package/dist/commands/section/reorder.d.ts +0 -3
- package/dist/commands/section/reorder.d.ts.map +0 -1
- package/dist/commands/section/reorder.js +0 -111
- package/dist/commands/section/reorder.js.map +0 -1
- package/dist/commands/section/translation/delete.d.ts +0 -3
- package/dist/commands/section/translation/delete.d.ts.map +0 -1
- package/dist/commands/section/translation/delete.js +0 -97
- package/dist/commands/section/translation/delete.js.map +0 -1
- package/dist/commands/section/translation/index.d.ts +0 -4
- package/dist/commands/section/translation/index.d.ts.map +0 -1
- package/dist/commands/section/translation/index.js +0 -11
- package/dist/commands/section/translation/index.js.map +0 -1
- package/dist/commands/section/translation/list.d.ts +0 -3
- package/dist/commands/section/translation/list.d.ts.map +0 -1
- package/dist/commands/section/translation/list.js +0 -104
- package/dist/commands/section/translation/list.js.map +0 -1
- package/dist/commands/section/translation/set.d.ts +0 -3
- package/dist/commands/section/translation/set.d.ts.map +0 -1
- package/dist/commands/section/translation/set.js +0 -151
- package/dist/commands/section/translation/set.js.map +0 -1
- package/dist/commands/section/update.d.ts +0 -3
- package/dist/commands/section/update.d.ts.map +0 -1
- package/dist/commands/section/update.js +0 -137
- package/dist/commands/section/update.js.map +0 -1
- package/dist/commands/variant/get.d.ts +0 -3
- package/dist/commands/variant/get.d.ts.map +0 -1
- package/dist/commands/variant/get.js +0 -41
- package/dist/commands/variant/get.js.map +0 -1
|
@@ -1,137 +0,0 @@
|
|
|
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 customization (merchant-level)')
|
|
10
|
-
.argument('<handle>', 'Section handle to update')
|
|
11
|
-
.option('--type <type>', 'Section type: collapsible | static')
|
|
12
|
-
.option('--position <n>', 'Display position')
|
|
13
|
-
.option('--content <text>', 'Section content in Markdown')
|
|
14
|
-
.option('--tab-group <group>', 'Tab group name (use empty string to clear)')
|
|
15
|
-
.action(async (handle, options) => {
|
|
16
|
-
try {
|
|
17
|
-
await updateSection(handle, options);
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
handleError(error);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
addEnhancedHelp(cmd, {
|
|
24
|
-
examples: [
|
|
25
|
-
'# Update section content',
|
|
26
|
-
'$ commerce section update care --content "New care instructions..."',
|
|
27
|
-
'',
|
|
28
|
-
'# Update section position',
|
|
29
|
-
'$ commerce section update care --position 5',
|
|
30
|
-
'',
|
|
31
|
-
'# Update multiple fields',
|
|
32
|
-
'$ commerce section update care --type static --position 3 --content "Updated content"',
|
|
33
|
-
'',
|
|
34
|
-
'# Move section to a tab group',
|
|
35
|
-
'$ commerce section update care --tab-group product-info',
|
|
36
|
-
'',
|
|
37
|
-
'# Remove from tab group (make independent)',
|
|
38
|
-
'$ commerce section update care --tab-group ""',
|
|
39
|
-
],
|
|
40
|
-
output: {
|
|
41
|
-
example: JSON.stringify({
|
|
42
|
-
success: true,
|
|
43
|
-
data: {
|
|
44
|
-
id: 'customization-uuid',
|
|
45
|
-
merchant_id: 'merchant-uuid',
|
|
46
|
-
handle: 'care',
|
|
47
|
-
operation_type: 'override',
|
|
48
|
-
type: 'collapsible',
|
|
49
|
-
position: 5,
|
|
50
|
-
content: 'New care instructions...',
|
|
51
|
-
tab_group: null,
|
|
52
|
-
created_at: '2025-11-27T00:00:00Z',
|
|
53
|
-
updated_at: '2025-11-27T00:00:00Z',
|
|
54
|
-
},
|
|
55
|
-
message: '区块更新成功',
|
|
56
|
-
}, null, 2),
|
|
57
|
-
},
|
|
58
|
-
relatedCommands: [
|
|
59
|
-
{ command: 'section list --resolved', description: 'View all sections' },
|
|
60
|
-
{ command: 'section create', description: 'Create a section' },
|
|
61
|
-
{ command: 'section delete', description: 'Delete a customization' },
|
|
62
|
-
],
|
|
63
|
-
notes: [
|
|
64
|
-
'Only updates the fields you specify',
|
|
65
|
-
'The section must have a merchant customization to update',
|
|
66
|
-
'Use section create first if the section has no customization',
|
|
67
|
-
],
|
|
68
|
-
});
|
|
69
|
-
export const updateSectionCommand = cmd;
|
|
70
|
-
async function updateSection(handle, options) {
|
|
71
|
-
const { type, position, content, tabGroup } = options;
|
|
72
|
-
// 验证至少有一个更新字段
|
|
73
|
-
if (!type && !position && !content && tabGroup === undefined) {
|
|
74
|
-
if (!isInteractiveEnvironment()) {
|
|
75
|
-
throw new ValidationError('至少需要一个更新字段: --type, --position, --content, 或 --tab-group', 'options');
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
console.log(chalk.yellow('提示: 请指定要更新的字段'));
|
|
79
|
-
console.log(chalk.gray(' --type <type> 区块类型'));
|
|
80
|
-
console.log(chalk.gray(' --position <n> 显示位置'));
|
|
81
|
-
console.log(chalk.gray(' --content <text> 区块内容'));
|
|
82
|
-
console.log(chalk.gray(' --tab-group <group> Tab分组'));
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// 验证 type
|
|
87
|
-
if (type) {
|
|
88
|
-
const validTypes = ['collapsible', 'static'];
|
|
89
|
-
if (!validTypes.includes(type)) {
|
|
90
|
-
throw new ValidationError(`无效的区块类型: ${type}。有效值: ${validTypes.join(', ')}`, 'type');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const spinner = output.spinner('正在更新区块...');
|
|
94
|
-
try {
|
|
95
|
-
const data = {};
|
|
96
|
-
if (type) {
|
|
97
|
-
data.type = type;
|
|
98
|
-
}
|
|
99
|
-
if (position) {
|
|
100
|
-
data.position = parseInt(position, 10);
|
|
101
|
-
}
|
|
102
|
-
if (content) {
|
|
103
|
-
data.content = content;
|
|
104
|
-
}
|
|
105
|
-
if (tabGroup !== undefined) {
|
|
106
|
-
data.tab_group = tabGroup || null;
|
|
107
|
-
}
|
|
108
|
-
const result = await commerceApi.productSections.merchant.update(handle, data);
|
|
109
|
-
spinner.succeed('区块更新成功!');
|
|
110
|
-
if (output.isJson()) {
|
|
111
|
-
output.success(result, '区块更新成功');
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
console.log();
|
|
115
|
-
console.log(chalk.green('✓ 区块更新成功!'));
|
|
116
|
-
console.log();
|
|
117
|
-
console.log(chalk.gray('ID: ') + chalk.cyan(result.id));
|
|
118
|
-
console.log(chalk.gray('Handle: ') + chalk.white(result.handle));
|
|
119
|
-
console.log(chalk.gray('操作类型: ') + chalk.white(result.operation_type));
|
|
120
|
-
console.log(chalk.gray('区块类型: ') + chalk.white(result.type));
|
|
121
|
-
console.log(chalk.gray('位置: ') + chalk.white(result.position.toString()));
|
|
122
|
-
if (result.tab_group) {
|
|
123
|
-
console.log(chalk.gray('Tab分组: ') + chalk.white(result.tab_group));
|
|
124
|
-
}
|
|
125
|
-
if (result.content) {
|
|
126
|
-
const preview = result.content.length > 100 ? result.content.substring(0, 100) + '...' : result.content;
|
|
127
|
-
console.log(chalk.gray('内容: ') + chalk.white(preview));
|
|
128
|
-
}
|
|
129
|
-
console.log();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
spinner.fail('更新区块失败');
|
|
134
|
-
throw createApiError(error);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=update.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/section/update.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;AAStE,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC9B,WAAW,CAAC,8DAA8D,CAAC;KAC3E,QAAQ,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAChD,MAAM,CAAC,eAAe,EAAE,oCAAoC,CAAC;KAC7D,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;KAC5C,MAAM,CAAC,kBAA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ts","sourceRoot":"","sources":["../../../src/commands/variant/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,iBAAiB,SAU1B,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import ora from 'ora';
|
|
3
|
-
import { commerceApi } from '../../api/rest/commerce.js';
|
|
4
|
-
import { handleError, createApiError, ValidationError } from '../../utils/error.js';
|
|
5
|
-
import { formatVariant } from '../../utils/format.js';
|
|
6
|
-
export const getVariantCommand = new Command('get')
|
|
7
|
-
.description('变体详情')
|
|
8
|
-
.option('--product-id <id>', '商品 ID')
|
|
9
|
-
.option('--variant-id <id>', '变体 ID')
|
|
10
|
-
.action(async (options) => {
|
|
11
|
-
try {
|
|
12
|
-
await getVariant(options);
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
handleError(error);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
async function getVariant(options) {
|
|
19
|
-
// 验证参数
|
|
20
|
-
if (!options.productId || options.productId.trim().length === 0) {
|
|
21
|
-
throw new ValidationError('商品 ID 不能为空', 'product-id');
|
|
22
|
-
}
|
|
23
|
-
if (!options.variantId || options.variantId.trim().length === 0) {
|
|
24
|
-
throw new ValidationError('变体 ID 不能为空', 'variant-id');
|
|
25
|
-
}
|
|
26
|
-
const productId = options.productId;
|
|
27
|
-
const variantId = options.variantId;
|
|
28
|
-
const spinner = ora('正在获取变体详情...').start();
|
|
29
|
-
try {
|
|
30
|
-
const variant = await commerceApi.variants.get(productId, variantId);
|
|
31
|
-
spinner.stop();
|
|
32
|
-
// 显示变体详情
|
|
33
|
-
console.log();
|
|
34
|
-
console.log(formatVariant(variant));
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
spinner.fail('获取变体详情失败');
|
|
38
|
-
throw createApiError(error);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
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