1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const inquirer = require("inquirer");
|
4 | const base_1 = require("./base");
|
5 | class LinkAction extends base_1.default {
|
6 | async run(anIdentifier) {
|
7 | let identifier = anIdentifier;
|
8 | let { integrationTitle } = this.logger.bearerConfig;
|
9 | if (!identifier) {
|
10 | const { data } = await this.logger.devPortalClient.request({ query: QUERY });
|
11 | if (!data.data) {
|
12 | throw 'Unable to fetch integration list';
|
13 | }
|
14 | const { integrations } = data.data;
|
15 | const { integration } = await inquirer.prompt([
|
16 | {
|
17 | name: 'integration',
|
18 | type: 'list',
|
19 | choices: integrations.map(int => ({
|
20 | name: `${int.uuid} - ${int.name}`,
|
21 | value: int
|
22 | }))
|
23 | }
|
24 | ]);
|
25 | integrationTitle = integration.name;
|
26 | identifier = integration.uuid;
|
27 | }
|
28 | const integrationRc = { integrationTitle, integrationId: identifier };
|
29 | this.logger.bearerConfig.setIntegrationConfig(integrationRc);
|
30 | this.logger.log('Integration successfully linked! 🎉');
|
31 | }
|
32 | }
|
33 | exports.default = base_1.createExport(LinkAction);
|
34 | const QUERY = `
|
35 | query CLILinkIntegrationList {
|
36 | integrations(includeGloballyAvailable: false) {
|
37 | uuid: uuidv2
|
38 | name
|
39 | latestActivity {
|
40 | state
|
41 | }
|
42 | }
|
43 | }
|
44 | `;
|