@trayio/cdk-cli 3.8.0-beta → 3.9.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.
@@ -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
  };
@@ -37,78 +28,83 @@ describe('GetDeploymentStatus', () => {
37
28
  success = true;
38
29
  failure = false;
39
30
  ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient.mockImplementation(() => ({
40
- get: jest.fn().mockReturnValue(Object.assign(Object.assign(Object.assign({ isSuccess: success }, (success && {
41
- value: {
42
- deploymentStatus: status,
43
- },
44
- })), { isFailure: failure }), (failure && {
45
- error: {
46
- message: 'There was an error fetching deployment status',
47
- },
48
- }))),
31
+ get: jest.fn().mockReturnValue({
32
+ isSuccess: success,
33
+ ...(success && {
34
+ value: {
35
+ deploymentStatus: status,
36
+ },
37
+ }),
38
+ isFailure: failure,
39
+ ...(failure && {
40
+ error: {
41
+ message: 'There was an error fetching deployment status',
42
+ },
43
+ }),
44
+ }),
49
45
  }));
50
46
  });
51
47
  afterAll(() => {
52
48
  jest.clearAllMocks();
53
49
  });
54
- it('should log success message when connector is deployed', () => __awaiter(void 0, void 0, void 0, function* () {
50
+ it('should log success message when connector is deployed', async () => {
55
51
  status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deployed;
56
52
  const uxStartSpy = jest.spyOn(core_1.ux.action, 'start');
57
53
  stdout_stderr_1.stdout.start();
58
- yield get_1.default.run([connectorName, connectorVersion, uuid]);
54
+ await get_1.default.run([connectorName, connectorVersion, uuid]);
59
55
  stdout_stderr_1.stdout.stop();
60
56
  expect(uxStartSpy).toHaveBeenCalledWith(`Checking the connector deployment status`);
61
57
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deployed Successfully!'));
62
- }));
63
- it('should log failed message when connector failed to deploy', () => __awaiter(void 0, void 0, void 0, function* () {
58
+ });
59
+ it('should log failed message when connector failed to deploy', async () => {
64
60
  status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Failed;
65
61
  stdout_stderr_1.stdout.start();
66
- yield get_1.default.run([connectorName, connectorVersion, uuid]);
62
+ await get_1.default.run([connectorName, connectorVersion, uuid]);
67
63
  stdout_stderr_1.stdout.stop();
68
64
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deploy Failed, please try again or contact support'));
69
- }));
70
- it('should log connector is still deploying message when deploying', () => __awaiter(void 0, void 0, void 0, function* () {
65
+ });
66
+ it('should log connector is still deploying message when deploying', async () => {
71
67
  status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deploying;
72
68
  stdout_stderr_1.stdout.start();
73
- yield get_1.default.run([connectorName, connectorVersion, uuid]);
69
+ await get_1.default.run([connectorName, connectorVersion, uuid]);
74
70
  stdout_stderr_1.stdout.stop();
75
71
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector is currently being deployed, this could take a few minutes. Please check the connector status again later.'));
76
- }));
77
- it('should log error messages when the request fails', () => __awaiter(void 0, void 0, void 0, function* () {
72
+ });
73
+ it('should log error messages when the request fails', async () => {
78
74
  success = false;
79
75
  failure = true;
80
76
  status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Failed;
81
77
  stdout_stderr_1.stdout.start();
82
- yield get_1.default.run([connectorName, connectorVersion, uuid]);
78
+ await get_1.default.run([connectorName, connectorVersion, uuid]);
83
79
  stdout_stderr_1.stdout.stop();
84
80
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deploy Failed, please try again or contact support'));
85
81
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('There was an error fetching deployment status'));
86
- }));
87
- it('should run the polling function when tail flag is set', () => __awaiter(void 0, void 0, void 0, function* () {
82
+ });
83
+ it('should run the polling function when tail flag is set', async () => {
88
84
  status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deployed;
89
85
  const uxStartSpy = jest.spyOn(core_1.ux.action, 'start');
90
86
  stdout_stderr_1.stdout.start();
91
- yield get_1.default.run([connectorName, connectorVersion, uuid, '-t']);
87
+ await get_1.default.run([connectorName, connectorVersion, uuid, '-t']);
92
88
  stdout_stderr_1.stdout.stop();
93
89
  expect(uxStartSpy).toHaveBeenCalledWith(`Checking the connector deployment status with tailing`);
94
90
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deployed Successfully!'));
95
- }));
96
- it('should run the get status command when a uuid is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
91
+ });
92
+ it('should run the get status command when a uuid is not provided', async () => {
97
93
  status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deployed;
98
94
  stdout_stderr_1.stdout.start();
99
- yield get_1.default.run([connectorName, connectorVersion]);
95
+ await get_1.default.run([connectorName, connectorVersion]);
100
96
  stdout_stderr_1.stdout.stop();
101
97
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deployed Successfully!'));
102
- }));
103
- it('should use local connector when no args are provided', () => __awaiter(void 0, void 0, void 0, function* () {
98
+ });
99
+ it('should use local connector when no args are provided', async () => {
104
100
  status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deployed;
105
101
  stdout_stderr_1.stdout.start();
106
- yield get_1.default.run([]);
102
+ await get_1.default.run([]);
107
103
  stdout_stderr_1.stdout.stop();
108
104
  const uxStartSpy = jest.spyOn(core_1.ux.action, 'start');
109
105
  expect(uxStartSpy).toHaveBeenCalledTimes(2);
110
106
  expect(uxStartSpy.mock.calls[0][0]).toEqual('No arguments provided, attempting to use local connector');
111
107
  expect(uxStartSpy.mock.calls[1][0]).toEqual('Checking the connector deployment status');
112
108
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deployed Successfully!'));
113
- }));
109
+ });
114
110
  });
