@trayio/cdk-cli 3.8.1-beta → 3.9.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.
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -19,86 +10,81 @@ const ConnectorPermissionsHttpClient_1 = require("@trayio/tray-client/connector/
19
10
  const check_env_1 = require("../../utils/check-env");
20
11
  const colorizeString_1 = require("../../utils/colorizeString");
21
12
  class PermissionsList extends core_1.Command {
22
- constructor() {
23
- super(...arguments);
24
- this.connectorPermissions = new ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient({
25
- baseUrl: process.env.TRAY_API_URL,
26
- }, new AxiosHttpClient_1.AxiosHttpClient());
27
- }
28
- run() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- (0, check_env_1.checkEnv)();
31
- const { args, flags } = yield this.parse(PermissionsList);
32
- const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
33
- const promptRes = yield inquirer_1.default.prompt([
34
- {
35
- name: 'connectorName',
36
- message: 'The name of the connector to share',
37
- type: 'input',
38
- when: !args.connectorName,
39
- },
40
- {
41
- name: 'connectorVersion',
42
- message: 'The version of the connector to share',
43
- type: 'input',
44
- when: !args.connectorVersion,
45
- },
46
- // {
47
- // name: 'permissionsType',
48
- // message: 'How would you like to list connector permissions?',
49
- // type: 'list',
50
- // choices: [{ name: 'emails' }, { name: 'workspaces' }],
51
- // when: !flags.email && !flags.workspaces,
52
- // },
53
- ]);
54
- const input = {
55
- connectorName: args.connectorName || promptRes.connectorName,
56
- connectorVersion: args.connectorVersion || promptRes.connectorVersion,
57
- token: TRAY_API_TOKEN,
58
- };
59
- core_1.ux.action.start(`Checking the connector deployment status`);
60
- const response = yield this.connectorPermissions.listSharedEmails(input);
61
- core_1.ux.action.stop();
62
- if (response.isSuccess) {
63
- this.log((0, colorizeString_1.success)(`Success! These are the emails that have access to ${input.connectorName}:`));
64
- this.log(response.value.emails.join('\n'));
65
- }
66
- if (response.isFailure) {
67
- this.log((0, colorizeString_1.error)(`There was an error when listing connector permissions.`));
68
- }
69
- });
13
+ static description = 'Retrieves a list of emails that have access to a connector';
14
+ // 'Retrieves a list of emails and workspaces that have access to a connector';
15
+ static examples = [
16
+ '<%= config.bin %> <%= command.id %>',
17
+ '<%= config.bin %> <%= command.id %> my-connector',
18
+ '<%= config.bin %> <%= command.id %> my-connector 1.0',
19
+ ];
20
+ static args = {
21
+ connectorName: core_1.Args.string({
22
+ name: 'Connector Name',
23
+ required: false,
24
+ description: 'The name of the connector',
25
+ }),
26
+ connectorVersion: core_1.Args.string({
27
+ name: 'Connector Version',
28
+ required: false,
29
+ description: 'The version of the connector',
30
+ }),
31
+ };
32
+ static flags = {
33
+ // email: Flags.string({
34
+ // char: 'e',
35
+ // aliases: ['emails', 'email'],
36
+ // description: 'Retrieve a list of emails that have access to a connector',
37
+ // }),
38
+ // workspaces: Flags.string({
39
+ // char: 'w',
40
+ // aliases: ['workspaces', 'workspace'],
41
+ // description:
42
+ // 'Retrieve a list of workspace IDs that have access to a connector',
43
+ // }),
44
+ };
45
+ connectorPermissions = new ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient({
46
+ baseUrl: process.env.TRAY_API_URL,
47
+ }, new AxiosHttpClient_1.AxiosHttpClient());
48
+ async run() {
49
+ (0, check_env_1.checkEnv)();
50
+ const { args, flags } = await this.parse(PermissionsList);
51
+ const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
52
+ const promptRes = await inquirer_1.default.prompt([
53
+ {
54
+ name: 'connectorName',
55
+ message: 'The name of the connector to share',
56
+ type: 'input',
57
+ when: !args.connectorName,
58
+ },
59
+ {
60
+ name: 'connectorVersion',
61
+ message: 'The version of the connector to share',
62
+ type: 'input',
63
+ when: !args.connectorVersion,
64
+ },
65
+ // {
66
+ // name: 'permissionsType',
67
+ // message: 'How would you like to list connector permissions?',
68
+ // type: 'list',
69
+ // choices: [{ name: 'emails' }, { name: 'workspaces' }],
70
+ // when: !flags.email && !flags.workspaces,
71
+ // },
72
+ ]);
73
+ const input = {
74
+ connectorName: args.connectorName || promptRes.connectorName,
75
+ connectorVersion: args.connectorVersion || promptRes.connectorVersion,
76
+ token: TRAY_API_TOKEN,
77
+ };
78
+ core_1.ux.action.start(`Checking the connector deployment status`);
79
+ const response = await this.connectorPermissions.listSharedEmails(input);
80
+ core_1.ux.action.stop();
81
+ if (response.isSuccess) {
82
+ this.log((0, colorizeString_1.success)(`Success! These are the emails that have access to ${input.connectorName}:`));
83
+ this.log(response.value.emails.join('\n'));
84
+ }
85
+ if (response.isFailure) {
86
+ this.log((0, colorizeString_1.error)(`There was an error when listing connector permissions.`));
87
+ }
70
88
  }
