@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.
- package/README.md +1 -1
- package/dist/commands/connector/add-operation.js +61 -75
- package/dist/commands/connector/add-operation.unit.test.js +6 -15
- package/dist/commands/connector/build.js +8 -22
- package/dist/commands/connector/import.js +49 -60
- package/dist/commands/connector/init.js +52 -66
- package/dist/commands/connector/init.unit.test.js +13 -19
- package/dist/commands/connector/test.js +31 -42
- package/dist/commands/deployment/create.js +38 -52
- package/dist/commands/deployment/create.unit.test.js +24 -28
- package/dist/commands/deployment/get.js +115 -129
- package/dist/commands/deployment/get.unit.test.js +35 -39
- package/dist/commands/permissions/add.js +137 -155
- package/dist/commands/permissions/add.unit.test.js +6 -15
- package/dist/commands/permissions/list.js +75 -89
- package/dist/commands/permissions/list.unit.test.js +20 -24
- package/dist/templates/connector-template.zip +0 -0
- package/oclif.manifest.json +1 -1
- package/package.json +7 -7
|
@@ -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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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', () =>
|
|
39
|
+
it('should list shared emails', async () => {
|
|
44
40
|
stdout_stderr_1.stdout.start();
|
|
45
|
-
|
|
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', () =>
|
|
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
|
-
|
|
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
|
});
|
|
Binary file
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
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.
|
|
23
|
-
"@trayio/cdk-build": "3.
|
|
24
|
-
"@trayio/commons": "3.
|
|
25
|
-
"@trayio/generator": "3.
|
|
26
|
-
"@trayio/tray-client": "3.
|
|
27
|
-
"@trayio/tray-openapi": "3.
|
|
22
|
+
"@trayio/axios": "3.9.0",
|
|
23
|
+
"@trayio/cdk-build": "3.9.0",
|
|
24
|
+
"@trayio/commons": "3.9.0",
|
|
25
|
+
"@trayio/generator": "3.9.0",
|
|
26
|
+
"@trayio/tray-client": "3.9.0",
|
|
27
|
+
"@trayio/tray-openapi": "3.9.0",
|
|
28
28
|
"@types/inquirer": "8.2.6",
|
|
29
29
|
"chalk": "4.1.2",
|
|
30
30
|
"inquirer": "8.2.5"
|