@@ -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
  };
@@ -22,121 +13,147 @@ const colorizeString_1 = require("../../utils/colorizeString");
22
13
  * We might want to revisit this in the future to implement it
23
14
  */
24
15
  class Add extends core_1.Command {
25
- constructor() {
26
- super(...arguments);
27
- this.connectorPermissions = new ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient({
28
- baseUrl: process.env.TRAY_API_URL,
29
- }, new AxiosHttpClient_1.AxiosHttpClient());
30
- }
31
- run() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const { args, flags } = yield this.parse(Add);
34
- const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
35
- const promptRes = yield inquirer_1.default.prompt([
36
- {
37
- name: 'connectorName',
38
- message: 'The name of the connector to share',
39
- type: 'input',
40
- when: !args.connectorName,
41
- },
42
- {
43
- name: 'connectorVersion',
44
- message: 'The version of the connector to share',
45
- type: 'input',
46
- when: !args.connectorVersion,
47
- },
48
- // {
49
- // name: 'shareMethod',
50
- // message: 'How would you like to share the connector?',
51
- // type: 'list',
52
- // choices: [{ name: 'email' }, { name: 'workspace' }],
53
- // when: !flags.email && !flags.workspaces,
54
- // },
55
- ]);
56
- const shareTargetPrompt = yield inquirer_1.default.prompt([
57
- {
58
- name: 'emails',
59
- message: 'Enter a comma separated list of emails to share the connector version with',
60
- type: 'input',
61
- when: !flags.email,
62
- // !flags.workspaces &&
63
- // promptRes.shareMethod === 'email',
64
- },
65
- // {
66
- // name: 'workspaceIds',
67
- // message: 'Enter the workspace IDs to share the connector version with',
68
- // type: 'input',
69
- // when:
70
- // !flags.email &&
71
- // !flags.workspaces &&
72
- // promptRes.shareMethod === 'workspace',
73
- // },
74
- ]);
75
- const connectorName = args.connectorName || promptRes.connectorName;
76
- const connectorVersion = this.truncateVersion(args.connectorVersion || promptRes.connectorVersion);
77
- const emails = flags.email || shareTargetPrompt.emails;
78
- // const workspaceIds = flags.workspaces || shareTargetPrompt.workspaceIds;
79
- // if (emails && workspaceIds) {
80
- // this.log(
81
- // error('Please provide either emails or workspace IDs, not both')
16
+ static description = 'Share your connector version with other users in your organization';
17
+ static examples = [
18
+ '<%= config.bin %> <%= command.id %>',
19
+ '<%= config.bin %> <%= command.id %> my-connector',
20
+ '<%= config.bin %> <%= command.id %> my-connector 1.0',
21
+ '<%= config.bin %> <%= command.id %> my-connector 1.0 --email="my.email@domain.com, your.email@domain.com"',
22
+ '<%= config.bin %> <%= command.id %> my-connector 1.0 -e="my.email@domain.com, your.email@domain.com"',
23
+ // '<%= config.bin %> <%= command.id %> my-connector 1.0 --workspace="<workspace-id>, <another-workspace-id>"',
24
+ // '<%= config.bin %> <%= command.id %> my-connector 1.0 -w="<workspace-id>, <another-workspace-id>"',
25
+ ];
26
+ static args = {
27
+ connectorName: core_1.Args.string({
28
+ name: 'Connector Name',
29
+ required: false,
30
+ description: 'The name of the connector',
31
+ }),
32
+ connectorVersion: core_1.Args.string({
33
+ name: 'Connector Version',
34
+ required: false,
35
+ description: 'The version of the connector',
36
+ }),
37
+ };
38
+ static flags = {
39
+ email: core_1.Flags.string({
40
+ char: 'e',
41
+ aliases: ['emails', 'email'],
42
+ description: 'Share with users by providing a list of emails',
43
+ }),
44
+ // workspaces: Flags.string({
45
+ // char: 'w',
46
+ // aliases: ['workspaces', 'workspace'],
47
+ // description:
48
+ // 'Share with the emails of users in a workspace by providing a list of workspace IDs',
49
+ // }),
50
+ };
51
+ connectorPermissions = new ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient({
52
+ baseUrl: process.env.TRAY_API_URL,
53
+ }, new AxiosHttpClient_1.AxiosHttpClient());
54
+ async run() {
55
+ const { args, flags } = await this.parse(Add);
56
+ const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
57
+ const promptRes = await inquirer_1.default.prompt([
58
+ {
59
+ name: 'connectorName',
60
+ message: 'The name of the connector to share',
61
+ type: 'input',
62
+ when: !args.connectorName,
63
+ },
64
+ {
65
+ name: 'connectorVersion',
66
+ message: 'The version of the connector to share',
67
+ type: 'input',
68
+ when: !args.connectorVersion,
69
+ },
70
+ // {
71
+ // name: 'shareMethod',
72
+ // message: 'How would you like to share the connector?',
73
+ // type: 'list',
74
+ // choices: [{ name: 'email' }, { name: 'workspace' }],
75
+ // when: !flags.email && !flags.workspaces,
76
+ // },
77
+ ]);
78
+ const shareTargetPrompt = await inquirer_1.default.prompt([
79
+ {
80
+ name: 'emails',
81
+ message: 'Enter a comma separated list of emails to share the connector version with',
82
+ type: 'input',
83
+ when: !flags.email,
84
+ // !flags.workspaces &&
85
+ // promptRes.shareMethod === 'email',
86
+ },
87
+ // {
88
+ // name: 'workspaceIds',
89
+ // message: 'Enter the workspace IDs to share the connector version with',
90
+ // type: 'input',
91
+ // when:
92
+ // !flags.email &&
93
+ // !flags.workspaces &&
94
+ // promptRes.shareMethod === 'workspace',
95
+ // },
96
+ ]);
97
+ const connectorName = args.connectorName || promptRes.connectorName;
98
+ const connectorVersion = this.truncateVersion(args.connectorVersion || promptRes.connectorVersion);
99
+ const emails = flags.email || shareTargetPrompt.emails;
100
+ // const workspaceIds = flags.workspaces || shareTargetPrompt.workspaceIds;
101
+ // if (emails && workspaceIds) {
102
+ // this.log(
103
+ // error('Please provide either emails or workspace IDs, not both')
104
+ // );
105
+ if (emails) {
106
+ this.handleShareByEmail(connectorName, connectorVersion, TRAY_API_TOKEN, emails);
107
+ // } else if (workspaceIds && !emails) {
108
+ // this.handleShareByWorkspace(
109
+ // connectorName,
110
+ // connectorVersion,
111
+ // TRAY_API_TOKEN,
112
+ // workspaceIds
82
113
  // );
83
- if (emails) {
84
- this.handleShareByEmail(connectorName, connectorVersion, TRAY_API_TOKEN, emails);
85
- // } else if (workspaceIds && !emails) {
86
- // this.handleShareByWorkspace(
87
- // connectorName,
88
- // connectorVersion,
89
- // TRAY_API_TOKEN,
90
- // workspaceIds
91
- // );
92
- }
93
- else {
94
- this.log((0, colorizeString_1.error)('Please provide at least 1 email.'));
95
- }
96
- });
114
+ }
115
+ else {
116
+ this.log((0, colorizeString_1.error)('Please provide at least 1 email.'));
117
+ }
97
118
  }
