@commercelayer/cli-plugin-triggers 4.5.0 → 4.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/README.md CHANGED
@@ -35,6 +35,7 @@ $ commercelayer plugins:install triggers
35
35
  * [`commercelayer authorization ID`](#commercelayer-authorization-id)
36
36
  * [`commercelayer authorization:capture ID`](#commercelayer-authorizationcapture-id)
37
37
  * [`commercelayer authorization:capture_amount_cents ID`](#commercelayer-authorizationcapture_amount_cents-id)
38
+ * [`commercelayer authorization:forward ID`](#commercelayer-authorizationforward-id)
38
39
  * [`commercelayer authorization:void ID`](#commercelayer-authorizationvoid-id)
39
40
  * [`commercelayer axerve_payment ID`](#commercelayer-axerve_payment-id)
40
41
  * [`commercelayer axerve_payment:update ID`](#commercelayer-axerve_paymentupdate-id)
@@ -45,6 +46,7 @@ $ commercelayer plugins:install triggers
45
46
  * [`commercelayer buy_x_pay_y_promotion:disable ID`](#commercelayer-buy_x_pay_y_promotiondisable-id)
46
47
  * [`commercelayer buy_x_pay_y_promotion:enable ID`](#commercelayer-buy_x_pay_y_promotionenable-id)
47
48
  * [`commercelayer capture ID`](#commercelayer-capture-id)
49
+ * [`commercelayer capture:forward ID`](#commercelayer-captureforward-id)
48
50
  * [`commercelayer capture:refund ID`](#commercelayer-capturerefund-id)
49
51
  * [`commercelayer capture:refund_amount_cents ID`](#commercelayer-capturerefund_amount_cents-id)
50
52
  * [`commercelayer checkout_com_payment ID`](#commercelayer-checkout_com_payment-id)
@@ -142,6 +144,8 @@ $ commercelayer plugins:install triggers
142
144
  * [`commercelayer return:archive ID`](#commercelayer-returnarchive-id)
143
145
  * [`commercelayer return:cancel ID`](#commercelayer-returncancel-id)
144
146
  * [`commercelayer return:receive ID`](#commercelayer-returnreceive-id)
147
+ * [`commercelayer return:refund ID`](#commercelayer-returnrefund-id)
148
+ * [`commercelayer return:refund_amount_cents ID`](#commercelayer-returnrefund_amount_cents-id)
145
149
  * [`commercelayer return:reject ID`](#commercelayer-returnreject-id)
146
150
  * [`commercelayer return:request ID`](#commercelayer-returnrequest-id)
147
151
  * [`commercelayer return:restock ID`](#commercelayer-returnrestock-id)
@@ -282,7 +286,7 @@ _See code: [src/commands/authorization/capture.ts](https://github.com/commercela
282
286
 
283
287
  ### `commercelayer authorization:capture_amount_cents ID`
284
288
 
285
- The associated capture amount, in cents.
289
+ Send this attribute as a value in cents if you want to overwrite the amount to be captured.
286
290
 
287
291
  ```sh-session
288
292
  USAGE
@@ -297,11 +301,34 @@ FLAGS
297
301
  -u, --unformatted print JSON output without indentation
298
302
 
299
303
  DESCRIPTION
300
- The associated capture amount, in cents.
304
+ Send this attribute as a value in cents if you want to overwrite the amount to be captured.
301
305
  ```
302
306
 
303
307
  _See code: [src/commands/authorization/capture_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/authorization/capture_amount_cents.ts)_
304
308
 
309
+ ### `commercelayer authorization:forward ID`
310
+
311
+ Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.
312
+
313
+ ```sh-session
314
+ USAGE
315
+ $ commercelayer authorization:forward ID [-u [-j -p]]
316
+
317
+ ARGUMENTS
318
+ ID the unique id of the resource
319
+
320
+ FLAGS
321
+ -j, --json print result in JSON format
322
+ -p, --print print out the modified resource
323
+ -u, --unformatted print JSON output without indentation
324
+
325
+ DESCRIPTION
326
+ Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states
327
+ accordingly.
328
+ ```
329
+
330
+ _See code: [src/commands/authorization/forward.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/authorization/forward.ts)_
331
+
305
332
  ### `commercelayer authorization:void ID`
306
333
 
307
334
  Send this attribute if you want to create a void for this authorization.
@@ -524,6 +551,29 @@ DESCRIPTION
524
551
 
525
552
  _See code: [src/commands/capture/index.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/capture/index.ts)_
526
553
 
554
+ ### `commercelayer capture:forward ID`
555
+
556
+ Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.
557
+
558
+ ```sh-session
559
+ USAGE
560
+ $ commercelayer capture:forward ID [-u [-j -p]]
561
+
562
+ ARGUMENTS
563
+ ID the unique id of the resource
564
+
565
+ FLAGS
566
+ -j, --json print result in JSON format
567
+ -p, --print print out the modified resource
568
+ -u, --unformatted print JSON output without indentation
569
+
570
+ DESCRIPTION
571
+ Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states
572
+ accordingly.
573
+ ```
574
+
575
+ _See code: [src/commands/capture/forward.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/capture/forward.ts)_
576
+
527
577
  ### `commercelayer capture:refund ID`
528
578
 
529
579
  Send this attribute if you want to create a refund for this capture.
@@ -548,7 +598,7 @@ _See code: [src/commands/capture/refund.ts](https://github.com/commercelayer/com
548
598
 
549
599
  ### `commercelayer capture:refund_amount_cents ID`
550
600
 
551
- The associated refund amount, in cents.
601
+ Send this attribute as a value in cents if you want to overwrite the amount to be refunded.
552
602
 
553
603
  ```sh-session
554
604
  USAGE
@@ -563,7 +613,7 @@ FLAGS
563
613
  -u, --unformatted print JSON output without indentation
564
614
 
565
615
  DESCRIPTION
566
- The associated refund amount, in cents.
616
+ Send this attribute as a value in cents if you want to overwrite the amount to be refunded.
567
617
  ```
568
618
 
569
619
  _See code: [src/commands/capture/refund_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/capture/refund_amount_cents.ts)_
@@ -1657,7 +1707,7 @@ _See code: [src/commands/order/archive.ts](https://github.com/commercelayer/comm
1657
1707
 
1658
1708
  ### `commercelayer order:authorization_amount_cents ID`
1659
1709
 
1660
- The authorization amount, in cents.
1710
+ Send this attribute as a value in cents if you want to overwrite the amount to be authorized.
1661
1711
 
1662
1712
  ```sh-session
1663
1713
  USAGE
@@ -1672,7 +1722,7 @@ FLAGS
1672
1722
  -u, --unformatted print JSON output without indentation
1673
1723
 
1674
1724
  DESCRIPTION
1675
- The authorization amount, in cents.
1725
+ Send this attribute as a value in cents if you want to overwrite the amount to be authorized.
1676
1726
  ```
1677
1727
 
1678
1728
  _See code: [src/commands/order/authorization_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/order/authorization_amount_cents.ts)_
@@ -2680,6 +2730,50 @@ DESCRIPTION
2680
2730
 
2681
2731
  _See code: [src/commands/return/receive.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/return/receive.ts)_
2682
2732
 
2733
+ ### `commercelayer return:refund ID`
2734
+
2735
+ Send this attribute if you want to create a refund for this return.
2736
+
2737
+ ```sh-session
2738
+ USAGE
2739
+ $ commercelayer return:refund ID [-u [-j -p]]
2740
+
2741
+ ARGUMENTS
2742
+ ID the unique id of the resource
2743
+
2744
+ FLAGS
2745
+ -j, --json print result in JSON format
2746
+ -p, --print print out the modified resource
2747
+ -u, --unformatted print JSON output without indentation
2748
+
2749
+ DESCRIPTION
2750
+ Send this attribute if you want to create a refund for this return.
2751
+ ```
2752
+
2753
+ _See code: [src/commands/return/refund.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/return/refund.ts)_
2754
+
2755
+ ### `commercelayer return:refund_amount_cents ID`
2756
+
2757
+ Send this attribute as a value in cents to specify the amount to be refunded.
2758
+
2759
+ ```sh-session
2760
+ USAGE
2761
+ $ commercelayer return:refund_amount_cents ID [-u [-j -p]]
2762
+
2763
+ ARGUMENTS
2764
+ ID the unique id of the resource
2765
+
2766
+ FLAGS
2767
+ -j, --json print result in JSON format
2768
+ -p, --print print out the modified resource
2769
+ -u, --unformatted print JSON output without indentation
2770
+
2771
+ DESCRIPTION
2772
+ Send this attribute as a value in cents to specify the amount to be refunded.
2773
+ ```
2774
+
2775
+ _See code: [src/commands/return/refund_amount_cents.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/return/refund_amount_cents.ts)_
2776
+
2683
2777
  ### `commercelayer return:reject ID`
2684
2778
 
2685
2779
  Send this attribute if you want to mark this return as rejected.
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class AuthorizationForward extends Command {
3
+ static description: string;
4
+ static flags: {};
5
+ static args: {
6
+ id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<any>;
9
+ }
@@ -0,0 +1,22 @@
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 authorizations_1 = require("../../triggers/authorizations");
6
+ const TRIGGER = 'forward';
7
+ class AuthorizationForward extends base_1.default {
8
+ static description = authorizations_1.triggers[TRIGGER].description;
9
+ static flags = {};
10
+ static args = {
11
+ ...base_1.default.args,
12
+ };
13
+ async run() {
14
+ const { args, flags } = await this.parse(AuthorizationForward);
15
+ const res = await this.executeAction('authorizations', args.id, TRIGGER, flags);
16
+ if (flags.print)
17
+ this.printOutput(res, flags);
18
+ this.successMessage('authorization', TRIGGER, res.id);
19
+ return res;
20
+ }
21
+ }
22
+ exports.default = AuthorizationForward;
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class CaptureForward extends Command {
3
+ static description: string;
4
+ static flags: {};
5
+ static args: {
6
+ id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<any>;
9
+ }
@@ -0,0 +1,22 @@
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 captures_1 = require("../../triggers/captures");
6
+ const TRIGGER = 'forward';
7
+ class CaptureForward extends base_1.default {
8
+ static description = captures_1.triggers[TRIGGER].description;
9
+ static flags = {};
10
+ static args = {
11
+ ...base_1.default.args,
12
+ };
13
+ async run() {
14
+ const { args, flags } = await this.parse(CaptureForward);
15
+ const res = await this.executeAction('captures', args.id, TRIGGER, flags);
16
+ if (flags.print)
17
+ this.printOutput(res, flags);
18
+ this.successMessage('capture', TRIGGER, res.id);
19
+ return res;
20
+ }
21
+ }
22
+ exports.default = CaptureForward;
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class ReturnRefund extends Command {
3
+ static description: string;
4
+ static flags: {};
5
+ static args: {
6
+ id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<any>;
9
+ }
@@ -0,0 +1,22 @@
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 returns_1 = require("../../triggers/returns");
6
+ const TRIGGER = 'refund';
7
+ class ReturnRefund extends base_1.default {
8
+ static description = returns_1.triggers[TRIGGER].description;
9
+ static flags = {};
10
+ static args = {
11
+ ...base_1.default.args,
12
+ };
13
+ async run() {
14
+ const { args, flags } = await this.parse(ReturnRefund);
15
+ const res = await this.executeAction('returns', args.id, TRIGGER, flags);
16
+ if (flags.print)
17
+ this.printOutput(res, flags);
18
+ this.successMessage('return', TRIGGER, res.id);
19
+ return res;
20
+ }
21
+ }
22
+ exports.default = ReturnRefund;
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class ReturnRefundAmountCents extends Command {
3
+ static description: string;
4
+ static flags: {};
5
+ static args: {
6
+ id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<any>;
9
+ }
@@ -0,0 +1,22 @@
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 returns_1 = require("../../triggers/returns");
6
+ const TRIGGER = 'refund_amount_cents';
7
+ class ReturnRefundAmountCents extends base_1.default {
8
+ static description = returns_1.triggers[TRIGGER].description;
9
+ static flags = {};
10
+ static args = {
11
+ ...base_1.default.args,
12
+ };
13
+ async run() {
14
+ const { args, flags } = await this.parse(ReturnRefundAmountCents);
15
+ const res = await this.executeAction('returns', args.id, TRIGGER, flags);
16
+ if (flags.print)
17
+ this.printOutput(res, flags);
18
+ this.successMessage('return', TRIGGER, res.id);
19
+ return res;
20
+ }
21
+ }
22
+ exports.default = ReturnRefundAmountCents;
package/lib/exec.js CHANGED
@@ -19,10 +19,11 @@ const commercelayerInit = (flags, config) => {
19
19
  const exec = async (resourceType, id, action, flags, fields, config) => {
20
20
  const cl = commercelayerInit(flags, config);
21
21
  const resSdk = cl[resourceType];
22
- await cl.orders.retrieve(id).catch(err => {
23
- const resource = cli_core_1.clApi.humanizeResource(cli_core_1.clText.singularize(resourceType));
24
- if (cl.isApiError(err) && (err.status === 404))
22
+ await resSdk.retrieve(id).catch((err) => {
23
+ if (cl.isApiError(err) && (err.status === 404)) {
24
+ const resource = cli_core_1.clApi.humanizeResource(cli_core_1.clText.singularize(resourceType));
25
25
  throw new errors_1.CLIError(`Invalid ${resource} or ${resource} not found: ${cli_core_1.clColor.msg.error(id)}`);
26
+ }
26
27
  });
27
28
  const res = { id, [`_${action}`]: flags.value || true };
28
29
  const params = {};
@@ -1,3 +1,3 @@
1
1
  import type { Trigger } from '../common';
2
2
  export declare const triggers: Record<string, Trigger>;
3
- export type ActionType = 'capture' | 'capture_amount_cents' | 'void';
3
+ export type ActionType = 'forward' | 'capture' | 'capture_amount_cents' | 'void';
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.triggers = void 0;
4
4
  exports.triggers = {
5
+ forward: {
6
+ action: 'forward',
7
+ trigger: '_forward',
8
+ description: 'Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.',
9
+ },
5
10
  capture: {
6
11
  action: 'capture',
7
12
  trigger: '_capture',
@@ -10,7 +15,7 @@ exports.triggers = {
10
15
  capture_amount_cents: {
11
16
  action: 'capture_amount_cents',
12
17
  trigger: '_capture_amount_cents',
13
- description: 'The associated capture amount, in cents.',
18
+ description: 'Send this attribute as a value in cents if you want to overwrite the amount to be captured.',
14
19
  },
15
20
  void: {
16
21
  action: 'void',
@@ -1,3 +1,3 @@
1
1
  import type { Trigger } from '../common';
2
2
  export declare const triggers: Record<string, Trigger>;
3
- export type ActionType = 'refund' | 'refund_amount_cents';
3
+ export type ActionType = 'forward' | 'refund' | 'refund_amount_cents';
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.triggers = void 0;
4
4
  exports.triggers = {
5
+ forward: {
6
+ action: 'forward',
7
+ trigger: '_forward',
8
+ description: 'Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.',
9
+ },
5
10
  refund: {
6
11
  action: 'refund',
7
12
  trigger: '_refund',
@@ -10,6 +15,6 @@ exports.triggers = {
10
15
  refund_amount_cents: {
11
16
  action: 'refund_amount_cents',
12
17
  trigger: '_refund_amount_cents',
13
- description: 'The associated refund amount, in cents.',
18
+ description: 'Send this attribute as a value in cents if you want to overwrite the amount to be refunded.',
14
19
  },
15
20
  };
@@ -45,7 +45,7 @@ exports.triggers = {
45
45
  authorization_amount_cents: {
46
46
  action: 'authorization_amount_cents',
47
47
  trigger: '_authorization_amount_cents',
48
- description: 'The authorization amount, in cents.',
48
+ description: 'Send this attribute as a value in cents if you want to overwrite the amount to be authorized.',
49
49
  },
50
50
  capture: {
51
51
  action: 'capture',
@@ -1,3 +1,3 @@
1
1
  import type { Trigger } from '../common';
2
2
  export declare const triggers: Record<string, Trigger>;
3
- export type ActionType = 'request' | 'approve' | 'cancel' | 'ship' | 'reject' | 'receive' | 'restock' | 'archive' | 'unarchive';
3
+ export type ActionType = 'request' | 'approve' | 'cancel' | 'ship' | 'reject' | 'receive' | 'restock' | 'archive' | 'unarchive' | 'refund' | 'refund_amount_cents';
@@ -47,4 +47,14 @@ exports.triggers = {
47
47
  trigger: '_unarchive',
48
48
  description: 'Send this attribute if you want to unarchive the return.',
49
49
  },
50
+ refund: {
51
+ action: 'refund',
52
+ trigger: '_refund',
53
+ description: 'Send this attribute if you want to create a refund for this return.',
54
+ },
55
+ refund_amount_cents: {
56
+ action: 'refund_amount_cents',
57
+ trigger: '_refund_amount_cents',
58
+ description: 'Send this attribute as a value in cents to specify the amount to be refunded.',
59
+ },
50
60
  };