@contrail/cli 2.1.4 → 2.1.5

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
@@ -15,7 +15,7 @@ $ npm install -g @contrail/cli
15
15
  $ contrail COMMAND
16
16
  running command...
17
17
  $ contrail (--version)
18
- @contrail/cli/2.1.4 darwin-arm64 node-v18.13.0
18
+ @contrail/cli/2.1.5 darwin-arm64 node-v18.13.0
19
19
  $ contrail --help [COMMAND]
20
20
  USAGE
21
21
  $ contrail COMMAND
@@ -80,6 +80,10 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
80
80
  * [`contrail types uploadUsageInfo`](#contrail-types-uploadusageinfo)
81
81
  * [`contrail users export`](#contrail-users-export)
82
82
  * [`contrail users upload USERSFILE`](#contrail-users-upload-usersfile)
83
+ * [`contrail webhooks create`](#contrail-webhooks-create)
84
+ * [`contrail webhooks delete [WEBHOOKID]`](#contrail-webhooks-delete-webhookid)
85
+ * [`contrail webhooks getWebhookTrigger [WEBHOOKID]`](#contrail-webhooks-getwebhooktrigger-webhookid)
86
+ * [`contrail webhooks list`](#contrail-webhooks-list)
83
87
  * [`contrail workflow-template-definitions install`](#contrail-workflow-template-definitions-install)
84
88
  * [`contrail workflow-template-definitions list`](#contrail-workflow-template-definitions-list)
85
89
  * [`contrail workflow-templates delete`](#contrail-workflow-templates-delete)
@@ -1143,6 +1147,85 @@ EXAMPLES
1143
1147
  $ contrail users import <USERS_FILE>
1144
1148
  ```
1145
1149
 
1150
+ ## `contrail webhooks create`
1151
+
1152
+ Create a new webhook
1153
+
1154
+ ```
1155
+ USAGE
1156
+ $ contrail webhooks create [-j]
1157
+
1158
+ FLAGS
1159
+ -j, --json output in json format
1160
+
1161
+ DESCRIPTION
1162
+ Create a new webhook
1163
+
1164
+ EXAMPLES
1165
+ $ contrail webhooks create
1166
+ ```
1167
+
1168
+ ## `contrail webhooks delete [WEBHOOKID]`
1169
+
1170
+ Delete an existing webhook. To delete a single webhook, pass its ID. To delete multiple webhooks, do not pass a value for the ID, and select multiple using the interactive selector
1171
+
1172
+ ```
1173
+ USAGE
1174
+ $ contrail webhooks delete [WEBHOOKID] [-j]
1175
+
1176
+ ARGUMENTS
1177
+ WEBHOOKID The id of the webhook to delete
1178
+
1179
+ FLAGS
1180
+ -j, --json output in json format
1181
+
1182
+ DESCRIPTION
1183
+ Delete an existing webhook. To delete a single webhook, pass its ID. To delete multiple webhooks, do not pass a value
1184
+ for the ID, and select multiple using the interactive selector
1185
+
1186
+ EXAMPLES
1187
+ $ contrail webhooks delete
1188
+
1189
+ $ contrail webhooks delete 12345abcd-1234-abcd-1234-12345abcde
1190
+ ```
1191
+
1192
+ ## `contrail webhooks getWebhookTrigger [WEBHOOKID]`
1193
+
1194
+ Crafts a webhook trigger that can be used for event workflows. This command does not alter the state of any webhook or event workflow. It is only a utility for generating a webhook trigger.
1195
+
1196
+ ```
1197
+ USAGE
1198
+ $ contrail webhooks getWebhookTrigger [WEBHOOKID]
1199
+
1200
+ ARGUMENTS
1201
+ WEBHOOKID The id of the webhook to delete
1202
+
1203
+ DESCRIPTION
1204
+ Crafts a webhook trigger that can be used for event workflows. This command does not alter the state of any webhook or
1205
+ event workflow. It is only a utility for generating a webhook trigger.
1206
+
1207
+ EXAMPLES
1208
+ $ contrail webhooks getWebhookTrigger 1234-abcd-1234-abcd-1234abcd
1209
+ ```
1210
+
1211
+ ## `contrail webhooks list`
1212
+
1213
+ List current webhooks
1214
+
1215
+ ```
1216
+ USAGE
1217
+ $ contrail webhooks list [-j]
1218
+
1219
+ FLAGS
1220
+ -j, --json output in json format
1221
+
1222
+ DESCRIPTION
1223
+ List current webhooks
1224
+
1225
+ EXAMPLES
1226
+ $ contrail webhooks list
1227
+ ```
1228
+
1146
1229
  ## `contrail workflow-template-definitions install`
1147
1230
 
1148
1231
  Install the template definitions of an app to your org
@@ -0,0 +1,4 @@
1
+ import { Webhook } from '../interfaces';
2
+ export declare function getWebhooks(): Promise<Webhook[]>;
3
+ export declare function createWebhook(webhook: Webhook): Promise<Webhook>;
4
+ export declare function deleteWebhook(webhookId: string): Promise<Webhook>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteWebhook = exports.createWebhook = exports.getWebhooks = void 0;
4
+ const sdk_1 = require("@contrail/sdk");
5
+ async function getWebhooks() {
6
+ return await new sdk_1.Entities().get({ entityName: 'webhook' });
7
+ }
8
+ exports.getWebhooks = getWebhooks;
9
+ async function createWebhook(webhook) {
10
+ return await new sdk_1.Entities().create({ entityName: 'webhook', object: webhook });
11
+ }
12
+ exports.createWebhook = createWebhook;
13
+ async function deleteWebhook(webhookId) {
14
+ return await new sdk_1.Entities().delete({ entityName: 'webhook', id: webhookId });
15
+ }
16
+ exports.deleteWebhook = deleteWebhook;
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class CreateWebhooks extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const login_1 = require("../../auth/login");
5
+ const webhooks_1 = require("../../api/webhooks");
6
+ class CreateWebhooks extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(CreateWebhooks);
9
+ await (0, login_1.authUser)();
10
+ const webhook = await (0, webhooks_1.createWebhook)({});
11
+ if (flags.json) {
12
+ console.log(JSON.stringify(webhook, null, 2));
13
+ }
14
+ else {
15
+ console.log(webhook.id);
16
+ }
17
+ }
18
+ }
19
+ exports.default = CreateWebhooks;
20
+ CreateWebhooks.description = 'Create a new webhook';
21
+ CreateWebhooks.examples = [
22
+ 'contrail webhooks create',
23
+ ];
24
+ CreateWebhooks.flags = {
25
+ json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
26
+ };
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class DeleteWebhooks extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ };
8
+ static args: {
9
+ webhookId: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const login_1 = require("../../auth/login");
6
+ const webhooks_1 = require("../../api/webhooks");
7
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
+ class DeleteWebhooks extends core_1.Command {
9
+ async run() {
10
+ const { flags, args } = await this.parse(DeleteWebhooks);
11
+ await (0, login_1.authUser)();
12
+ const webhooks = await (0, webhooks_1.getWebhooks)();
13
+ const deletedWebhooks = [];
14
+ if (args.webhookId) {
15
+ const toDelete = webhooks.find(x => x.id === args.webhookId);
16
+ if (!toDelete) {
17
+ throw new Error(`No webhook found with id ${args.webhookId}`);
18
+ }
19
+ deletedWebhooks.push(await (0, webhooks_1.deleteWebhook)(toDelete.id));
20
+ }
21
+ else {
22
+ const answer = await inquirer_1.default.prompt({
23
+ type: 'checkbox',
24
+ name: 'webhookIds',
25
+ message: 'which webhook(s) would you like to delete?',
26
+ choices: webhooks.map(x => ({ name: x.id, value: x.id })),
27
+ });
28
+ for (const id of answer.webhookIds) {
29
+ deletedWebhooks.push(await (0, webhooks_1.deleteWebhook)(id));
30
+ }
31
+ }
32
+ if (flags.json) {
33
+ console.log(JSON.stringify(deletedWebhooks, null, 2));
34
+ }
35
+ else {
36
+ console.log(deletedWebhooks.map(x => x.id).join('\n'));
37
+ }
38
+ }
39
+ }
40
+ exports.default = DeleteWebhooks;
41
+ DeleteWebhooks.description = 'Delete an existing webhook. To delete a single webhook, pass its ID. To delete multiple webhooks, do not pass a value for the ID, and select multiple using the interactive selector';
42
+ DeleteWebhooks.examples = [
43
+ 'contrail webhooks delete',
44
+ 'contrail webhooks delete 12345abcd-1234-abcd-1234-12345abcde',
45
+ ];
46
+ DeleteWebhooks.flags = {
47
+ json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
48
+ };
49
+ DeleteWebhooks.args = {
50
+ webhookId: core_1.Args.string({ description: 'The id of the webhook to delete', required: false }),
51
+ };
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class GetWebhookTrigger extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ webhookId: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const login_1 = require("../../auth/login");
6
+ const webhooks_1 = require("../../api/webhooks");
7
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
+ class GetWebhookTrigger extends core_1.Command {
9
+ async run() {
10
+ const { args } = await this.parse(GetWebhookTrigger);
11
+ await (0, login_1.authUser)();
12
+ const webhooks = await (0, webhooks_1.getWebhooks)();
13
+ if (args.webhookId) {
14
+ const foundWebhook = webhooks.find(x => x.id === args.webhookId);
15
+ if (!foundWebhook) {
16
+ throw new Error(`No webhook found with id ${args.webhookId}`);
17
+ }
18
+ console.log(`webhookId:${foundWebhook.id}`);
19
+ }
20
+ else {
21
+ const answer = await inquirer_1.default.prompt({
22
+ type: 'list',
23
+ name: 'webhookId',
24
+ message: 'For which webhook would you like ot generate an event tirgger?',
25
+ choices: webhooks.map(x => ({ name: x.id, value: x.id })),
26
+ });
27
+ console.log(`webhookId:${answer.webhookId}`);
28
+ }
29
+ }
30
+ }
31
+ exports.default = GetWebhookTrigger;
32
+ GetWebhookTrigger.description = 'Crafts a webhook trigger that can be used for event workflows. This command does not alter the state of any webhook or event workflow. It is only a utility for generating a webhook trigger.';
33
+ GetWebhookTrigger.examples = [
34
+ 'contrail webhooks getWebhookTrigger 1234-abcd-1234-abcd-1234abcd',
35
+ ];
36
+ GetWebhookTrigger.args = {
37
+ webhookId: core_1.Args.string({ description: 'The id of the webhook to delete', required: false }),
38
+ };
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class ListWebhooks extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ };
8
+ static args: {};
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const login_1 = require("../../auth/login");
5
+ const webhooks_1 = require("../../api/webhooks");
6
+ class ListWebhooks extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(ListWebhooks);
9
+ await (0, login_1.authUser)();
10
+ const webhooks = await (0, webhooks_1.getWebhooks)();
11
+ if (flags.json) {
12
+ console.log(JSON.stringify(webhooks, null, 2));
13
+ }
14
+ else {
15
+ console.log(webhooks.map(x => x.id).join('\n'));
16
+ }
17
+ }
18
+ }
19
+ exports.default = ListWebhooks;
20
+ ListWebhooks.description = 'List current webhooks';
21
+ ListWebhooks.examples = [
22
+ 'contrail webhooks list',
23
+ ];
24
+ ListWebhooks.flags = {
25
+ // // flag with a value (-n, --name=VALUE)
26
+ // name: Flags.string({char: 'n', description: 'name to print'}),
27
+ // flag with no value (-f, --force)
28
+ json: core_1.Flags.boolean({ char: 'j', description: 'output in json format', default: false }),
29
+ };
30
+ ListWebhooks.args = {
31
+ // file: Args.string({description: 'file to read'}),
32
+ };
@@ -127,6 +127,13 @@ export interface AppOrg {
127
127
  apiKey?: AppApiKey;
128
128
  appConfig?: any;
129
129
  }
130
+ export interface Webhook {
131
+ id?: string;
132
+ createdOn?: Date;
133
+ createdById?: string;
134
+ createdBy?: any;
135
+ orgId?: string;
136
+ }
130
137
  export interface AppCodePackage {
131
138
  id: string;
132
139
  appId: string;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.1.4",
2
+ "version": "2.1.5",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -1014,6 +1014,99 @@
1014
1014
  }
1015
1015
  }
1016
1016
  },
1017
+ "webhooks:create": {
1018
+ "id": "webhooks:create",
1019
+ "description": "Create a new webhook",
1020
+ "strict": true,
1021
+ "pluginName": "@contrail/cli",
1022
+ "pluginAlias": "@contrail/cli",
1023
+ "pluginType": "core",
1024
+ "aliases": [],
1025
+ "examples": [
1026
+ "contrail webhooks create"
1027
+ ],
1028
+ "flags": {
1029
+ "json": {
1030
+ "name": "json",
1031
+ "type": "boolean",
1032
+ "char": "j",
1033
+ "description": "output in json format",
1034
+ "allowNo": false
1035
+ }
1036
+ },
1037
+ "args": {}
1038
+ },
1039
+ "webhooks:delete": {
1040
+ "id": "webhooks:delete",
1041
+ "description": "Delete an existing webhook. To delete a single webhook, pass its ID. To delete multiple webhooks, do not pass a value for the ID, and select multiple using the interactive selector",
1042
+ "strict": true,
1043
+ "pluginName": "@contrail/cli",
1044
+ "pluginAlias": "@contrail/cli",
1045
+ "pluginType": "core",
1046
+ "aliases": [],
1047
+ "examples": [
1048
+ "contrail webhooks delete",
1049
+ "contrail webhooks delete 12345abcd-1234-abcd-1234-12345abcde"
1050
+ ],
1051
+ "flags": {
1052
+ "json": {
1053
+ "name": "json",
1054
+ "type": "boolean",
1055
+ "char": "j",
1056
+ "description": "output in json format",
1057
+ "allowNo": false
1058
+ }
1059
+ },
1060
+ "args": {
1061
+ "webhookId": {
1062
+ "name": "webhookId",
1063
+ "description": "The id of the webhook to delete",
1064
+ "required": false
1065
+ }
1066
+ }
1067
+ },
1068
+ "webhooks:getWebhookTrigger": {
1069
+ "id": "webhooks:getWebhookTrigger",
1070
+ "description": "Crafts a webhook trigger that can be used for event workflows. This command does not alter the state of any webhook or event workflow. It is only a utility for generating a webhook trigger.",
1071
+ "strict": true,
1072
+ "pluginName": "@contrail/cli",
1073
+ "pluginAlias": "@contrail/cli",
1074
+ "pluginType": "core",
1075
+ "aliases": [],
1076
+ "examples": [
1077
+ "contrail webhooks getWebhookTrigger 1234-abcd-1234-abcd-1234abcd"
1078
+ ],
1079
+ "flags": {},
1080
+ "args": {
1081
+ "webhookId": {
1082
+ "name": "webhookId",
1083
+ "description": "The id of the webhook to delete",
1084
+ "required": false
1085
+ }
1086
+ }
1087
+ },
1088
+ "webhooks:list": {
1089
+ "id": "webhooks:list",
1090
+ "description": "List current webhooks",
1091
+ "strict": true,
1092
+ "pluginName": "@contrail/cli",
1093
+ "pluginAlias": "@contrail/cli",
1094
+ "pluginType": "core",
1095
+ "aliases": [],
1096
+ "examples": [
1097
+ "contrail webhooks list"
1098
+ ],
1099
+ "flags": {
1100
+ "json": {
1101
+ "name": "json",
1102
+ "type": "boolean",
1103
+ "char": "j",
1104
+ "description": "output in json format",
1105
+ "allowNo": false
1106
+ }
1107
+ },
1108
+ "args": {}
1109
+ },
1017
1110
  "workflow-template-definitions:install": {
1018
1111
  "id": "workflow-template-definitions:install",
1019
1112
  "description": "Install the template definitions of an app to your org",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",