98
- handleShareByEmail(connectorName, connectorVersion, token, emails) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- core_1.ux.action.start(`Sharing ${connectorName} ${connectorVersion} with emails`);
101
- const input = {
102
- connectorName,
103
- connectorVersion,
104
- emails: this.splitList(emails),
105
- token,
106
- };
107
- const response = yield this.connectorPermissions.shareWithEmails(input);
108
- core_1.ux.action.stop();
109
- if (response.isSuccess) {
110
- this.log((0, colorizeString_1.success)(response.value.message));
111
- }
112
- if (response.isFailure) {
113
- this.log((0, colorizeString_1.error)(`Connector Share By Email Failed, please try again or contact support`));
114
- this.log(response.error.message);
115
- }
116
- });
119
+ async handleShareByEmail(connectorName, connectorVersion, token, emails) {
120
+ core_1.ux.action.start(`Sharing ${connectorName} ${connectorVersion} with emails`);
121
+ const input = {
122
+ connectorName,
123
+ connectorVersion,
124
+ emails: this.splitList(emails),
125
+ token,
126
+ };
127
+ const response = await this.connectorPermissions.shareWithEmails(input);
128
+ core_1.ux.action.stop();
129
+ if (response.isSuccess) {
130
+ this.log((0, colorizeString_1.success)(response.value.message));
131
+ }
132
+ if (response.isFailure) {
133
+ this.log((0, colorizeString_1.error)(`Connector Share By Email Failed, please try again or contact support`));
134
+ this.log(response.error.message);
135
+ }
117
136
  }
