mage-remote-run 0.5.0 → 0.6.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/bin/mage-remote-run.js +2 -0
- package/lib/commands/webhooks.js +48 -0
- package/lib/commands/websites.js +17 -2
- package/package.json +1 -1
package/bin/mage-remote-run.js
CHANGED
|
@@ -28,6 +28,7 @@ import { registerCompanyCommands } from '../lib/commands/company.js';
|
|
|
28
28
|
import { registerTaxCommands } from '../lib/commands/tax.js';
|
|
29
29
|
import { registerInventoryCommands } from '../lib/commands/inventory.js';
|
|
30
30
|
import { registerAdobeIoEventsCommands } from '../lib/commands/adobe-io-events.js';
|
|
31
|
+
import { registerWebhooksCommands } from '../lib/commands/webhooks.js';
|
|
31
32
|
import { getActiveProfile } from '../lib/config.js';
|
|
32
33
|
|
|
33
34
|
registerConnectionCommands(program);
|
|
@@ -47,6 +48,7 @@ if (profile) {
|
|
|
47
48
|
if (profile.type === 'ac-cloud-paas' || profile.type === 'ac-saas') {
|
|
48
49
|
registerAdobeIoEventsCommands(program);
|
|
49
50
|
registerCompanyCommands(program);
|
|
51
|
+
registerWebhooksCommands(program);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createClient } from '../api/factory.js';
|
|
2
|
+
import { printTable, handleError } from '../utils.js';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
|
|
5
|
+
export function registerWebhooksCommands(program) {
|
|
6
|
+
const webhooks = program.command('webhook').description('Manage webhooks');
|
|
7
|
+
|
|
8
|
+
webhooks.command('list')
|
|
9
|
+
.description('List available webhooks')
|
|
10
|
+
.option('-p, --page <number>', 'Page number', '1')
|
|
11
|
+
.option('-s, --size <number>', 'Page size', '20')
|
|
12
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
try {
|
|
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
|
+
|
|
20
|
+
const params = {
|
|
21
|
+
'searchCriteria[currentPage]': options.page,
|
|
22
|
+
'searchCriteria[pageSize]': options.size
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const data = await client.get('V1/webhooks/list', 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
|
+
|
|
36
|
+
const rows = (data.items || []).map(w => [
|
|
37
|
+
w.hook_id,
|
|
38
|
+
w.name,
|
|
39
|
+
w.status,
|
|
40
|
+
w.store_ids ? w.store_ids.join(',') : '-',
|
|
41
|
+
w.url
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
console.log(chalk.bold(`Total: ${data.total_count}, Page: ${options.page}, Size: ${options.size}`));
|
|
45
|
+
printTable(['ID', 'Name', 'Status', 'Store IDs', 'URL'], rows);
|
|
46
|
+
} catch (e) { handleError(e); }
|
|
47
|
+
});
|
|
48
|
+
}
|
package/lib/commands/websites.js
CHANGED
|
@@ -8,10 +8,25 @@ export function registerWebsitesCommands(program) {
|
|
|
8
8
|
|
|
9
9
|
websites.command('list')
|
|
10
10
|
.description('List all websites')
|
|
11
|
-
.
|
|
11
|
+
.option('-f, --format <type>', 'Output format (text, json, xml)', 'text')
|
|
12
|
+
.action(async (options) => {
|
|
12
13
|
try {
|
|
13
14
|
const client = await createClient();
|
|
14
|
-
const
|
|
15
|
+
const headers = {};
|
|
16
|
+
if (options.format === 'json') headers['Accept'] = 'application/json';
|
|
17
|
+
else if (options.format === 'xml') headers['Accept'] = 'application/xml';
|
|
18
|
+
|
|
19
|
+
const data = await client.get('V1/store/websites', {}, { headers });
|
|
20
|
+
|
|
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);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
const rows = data.map(w => [w.id, w.code, w.name, w.default_group_id]);
|
|
16
31
|
printTable(['ID', 'Code', 'Name', 'Def Group ID'], rows);
|
|
17
32
|
} catch (e) { handleError(e); }
|