@commercelayer/cli-plugin-triggers 3.8.0 → 3.8.1
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/README.md +445 -498
- package/lib/base.js +8 -3
- package/lib/commands/satispay_payment/index.d.ts +9 -0
- package/lib/commands/satispay_payment/index.js +38 -0
- package/lib/commands/satispay_payment/refresh.d.ts +9 -0
- package/lib/commands/satispay_payment/refresh.js +21 -0
- package/lib/triggers/satispay_payments.d.ts +5 -0
- package/lib/triggers/satispay_payments.js +10 -0
- package/oclif.manifest.json +244 -1
- package/package.json +7 -7
package/lib/base.js
CHANGED
|
@@ -16,11 +16,15 @@ class default_1 extends core_1.Command {
|
|
|
16
16
|
this.handleError(error);
|
|
17
17
|
}
|
|
18
18
|
handleError(error, flags) {
|
|
19
|
-
var _a;
|
|
20
|
-
if (
|
|
19
|
+
var _a, _b;
|
|
20
|
+
if ((_a = error.message) === null || _a === void 0 ? void 0 : _a.match(/Missing \d required args?:\nid/)) {
|
|
21
|
+
const resName = (error.parse.input.context.id).split(':')[0].replace(/_/g, ' ');
|
|
22
|
+
this.error(`Missing the required unique ${cli_core_1.clColor.style.error('id')} of the ${cli_core_1.clColor.cli.command(resName)}`);
|
|
23
|
+
}
|
|
24
|
+
else if (sdk_1.CommerceLayerStatic.isApiError(error)) {
|
|
21
25
|
let res = '';
|
|
22
26
|
let id = '';
|
|
23
|
-
if ((
|
|
27
|
+
if ((_b = error.code) === null || _b === void 0 ? void 0 : _b.startsWith('RES_')) {
|
|
24
28
|
const tokens = error.code.replace('RES_', '').split('_');
|
|
25
29
|
if (tokens.length > 0)
|
|
26
30
|
res = tokens[0];
|
|
@@ -54,6 +58,7 @@ default_1.baseFlags = {
|
|
|
54
58
|
description: 'the slug of your organization',
|
|
55
59
|
required: true,
|
|
56
60
|
env: 'CL_CLI_ORGANIZATION',
|
|
61
|
+
hidden: true,
|
|
57
62
|
}),
|
|
58
63
|
domain: core_1.Flags.string({
|
|
59
64
|
char: 'd',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class SatispayPaymentIndex extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const exec_1 = tslib_1.__importDefault(require("../../exec"));
|
|
6
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
|
+
const cli_core_1 = require("@commercelayer/cli-core");
|
|
8
|
+
const satispay_payments_1 = require("../../triggers/satispay_payments");
|
|
9
|
+
const promptAction = async (id) => {
|
|
10
|
+
const answers = await inquirer_1.default.prompt([{
|
|
11
|
+
type: 'list',
|
|
12
|
+
name: 'trigger',
|
|
13
|
+
message: `Select an action to execute on satispay payment ${cli_core_1.clColor.api.id(id)}:`,
|
|
14
|
+
choices: Object.keys(satispay_payments_1.triggers).sort().map(a => {
|
|
15
|
+
return { name: a, value: a };
|
|
16
|
+
}),
|
|
17
|
+
loop: false,
|
|
18
|
+
pageSize: 10,
|
|
19
|
+
}]);
|
|
20
|
+
return answers.trigger;
|
|
21
|
+
};
|
|
22
|
+
class SatispayPaymentIndex extends base_1.default {
|
|
23
|
+
async run() {
|
|
24
|
+
const { args, flags } = await this.parse(SatispayPaymentIndex);
|
|
25
|
+
const id = args.id;
|
|
26
|
+
const action = await promptAction(id);
|
|
27
|
+
const fields = [];
|
|
28
|
+
const res = await (0, exec_1.default)('satispay_payments', id, action, flags, fields);
|
|
29
|
+
this.log();
|
|
30
|
+
this.printOutput(res, flags);
|
|
31
|
+
this.successMessage('satispay payment', action, res.id);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = SatispayPaymentIndex;
|
|
36
|
+
SatispayPaymentIndex.description = 'execute an action on a resource of type satispay_payments';
|
|
37
|
+
SatispayPaymentIndex.flags = {};
|
|
38
|
+
SatispayPaymentIndex.args = Object.assign({}, base_1.default.args);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class SatispayPaymentRefresh extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {};
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
run(): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
5
|
+
const exec_1 = tslib_1.__importDefault(require("../../exec"));
|
|
6
|
+
const satispay_payments_1 = require("../../triggers/satispay_payments");
|
|
7
|
+
const TRIGGER = 'refresh';
|
|
8
|
+
class SatispayPaymentRefresh extends base_1.default {
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(SatispayPaymentRefresh);
|
|
11
|
+
const res = await (0, exec_1.default)('satispay_payments', args.id, TRIGGER, flags);
|
|
12
|
+
if (flags.print)
|
|
13
|
+
this.printOutput(res, flags);
|
|
14
|
+
this.successMessage('satispay_payment', TRIGGER, res.id);
|
|
15
|
+
return res;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = SatispayPaymentRefresh;
|
|
19
|
+
SatispayPaymentRefresh.description = satispay_payments_1.triggers[TRIGGER].description;
|
|
20
|
+
SatispayPaymentRefresh.flags = {};
|
|
21
|
+
SatispayPaymentRefresh.args = Object.assign({}, base_1.default.args);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.triggers = void 0;
|
|
4
|
+
exports.triggers = {
|
|
5
|
+
refresh: {
|
|
6
|
+
action: 'refresh',
|
|
7
|
+
trigger: '_refresh',
|
|
8
|
+
description: 'Send this attribute if you want to refresh all the pending transactions, can be used as webhooks fallback logic.',
|
|
9
|
+
},
|
|
10
|
+
};
|