118
- handleShareByWorkspace(connectorName, connectorVersion, token, workspaceIds) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- core_1.ux.action.start(`Sharing ${connectorName} ${connectorVersion} with emails assigned to the given workspaces`);
121
- const input = {
122
- connectorName,
123
- connectorVersion,
124
- workspaceIds: this.splitList(workspaceIds),
125
- token,
126
- };
127
- const response = yield this.connectorPermissions.shareWithWorkspaces(input);
128
- core_1.ux.action.stop();
129
- if (response.isSuccess) {
130
- this.log((0, colorizeString_1.success)(response.value.success.message));
131
- if (response.value.warnings.emptyWorkspaces.length > 0) {
132
- this.log((0, colorizeString_1.error)(response.value.warnings.emptyWorkspaces.join(', ')));
133
- }
134
- }
135
- if (response.isFailure) {
136
- this.log((0, colorizeString_1.error)(`Connector Share By Workspace Failed, please try again or contact support`));
137
- this.log(response.error.message);
137
+ async handleShareByWorkspace(connectorName, connectorVersion, token, workspaceIds) {
138
+ core_1.ux.action.start(`Sharing ${connectorName} ${connectorVersion} with emails assigned to the given workspaces`);
139
+ const input = {
140
+ connectorName,
141
+ connectorVersion,
142
+ workspaceIds: this.splitList(workspaceIds),
143
+ token,
144
+ };
145
+ const response = await this.connectorPermissions.shareWithWorkspaces(input);
146
+ core_1.ux.action.stop();
147
+ if (response.isSuccess) {
148
+ this.log((0, colorizeString_1.success)(response.value.success.message));
149
+ if (response.value.warnings.emptyWorkspaces.length > 0) {
150
+ this.log((0, colorizeString_1.error)(response.value.warnings.emptyWorkspaces.join(', ')));
138
151
  }
139
- });
152
+ }
153
+ if (response.isFailure) {
154
+ this.log((0, colorizeString_1.error)(`Connector Share By Workspace Failed, please try again or contact support`));
155
+ this.log(response.error.message);
156
+ }
140
157
  }