71
89
  }
72
- PermissionsList.description = 'Retrieves a list of emails that have access to a connector';
73
- // 'Retrieves a list of emails and workspaces that have access to a connector';
74
- PermissionsList.examples = [
75
- '<%= config.bin %> <%= command.id %>',
76
- '<%= config.bin %> <%= command.id %> my-connector',
77
- '<%= config.bin %> <%= command.id %> my-connector 1.0',
78
- ];
79
- PermissionsList.args = {
80
- connectorName: core_1.Args.string({
81
- name: 'Connector Name',
82
- required: false,
83
- description: 'The name of the connector',
84
- }),
85
- connectorVersion: core_1.Args.string({
86
- name: 'Connector Version',
87
- required: false,
88
- description: 'The version of the connector',
89
- }),
90
- };
91
- PermissionsList.flags = {
92
- // email: Flags.string({
93
- // char: 'e',
94
- // aliases: ['emails', 'email'],
95
- // description: 'Retrieve a list of emails that have access to a connector',
96
- // }),
97
- // workspaces: Flags.string({
98
- // char: 'w',
99
- // aliases: ['workspaces', 'workspace'],
100
- // description:
101
- // 'Retrieve a list of workspace IDs that have access to a connector',
102
- // }),
103
- };
104
90
  exports.default = PermissionsList;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -26,33 +17,38 @@ describe('PermissionsList', () => {
26
17
  const emails = ['some@test.com', 'someOther@test.com'];
27
18
  beforeEach(() => {
28
19
  ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient.mockImplementation(() => ({
29
- listSharedEmails: jest.fn().mockReturnValue(Object.assign(Object.assign(Object.assign({ isSuccess: success }, (success && {
30
- value: {
31
- emails,
32
- },
33
- })), { isFailure: true }), (failure && {
34
- error: {
35
- message: 'There was an error listing connector permissions',
36
- },
37
- }))),
20
+ listSharedEmails: jest.fn().mockReturnValue({
21
+ isSuccess: success,
22
+ ...(success && {
23
+ value: {
24
+ emails,
25
+ },
26
+ }),
27
+ isFailure: true,
28
+ ...(failure && {
29
+ error: {
30
+ message: 'There was an error listing connector permissions',
31
+ },
32
+ }),
33
+ }),
38
34
  }));
39
35
  });
40
36
  afterAll(() => {
41
37
  jest.clearAllMocks();
42
38
  });
43
- it('should list shared emails', () => __awaiter(void 0, void 0, void 0, function* () {
39
+ it('should list shared emails', async () => {
44
40
  stdout_stderr_1.stdout.start();
45
- yield list_1.default.run([connectorName, connectorVersion]);
41
+ await list_1.default.run([connectorName, connectorVersion]);
46
42
  stdout_stderr_1.stdout.stop();
47
43
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`Success! These are the emails that have access to some-connector-name:`));
48
44
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(emails.join('\n')));
49
- }));
50
- it('should handle error when listing shared emails', () => __awaiter(void 0, void 0, void 0, function* () {
45
+ });
46
+ it('should handle error when listing shared emails', async () => {
51
47
  success = false;
52
48
  failure = true;
53
49
  stdout_stderr_1.stdout.start();
54
- yield list_1.default.run([connectorName, connectorVersion]);
50
+ await list_1.default.run([connectorName, connectorVersion]);
55
51
  stdout_stderr_1.stdout.stop();
56
52
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`There was an error when listing connector permissions.`));
57
- }));
53
+ });
58
54
  });
@@ -343,5 +343,5 @@
343
343
  ]
344
344
  }
345
345
  },
346
- "version": "3.8.1-beta"
346
+ "version": "3.9.1"
347
347
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "3.8.1-beta",
3
+ "version": "3.9.1",
4
4
  "description": "A CLI for connector development",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -19,12 +19,12 @@
19
19
  "@oclif/plugin-help": "6.0.12",
20
20
  "@oclif/plugin-version": "2.0.11",
21
21
  "@oclif/test": "3.1.12",
22
- "@trayio/axios": "3.8.1-beta",
23
- "@trayio/cdk-build": "3.8.1-beta",
24
- "@trayio/commons": "3.8.1-beta",
25
- "@trayio/generator": "3.8.1-beta",
26
- "@trayio/tray-client": "3.8.1-beta",
27
- "@trayio/tray-openapi": "3.8.1-beta",
22
+ "@trayio/axios": "3.9.1",
23
+ "@trayio/cdk-build": "3.9.1",
24
+ "@trayio/commons": "3.9.1",
25
+ "@trayio/generator": "3.9.1",
26
+ "@trayio/tray-client": "3.9.1",
27
+ "@trayio/tray-openapi": "3.9.1",
28
28
  "@types/inquirer": "8.2.6",
29
29
  "chalk": "4.1.2",
30
30
  "inquirer": "8.2.5"