@commercelayer/cli-plugin-triggers 3.13.1 → 3.15.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.
Files changed (168) hide show
  1. package/README.md +653 -5
  2. package/lib/base.d.ts +1 -0
  3. package/lib/base.js +5 -0
  4. package/lib/commands/adyen_payment/details.js +1 -2
  5. package/lib/commands/authorization/capture.js +1 -2
  6. package/lib/commands/authorization/capture_amount_cents.js +1 -2
  7. package/lib/commands/authorization/void.js +1 -2
  8. package/lib/commands/axerve_payment/update.js +1 -2
  9. package/lib/commands/bundle/compute_compare_at_amount.js +1 -2
  10. package/lib/commands/bundle/compute_price_amount.js +1 -2
  11. package/lib/commands/buy_x_pay_y_promotion/disable.d.ts +9 -0
  12. package/lib/commands/buy_x_pay_y_promotion/disable.js +20 -0
  13. package/lib/commands/buy_x_pay_y_promotion/enable.d.ts +9 -0
  14. package/lib/commands/buy_x_pay_y_promotion/enable.js +20 -0
  15. package/lib/commands/buy_x_pay_y_promotion/index.d.ts +9 -0
  16. package/lib/commands/buy_x_pay_y_promotion/index.js +38 -0
  17. package/lib/commands/capture/refund.js +1 -2
  18. package/lib/commands/capture/refund_amount_cents.js +1 -2
  19. package/lib/commands/checkout_com_payment/details.js +1 -2
  20. package/lib/commands/checkout_com_payment/refresh.js +1 -2
  21. package/lib/commands/customer_password_reset/reset_password_token.js +1 -2
  22. package/lib/commands/external_promotion/disable.d.ts +9 -0
  23. package/lib/commands/external_promotion/disable.js +20 -0
  24. package/lib/commands/external_promotion/enable.d.ts +9 -0
  25. package/lib/commands/external_promotion/enable.js +20 -0
  26. package/lib/commands/external_promotion/index.d.ts +9 -0
  27. package/lib/commands/external_promotion/index.js +38 -0
  28. package/lib/commands/fixed_amount_promotion/disable.d.ts +9 -0
  29. package/lib/commands/fixed_amount_promotion/disable.js +20 -0
  30. package/lib/commands/fixed_amount_promotion/enable.d.ts +9 -0
  31. package/lib/commands/fixed_amount_promotion/enable.js +20 -0
  32. package/lib/commands/fixed_amount_promotion/index.d.ts +9 -0
  33. package/lib/commands/fixed_amount_promotion/index.js +38 -0
  34. package/lib/commands/fixed_price_promotion/disable.d.ts +9 -0
  35. package/lib/commands/fixed_price_promotion/disable.js +20 -0
  36. package/lib/commands/fixed_price_promotion/enable.d.ts +9 -0
  37. package/lib/commands/fixed_price_promotion/enable.js +20 -0
  38. package/lib/commands/fixed_price_promotion/index.d.ts +9 -0
  39. package/lib/commands/fixed_price_promotion/index.js +38 -0
  40. package/lib/commands/free_gift_promotion/disable.d.ts +9 -0
  41. package/lib/commands/free_gift_promotion/disable.js +20 -0
  42. package/lib/commands/free_gift_promotion/enable.d.ts +9 -0
  43. package/lib/commands/free_gift_promotion/enable.js +20 -0
  44. package/lib/commands/free_gift_promotion/index.d.ts +9 -0
  45. package/lib/commands/free_gift_promotion/index.js +38 -0
  46. package/lib/commands/free_shipping_promotion/disable.d.ts +9 -0
  47. package/lib/commands/free_shipping_promotion/disable.js +20 -0
  48. package/lib/commands/free_shipping_promotion/enable.d.ts +9 -0
  49. package/lib/commands/free_shipping_promotion/enable.js +20 -0
  50. package/lib/commands/free_shipping_promotion/index.d.ts +9 -0
  51. package/lib/commands/free_shipping_promotion/index.js +38 -0
  52. package/lib/commands/gift_card/activate.js +1 -2
  53. package/lib/commands/gift_card/balance_change_cents.js +1 -2
  54. package/lib/commands/gift_card/deactivate.js +1 -2
  55. package/lib/commands/gift_card/purchase.js +1 -2
  56. package/lib/commands/in_stock_subscription/activate.js +1 -2
  57. package/lib/commands/in_stock_subscription/deactivate.js +1 -2
  58. package/lib/commands/klarna_payment/update.js +1 -2
  59. package/lib/commands/line_item/external_price.js +1 -2
  60. package/lib/commands/line_item/reserve_stock.js +1 -2
  61. package/lib/commands/market/disable.js +1 -2
  62. package/lib/commands/market/enable.js +1 -2
  63. package/lib/commands/order/approve.js +1 -2
  64. package/lib/commands/order/approve_and_capture.js +1 -2
  65. package/lib/commands/order/archive.js +1 -2
  66. package/lib/commands/order/authorization_amount_cents.js +1 -2
  67. package/lib/commands/order/authorize.js +1 -2
  68. package/lib/commands/order/billing_address_clone_id.js +1 -2
  69. package/lib/commands/order/billing_address_same_as_shipping.js +1 -2
  70. package/lib/commands/order/cancel.js +1 -2
  71. package/lib/commands/order/capture.js +1 -2
  72. package/lib/commands/order/commit_invoice.js +1 -2
  73. package/lib/commands/order/create_subscriptions.js +1 -2
  74. package/lib/commands/order/customer_payment_source_id.js +1 -2
  75. package/lib/commands/order/nullify_payment_source.js +1 -2
  76. package/lib/commands/order/place.js +1 -2
  77. package/lib/commands/order/refresh.js +1 -2
  78. package/lib/commands/order/refund.js +1 -2
  79. package/lib/commands/order/refund_invoice.js +1 -2
  80. package/lib/commands/order/save_billing_address_to_customer_address_book.js +1 -2
  81. package/lib/commands/order/save_payment_source_to_customer_wallet.js +1 -2
  82. package/lib/commands/order/save_shipping_address_to_customer_address_book.js +1 -2
  83. package/lib/commands/order/shipping_address_clone_id.js +1 -2
  84. package/lib/commands/order/shipping_address_same_as_billing.js +1 -2
  85. package/lib/commands/order/start_editing.js +1 -2
  86. package/lib/commands/order/stop_editing.js +1 -2
  87. package/lib/commands/order/unarchive.js +1 -2
  88. package/lib/commands/order/update_taxes.js +1 -2
  89. package/lib/commands/order/validate.js +1 -2
  90. package/lib/commands/order_subscription/activate.js +1 -2
  91. package/lib/commands/order_subscription/cancel.js +1 -2
  92. package/lib/commands/order_subscription/deactivate.js +1 -2
  93. package/lib/commands/payment_method/disable.js +1 -2
  94. package/lib/commands/payment_method/enable.js +1 -2
  95. package/lib/commands/percentage_discount_promotion/disable.d.ts +9 -0
  96. package/lib/commands/percentage_discount_promotion/disable.js +20 -0
  97. package/lib/commands/percentage_discount_promotion/enable.d.ts +9 -0
  98. package/lib/commands/percentage_discount_promotion/enable.js +20 -0
  99. package/lib/commands/percentage_discount_promotion/index.d.ts +9 -0
  100. package/lib/commands/percentage_discount_promotion/index.js +38 -0
  101. package/lib/commands/return/approve.js +1 -2
  102. package/lib/commands/return/archive.js +1 -2
  103. package/lib/commands/return/cancel.js +1 -2
  104. package/lib/commands/return/receive.js +1 -2
  105. package/lib/commands/return/reject.js +1 -2
  106. package/lib/commands/return/request.js +1 -2
  107. package/lib/commands/return/restock.js +1 -2
  108. package/lib/commands/return/ship.js +1 -2
  109. package/lib/commands/return/unarchive.js +1 -2
  110. package/lib/commands/return_line_item/restock.js +1 -2
  111. package/lib/commands/satispay_payment/refresh.js +1 -2
  112. package/lib/commands/shipment/decrement_stock.d.ts +9 -0
  113. package/lib/commands/shipment/decrement_stock.js +20 -0
  114. package/lib/commands/shipment/get_rates.js +1 -2
  115. package/lib/commands/shipment/on_hold.js +1 -2
  116. package/lib/commands/shipment/packing.js +1 -2
  117. package/lib/commands/shipment/picking.js +1 -2
  118. package/lib/commands/shipment/purchase.js +1 -2
  119. package/lib/commands/shipment/ready_to_ship.js +1 -2
  120. package/lib/commands/shipment/release_stock.d.ts +9 -0
  121. package/lib/commands/shipment/release_stock.js +20 -0
  122. package/lib/commands/shipment/reserve_stock.d.ts +9 -0
  123. package/lib/commands/shipment/reserve_stock.js +20 -0
  124. package/lib/commands/shipment/ship.js +1 -2
  125. package/lib/commands/shipment/upcoming.d.ts +9 -0
  126. package/lib/commands/shipment/upcoming.js +20 -0
  127. package/lib/commands/shipping_method/disable.js +1 -2
  128. package/lib/commands/shipping_method/enable.js +1 -2
  129. package/lib/commands/stock_reservation/index.d.ts +9 -0
  130. package/lib/commands/stock_reservation/index.js +38 -0
  131. package/lib/commands/stock_reservation/pending.d.ts +9 -0
  132. package/lib/commands/stock_reservation/pending.js +20 -0
  133. package/lib/commands/stock_transfer/cancel.js +1 -2
  134. package/lib/commands/stock_transfer/complete.js +1 -2
  135. package/lib/commands/stock_transfer/in_transit.js +1 -2
  136. package/lib/commands/stock_transfer/on_hold.d.ts +9 -0
  137. package/lib/commands/stock_transfer/on_hold.js +20 -0
  138. package/lib/commands/stock_transfer/picking.js +1 -2
  139. package/lib/commands/stock_transfer/upcoming.js +1 -2
  140. package/lib/commands/stripe_payment/refresh.js +1 -2
  141. package/lib/commands/stripe_payment/update.js +1 -2
  142. package/lib/commands/webhook/reset_circuit.js +1 -2
  143. package/lib/exec.d.ts +3 -2
  144. package/lib/exec.js +7 -4
  145. package/lib/triggers/buy_x_pay_y_promotions.d.ts +3 -0
  146. package/lib/triggers/buy_x_pay_y_promotions.js +15 -0
  147. package/lib/triggers/external_promotions.d.ts +3 -0
  148. package/lib/triggers/external_promotions.js +15 -0
  149. package/lib/triggers/fixed_amount_promotions.d.ts +3 -0
  150. package/lib/triggers/fixed_amount_promotions.js +15 -0
  151. package/lib/triggers/fixed_price_promotions.d.ts +3 -0
  152. package/lib/triggers/fixed_price_promotions.js +15 -0
  153. package/lib/triggers/free_gift_promotions.d.ts +3 -0
  154. package/lib/triggers/free_gift_promotions.js +15 -0
  155. package/lib/triggers/free_shipping_promotions.d.ts +3 -0
  156. package/lib/triggers/free_shipping_promotions.js +15 -0
  157. package/lib/triggers/line_items.js +1 -1
  158. package/lib/triggers/orders.js +1 -1
  159. package/lib/triggers/percentage_discount_promotions.d.ts +3 -0
  160. package/lib/triggers/percentage_discount_promotions.js +15 -0
  161. package/lib/triggers/shipments.d.ts +1 -1
  162. package/lib/triggers/shipments.js +20 -0
  163. package/lib/triggers/stock_reservations.d.ts +3 -0
  164. package/lib/triggers/stock_reservations.js +10 -0
  165. package/lib/triggers/stock_transfers.d.ts +1 -1
  166. package/lib/triggers/stock_transfers.js +5 -0
  167. package/oclif.manifest.json +7757 -3720
  168. package/package.json +17 -17
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const satispay_payments_1 = require("../../triggers/satispay_payments");
7
6
  const TRIGGER = 'refresh';