141
158
  splitList(list) {
142
159
  return list
@@ -148,39 +165,4 @@ class Add extends core_1.Command {
148
165
  return version.split('.').slice(0, 2).join('.');
149
166
  }
150
167
  }
151
- Add.description = 'Share your connector version with other users in your organization';
152
- Add.examples = [
153
- '<%= config.bin %> <%= command.id %>',
154
- '<%= config.bin %> <%= command.id %> my-connector',
155
- '<%= config.bin %> <%= command.id %> my-connector 1.0',
156
- '<%= config.bin %> <%= command.id %> my-connector 1.0 --email="my.email@domain.com, your.email@domain.com"',
157
- '<%= config.bin %> <%= command.id %> my-connector 1.0 -e="my.email@domain.com, your.email@domain.com"',
158
- // '<%= config.bin %> <%= command.id %> my-connector 1.0 --workspace="<workspace-id>, <another-workspace-id>"',
159
- // '<%= config.bin %> <%= command.id %> my-connector 1.0 -w="<workspace-id>, <another-workspace-id>"',
160
- ];
161
- Add.args = {
162
- connectorName: core_1.Args.string({
163
- name: 'Connector Name',
164
- required: false,
165
- description: 'The name of the connector',
166
- }),
167
- connectorVersion: core_1.Args.string({
168
- name: 'Connector Version',
169
- required: false,
170
- description: 'The version of the connector',
171
- }),
172
- };
173
- Add.flags = {
174
- email: core_1.Flags.string({
175
- char: 'e',
176
- aliases: ['emails', 'email'],
177
- description: 'Share with users by providing a list of emails',
178
- }),
179
- // workspaces: Flags.string({
180
- // char: 'w',
181
- // aliases: ['workspaces', 'workspace'],
182
- // description:
183
- // 'Share with the emails of users in a workspace by providing a list of workspace IDs',
184
- // }),
185
- };
186
168
  exports.default = Add;
@@ -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
  };
@@ -66,10 +57,10 @@ describe('Share', () => {
66
57
  afterAll(() => {
67
58
  jest.clearAllMocks();
68
59
  });
69
- it('should log success message when connector is shared by email', () => __awaiter(void 0, void 0, void 0, function* () {
60
+ it('should log success message when connector is shared by email', async () => {
70
61
  success = true;
71
62
  stdout_stderr_1.stdout.start();
72
- yield add_1.default.run([connectorName, connectorVersion, `--email='${emails}'`]);
63
+ await add_1.default.run([connectorName, connectorVersion, `--email='${emails}'`]);
73
64
  stdout_stderr_1.stdout.stop();
74
65
  expect(mockedShareWithEmailsSuccess).toHaveBeenCalledWith({
75
66
  connectorName,
@@ -78,15 +69,15 @@ describe('Share', () => {
78
69
  token: process.env.TRAY_API_TOKEN,
79
70
  });
80
71
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('1 permissions added'));
81
- }));
82
- it('should log error messages when share with emails fails', () => __awaiter(void 0, void 0, void 0, function* () {
72
+ });
73
+ it('should log error messages when share with emails fails', async () => {
83
74
  success = false;
84
75
  stdout_stderr_1.stdout.start();
85
- yield add_1.default.run([connectorName, connectorVersion, `--emails='${emails}'`]);
76
+ await add_1.default.run([connectorName, connectorVersion, `--emails='${emails}'`]);
86
77
  stdout_stderr_1.stdout.stop();
87
78
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Share By Email Failed, please try again or contact support'));
88
79
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`The connector (Left(some-connector-name~1.1)) was not found or you don't have permission to access it`));
89
- }));
80
+ });
90
81
  // it('should log success message when connector is shared by workspaces and warn of empty workspaces', async () => {
91
82
  // success = true;
92
83
  // stdout.start();