@commercelayer/cli-plugin-triggers 4.6.0 → 4.7.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 CHANGED
@@ -54,6 +54,8 @@ $ commercelayer plugins:install triggers
54
54
  * [`commercelayer checkout_com_payment:refresh ID`](#commercelayer-checkout_com_paymentrefresh-id)
55
55
  * [`commercelayer customer_password_reset ID`](#commercelayer-customer_password_reset-id)
56
56
  * [`commercelayer customer_password_reset:reset_password_token ID`](#commercelayer-customer_password_resetreset_password_token-id)
57
+ * [`commercelayer event ID`](#commercelayer-event-id)
58
+ * [`commercelayer event:trigger ID`](#commercelayer-eventtrigger-id)
57
59
  * [`commercelayer external_gateway ID`](#commercelayer-external_gateway-id)
58
60
  * [`commercelayer external_gateway:reset_circuit ID`](#commercelayer-external_gatewayreset_circuit-id)
59
61
  * [`commercelayer external_promotion ID`](#commercelayer-external_promotion-id)
@@ -308,7 +310,7 @@ _See code: [src/commands/authorization/capture_amount_cents.ts](https://github.c
308
310
 
309
311
  ### `commercelayer authorization:forward ID`
310
312
 
311
- Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.
313
+ Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.
312
314
 
313
315
  ```sh-session
314
316
  USAGE
@@ -323,7 +325,7 @@ FLAGS
323
325
  -u, --unformatted print JSON output without indentation
324
326
 
325
327
  DESCRIPTION
326
- Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states
328
+ Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states
327
329
  accordingly.
328
330
  ```
329
331
 
@@ -553,7 +555,7 @@ _See code: [src/commands/capture/index.ts](https://github.com/commercelayer/comm
553
555
 
554
556
  ### `commercelayer capture:forward ID`
555
557
 
556
- Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.
558
+ Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.
557
559
 
558
560
  ```sh-session
559
561
  USAGE
@@ -568,7 +570,7 @@ FLAGS
568
570
  -u, --unformatted print JSON output without indentation
569
571
 
570
572
  DESCRIPTION
571
- Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states
573
+ Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states
572
574
  accordingly.
573
575
  ```
574
576
 
@@ -728,6 +730,50 @@ DESCRIPTION
728
730
 
729
731
  _See code: [src/commands/customer_password_reset/reset_password_token.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/customer_password_reset/reset_password_token.ts)_
730
732
 
733
+ ### `commercelayer event ID`
734
+
735
+ Execute an action on a resource of type events.
736
+
737
+ ```sh-session
738
+ USAGE
739
+ $ commercelayer event ID [-u [-j -p]]
740
+
741
+ ARGUMENTS
742
+ ID the unique id of the resource
743
+
744
+ FLAGS
745
+ -j, --json print result in JSON format
746
+ -p, --print print out the modified resource
747
+ -u, --unformatted print JSON output without indentation
748
+
749
+ DESCRIPTION
750
+ execute an action on a resource of type events
751
+ ```
752
+
753
+ _See code: [src/commands/event/index.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/event/index.ts)_
754
+
755
+ ### `commercelayer event:trigger ID`
756
+
757
+ Send this attribute if you want to force webhooks execution for this event.
758
+
759
+ ```sh-session
760
+ USAGE
761
+ $ commercelayer event:trigger ID [-u [-j -p]]
762
+
763
+ ARGUMENTS
764
+ ID the unique id of the resource
765
+
766
+ FLAGS
767
+ -j, --json print result in JSON format
768
+ -p, --print print out the modified resource
769
+ -u, --unformatted print JSON output without indentation
770
+
771
+ DESCRIPTION
772
+ Send this attribute if you want to force webhooks execution for this event.
773
+ ```
774
+
775
+ _See code: [src/commands/event/trigger.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/event/trigger.ts)_
776
+
731
777
  ### `commercelayer external_gateway ID`
732
778
 
733
779
  Execute an action on a resource of type external_gateways.
@@ -1909,7 +1955,7 @@ _See code: [src/commands/order/customer_payment_source_id.ts](https://github.com
1909
1955
 
1910
1956
  ### `commercelayer order:fulfill ID`
1911
1957
 
1912
- Send this attribute if you want to mark as fulfilled a shipped/delivered order.
1958
+ Send this attribute if you want to mark as fulfilled the order (shipments must be cancelled, shipped or delivered).
1913
1959
 
1914
1960
  ```sh-session
1915
1961
  USAGE
@@ -1924,7 +1970,7 @@ FLAGS
1924
1970
  -u, --unformatted print JSON output without indentation
1925
1971
 
1926
1972
  DESCRIPTION
1927
- Send this attribute if you want to mark as fulfilled a shipped/delivered order.
1973
+ Send this attribute if you want to mark as fulfilled the order (shipments must be cancelled, shipped or delivered).
1928
1974
  ```
1929
1975
 
1930
1976
  _See code: [src/commands/order/fulfill.ts](https://github.com/commercelayer/commercelayer-cli-plugin-triggers/blob/main/src/commands/order/fulfill.ts)_
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class EventIndex 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,40 @@
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 events_1 = require("../../triggers/events");
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 event ${cli_core_1.clColor.api.id(id)}:`,
14
+ choices: Object.keys(events_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 EventIndex extends base_1.default {
23
+ static description = 'execute an action on a resource of type events';
24
+ static flags = {};
25
+ static args = {
26
+ ...base_1.default.args,
27
+ };
28
+ async run() {
29
+ const { args, flags } = await this.parse(EventIndex);
30
+ const id = args.id;
31
+ const action = await promptAction(id);
32
+ const fields = [];
33
+ const res = await (0, exec_1.default)('events', id, action, flags, fields);
34
+ this.log();
35
+ this.printOutput(res, flags);
36
+ this.successMessage('event', action, res.id);
37
+ return res;
38
+ }
39
+ }
40
+ exports.default = EventIndex;
@@ -0,0 +1,9 @@
1
+ import Command from '../../base';
2
+ export default class EventTrigger 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 events_1 = require("../../triggers/events");
6
+ const TRIGGER = 'trigger';
7
+ class EventTrigger extends base_1.default {
8
+ static description = events_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(EventTrigger);
15
+ const res = await this.executeAction('events', args.id, TRIGGER, flags);
16
+ if (flags.print)
17
+ this.printOutput(res, flags);
18
+ this.successMessage('event', TRIGGER, res.id);
19
+ return res;
20
+ }
21
+ }
22
+ exports.default = EventTrigger;
@@ -5,7 +5,7 @@ exports.triggers = {
5
5
  forward: {
6
6
  action: 'forward',
7
7
  trigger: '_forward',
8
- description: 'Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.',
8
+ description: 'Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.',
9
9
  },
10
10
  capture: {
11
11
  action: 'capture',
@@ -5,7 +5,7 @@ exports.triggers = {
5
5
  forward: {
6
6
  action: 'forward',
7
7
  trigger: '_forward',
8
- description: 'Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.',
8
+ description: 'Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.',
9
9
  },
10
10
  refund: {
11
11
  action: 'refund',
@@ -0,0 +1,3 @@
1
+ import type { Trigger } from '../common';
2
+ export declare const triggers: Record<string, Trigger>;
3
+ export type ActionType = 'trigger';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.triggers = void 0;
4
+ exports.triggers = {
5
+ trigger: {
6
+ action: 'trigger',
7
+ trigger: '_trigger',
8
+ description: 'Send this attribute if you want to force webhooks execution for this event.',
9
+ },
10
+ };
@@ -60,7 +60,7 @@ exports.triggers = {
60
60
  fulfill: {
61
61
  action: 'fulfill',
62
62
  trigger: '_fulfill',
63
- description: 'Send this attribute if you want to mark as fulfilled a shipped/delivered order.',
63
+ description: 'Send this attribute if you want to mark as fulfilled the order (shipments must be cancelled, shipped or delivered).',
64
64
  },
65
65
  update_taxes: {
66
66
  action: 'update_taxes',
@@ -381,7 +381,7 @@
381
381
  "required": true
382
382
  }
383
383
  },
384
- "description": "Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.",
384
+ "description": "Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.",
385
385
  "flags": {
386
386
  "organization": {
387
387
  "char": "o",
@@ -1349,7 +1349,7 @@
1349
1349
  "required": true
1350
1350
  }
1351
1351
  },
1352
- "description": "Send this attribute if you want to forwrad a stuck transaction to succeeded and update associated order states accordingly.",
1352
+ "description": "Send this attribute if you want to forward a stuck transaction to succeeded and update associated order states accordingly.",
1353
1353
  "flags": {
1354
1354
  "organization": {
1355
1355
  "char": "o",
@@ -2132,6 +2132,182 @@
2132
2132
  "reset_password_token.js"
2133
2133
  ]
2134
2134
  },
2135
+ "event": {
2136
+ "aliases": [],
2137
+ "args": {
2138
+ "id": {
2139
+ "description": "the unique id of the resource",
2140
+ "name": "id",
2141
+ "required": true
2142
+ }
2143
+ },
2144
+ "description": "execute an action on a resource of type events",
2145
+ "flags": {
2146
+ "organization": {
2147
+ "char": "o",
2148
+ "description": "the slug of your organization",
2149
+ "env": "CL_CLI_ORGANIZATION",
2150
+ "hidden": true,
2151
+ "name": "organization",
2152
+ "required": true,
2153
+ "hasDynamicHelp": false,
2154
+ "multiple": false,
2155
+ "type": "option"
2156
+ },
2157
+ "domain": {
2158
+ "char": "d",
2159
+ "dependsOn": [
2160
+ "organization"
2161
+ ],
2162
+ "env": "CL_CLI_DOMAIN",
2163
+ "hidden": true,
2164
+ "name": "domain",
2165
+ "required": false,
2166
+ "hasDynamicHelp": false,
2167
+ "multiple": false,
2168
+ "type": "option"
2169
+ },
2170
+ "accessToken": {
2171
+ "env": "CL_CLI_ACCESS_TOKEN",
2172
+ "hidden": true,
2173
+ "name": "accessToken",
2174
+ "required": true,
2175
+ "hasDynamicHelp": false,
2176
+ "multiple": false,
2177
+ "type": "option"
2178
+ },
2179
+ "print": {
2180
+ "char": "p",
2181
+ "description": "print out the modified resource",
2182
+ "name": "print",
2183
+ "allowNo": false,
2184
+ "type": "boolean"
2185
+ },
2186
+ "json": {
2187
+ "char": "j",
2188
+ "dependsOn": [
2189
+ "print"
2190
+ ],
2191
+ "description": "print result in JSON format",
2192
+ "name": "json",
2193
+ "allowNo": false,
2194
+ "type": "boolean"
2195
+ },
2196
+ "unformatted": {
2197
+ "char": "u",
2198
+ "dependsOn": [
2199
+ "json"
2200
+ ],
2201
+ "description": "print JSON output without indentation",
2202
+ "name": "unformatted",
2203
+ "allowNo": false,
2204
+ "type": "boolean"
2205
+ }
2206
+ },
2207
+ "hasDynamicHelp": false,
2208
+ "hiddenAliases": [],
2209
+ "id": "event",
2210
+ "pluginAlias": "@commercelayer/cli-plugin-triggers",
2211
+ "pluginName": "@commercelayer/cli-plugin-triggers",
2212
+ "pluginType": "core",
2213
+ "strict": true,
2214
+ "enableJsonFlag": false,
2215
+ "isESM": false,
2216
+ "relativePath": [
2217
+ "lib",
2218
+ "commands",
2219
+ "event",
2220
+ "index.js"
2221
+ ]
2222
+ },
2223
+ "event:trigger": {
2224
+ "aliases": [],
2225
+ "args": {
2226
+ "id": {
2227
+ "description": "the unique id of the resource",
2228
+ "name": "id",
2229
+ "required": true
2230
+ }
2231
+ },
2232
+ "description": "Send this attribute if you want to force webhooks execution for this event.",
2233
+ "flags": {
2234
+ "organization": {
2235
+ "char": "o",
2236
+ "description": "the slug of your organization",
2237
+ "env": "CL_CLI_ORGANIZATION",
2238
+ "hidden": true,
2239
+ "name": "organization",
2240
+ "required": true,
2241
+ "hasDynamicHelp": false,
2242
+ "multiple": false,
2243
+ "type": "option"
2244
+ },
2245
+ "domain": {
2246
+ "char": "d",
2247
+ "dependsOn": [
2248
+ "organization"
2249
+ ],
2250
+ "env": "CL_CLI_DOMAIN",
2251
+ "hidden": true,
2252
+ "name": "domain",
2253
+ "required": false,
2254
+ "hasDynamicHelp": false,
2255
+ "multiple": false,
2256
+ "type": "option"
2257
+ },
2258
+ "accessToken": {
2259
+ "env": "CL_CLI_ACCESS_TOKEN",
2260
+ "hidden": true,
2261
+ "name": "accessToken",
2262
+ "required": true,
2263
+ "hasDynamicHelp": false,
2264
+ "multiple": false,
2265
+ "type": "option"
2266
+ },
2267
+ "print": {
2268
+ "char": "p",
2269
+ "description": "print out the modified resource",
2270
+ "name": "print",
2271
+ "allowNo": false,
2272
+ "type": "boolean"
2273
+ },
2274
+ "json": {
2275
+ "char": "j",
2276
+ "dependsOn": [
2277
+ "print"
2278
+ ],
2279
+ "description": "print result in JSON format",
2280
+ "name": "json",
2281
+ "allowNo": false,
2282
+ "type": "boolean"
2283
+ },
2284
+ "unformatted": {
2285
+ "char": "u",
2286
+ "dependsOn": [
2287
+ "json"
2288
+ ],
2289
+ "description": "print JSON output without indentation",
2290
+ "name": "unformatted",
2291
+ "allowNo": false,
2292
+ "type": "boolean"
2293
+ }
2294
+ },
2295
+ "hasDynamicHelp": false,
2296
+ "hiddenAliases": [],
2297
+ "id": "event:trigger",
2298
+ "pluginAlias": "@commercelayer/cli-plugin-triggers",
2299
+ "pluginName": "@commercelayer/cli-plugin-triggers",
2300
+ "pluginType": "core",
2301
+ "strict": true,
2302
+ "enableJsonFlag": false,
2303
+ "isESM": false,
2304
+ "relativePath": [
2305
+ "lib",
2306
+ "commands",
2307
+ "event",
2308
+ "trigger.js"
2309
+ ]
2310
+ },
2135
2311
  "external_gateway": {
2136
2312
  "aliases": [],
2137
2313
  "args": {
@@ -6735,7 +6911,7 @@
6735
6911
  "required": true
6736
6912
  }
6737
6913
  },
6738
- "description": "Send this attribute if you want to mark as fulfilled a shipped/delivered order.",
6914
+ "description": "Send this attribute if you want to mark as fulfilled the order (shipments must be cancelled, shipped or delivered).",
6739
6915
  "flags": {
6740
6916
  "organization": {
6741
6917
  "char": "o",
@@ -14568,5 +14744,5 @@
14568
14744
  ]
14569
14745
  }
14570
14746
  },
14571
- "version": "4.6.0"
14747
+ "version": "4.7.1"
14572
14748
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercelayer/cli-plugin-triggers",
3
3
  "description": "Commerce Layer CLI Triggers plugin",
4
- "version": "4.6.0",
4
+ "version": "4.7.1",
5
5
  "author": "Pierluigi Viti <pierluigi@commercelayer.io>",
6
6
  "homepage": "https://github.com/commercelayer/commercelayer-cli-plugin-triggers",
7
7
  "repository": "commercelayer/commercelayer-cli-plugin-triggers",
@@ -56,29 +56,29 @@
56
56
  "devDependencies": {
57
57
  "@commercelayer/cli-dev": "^3.0.5",
58
58
  "@commercelayer/eslint-config-ts": "^1.4.5",
59
- "@oclif/plugin-help": "^6.2.6",
59
+ "@oclif/plugin-help": "^6.2.8",
60
60
  "@oclif/test": "^3.2.15",
61
61
  "@semantic-release/changelog": "^6.0.3",
62
62
  "@semantic-release/git": "^10.0.1",
63
- "@types/chai": "^4.3.16",
63
+ "@types/chai": "^4.3.17",
64
64
  "@types/inquirer": "^8.2.10",
65
65
  "@types/lodash.snakecase": "^4.1.9",
66
66
  "@types/mocha": "^10.0.7",
67
- "@types/node": "^20.14.10",
68
- "chai": "^4.4.1",
67
+ "@types/node": "^20.16.1",
68
+ "chai": "^4.5.0",
69
69
  "eslint": "^8.57.0",
70
70
  "inflector-js": "^1.0.1",
71
71
  "lodash.snakecase": "^4.1.1",
72
- "mocha": "^10.6.0",
72
+ "mocha": "^10.7.3",
73
73
  "nyc": "^15.1.0",
74
- "oclif": "^4.14.5",
74
+ "oclif": "^4.14.22",
75
75
  "semantic-release": "^22.0.12",
76
- "tsx": "^4.16.2",
76
+ "tsx": "^4.17.0",
77
77
  "typescript": "5.3.2"
78
78
  },
79
79
  "dependencies": {
80
- "@commercelayer/cli-core": "^5.1.1",
81
- "@commercelayer/sdk": "^6.9.1",
80
+ "@commercelayer/cli-core": "^5.2.3",
81
+ "@commercelayer/sdk": "^6.13.0",
82
82
  "@oclif/core": "^3.27.0",
83
83
  "inquirer": "^8.2.6",
84
84
  "tslib": "^2.6.3"