@optima-chat/commerce-cli 1.8.0 → 1.9.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 (66) hide show
  1. package/.claude/skills/commerce-review/SKILL.md +196 -0
  2. package/dist/api/rest/commerce.d.ts +117 -1
  3. package/dist/api/rest/commerce.d.ts.map +1 -1
  4. package/dist/api/rest/commerce.js +76 -0
  5. package/dist/api/rest/commerce.js.map +1 -1
  6. package/dist/commands/review/approve.d.ts +3 -0
  7. package/dist/commands/review/approve.d.ts.map +1 -0
  8. package/dist/commands/review/approve.js +73 -0
  9. package/dist/commands/review/approve.js.map +1 -0
  10. package/dist/commands/review/batch.d.ts +3 -0
  11. package/dist/commands/review/batch.d.ts.map +1 -0
  12. package/dist/commands/review/batch.js +120 -0
  13. package/dist/commands/review/batch.js.map +1 -0
  14. package/dist/commands/review/delete-response.d.ts +3 -0
  15. package/dist/commands/review/delete-response.d.ts.map +1 -0
  16. package/dist/commands/review/delete-response.js +91 -0
  17. package/dist/commands/review/delete-response.js.map +1 -0
  18. package/dist/commands/review/delete.d.ts +3 -0
  19. package/dist/commands/review/delete.d.ts.map +1 -0
  20. package/dist/commands/review/delete.js +93 -0
  21. package/dist/commands/review/delete.js.map +1 -0
  22. package/dist/commands/review/feature.d.ts +3 -0
  23. package/dist/commands/review/feature.d.ts.map +1 -0
  24. package/dist/commands/review/feature.js +89 -0
  25. package/dist/commands/review/feature.js.map +1 -0
  26. package/dist/commands/review/get.d.ts +3 -0
  27. package/dist/commands/review/get.d.ts.map +1 -0
  28. package/dist/commands/review/get.js +79 -0
  29. package/dist/commands/review/get.js.map +1 -0
  30. package/dist/commands/review/handle-report.d.ts +3 -0
  31. package/dist/commands/review/handle-report.d.ts.map +1 -0
  32. package/dist/commands/review/handle-report.js +85 -0
  33. package/dist/commands/review/handle-report.js.map +1 -0
  34. package/dist/commands/review/index.d.ts +3 -0
  35. package/dist/commands/review/index.d.ts.map +1 -0
  36. package/dist/commands/review/index.js +28 -0
  37. package/dist/commands/review/index.js.map +1 -0
  38. package/dist/commands/review/list.d.ts +3 -0
  39. package/dist/commands/review/list.d.ts.map +1 -0
  40. package/dist/commands/review/list.js +144 -0
  41. package/dist/commands/review/list.js.map +1 -0
  42. package/dist/commands/review/reject.d.ts +3 -0
  43. package/dist/commands/review/reject.d.ts.map +1 -0
  44. package/dist/commands/review/reject.js +73 -0
  45. package/dist/commands/review/reject.js.map +1 -0
  46. package/dist/commands/review/reports.d.ts +3 -0
  47. package/dist/commands/review/reports.d.ts.map +1 -0
  48. package/dist/commands/review/reports.js +90 -0
  49. package/dist/commands/review/reports.js.map +1 -0
  50. package/dist/commands/review/respond.d.ts +3 -0
  51. package/dist/commands/review/respond.d.ts.map +1 -0
  52. package/dist/commands/review/respond.js +106 -0
  53. package/dist/commands/review/respond.js.map +1 -0
  54. package/dist/commands/review/stats.d.ts +3 -0
  55. package/dist/commands/review/stats.d.ts.map +1 -0
  56. package/dist/commands/review/stats.js +71 -0
  57. package/dist/commands/review/stats.js.map +1 -0
  58. package/dist/index.js +2 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/utils/config.js +1 -1
  61. package/dist/utils/config.js.map +1 -1
  62. package/dist/utils/format.d.ts +28 -0
  63. package/dist/utils/format.d.ts.map +1 -1
  64. package/dist/utils/format.js +186 -0
  65. package/dist/utils/format.js.map +1 -1
  66. package/package.json +1 -1
