mage-remote-run 0.3.0 → 0.4.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.
- package/lib/commands/customers.js +18 -2
- package/lib/commands/eav.js +16 -1
- package/lib/commands/inventory.js +17 -3
- package/lib/commands/orders.js +16 -1
- package/lib/commands/products.js +18 -3
- package/lib/commands/tax.js +16 -1
- package/package.json +1 -1
|
@@ -7,19 +7,35 @@ export function registerCustomersCommands(program) {
|
|
|
7
7
|
const customers = program.command('customer').description('Manage customers');
|
|
8
8
|
|
|
9
9
|
customers.command('list')
|
|
10
|
+
.description('List customers')
|
|
10
11
|
.option('-p, --page <number>', 'Page number', '1')
|
|
11
12
|
.option('-s, --size <number>', 'Page size', '20')
|
|
13
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
12
14
|
.action(async (options) => {
|
|
13
15
|
try {
|
|
14
16
|
const client = await createClient();
|
|
17
|
+
const headers = {};
|
|
18
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
19
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
20
|
+
|
|
15
21
|
const params = {
|
|
16
22
|
'searchCriteria[currentPage]': options.page,
|
|
17
23
|
'searchCriteria[pageSize]': options.size
|
|
18
24
|
};
|
|
19
|
-
const data = await client.get('V1/customers/search', params);
|
|
25
|
+
const data = await client.get('V1/customers/search', params, { headers });
|
|
26
|
+
|
|
27
|
+
if (options.format === 'json') {
|
|
28
|
+
console.log(JSON.stringify(data, null, 2));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (options.format === 'xml') {
|
|
32
|
+
console.log(data);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
const rows = (data.items || []).map(c => [c.id, c.email, c.firstname, c.lastname, c.group_id]);
|
|
21
37
|
console.log(chalk.bold(`Total: ${data.total_count}, Page: ${options.page}, Size: ${options.size}`));
|
|
22
|
-
printTable(['ID', 'Email', 'First Name', 'Last Name', 'Group'], rows);
|
|
38
|
+
printTable(['ID', 'Email', 'First Name', 'Last Name', 'Group ID'], rows);
|
|
23
39
|
} catch (e) { handleError(e); }
|
|
24
40
|
});
|
|
25
41
|
|
package/lib/commands/eav.js
CHANGED
|
@@ -12,14 +12,29 @@ export function registerEavCommands(program) {
|
|
|
12
12
|
.description('List all attribute sets')
|
|
13
13
|
.option('-p, --page <number>', 'Page number', '1')
|
|
14
14
|
.option('-s, --size <number>', 'Page size', '20')
|
|
15
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
15
16
|
.action(async (options) => {
|
|
16
17
|
try {
|
|
17
18
|
const client = await createClient();
|
|
19
|
+
const headers = {};
|
|
20
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
21
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
22
|
+
|
|
18
23
|
const params = {
|
|
19
24
|
'searchCriteria[currentPage]': options.page,
|
|
20
25
|
'searchCriteria[pageSize]': options.size
|
|
21
26
|
};
|
|
22
|
-
const data = await client.get('V1/eav/attribute-sets/list', params);
|
|
27
|
+
const data = await client.get('V1/eav/attribute-sets/list', params, { headers });
|
|
28
|
+
|
|
29
|
+
if (options.format === 'json') {
|
|
30
|
+
console.log(JSON.stringify(data, null, 2));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (options.format === 'xml') {
|
|
34
|
+
console.log(data);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
23
38
|
const rows = (data.items || []).map(set => [
|
|
24
39
|
set.attribute_set_id,
|
|
25
40
|
set.attribute_set_name,
|
|
@@ -60,16 +60,30 @@ export function registerInventoryCommands(program) {
|
|
|
60
60
|
.description('List inventory sources')
|
|
61
61
|
.option('-p, --page <number>', 'Page number', '1')
|
|
62
62
|
.option('-s, --size <number>', 'Page size', '20')
|
|
63
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
63
64
|
.action(async (options) => {
|
|
64
65
|
try {
|
|
65
66
|
const client = await createClient();
|
|
67
|
+
const headers = {};
|
|
68
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
69
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
70
|
+
|
|
66
71
|
const params = {
|
|
67
72
|
'searchCriteria[currentPage]': options.page,
|
|
68
73
|
'searchCriteria[pageSize]': options.size
|
|
69
74
|
};
|
|
70
|
-
const data = await client.get('V1/inventory/sources', params);
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
const data = await client.get('V1/inventory/sources', params, { headers });
|
|
76
|
+
|
|
77
|
+
if (options.format === 'json') {
|
|
78
|
+
console.log(JSON.stringify(data, null, 2));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (options.format === 'xml') {
|
|
82
|
+
console.log(data);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const rows = (data.items || []).map(s => [s.source_code, s.name, s.enabled ? 'Yes' : 'No', s.postcode]);
|
|
73
87
|
console.log(chalk.bold(`Total: ${data.total_count}, Page: ${options.page}, Size: ${options.size}`));
|
|
74
88
|
printTable(['Code', 'Name', 'Enabled', 'Postcode'], rows);
|
|
75
89
|
} catch (e) { handleError(e); }
|
package/lib/commands/orders.js
CHANGED
|
@@ -9,14 +9,29 @@ export function registerOrdersCommands(program) {
|
|
|
9
9
|
orders.command('list')
|
|
10
10
|
.option('-p, --page <number>', 'Page number', '1')
|
|
11
11
|
.option('-s, --size <number>', 'Page size', '20')
|
|
12
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
12
13
|
.action(async (options) => {
|
|
13
14
|
try {
|
|
14
15
|
const client = await createClient();
|
|
16
|
+
const headers = {};
|
|
17
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
18
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
19
|
+
|
|
15
20
|
const params = {
|
|
16
21
|
'searchCriteria[currentPage]': options.page,
|
|
17
22
|
'searchCriteria[pageSize]': options.size
|
|
18
23
|
};
|
|
19
|
-
const data = await client.get('V1/orders', params);
|
|
24
|
+
const data = await client.get('V1/orders', params, { headers });
|
|
25
|
+
|
|
26
|
+
if (options.format === 'json') {
|
|
27
|
+
console.log(JSON.stringify(data, null, 2));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (options.format === 'xml') {
|
|
31
|
+
console.log(data);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
const rows = (data.items || []).map(o => [o.entity_id, o.increment_id, o.status, o.grand_total, o.customer_email]);
|
|
21
36
|
console.log(chalk.bold(`Total: ${data.total_count}, Page: ${options.page}, Size: ${options.size}`));
|
|
22
37
|
printTable(['ID', 'Increment ID', 'Status', 'Total', 'Email'], rows);
|
package/lib/commands/products.js
CHANGED
|
@@ -9,18 +9,33 @@ export function registerProductsCommands(program) {
|
|
|
9
9
|
.description('List products')
|
|
10
10
|
.option('-p, --page <number>', 'Page number', '1')
|
|
11
11
|
.option('-s, --size <number>', 'Page size', '20')
|
|
12
|
-
.option('--sort-by <
|
|
13
|
-
.option('--sort-order <order>', 'Sort order (ASC
|
|
12
|
+
.option('--sort-by <field>', 'Field to sort by', 'entity_id')
|
|
13
|
+
.option('--sort-order <order>', 'Sort order (ASC, DESC)', 'ASC')
|
|
14
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
try {
|
|
16
17
|
const client = await createClient();
|
|
18
|
+
const headers = {};
|
|
19
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
20
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
21
|
+
|
|
17
22
|
const params = {
|
|
18
23
|
'searchCriteria[currentPage]': options.page,
|
|
19
24
|
'searchCriteria[pageSize]': options.size,
|
|
20
25
|
'searchCriteria[sortOrders][0][field]': options.sortBy,
|
|
21
26
|
'searchCriteria[sortOrders][0][direction]': options.sortOrder
|
|
22
27
|
};
|
|
23
|
-
const data = await client.get('V1/products', params);
|
|
28
|
+
const data = await client.get('V1/products', params, { headers });
|
|
29
|
+
|
|
30
|
+
if (options.format === 'json') {
|
|
31
|
+
console.log(JSON.stringify(data, null, 2));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (options.format === 'xml') {
|
|
35
|
+
console.log(data);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
24
39
|
const rows = (data.items || []).map(p => [p.id, p.sku, p.name, p.type_id, p.price]);
|
|
25
40
|
console.log(chalk.bold(`Total: ${data.total_count}, Page: ${options.page}, Size: ${options.size}`));
|
|
26
41
|
printTable(['ID', 'SKU', 'Name', 'Type', 'Price'], rows);
|
package/lib/commands/tax.js
CHANGED
|
@@ -11,14 +11,29 @@ export function registerTaxCommands(program) {
|
|
|
11
11
|
.description('List tax classes')
|
|
12
12
|
.option('-p, --page <number>', 'Page number', '1')
|
|
13
13
|
.option('-s, --size <number>', 'Page size', '20')
|
|
14
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
try {
|
|
16
17
|
const client = await createClient();
|
|
18
|
+
const headers = {};
|
|
19
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
20
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
21
|
+
|
|
17
22
|
const params = {
|
|
18
23
|
'searchCriteria[currentPage]': options.page,
|
|
19
24
|
'searchCriteria[pageSize]': options.size
|
|
20
25
|
};
|
|
21
|
-
const data = await client.get('V1/taxClasses/search', params);
|
|
26
|
+
const data = await client.get('V1/taxClasses/search', params, { headers });
|
|
27
|
+
|
|
28
|
+
if (options.format === 'json') {
|
|
29
|
+
console.log(JSON.stringify(data, null, 2));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (options.format === 'xml') {
|
|
33
|
+
console.log(data);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
22
37
|
const rows = (data.items || []).map(tc => [
|
|
23
38
|
tc.class_id,
|
|
24
39
|
tc.class_name,
|