8
7
  class SatispayPaymentRefresh extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(SatispayPaymentRefresh);
11
- const res = await (0, exec_1.default)('satispay_payments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('satispay_payments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('satispay_payment', TRIGGER, res.id);
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class ShipmentDecrementStock 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,20 @@
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 shipments_1 = require("../../triggers/shipments");
6
+ const TRIGGER = 'decrement_stock';
7
+ class ShipmentDecrementStock extends base_1.default {
8
+ async run() {
9
+ const { args, flags } = await this.parse(ShipmentDecrementStock);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
11
+ if (flags.print)
12
+ this.printOutput(res, flags);
13
+ this.successMessage('shipment', TRIGGER, res.id);
14
+ return res;
15
+ }
16
+ }
17
+ ShipmentDecrementStock.description = shipments_1.triggers[TRIGGER].description;
18
+ ShipmentDecrementStock.flags = {};
19
+ ShipmentDecrementStock.args = Object.assign({}, base_1.default.args);
20
+ exports.default = ShipmentDecrementStock;
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipments_1 = require("../../triggers/shipments");
7
6
  const TRIGGER = 'get_rates';
8
7
  class ShipmentGetRates extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShipmentGetRates);
11
- const res = await (0, exec_1.default)('shipments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipment', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipments_1 = require("../../triggers/shipments");
7
6
  const TRIGGER = 'on_hold';
8
7
  class ShipmentOnHold extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShipmentOnHold);
