mage-remote-run 0.32.0 → 1.1.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.
@@ -1,5 +1,8 @@
1
1
  import { createClient } from '../api/factory.js';
2
- import { printTable, handleError } from '../utils.js';
2
+ import {
3
+ printTable, handleError, buildPaginationCriteria,
4
+ getFormatHeaders, formatOutput, buildSearchCriteria, buildSortCriteria
5
+ } from '../utils.js';
3
6
  import chalk from 'chalk';
4
7
 
5
8
  function printAddress(addr) {
@@ -34,18 +37,11 @@ function printAddress(addr) {
34
37
  export async function showCartAction(cartId, options) {
35
38
  try {
36
39
  const client = await createClient();
37
- const headers = {};
38
- if (options.format === 'json') headers.Accept = 'application/json';
39
- else if (options.format === 'xml') headers.Accept = 'application/xml';
40
+ const headers = getFormatHeaders(options);
40
41
 
41
42
  const data = await client.get(`V1/carts/${cartId}`, {}, { headers });
42
43
 
43
- if (options.format === 'json') {
44
- console.log(JSON.stringify(data, null, 2));
45
- return;
46
- }
47
- if (options.format === 'xml') {
48
- console.log(data);
44
+ if (formatOutput(options, data)) {
49
45
  return;
50
46
  }
51
47
 
@@ -126,47 +122,20 @@ export async function showCartAction(cartId, options) {
126
122
  export async function listCartsAction(options) {
127
123
  try {
128
124
  const client = await createClient();
129
- const headers = {};
130
- if (options.format === 'json') headers.Accept = 'application/json';
131
- else if (options.format === 'xml') headers.Accept = 'application/xml';
125
+ const headers = getFormatHeaders(options);
126
+
127
+ const { params: filterParams } = buildSearchCriteria(options);
128
+ const { params: sortParams } = buildSortCriteria(options);
132
129
 
133
130
  const params = {
134
- 'searchCriteria[currentPage]': options.page,
135
- 'searchCriteria[pageSize]': options.size
131
+ ...buildPaginationCriteria(options),
132
+ ...filterParams,
133
+ ...sortParams
136
134
  };
137
135
 
138
- if (options.filter && options.filter.length > 0) {
139
- options.filter.forEach((f, idx) => {
140
- const parts = f.split(':');
141
- const field = parts[0];
142
- const value = parts[1];
143
- const condition = parts[2] || 'eq';
144
-
145
- params[`searchCriteria[filter_groups][${idx}][filters][0][field]`] = field;
146
- params[`searchCriteria[filter_groups][${idx}][filters][0][value]`] = value;
147
- params[`searchCriteria[filter_groups][${idx}][filters][0][condition_type]`] = condition;
148
- });
149
- }
150
-
151
- if (options.sort && options.sort.length > 0) {
152
- options.sort.forEach((s, idx) => {
153
- const parts = s.split(':');
154
- const field = parts[0];
155
- const direction = parts[1] || 'ASC';
156
-
157
- params[`searchCriteria[sortOrders][${idx}][field]`] = field;
158
- params[`searchCriteria[sortOrders][${idx}][direction]`] = direction;
159
- });
160
- }
161
-
162
136
  const data = await client.get('V1/carts/search', params, { headers });
163
137
 
164
- if (options.format === 'json') {
165
- console.log(JSON.stringify(data, null, 2));
166
- return;
167
- }
168
- if (options.format === 'xml') {
169
- console.log(data);
138
+ if (formatOutput(options, data)) {
170
139
  return;
171
140
  }
172
141
 
@@ -1,31 +1,32 @@
1
1
  import { listCartsAction, showCartAction } from './cart-actions.js';
2
2
 
3
+ import {
4
+ addPaginationOptions,
5
+ addFormatOption,
6
+ addFilterOption,
7
+ addSortOption
8
+ } from '../utils.js';
9
+
3
10
  export function registerCartCommands(program) {
4
- const carts = program.command('cart').description('Manage carts');
11
+ const carts = program.command('cart').description('Manage carts');
5
12
 
6
- carts.command('show <cartId>')
7
- .description('Show detailed cart information')
8
- .option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
9
- .addHelpText('after', `
13
+ addFormatOption(carts.command('show <cartId>')
14
+ .description('Show detailed cart information'))
15
+ .addHelpText('after', `
10
16
  Examples:
11
17
  $ mage-remote-run cart show 123
12
18
  $ mage-remote-run cart show 123 --format json
13
19
  `)
14
- .action(showCartAction);
20
+ .action(showCartAction);
15
21
 
16
- carts.command('list')
17
- .description('List carts')
18
- .option('-p, --page <number>', 'Page number', '1')
19
- .option('-s, --size <number>', 'Page size', '20')
20
- .option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
21
- .option('--filter <filter...>', 'Filter options (e.g. "field:value:condition_type" or "field:value")', [])
22
- .option('--sort <sort...>', 'Sort options (e.g. "field:direction")', [])
23
- .addHelpText('after', `
22
+ addFormatOption(addSortOption(addFilterOption(addPaginationOptions(carts.command('list')
23
+ .description('List carts')))))
24
+ .addHelpText('after', `
24
25
  Examples:
25
26
  $ mage-remote-run cart list
26
27
  $ mage-remote-run cart list --page 2 --size 50
27
- $ mage-remote-run cart list --filter "is_active:1"
28
+ $ mage-remote-run cart list --filter "is_active=1"
28
29
  $ mage-remote-run cart list --sort "created_at:DESC"
29
30
  `)
30
- .action(listCartsAction);
31
+ .action(listCartsAction);
31
32
  }
@@ -1,29 +1,27 @@
1
1
  import { createClient } from '../api/factory.js';
2
- import { printTable, handleError } from '../utils.js';
2
+ import {
3
+ printTable, handleError, buildPaginationCriteria,
4
+ getFormatHeaders, formatOutput, buildSearchCriteria, buildSortCriteria
5
+ } from '../utils.js';
3
6
  import { COMPANY_CREATE_QUESTIONS, getAddressQuestions, getCompanyUpdateQuestions } from '../prompts/company.js';
4
7
  import chalk from 'chalk';
5
8
 
6
9
  export async function listCompaniesAction(options) {
7
10
  try {
8
11
  const client = await createClient();
9
- const headers = {};
10
- if (options.format === 'json') headers['Accept'] = 'application/json';
11
- else if (options.format === 'xml') headers['Accept'] = 'application/xml';
12
+ const headers = getFormatHeaders(options);
13
+
14
+ const { params: filterParams } = buildSearchCriteria(options);
15
+ const { params: sortParams } = buildSortCriteria(options);
12
16
 
13
17
  const params = {
14
- 'searchCriteria[currentPage]': options.page,
15
- 'searchCriteria[pageSize]': options.size,
16
- 'searchCriteria[sortOrders][0][field]': options.sortBy,
17
- 'searchCriteria[sortOrders][0][direction]': options.sortOrder
18
+ ...buildPaginationCriteria(options),
19
+ ...filterParams,
20
+ ...sortParams
18
21
  };
19
22
  const data = await client.get('V1/company', params, { headers });
20
23
 
21
- if (options.format === 'json') {
22
- console.log(JSON.stringify(data, null, 2));
23
- return;
24
- }
25
- if (options.format === 'xml') {
26
- console.log(data);
24
+ if (formatOutput(options, data)) {
27
25
  return;
28
26
  }
29
27
 
@@ -43,9 +41,7 @@ export async function listCompaniesAction(options) {
43
41
  export async function showCompanyAction(companyId, options) {
44
42
  try {
45
43
  const client = await createClient();
46
- let headers = {};
47
- if (options.format === 'json') headers['Accept'] = 'application/json';
48
- else if (options.format === 'xml') headers['Accept'] = 'application/xml';
44
+ let headers = getFormatHeaders(options);
49
45
 
50
46
  let data;
51
47
  try {
@@ -54,12 +50,7 @@ export async function showCompanyAction(companyId, options) {
54
50
  throw new Error(`Company '${companyId}' not found.`);
55
51
  }
56
52
 
57
- if (options.format === 'json') {
58
- console.log(JSON.stringify(data, null, 2));
59
- return;
60
- }
61
- if (options.format === 'xml') {
62
- console.log(data);
53
+ if (formatOutput(options, data)) {
63
54
  return;
64
55
  }
65
56
 
@@ -204,11 +195,20 @@ export async function structureCompanyAction(companyId) {
204
195
  } catch (e) { handleError(e); }
205
196
  }
206
197
 
207
- export async function listRolesAction() {
198
+ export async function listRolesAction(options) {
208
199
  try {
209
200
  const client = await createClient();
210
- // Assuming lists all roles visible to admin context
211
- const data = await client.get('V1/company/role', { 'searchCriteria[pageSize]': 20 });
201
+
202
+ const { params: filterParams } = buildSearchCriteria(options);
203
+ const { params: sortParams } = buildSortCriteria(options);
204
+
205
+ const params = {
206
+ ...buildPaginationCriteria(options),
207
+ ...filterParams,
208
+ ...sortParams
209
+ };
210
+
211
+ const data = await client.get('V1/company/role', params);
212
212
  const items = data.items || [];
213
213
  const rows = items.map(r => [r.role_id, r.role_name, r.company_id]);
214
214
  console.log(chalk.bold(`Total Roles: ${data.total_count}`));
@@ -253,11 +253,16 @@ export async function historyCreditAction(companyId, options) {
253
253
  const creditId = creditData.id;
254
254
 
255
255
  // 2. Search History by company_credit_id
256
+ options.filter = options.filter || [];
257
+ options.filter.push(`company_credit_id=${creditId}`);
258
+
259
+ const { params: filterParams } = buildSearchCriteria(options);
260
+ const { params: sortParams } = buildSortCriteria(options);
261
+
256
262
  const params = {
257
- 'searchCriteria[filterGroups][0][filters][0][field]': 'company_credit_id',
258
- 'searchCriteria[filterGroups][0][filters][0][value]': creditId,
259
- 'searchCriteria[currentPage]': options.page,
260
- 'searchCriteria[pageSize]': 20
263
+ ...buildPaginationCriteria(options),
264
+ ...filterParams,
265
+ ...sortParams
261
266
  };
262
267
  const data = await client.get('V1/companyCredits/history', params);
263
268
 
@@ -13,34 +13,36 @@ import {
13
13
  decreaseCreditAction
14
14
  } from './company-actions.js';
15
15
 
16
+ import {
17
+ addPaginationOptions,
18
+ addFormatOption,
19
+ addFilterOption,
20
+ addSortOption
21
+ } from '../utils.js';
22
+
16
23
  export function registerCompanyCommands(program) {
17
24
  const company = program.command('company').description('Manage companies');
18
25
 
19
26
  //-------------------------------------------------------
20
27
  // "company list" Command
21
28
  //-------------------------------------------------------
22
- company.command('list')
23
- .description('List companies')
24
- .option('-p, --page <number>', 'Page number', '1')
25
- .option('-s, --size <number>', 'Page size', '20')
26
- .option('--sort-by <field>', 'Field to sort by', 'entity_id')
27
- .option('--sort-order <order>', 'Sort order (ASC, DESC)', 'ASC')
28
- .option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
29
+ addFormatOption(addSortOption(addFilterOption(addPaginationOptions(company.command('list')
30
+ .description('List companies')))))
29
31
  .addHelpText('after', `
30
32
  Examples:
31
33
  $ mage-remote-run company list
32
34
  $ mage-remote-run company list --page 2 --size 50
33
- $ mage-remote-run company list --sort-by company_name --sort-order DESC
34
35
  $ mage-remote-run company list --format json
36
+ $ mage-remote-run company list --filter "status=1"
37
+ $ mage-remote-run company list --sort "company_name:ASC"
35
38
  `)
36
39
  .action(listCompaniesAction);
37
40
 
38
41
  //-------------------------------------------------------
39
42
  // "company show" Command
40
43
  //-------------------------------------------------------
41
- company.command('show <companyId>')
42
- .description('Show company details')
43
- .option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
44
+ addFormatOption(company.command('show <companyId>')
45
+ .description('Show company details'))
44
46
  .addHelpText('after', `
45
47
  Examples:
46
48
  $ mage-remote-run company show 123
@@ -95,8 +97,14 @@ function registerRoleCommands(company) {
95
97
  //-------------------------------------------------------
96
98
  const role = company.command('role').description('Manage company roles');
97
99
 
98
- role.command('list')
99
- .description('List roles')
100
+ addSortOption(addFilterOption(addPaginationOptions(role.command('list')
101
+ .description('List roles'))))
102
+ .addHelpText('after', `
103
+ Examples:
104
+ $ mage-remote-run company role list
105
+ $ mage-remote-run company role list --filter "role_name=%Admin%"
106
+ $ mage-remote-run company role list --sort "role_name:ASC"
107
+ `)
100
108
  .action(listRolesAction);
101
109
 
102
110
  role.command('show <roleId>')
@@ -114,9 +122,14 @@ function registerCreditCommands(company) {
114
122
  .description('Show credit for company')
115
123
  .action(showCreditAction);
116
124
 
117
- credit.command('history <companyId>')
118
- .description('Show credit history')
119
- .option('-p, --page <number>', 'Page number', '1')
125
+ addSortOption(addFilterOption(addPaginationOptions(credit.command('history <companyId>')
126
+ .description('Show credit history'))))
127
+ .addHelpText('after', `
128
+ Examples:
129
+ $ mage-remote-run company credit history 123
130
+ $ mage-remote-run company credit history 123 --filter "type=1"
131
+ $ mage-remote-run company credit history 123 --sort "datetime:DESC"
132
+ `)
120
133
  .action(historyCreditAction);
121
134
 
122
135
  credit.command('increase [creditId] [amount]')
@@ -1,27 +1,27 @@
1
1
  import { createClient } from '../api/factory.js';
2
- import { printTable, handleError } from '../utils.js';
2
+ import {
3
+ printTable, handleError, buildPaginationCriteria,
4
+ getFormatHeaders, formatOutput, buildSearchCriteria, buildSortCriteria
5
+ } from '../utils.js';
3
6
  import chalk from 'chalk';
4
7
  import inquirer from 'inquirer';
5
8
 
6
9
  export async function listCustomersAction(options) {
7
10
  try {
8
11
  const client = await createClient();
9
- const headers = {};
10
- if (options.format === 'json') headers.Accept = 'application/json';
11
- else if (options.format === 'xml') headers.Accept = 'application/xml';
12
+ const headers = getFormatHeaders(options);
13
+
14
+ const { params: filterParams } = buildSearchCriteria(options);
15
+ const { params: sortParams } = buildSortCriteria(options);
12
16
 
13
17
  const params = {
14
- 'searchCriteria[currentPage]': options.page,
15
- 'searchCriteria[pageSize]': options.size
18
+ ...buildPaginationCriteria(options),
19
+ ...filterParams,
20
+ ...sortParams
16
21
  };
17
22
  const data = await client.get('V1/customers/search', params, { headers });
18
23
 
19
- if (options.format === 'json') {
20
- console.log(JSON.stringify(data, null, 2));
21
- return;
22
- }
23
- if (options.format === 'xml') {
24
- console.log(data);
24
+ if (formatOutput(options, data)) {
25
25
  return;
26
26
  }
27
27
 
@@ -105,18 +105,11 @@ export async function editCustomerAction(id) {
105
105
  export async function showCustomerAction(customerId, options) {
106
106
  try {
107
107
  const client = await createClient();
108
- const headers = {};
109
- if (options.format === 'json') headers.Accept = 'application/json';
110
- else if (options.format === 'xml') headers.Accept = 'application/xml';
108
+ const headers = getFormatHeaders(options);
111
109
 
112
110
  const data = await client.get(`V1/customers/${customerId}`, {}, { headers });
113
111
 
114
- if (options.format === 'json') {
115
- console.log(JSON.stringify(data, null, 2));
116
- return;
117
- }
118
- if (options.format === 'xml') {
119
- console.log(data);
112
+ if (formatOutput(options, data)) {
120
113
  return;
121
114
  }
122
115
 
@@ -222,9 +215,14 @@ export async function confirmCustomerAction(customerId, options) {
222
215
  export async function listCustomerGroupsAction(options) {
223
216
  try {
224
217
  const client = await createClient();
218
+
219
+ const { params: filterParams } = buildSearchCriteria(options);
220
+ const { params: sortParams } = buildSortCriteria(options);
221
+
225
222
  const params = {
226
- 'searchCriteria[currentPage]': options.page,
227
- 'searchCriteria[pageSize]': options.size
223
+ ...buildPaginationCriteria(options),
224
+ ...filterParams,
225
+ ...sortParams
228
226
  };
229
227
  const data = await client.get('V1/customerGroups/search', params);
230
228
  const rows = (data.items || []).map(g => [g.id, g.code, g.tax_class_id]);
@@ -1,95 +1,100 @@
1
1
  import {
2
- confirmCustomerAction,
3
- createCustomerAction,
4
- deleteCustomerAction,
5
- editCustomerAction,
6
- listCustomerGroupsAction,
7
- listCustomersAction,
8
- searchCustomersAction,
9
- showCustomerAction
2
+ confirmCustomerAction,
3
+ createCustomerAction,
4
+ deleteCustomerAction,
5
+ editCustomerAction,
6
+ listCustomerGroupsAction,
7
+ listCustomersAction,
8
+ searchCustomersAction,
9
+ showCustomerAction
10
10
  } from './customers-actions.js';
11
11
 
12
+ import {
13
+ addPaginationOptions,
14
+ addFormatOption,
15
+ addFilterOption,
16
+ addSortOption
17
+ } from '../utils.js';
18
+
12
19
  export function registerCustomersCommands(program) {
13
- const customers = program.command('customer').description('Manage customers');
20
+ const customers = program.command('customer').description('Manage customers');
14
21
 
15
- customers.command('list')
16
- .description('List customers')
17
- .option('-p, --page <number>', 'Page number', '1')
18
- .option('-s, --size <number>', 'Page size', '20')
19
- .option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
20
- .addHelpText('after', `
22
+ addFormatOption(addSortOption(addFilterOption(addPaginationOptions(customers.command('list')
23
+ .description('List customers')))))
24
+ .addHelpText('after', `
21
25
  Examples:
22
26
  $ mage-remote-run customer list
23
27
  $ mage-remote-run customer list --page 2 --size 50
24
28
  $ mage-remote-run customer list --format json
29
+ $ mage-remote-run customer list --filter "email=%@example.com%" --filter "group_id=1"
30
+ $ mage-remote-run customer list --sort "firstname:ASC" --sort "created_at:DESC"
25
31
  `)
26
- .action(listCustomersAction);
32
+ .action(listCustomersAction);
27
33
 
28
- customers.command('search <query>')
29
- .description('Search customers by email')
30
- .addHelpText('after', `
34
+ customers.command('search <query>')
35
+ .description('Search customers by email')
36
+ .addHelpText('after', `
31
37
  Examples:
32
38
  $ mage-remote-run customer search "john@example.com"
33
39
  `)
34
- .action(searchCustomersAction);
40
+ .action(searchCustomersAction);
35
41
 
36
- customers.command('create')
37
- .description('Create a new customer')
38
- .addHelpText('after', `
42
+ customers.command('create')
43
+ .description('Create a new customer')
44
+ .addHelpText('after', `
39
45
  Examples:
40
46
  $ mage-remote-run customer create
41
47
  `)
42
- .action(createCustomerAction);
48
+ .action(createCustomerAction);
43
49
 
44
- customers.command('edit <id>')
45
- .description('Edit a customer')
46
- .addHelpText('after', `
50
+ customers.command('edit <id>')
51
+ .description('Edit a customer')
52
+ .addHelpText('after', `
47
53
  Examples:
48
54
  $ mage-remote-run customer edit 123
49
55
  `)
50
- .action(editCustomerAction);
56
+ .action(editCustomerAction);
51
57
 
52
- customers.command('show <customerId>')
53
- .description('Show detailed customer information')
54
- .option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
55
- .addHelpText('after', `
58
+ addFormatOption(customers.command('show <customerId>')
59
+ .description('Show detailed customer information'))
60
+ .addHelpText('after', `
56
61
  Examples:
57
62
  $ mage-remote-run customer show 123
58
63
  $ mage-remote-run customer show 123 --format json
59
64
  `)
60
- .action(showCustomerAction);
65
+ .action(showCustomerAction);
61
66
 
62
- customers.command('delete <customerId>')
63
- .description('Delete a customer')
64
- .option('--force', 'Force delete without confirmation')
65
- .addHelpText('after', `
67
+ customers.command('delete <customerId>')
68
+ .description('Delete a customer')
69
+ .option('--force', 'Force delete without confirmation')
70
+ .addHelpText('after', `
66
71
  Examples:
67
72
  $ mage-remote-run customer delete 123
68
73
  $ mage-remote-run customer delete 123 --force
69
74
  `)
70
- .action(deleteCustomerAction);
75
+ .action(deleteCustomerAction);
71
76
 
72
- customers.command('confirm [customerId]')
73
- .description('Resend customer confirmation email')
74
- .option('--redirect-url <url>', 'Redirect URL after confirmation')
75
- .addHelpText('after', `
77
+ customers.command('confirm [customerId]')
78
+ .description('Resend customer confirmation email')
79
+ .option('--redirect-url <url>', 'Redirect URL after confirmation')
80
+ .addHelpText('after', `
76
81
  Examples:
77
82
  $ mage-remote-run customer confirm 123
78
83
  $ mage-remote-run customer confirm 123 --redirect-url "https://example.com/login"
79
84
  $ mage-remote-run customer confirm
80
85
  `)
81
- .action(confirmCustomerAction);
86
+ .action(confirmCustomerAction);
82
87
 
83
- const groups = customers.command('group').description('Manage customer groups');
88
+ const groups = customers.command('group').description('Manage customer groups');
84
89
 
85
- groups.command('list')
86
- .description('List customer groups')
87
- .option('-p, --page <number>', 'Page number', '1')
88
- .option('-s, --size <number>', 'Page size', '20')
89
- .addHelpText('after', `
90
+ addSortOption(addFilterOption(addPaginationOptions(groups.command('list')
91
+ .description('List customer groups'))))
92
+ .addHelpText('after', `
90
93
  Examples:
91
94
  $ mage-remote-run customer group list
92
95
  $ mage-remote-run customer group list --page 1 --size 50
96
+ $ mage-remote-run customer group list --filter "code=%VIP%"
97
+ $ mage-remote-run customer group list --sort "code:ASC"
93
98
  `)
94
- .action(listCustomerGroupsAction);
99
+ .action(listCustomerGroupsAction);
95
100
  }
@@ -1,26 +1,26 @@
1
1
  import { createClient } from '../api/factory.js';
2
- import { printTable, handleError } from '../utils.js';
2
+ import {
3
+ printTable, handleError, buildPaginationCriteria,
4
+ getFormatHeaders, formatOutput, buildSearchCriteria, buildSortCriteria
5
+ } from '../utils.js';
3
6
  import chalk from 'chalk';
4
7
 
5
8
  export async function listAttributeSetsAction(options) {
6
9
  try {
7
10
  const client = await createClient();
8
- const headers = {};
9
- if (options.format === 'json') headers.Accept = 'application/json';
10
- else if (options.format === 'xml') headers.Accept = 'application/xml';
11
+ const headers = getFormatHeaders(options);
12
+
13
+ const { params: filterParams } = buildSearchCriteria(options);
14
+ const { params: sortParams } = buildSortCriteria(options);
11
15
 
12
16
  const params = {
13
- 'searchCriteria[currentPage]': options.page,
14
- 'searchCriteria[pageSize]': options.size
17
+ ...buildPaginationCriteria(options),
18
+ ...filterParams,
19
+ ...sortParams
15
20
  };
16
21
  const data = await client.get('V1/eav/attribute-sets/list', params, { headers });
17
22
 
18
- if (options.format === 'json') {
19
- console.log(JSON.stringify(data, null, 2));
20
- return;
21
- }
22
- if (options.format === 'xml') {
23
- console.log(data);
23
+ if (formatOutput(options, data)) {
24
24
  return;
25
25
  }
26
26
 
@@ -37,10 +37,15 @@ export async function listAttributeSetsAction(options) {
37
37
  }
38
38
  }
39
39
 
40
- export async function showAttributeSetAction(id) {
40
+ export async function showAttributeSetAction(id, options) {
41
41
  try {
42
42
  const client = await createClient();
43
- const data = await client.get(`V1/eav/attribute-sets/${id}`);
43
+ const headers = getFormatHeaders(options);
44
+ const data = await client.get(`V1/eav/attribute-sets/${id}`, {}, { headers });
45
+
46
+ if (formatOutput(options, data)) {
47
+ return;
48
+ }
44
49
 
45
50
  console.log(chalk.bold.blue('\nAttribute Set Details:'));
46
51
  console.log(`${chalk.bold('ID:')} ${data.attribute_set_id}`);
@@ -1,26 +1,32 @@
1
1
  import { listAttributeSetsAction, showAttributeSetAction } from './eav-actions.js';
2
2
 
3
+ import {
4
+ addPaginationOptions,
5
+ addFormatOption,
6
+ addFilterOption,
7
+ addSortOption
8
+ } from '../utils.js';
9
+
3
10
  export function registerEavCommands(program) {
4
- const eav = program.command('eav').description('Manage EAV attributes and sets');
5
- const attributeSets = eav.command('attribute-set').description('Manage attribute sets');
11
+ const eav = program.command('eav').description('Manage EAV attributes and sets');
12
+ const attributeSets = eav.command('attribute-set').description('Manage attribute sets');
6
13
 
7
- attributeSets.command('list')
8
- .description('List all attribute sets')
9
- .option('-p, --page <number>', 'Page number', '1')
10
- .option('-s, --size <number>', 'Page size', '20')
11
- .option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
12
- .addHelpText('after', `
14
+ addFormatOption(addSortOption(addFilterOption(addPaginationOptions(attributeSets.command('list')
15
+ .description('List all attribute sets')))))
16
+ .addHelpText('after', `
13
17
  Examples:
14
18
  $ mage-remote-run eav attribute-set list
15
19
  $ mage-remote-run eav attribute-set list --page 1 --size 50
20
+ $ mage-remote-run eav attribute-set list --filter "attribute_set_name=%Default%"
21
+ $ mage-remote-run eav attribute-set list --sort "sort_order:ASC"
16
22
  `)
17
- .action(listAttributeSetsAction);
23
+ .action(listAttributeSetsAction);
18
24
 
19
- attributeSets.command('show <id>')
20
- .description('Show attribute set details')
21
- .addHelpText('after', `
25
+ addFormatOption(attributeSets.command('show <id>')
26
+ .description('Show attribute set details'))
27
+ .addHelpText('after', `
22
28
  Examples:
23
29
  $ mage-remote-run eav attribute-set show 4
24
30
  `)
25
- .action(showAttributeSetAction);
31
+ .action(showAttributeSetAction);
26
32
  }