@@ -0,0 +1,89 @@
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, requireParam } from '../../utils/interactive.js';
8
+ const cmd = new Command('feature')
9
+ .description('Set or unset a review as featured')
10
+ .option('--id <uuid>', 'Review ID (required)')
11
+ .option('--enable', 'Set as featured')
12
+ .option('--disable', 'Remove from featured')
13
+ .action(async (options) => {
14
+ try {
15
+ await featureReview(options);
16
+ }
17
+ catch (error) {
18
+ handleError(error);
19
+ }
20
+ });
21
+ addEnhancedHelp(cmd, {
22
+ examples: [
23
+ '# Set a review as featured',
24
+ '$ commerce review feature --id abc-123-def --enable',
25
+ '',
26
+ '# Remove from featured',
27
+ '$ commerce review feature --id abc-123-def --disable',
28
+ ],
29
+ output: {
30
+ example: JSON.stringify({
31
+ success: true,
32
+ data: {
33
+ review_id: 'abc-123-def',
34
+ is_featured: true,
35
+ },
36
+ message: 'Review featured',
37
+ }, null, 2),
38
+ },
39
+ relatedCommands: [
40
+ { command: 'review list --featured', description: 'View featured reviews' },
41
+ { command: 'review get', description: 'View review details' },
42
+ ],
43
+ notes: [
44
+ 'Featured reviews can be highlighted on your storefront',
45
+ 'Use --enable to feature, --disable to unfeature',
46
+ ],
47
+ });
48
+ export const featureCommand = cmd;
49
+ async function featureReview(options) {
50
+ const reviewId = isInteractiveEnvironment()
51
+ ? (options.id?.trim() || (() => { throw new ValidationError('Review ID is required', 'id'); })())
52
+ : requireParam(options.id, 'id', 'Review ID');
53
+ if (!options.enable && !options.disable) {
54
+ throw new ValidationError('Must specify --enable or --disable', 'enable');
55
+ }
56
+ if (options.enable && options.disable) {
57
+ throw new ValidationError('Cannot specify both --enable and --disable', 'enable');
58
+ }
59
+ const isFeatured = options.enable === true;
60
+ const spinner = output.spinner(isFeatured ? 'Setting as featured...' : 'Removing from featured...');
61
+ try {
62
+ const review = await commerceApi.reviews.update(reviewId, {
63
+ is_featured: isFeatured,
64
+ });
65
+ spinner.succeed(isFeatured ? 'Review featured' : 'Review unfeatured');
66
+ if (output.isJson()) {
67
+ output.success({
68
+ review_id: review.id,
69
+ is_featured: review.is_featured,
70
+ }, isFeatured ? 'Review featured' : 'Review unfeatured');
71
+ }
72
+ else {
73
+ console.log();
74
+ if (isFeatured) {
75
+ console.log(chalk.green('Review set as featured'));
76
+ }
77
+ else {
78
+ console.log(chalk.yellow('Review removed from featured'));
79
+ }
80
+ console.log(chalk.gray('Review ID: ') + chalk.white(review.id));
81
+ console.log();
82
+ }
83
+ }
84
+ catch (error) {
85
+ spinner.fail('Failed to update featured status');
86
+ throw createApiError(error);
87
+ }
88
+ }
89
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../src/commands/review/feature.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,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAQpF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC;KAC/B,WAAW,CAAC,mCAAmC,CAAC;KAChD,MAAM,CAAC,aAAa,EAAE,sBAAsB,CAAC;KAC7C,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAAC;KACrC,MAAM,CAAC,WAAW,EAAE,sBAAsB,CAAC;KAC3C,MAAM,CAAC,KAAK,EAAE,OAAuB,EAAE,EAAE;IACxC,IAAI,CAAC;QACH,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,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,4BAA4B;QAC5B,qDAAqD;QACrD,EAAE;QACF,wBAAwB;QACxB,sDAAsD;KACvD;IACD,MAAM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+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/review/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8DpC,eAAO,MAAM,gBAAgB,SAAM,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { Command } from 'commander';
2
+ import { commerceApi } from '../../api/rest/commerce.js';
3
+ import { handleError, createApiError, ValidationError } from '../../utils/error.js';
4
+ import { formatReview } from '../../utils/format.js';
5
+ import { output } from '../../utils/output.js';
6
+ import { addEnhancedHelp } from '../../utils/helpText.js';
7
+ import { isInteractiveEnvironment, requireParam } from '../../utils/interactive.js';
8
+ const cmd = new Command('get')
9
+ .description('Get detailed information for a specific review')
10
+ .option('--id <uuid>', 'Review ID (required)')
11
+ .action(async (options) => {
12
+ try {
13
+ await getReview(options);
14
+ }
15
+ catch (error) {
16
+ handleError(error);
17
+ }
18
+ });
19
+ addEnhancedHelp(cmd, {
20
+ examples: [
21
+ '# Get review details',
22
+ '$ commerce review get --id abc-123-def',
23
+ ],
24
+ output: {
25
+ example: JSON.stringify({
26
+ success: true,
27
+ data: {
28
+ review: {
29
+ id: 'review-uuid',
30
+ product_id: 'product-uuid',
31
+ product_name: 'Great Product',
32
+ rating: 5,
33
+ title: 'Excellent!',
34
+ content: 'Really love this product',
35
+ reviewer_name: 'John Doe',
36
+ moderation_status: 'approved',
37
+ is_featured: true,
38
+ is_verified_purchase: true,
39
+ helpful_count: 10,
40
+ not_helpful_count: 1,
41
+ merchant_response: 'Thank you for your feedback!',
42
+ merchant_response_at: '2025-12-21T12:00:00Z',
43
+ created_at: '2025-12-21T10:00:00Z',
44
+ },
45
+ },
46
+ }, null, 2),
47
+ },
48
+ relatedCommands: [
49
+ { command: 'review list', description: 'Find review IDs' },
50
+ { command: 'review approve', description: 'Approve the review' },
51
+ { command: 'review respond', description: 'Reply to the review' },
52
+ ],
53
+ notes: [
54
+ 'Use "commerce review list" to find review IDs',
55
+ ],
56
+ });
57
+ export const getReviewCommand = cmd;
58
+ async function getReview(options) {
59
+ const reviewId = isInteractiveEnvironment()
60
+ ? (options.id?.trim() || (() => { throw new ValidationError('Review ID is required', 'id'); })())
61
+ : requireParam(options.id, 'id', 'Review ID');
62
+ const spinner = output.spinner('Fetching review details...');
63
+ try {
64
+ const review = await commerceApi.reviews.get(reviewId);
65
+ spinner.succeed('Review details fetched');
66
+ if (output.isJson()) {
67
+ output.success({ review });
68
+ }
69
+ else {
70
+ console.log();
71
+ console.log(formatReview(review));
72
+ }
73
+ }
74
+ catch (error) {
75
+ spinner.fail('Failed to fetch review');
76
+ throw createApiError(error);
77
+ }
78
+ }
79
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/commands/review/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAMpF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;KAC3B,WAAW,CAAC,gDAAgD,CAAC;KAC7D,MAAM,CAAC,aAAa,EAAE,sBAAsB,CAAC;KAC7C,MAAM,CAAC,KAAK,EAAE,OAAyB,EAAE,EAAE;IAC1C,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,E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IAAI,eAAe,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjG,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE7D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvD,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAE1C,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const handleReportCommand: Command;
3
+ //# sourceMappingURL=handle-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-report.d.ts","sourceRoot":"","sources":["../../../src/commands/review/handle-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AA0D5C,eAAO,MAAM,mBAAmB,SAAM,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { Command, Option } 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, requireParam } from '../../utils/interactive.js';
8
+ const cmd = new Command('handle-report')
9
+ .description('Handle a review report')
10
+ .option('--id <uuid>', 'Report ID (required)')
11
+ .addOption(new Option('-a, --action <action>', 'Action to take (required)')
12
+ .choices(['reviewed', 'dismissed']))
13
+ .action(async (options) => {
14
+ try {
15
+ await handleReport(options);
16
+ }
17
+ catch (error) {
18
+ handleError(error);
19
+ }
20
+ });
21
+ addEnhancedHelp(cmd, {
22
+ examples: [
23
+ '# Mark report as reviewed (took action)',
24
+ '$ commerce review handle-report --id report-123 --action reviewed',
25
+ '',
26
+ '# Dismiss the report',
27
+ '$ commerce review handle-report --id report-123 --action dismissed',
28
+ ],
29
+ output: {
30
+ example: JSON.stringify({
31
+ success: true,
32
+ data: {
33
+ report_id: 'report-123',
34
+ status: 'reviewed',
35
+ },
36
+ message: 'Report handled',
37
+ }, null, 2),
38
+ },
39
+ relatedCommands: [
40
+ { command: 'review reports', description: 'View pending reports' },
41
+ { command: 'review delete', description: 'Delete the reported review' },
42
+ { command: 'review reject', description: 'Reject the reported review' },
43
+ ],
44
+ notes: [
45
+ 'reviewed: indicates you took action on the review',
46
+ 'dismissed: indicates the report was invalid',
47
+ 'Consider deleting or rejecting the review if report is valid',
48
+ ],
49
+ });
50
+ export const handleReportCommand = cmd;
51
+ async function handleReport(options) {
52
+ const reportId = isInteractiveEnvironment()
53
+ ? (options.id?.trim() || (() => { throw new ValidationError('Report ID is required', 'id'); })())
54
+ : requireParam(options.id, 'id', 'Report ID');
55
+ if (!options.action) {
56
+ throw new ValidationError('Action is required (--action reviewed|dismissed)', 'action');
57
+ }
58
+ const spinner = output.spinner('Processing report...');
59
+ try {
60
+ const report = await commerceApi.reviews.handleReport(reportId, options.action);
61
+ spinner.succeed('Report processed');
62
+ if (output.isJson()) {
63
+ output.success({
64
+ report_id: report.id,
65
+ status: report.status,
66
+ }, 'Report handled');
67
+ }
68
+ else {
69
+ console.log();
70
+ if (options.action === 'reviewed') {
71
+ console.log(chalk.green('Report marked as reviewed'));
72
+ }
73
+ else {
74
+ console.log(chalk.yellow('Report dismissed'));
75
+ }
76
+ console.log(chalk.gray('Report ID: ') + chalk.white(report.id));
77
+ console.log();
78
+ }
79
+ }
80
+ catch (error) {
81
+ spinner.fail('Failed to process report');
82
+ throw createApiError(error);
83
+ }
84
+ }
85
+ //# sourceMappingURL=handle-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-report.js","sourceRoot":"","sources":["../../../src/commands/review/handle-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,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,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAOpF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;KACrC,WAAW,CAAC,wBAAwB,CAAC;KACrC,MAAM,CAAC,aAAa,EAAE,sBAAsB,CAAC;KAC7C,SAAS,CACR,IAAI,MAAM,CAAC,uBAAuB,EAAE,2BAA2B,CAAC;KAC7D,OAAO,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CACtC;KACA,MAAM,CAAC,KAAK,EAAE,OAA4B,EAAE,EAAE;IAC7C,IAAI,CAAC;QACH,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC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AAsB,CAAC,CAAC;IAEvD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAkC,CAAC,CAAC;QAC5G,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAEpC,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC;gBACb,SAAS,EAAE,MAAM,CAAC,EAAE;gBACpB,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,EAAE,gBAAgB,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAChD,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAChE,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACzC,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const reviewCommand: Command;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/review/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,eAAO,MAAM,aAAa,SAaQ,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { Command } from 'commander';
2
+ import { listReviewsCommand } from './list.js';
3
+ import { getReviewCommand } from './get.js';
4
+ import { statsCommand } from './stats.js';
5
+ import { approveCommand } from './approve.js';
6
+ import { rejectCommand } from './reject.js';
7
+ import { featureCommand } from './feature.js';
8
+ import { respondCommand } from './respond.js';
9
+ import { deleteResponseCommand } from './delete-response.js';
10
+ import { deleteReviewCommand } from './delete.js';
11
+ import { batchCommand } from './batch.js';
12
+ import { reportsCommand } from './reports.js';
13
+ import { handleReportCommand } from './handle-report.js';
14
+ export const reviewCommand = new Command('review')
15
+ .description('评价管理 - 查看、审核、回复评价')
16
+ .addCommand(listReviewsCommand)
17
+ .addCommand(getReviewCommand)
18
+ .addCommand(statsCommand)
19
+ .addCommand(approveCommand)
20
+ .addCommand(rejectCommand)
21
+ .addCommand(featureCommand)
22
+ .addCommand(respondCommand)
23
+ .addCommand(deleteResponseCommand)
24
+ .addCommand(deleteReviewCommand)
25
+ .addCommand(batchCommand)
26
+ .addCommand(reportsCommand)
27
+ .addCommand(handleReportCommand);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/review/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,mBAAmB,CAAC;KAChC,UAAU,CAAC,kBAAkB,CAAC;KAC9B,UAAU,CAAC,gBAAgB,CAAC;KAC5B,UAAU,CAAC,YAAY,CAAC;KACxB,UAAU,CAAC,cAAc,CAAC;KAC1B,UAAU,CAAC,aAAa,CAAC;KACzB,UAAU,CAAC,cAAc,CAAC;KAC1B,UAAU,CAAC,cAAc,CAAC;KAC1B,UAAU,CAAC,qBAAqB,CAAC;KACjC,UAAU,CAAC,mBAAmB,CAAC;KAC/B,UAAU,CAAC,YAAY,CAAC;KACxB,UAAU,CAAC,cAAc,CAAC;KAC1B,UAAU,CAAC,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const listReviewsCommand: Command;
3
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/review/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAuG5C,eAAO,MAAM,kBAAkB,SAAM,CAAC"}
@@ -0,0 +1,144 @@
1
+ import { Command, Option } 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 { formatReviewList } from '../../utils/format.js';
6
+ import { output } from '../../utils/output.js';
7
+ import { addEnhancedHelp } from '../../utils/helpText.js';
8
+ const cmd = new Command('list')
9
+ .description('List reviews with filtering and pagination')
10
+ .option('--product-id <uuid>', 'Filter by product ID')
11
+ .addOption(new Option('-s, --status <status>', 'Filter by moderation status')
12
+ .choices(['pending', 'approved', 'rejected']))
13
+ .option('--rating <number>', 'Filter by rating (1-5)')
14
+ .option('--has-media', 'Only show reviews with media')
15
+ .option('--has-reply', 'Only show reviews with merchant reply')
16
+ .option('--featured', 'Only show featured reviews')
17
+ .option('--verified', 'Only show verified purchase reviews')
18
+ .addOption(new Option('--sort-by <sort>', 'Sort order')
19
+ .choices(['newest', 'oldest', 'highest_rating', 'lowest_rating', 'most_helpful'])
20
+ .default('newest'))
21
+ .option('-l, --limit <number>', 'Reviews per page (default: 20)', '20')
22
+ .option('-o, --offset <number>', 'Offset for pagination (default: 0)', '0')
23
+ .action(async (options) => {
24
+ try {
25
+ await listReviews(options);
26
+ }
27
+ catch (error) {
28
+ handleError(error);
29
+ }
30
+ });
31
+ addEnhancedHelp(cmd, {
32
+ examples: [
33
+ '# List all reviews',
34
+ '$ commerce review list',
35
+ '',
36
+ '# Filter by status',
37
+ '$ commerce review list --status pending',
38
+ '',
39
+ '# Filter by product',
40
+ '$ commerce review list --product-id abc-123',
41
+ '',
42
+ '# Show featured reviews with high ratings',
43
+ '$ commerce review list --featured --rating 5',
44
+ '',
45
+ '# Sort by helpfulness',
46
+ '$ commerce review list --sort-by most_helpful',
47
+ ],
48
+ output: {
49
+ example: JSON.stringify({
50
+ success: true,
51
+ data: {
52
+ reviews: [
53
+ {
54
+ id: 'review-uuid',
55
+ product_id: 'product-uuid',
56
+ product_name: 'Great Product',
57
+ rating: 5,
58
+ title: 'Excellent!',
59
+ content: 'Really love this product',
60
+ moderation_status: 'approved',
61
+ is_featured: true,
62
+ is_verified_purchase: true,
63
+ helpful_count: 10,
64
+ created_at: '2025-12-21T10:00:00Z',
65
+ },
66
+ ],
67
+ total: 1,
68
+ limit: 20,
69
+ offset: 0,
70
+ has_next: false,
71
+ },
72
+ }, null, 2),
73
+ },
74
+ relatedCommands: [
75
+ { command: 'review get', description: 'View review details' },
76
+ { command: 'review stats', description: 'View review statistics' },
77
+ { command: 'review approve', description: 'Approve a review' },
78
+ ],
79
+ notes: [
80
+ 'Default sort is by newest first',
81
+ 'Use --status pending to find reviews awaiting moderation',
82
+ 'Combine filters for more specific results',
83
+ ],
84
+ });
85
+ export const listReviewsCommand = cmd;
86
+ async function listReviews(options) {
87
+ const spinner = output.spinner('Fetching reviews...');
88
+ try {
89
+ const params = {
90
+ limit: parseInt(options.limit || '20', 10),
91
+ offset: parseInt(options.offset || '0', 10),
92
+ };
93
+ if (options.productId)
94
+ params.product_id = options.productId;
95
+ if (options.status)
96
+ params.status = options.status;
97
+ if (options.rating)
98
+ params.rating = parseInt(options.rating, 10);
99
+ if (options.hasMedia)
100
+ params.has_media = true;
101
+ if (options.hasReply)
102
+ params.has_reply = true;
103
+ if (options.featured)
104
+ params.featured = true;
105
+ if (options.verified)
106
+ params.verified = true;
107
+ if (options.sortBy)
108
+ params.sort_by = options.sortBy;
109
+ const result = await commerceApi.reviews.list(params);
110
+ spinner.succeed('Reviews fetched');
111
+ const reviews = result.reviews || [];
112
+ const total = result.total || 0;
113
+ if (output.isJson()) {
114
+ output.success({
115
+ reviews,
116
+ total,
117
+ limit: params.limit,
118
+ offset: params.offset,
119
+ has_next: total > (params.offset + params.limit),
120
+ }, `Retrieved ${reviews.length} reviews`);
121
+ }
122
+ else {
123
+ console.log();
124
+ console.log(chalk.cyan(`Found ${total} reviews`));
125
+ console.log();
126
+ if (reviews.length === 0) {
127
+ console.log(chalk.yellow('No reviews found'));
128
+ }
129
+ else {
130
+ console.log(formatReviewList(reviews));
131
+ // Pagination info
132
+ const page = Math.floor(params.offset / params.limit) + 1;
133
+ const totalPages = Math.ceil(total / params.limit);
134
+ console.log(chalk.gray(`Page ${page} of ${totalPages} (${total} total)`));
135
+ }
136
+ console.log();
137
+ }
138
+ }
139
+ catch (error) {
140
+ spinner.fail('Failed to fetch reviews');
141
+ throw createApiError(error);
142
+ }
143
+ }
144
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/review/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAe1D,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC5B,WAAW,CAAC,4CAA4C,CAAC;KACzD,MAAM,CAAC,qBAAqB,EAAE,sBAAsB,CAAC;KACrD,SAAS,CACR,IAAI,MAAM,CAAC,uBAAuB,EAAE,6BAA6B,CAAC;KAC/D,OAAO,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAChD;KACA,MAAM,CAAC,mBAAmB,EAAE,wBAAwB,CAAC;KACrD,MAAM,CAAC,aAAa,EAAE,8BAA8B,CAAC;KACrD,MAAM,CAAC,aAAa,EAAE,uCAAuC,CAAC;KAC9D,MAAM,CAAC,YAAY,EAAE,4BAA4B,CAAC;KAClD,MAAM,CAAC,YAAY,EAAE,qCAAqC,CAAC;KAC3D,SAAS,CACR,IAAI,MAAM,CAAC,kBAAkB,EAAE,YAAY,CAAC;KACzC,OAAO,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;KAChF,OAAO,CAAC,QAAQ,C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MAAM,CAAC,KAAK,CAAC,CAAC;gBACnD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,UAAU,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;YAC5E,CAAC;YACD,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACxC,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const rejectCommand: Command;
3
+ //# sourceMappingURL=reject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reject.d.ts","sourceRoot":"","sources":["../../../src/commands/review/reject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiDpC,eAAO,MAAM,aAAa,SAAM,CAAC"}
@@ -0,0 +1,73 @@
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, requireParam } from '../../utils/interactive.js';
8
+ const cmd = new Command('reject')
9
+ .description('Reject a review')
10
+ .option('--id <uuid>', 'Review ID (required)')
11
+ .action(async (options) => {
12
+ try {
13
+ await rejectReview(options);
14
+ }
15
+ catch (error) {
16
+ handleError(error);
17
+ }
18
+ });
19
+ addEnhancedHelp(cmd, {
20
+ examples: [
21
+ '# Reject a review',
22
+ '$ commerce review reject --id abc-123-def',
23
+ ],
24
+ output: {
25
+ example: JSON.stringify({
26
+ success: true,
27
+ data: {
28
+ review_id: 'abc-123-def',
29
+ moderation_status: 'rejected',
30
+ },
31
+ message: 'Review rejected',
32
+ }, null, 2),
33
+ },
34
+ relatedCommands: [
35
+ { command: 'review list --status pending', description: 'Find pending reviews' },
36
+ { command: 'review approve', description: 'Approve a review' },
37
+ { command: 'review delete', description: 'Delete a review' },
38
+ ],
39
+ notes: [
40
+ 'Rejected reviews are hidden from customers',
41
+ 'Consider deleting spam reviews instead of rejecting',
42
+ ],
43
+ });
44
+ export const rejectCommand = cmd;
45
+ async function rejectReview(options) {
46
+ const reviewId = isInteractiveEnvironment()
47
+ ? (options.id?.trim() || (() => { throw new ValidationError('Review ID is required', 'id'); })())
48
+ : requireParam(options.id, 'id', 'Review ID');
49
+ const spinner = output.spinner('Rejecting review...');
50
+ try {
51
+ const review = await commerceApi.reviews.update(reviewId, {
52
+ moderation_status: 'rejected',
53
+ });
54
+ spinner.succeed('Review rejected');
55
+ if (output.isJson()) {
56
+ output.success({
57
+ review_id: review.id,
58
+ moderation_status: review.moderation_status,
59
+ }, 'Review rejected');
60
+ }
61
+ else {
62
+ console.log();
63
+ console.log(chalk.yellow('Review rejected'));
64
+ console.log(chalk.gray('Review ID: ') + chalk.white(review.id));
65
+ console.log();
66
+ }
67
+ }
68
+ catch (error) {
69
+ spinner.fail('Failed to reject review');
70
+ throw createApiError(error);
71
+ }
72
+ }
73
+ //# sourceMappingURL=reject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reject.js","sourceRoot":"","sources":["../../../src/commands/review/reject.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,wBAA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CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjG,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAEtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE;YACxD,iBAAiB,EAAE,UAAU;SAC9B,CAAC,CAAC;QACH,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAEnC,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC;gBACb,SAAS,EAAE,MAAM,CAAC,EAAE;gBACpB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;aAC5C,EAAE,iBAAiB,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAChE,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACxC,MAAM,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const reportsCommand: Command;
3
+ //# sourceMappingURL=reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../../src/commands/review/reports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAgE5C,eAAO,MAAM,cAAc,SAAM,CAAC"}