11
- const res = await (0, exec_1.default)('shipments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipment', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipments_1 = require("../../triggers/shipments");
7
6
  const TRIGGER = 'packing';
8
7
  class ShipmentPacking extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShipmentPacking);
11
- const res = await (0, exec_1.default)('shipments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipment', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipments_1 = require("../../triggers/shipments");
7
6
  const TRIGGER = 'picking';
8
7
  class ShipmentPicking extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShipmentPicking);
11
- const res = await (0, exec_1.default)('shipments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipment', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipments_1 = require("../../triggers/shipments");
7
6
  const TRIGGER = 'purchase';
8
7
  class ShipmentPurchase extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShipmentPurchase);
11
- const res = await (0, exec_1.default)('shipments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipment', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipments_1 = require("../../triggers/shipments");
7
6
  const TRIGGER = 'ready_to_ship';
8
7
  class ShipmentReadyToShip extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShipmentReadyToShip);
11
- const res = await (0, exec_1.default)('shipments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipment', TRIGGER, res.id);
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class ShipmentReleaseStock 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,20 @@
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 shipments_1 = require("../../triggers/shipments");
6
+ const TRIGGER = 'release_stock';
7
+ class ShipmentReleaseStock extends base_1.default {
8
+ async run() {
9
+ const { args, flags } = await this.parse(ShipmentReleaseStock);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
11
+ if (flags.print)
12
+ this.printOutput(res, flags);
13
+ this.successMessage('shipment', TRIGGER, res.id);
14
+ return res;
15
+ }
16
+ }
17
+ ShipmentReleaseStock.description = shipments_1.triggers[TRIGGER].description;
18
+ ShipmentReleaseStock.flags = {};
19
+ ShipmentReleaseStock.args = Object.assign({}, base_1.default.args);
20
+ exports.default = ShipmentReleaseStock;
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class ShipmentReserveStock 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,20 @@
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 shipments_1 = require("../../triggers/shipments");
6
+ const TRIGGER = 'reserve_stock';
7
+ class ShipmentReserveStock extends base_1.default {
8
+ async run() {
9
+ const { args, flags } = await this.parse(ShipmentReserveStock);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
11
+ if (flags.print)
12
+ this.printOutput(res, flags);
13
+ this.successMessage('shipment', TRIGGER, res.id);
14
+ return res;
15
+ }
16
+ }
17
+ ShipmentReserveStock.description = shipments_1.triggers[TRIGGER].description;
18
+ ShipmentReserveStock.flags = {};
19
+ ShipmentReserveStock.args = Object.assign({}, base_1.default.args);
20
+ exports.default = ShipmentReserveStock;
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipments_1 = require("../../triggers/shipments");
7
6
  const TRIGGER = 'ship';
8
7
  class ShipmentShip extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShipmentShip);
11
- const res = await (0, exec_1.default)('shipments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipment', TRIGGER, res.id);
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class ShipmentUpcoming 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,20 @@
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 shipments_1 = require("../../triggers/shipments");
6
+ const TRIGGER = 'upcoming';
7
+ class ShipmentUpcoming extends base_1.default {
8
+ async run() {
9
+ const { args, flags } = await this.parse(ShipmentUpcoming);
10
+ const res = await this.executeAction('shipments', args.id, TRIGGER, flags);
11
+ if (flags.print)
12
+ this.printOutput(res, flags);
13
+ this.successMessage('shipment', TRIGGER, res.id);
14
+ return res;
15
+ }
16
+ }
17
+ ShipmentUpcoming.description = shipments_1.triggers[TRIGGER].description;
18
+ ShipmentUpcoming.flags = {};
19
+ ShipmentUpcoming.args = Object.assign({}, base_1.default.args);
20
+ exports.default = ShipmentUpcoming;
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipping_methods_1 = require("../../triggers/shipping_methods");
7
6
  const TRIGGER = 'disable';
8
7
  class ShippingMethodDisable extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShippingMethodDisable);
11
- const res = await (0, exec_1.default)('shipping_methods', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipping_methods', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipping_method', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const shipping_methods_1 = require("../../triggers/shipping_methods");
7
6
  const TRIGGER = 'enable';
8
7
  class ShippingMethodEnable extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(ShippingMethodEnable);
11
- const res = await (0, exec_1.default)('shipping_methods', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('shipping_methods', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('shipping_method', TRIGGER, res.id);
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class StockReservationIndex 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 stock_reservations_1 = require("../../triggers/stock_reservations");
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 stock reservation ${cli_core_1.clColor.api.id(id)}:`,
14
+ choices: Object.keys(stock_reservations_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 StockReservationIndex extends base_1.default {
23
+ async run() {
24
+ const { args, flags } = await this.parse(StockReservationIndex);
25
+ const id = args.id;
26
+ const action = await promptAction(id);
27
+ const fields = [];
28
+ const res = await (0, exec_1.default)('stock_reservations', id, action, flags, fields);
29
+ this.log();
30
+ this.printOutput(res, flags);
31
+ this.successMessage('stock reservation', action, res.id);
32
+ return res;
33
+ }
34
+ }
35
+ StockReservationIndex.description = 'execute an action on a resource of type stock_reservations';
36
+ StockReservationIndex.flags = {};
37
+ StockReservationIndex.args = Object.assign({}, base_1.default.args);
38
+ exports.default = StockReservationIndex;
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class StockReservationPending 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,20 @@
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 stock_reservations_1 = require("../../triggers/stock_reservations");
6
+ const TRIGGER = 'pending';
7
+ class StockReservationPending extends base_1.default {
8
+ async run() {
9
+ const { args, flags } = await this.parse(StockReservationPending);
10
+ const res = await this.executeAction('stock_reservations', args.id, TRIGGER, flags);
11
+ if (flags.print)
12
+ this.printOutput(res, flags);
13
+ this.successMessage('stock_reservation', TRIGGER, res.id);
14
+ return res;
15
+ }
16
+ }
17
+ StockReservationPending.description = stock_reservations_1.triggers[TRIGGER].description;
18
+ StockReservationPending.flags = {};
19
+ StockReservationPending.args = Object.assign({}, base_1.default.args);
20
+ exports.default = StockReservationPending;
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const stock_transfers_1 = require("../../triggers/stock_transfers");
7
6
  const TRIGGER = 'cancel';
8
7
  class StockTransferCancel extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(StockTransferCancel);
11
- const res = await (0, exec_1.default)('stock_transfers', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('stock_transfers', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('stock_transfer', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const stock_transfers_1 = require("../../triggers/stock_transfers");
7
6
  const TRIGGER = 'complete';
8
7
  class StockTransferComplete extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(StockTransferComplete);
11
- const res = await (0, exec_1.default)('stock_transfers', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('stock_transfers', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('stock_transfer', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const stock_transfers_1 = require("../../triggers/stock_transfers");
7
6
  const TRIGGER = 'in_transit';
8
7
  class StockTransferInTransit extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(StockTransferInTransit);
11
- const res = await (0, exec_1.default)('stock_transfers', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('stock_transfers', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('stock_transfer', TRIGGER, res.id);
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class StockTransferOnHold 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,20 @@
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 stock_transfers_1 = require("../../triggers/stock_transfers");
6
+ const TRIGGER = 'on_hold';
7
+ class StockTransferOnHold extends base_1.default {
8
+ async run() {
9
+ const { args, flags } = await this.parse(StockTransferOnHold);
10
+ const res = await this.executeAction('stock_transfers', args.id, TRIGGER, flags);
11
+ if (flags.print)
12
+ this.printOutput(res, flags);
13
+ this.successMessage('stock_transfer', TRIGGER, res.id);
14
+ return res;
15
+ }
16
+ }
17
+ StockTransferOnHold.description = stock_transfers_1.triggers[TRIGGER].description;
18
+ StockTransferOnHold.flags = {};
19
+ StockTransferOnHold.args = Object.assign({}, base_1.default.args);
20
+ exports.default = StockTransferOnHold;
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const stock_transfers_1 = require("../../triggers/stock_transfers");
7
6
  const TRIGGER = 'picking';
8
7
  class StockTransferPicking extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(StockTransferPicking);
11
- const res = await (0, exec_1.default)('stock_transfers', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('stock_transfers', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('stock_transfer', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const stock_transfers_1 = require("../../triggers/stock_transfers");
7
6
  const TRIGGER = 'upcoming';
8
7
  class StockTransferUpcoming extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(StockTransferUpcoming);
11
- const res = await (0, exec_1.default)('stock_transfers', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('stock_transfers', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('stock_transfer', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const stripe_payments_1 = require("../../triggers/stripe_payments");
7
6
  const TRIGGER = 'refresh';
8
7
  class StripePaymentRefresh extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(StripePaymentRefresh);
11
- const res = await (0, exec_1.default)('stripe_payments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('stripe_payments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('stripe_payment', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const stripe_payments_1 = require("../../triggers/stripe_payments");
7
6
  const TRIGGER = 'update';
8
7
  class StripePaymentUpdate extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(StripePaymentUpdate);
11
- const res = await (0, exec_1.default)('stripe_payments', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('stripe_payments', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('stripe_payment', TRIGGER, res.id);
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
- const exec_1 = tslib_1.__importDefault(require("../../exec"));
6
5
  const webhooks_1 = require("../../triggers/webhooks");
7
6
  const TRIGGER = 'reset_circuit';
8
7
  class WebhookResetCircuit extends base_1.default {
9
8
  async run() {
10
9
  const { args, flags } = await this.parse(WebhookResetCircuit);
11
- const res = await (0, exec_1.default)('webhooks', args.id, TRIGGER, flags);
10
+ const res = await this.executeAction('webhooks', args.id, TRIGGER, flags);
12
11
  if (flags.print)
13
12
  this.printOutput(res, flags);
14
13
  this.successMessage('webhook', TRIGGER, res.id);
package/lib/exec.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- declare const executeAction: (resourceType: string, id: string, action: string, flags: any, fields?: string[]) => Promise<any>;
2
- export default executeAction;
1
+ import { type Config } from '@oclif/core/lib/interfaces';
2
+ declare const exec: (resourceType: string, id: string, action: string, flags: any, fields?: string[], config?: Config) => Promise<any>;
3
+ export default exec;
package/lib/exec.js CHANGED
@@ -1,19 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const cli_core_1 = require("@commercelayer/cli-core");
4
5
  const sdk_1 = tslib_1.__importStar(require("@commercelayer/sdk"));
5
- const commercelayerInit = (flags) => {
6
+ const commercelayerInit = (flags, config) => {
6
7
  const organization = flags.organization;
7
8
  const domain = flags.domain;
8
9
  const accessToken = flags.accessToken;
10
+ const userAgent = config ? cli_core_1.clUtil.userAgent(config) : undefined;
9
11
  return (0, sdk_1.default)({
10
12
  organization,
11
13
  domain,
12
14
  accessToken,
15
+ userAgent
13
16
  });
14
17
  };
15
- const executeAction = async (resourceType, id, action, flags, fields) => {
16
- const cl = commercelayerInit(flags);
18
+ const exec = async (resourceType, id, action, flags, fields, config) => {
19
+ const cl = commercelayerInit(flags, config);
17
20
  const res = { id };
18
21
  const trigger = `_${action}`;
19
22
  res[trigger] = flags.value || true;
@@ -31,4 +34,4 @@ const executeAction = async (resourceType, id, action, flags, fields) => {
31
34
  });
32
35
  return result;
33
36
  };
34
- exports.default = executeAction;
37
+ exports.default = exec;
@@ -0,0 +1,3 @@
1
+ import type { Trigger } from '../common';
2
+ export declare const triggers: Record<string, Trigger>;
3
+ export type ActionType = 'disable' | 'enable';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.triggers = void 0;
4
+ exports.triggers = {
5
+ disable: {
6
+ action: 'disable',
7
+ trigger: '_disable',
8
+ description: 'Send this attribute if you want to mark the promotion as disabled.',
9
+ },
10
+ enable: {
11
+ action: 'enable',
12
+ trigger: '_enable',
13
+ description: 'Send this attribute if you want to mark the promotion as enabled.',
14
+ },
15
+ };
@@ -0,0 +1,3 @@
1
+ import type { Trigger } from '../common';
2
+ export declare const triggers: Record<string, Trigger>;
3
+ export type ActionType = 'disable' | 'enable';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.triggers = void 0;
4
+ exports.triggers = {
5
+ disable: {
6
+ action: 'disable',
7
+ trigger: '_disable',
8
+ description: 'Send this attribute if you want to mark the promotion as disabled.',
9
+ },
10
+ enable: {
11
+ action: 'enable',
12
+ trigger: '_enable',
13
+ description: 'Send this attribute if you want to mark the promotion as enabled.',
14
+ },
15
+ };
@@ -0,0 +1,3 @@
1
+ import type { Trigger } from '../common';
2
+ export declare const triggers: Record<string, Trigger>;
3
+ export type ActionType = 'disable' | 'enable';