@contrail/cli 2.1.20 → 2.1.21
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 +311 -105
- package/dist/api/apps.js +15 -15
- package/dist/api/event-workflow-action-definition.d.ts +1 -1
- package/dist/api/event-workflow-action-definition.js +1 -1
- package/dist/api/event-workflow-template-definition.d.ts +4 -3
- package/dist/api/event-workflow-templates.d.ts +5 -4
- package/dist/api/event-workflow-templates.js +2 -2
- package/dist/api/types.d.ts +10 -10
- package/dist/api/users.js +4 -2
- package/dist/auth/login.js +12 -14
- package/dist/commands/app/create.d.ts +2 -2
- package/dist/commands/app/create.js +15 -10
- package/dist/commands/app/delete.d.ts +2 -2
- package/dist/commands/app/delete.js +4 -2
- package/dist/commands/app/getApiKey.d.ts +2 -2
- package/dist/commands/app/getApiKey.js +17 -11
- package/dist/commands/app/install.d.ts +2 -2
- package/dist/commands/app/install.js +42 -25
- package/dist/commands/app/publish.d.ts +2 -2
- package/dist/commands/app/publish.js +26 -11
- package/dist/commands/app/uninstall.d.ts +2 -2
- package/dist/commands/app/uninstall.js +20 -11
- package/dist/commands/app/upgrade.d.ts +2 -2
- package/dist/commands/app/upgrade.js +46 -23
- package/dist/commands/basecommand.d.ts +7 -0
- package/dist/commands/basecommand.js +29 -0
- package/dist/commands/colors/deleteAll.d.ts +2 -2
- package/dist/commands/colors/deleteAll.js +8 -5
- package/dist/commands/colors/load.d.ts +2 -2
- package/dist/commands/colors/load.js +10 -7
- package/dist/commands/config/list.d.ts +2 -2
- package/dist/commands/config/list.js +4 -2
- package/dist/commands/config/remove.d.ts +2 -2
- package/dist/commands/config/remove.js +4 -2
- package/dist/commands/config/set.d.ts +3 -2
- package/dist/commands/config/set.js +21 -7
- package/dist/commands/groups/export.d.ts +2 -2
- package/dist/commands/groups/export.js +20 -8
- package/dist/commands/groups/upload.d.ts +3 -3
- package/dist/commands/groups/upload.js +44 -32
- package/dist/commands/instance/export.d.ts +2 -2
- package/dist/commands/instance/export.js +15 -3
- package/dist/commands/instance/import.d.ts +2 -2
- package/dist/commands/instance/import.js +9 -2
- package/dist/commands/loader-process/load.d.ts +2 -2
- package/dist/commands/loader-process/load.js +13 -6
- package/dist/commands/loader-process/upload-and-load.d.ts +2 -2
- package/dist/commands/loader-process/upload-and-load.js +18 -7
- package/dist/commands/projects/export.d.ts +2 -2
- package/dist/commands/projects/export.js +4 -2
- package/dist/commands/projects/list.d.ts +2 -2
- package/dist/commands/projects/list.js +6 -4
- package/dist/commands/projects/load.d.ts +2 -2
- package/dist/commands/projects/load.js +16 -8
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +2 -2
- package/dist/commands/types/exportOptionSetHierarchies.js +15 -12
- package/dist/commands/types/getAll.d.ts +2 -2
- package/dist/commands/types/getAll.js +107 -76
- package/dist/commands/types/loadAll.d.ts +2 -2
- package/dist/commands/types/loadAll.js +12 -4
- package/dist/commands/types/mergeOptionSets.d.ts +2 -2
- package/dist/commands/types/mergeOptionSets.js +13 -10
- package/dist/commands/types/mergeTypeProperties.d.ts +2 -2
- package/dist/commands/types/mergeTypeProperties.js +12 -9
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +19 -15
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +10 -0
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.js +102 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsLocalFiles.js +21 -21
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsToFolderStructure.js +17 -18
- package/dist/commands/types/parseTypesFromFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromFiles.js +14 -8
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromLocalFiles.js +10 -7
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +11 -8
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +11 -8
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +2 -2
- package/dist/commands/types/uploadOptionSetHierarchies.js +44 -32
- package/dist/commands/types/uploadOptionSets.d.ts +2 -2
- package/dist/commands/types/uploadOptionSets.js +21 -13
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +2 -2
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.js +26 -19
- package/dist/commands/types/uploadRuleSets.d.ts +2 -2
- package/dist/commands/types/uploadRuleSets.js +34 -26
- package/dist/commands/types/uploadTypePolicies.d.ts +2 -2
- package/dist/commands/types/uploadTypePolicies.js +37 -29
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +2 -2
- package/dist/commands/types/uploadTypePropertyPolicies.js +38 -30
- package/dist/commands/types/uploadTypes.d.ts +2 -2
- package/dist/commands/types/uploadTypes.js +10 -4
- package/dist/commands/types/uploadUsageInfo.d.ts +2 -2
- package/dist/commands/types/uploadUsageInfo.js +32 -24
- package/dist/commands/users/export.d.ts +2 -2
- package/dist/commands/users/export.js +15 -4
- package/dist/commands/users/upload.d.ts +2 -2
- package/dist/commands/users/upload.js +6 -4
- package/dist/commands/webhooks/create.d.ts +2 -2
- package/dist/commands/webhooks/create.js +8 -6
- package/dist/commands/webhooks/delete.d.ts +2 -2
- package/dist/commands/webhooks/delete.js +8 -5
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +2 -2
- package/dist/commands/webhooks/getWebhookTrigger.js +10 -9
- package/dist/commands/webhooks/list.d.ts +2 -2
- package/dist/commands/webhooks/list.js +8 -6
- package/dist/commands/workflow-template-definitions/install.d.ts +2 -2
- package/dist/commands/workflow-template-definitions/install.js +4 -2
- package/dist/commands/workflow-template-definitions/list.d.ts +2 -2
- package/dist/commands/workflow-template-definitions/list.js +4 -2
- package/dist/commands/workflow-templates/delete.d.ts +2 -2
- package/dist/commands/workflow-templates/delete.js +4 -2
- package/dist/commands/workflow-templates/export.d.ts +2 -2
- package/dist/commands/workflow-templates/export.js +19 -17
- package/dist/commands/workflow-templates/list.d.ts +2 -2
- package/dist/commands/workflow-templates/list.js +4 -2
- package/dist/commands/workflow-templates/load.d.ts +2 -2
- package/dist/commands/workflow-templates/load.js +8 -3
- package/dist/common.d.ts +4 -1
- package/dist/common.js +10 -1
- package/dist/helpers/app/actions-deployer.d.ts +2 -2
- package/dist/helpers/app/actions-deployer.js +12 -7
- package/dist/helpers/app/app-deployer.d.ts +1 -1
- package/dist/helpers/app/app-deployer.js +70 -52
- package/dist/helpers/app/app-template-parsers.js +3 -1
- package/dist/helpers/app/load-app-config.d.ts +2 -1
- package/dist/helpers/app/load-app-config.js +2 -2
- package/dist/helpers/app/setup-template.js +4 -3
- package/dist/helpers/colors/helpers.d.ts +10 -2
- package/dist/helpers/colors/helpers.js +11 -10
- package/dist/helpers/config/config.js +15 -10
- package/dist/helpers/file-helpers.js +7 -4
- package/dist/helpers/loader-process/helpers.js +14 -13
- package/dist/helpers/projects/helpers.d.ts +2 -1
- package/dist/helpers/projects/helpers.js +16 -15
- package/dist/helpers/types/csv-parser.js +17 -14
- package/dist/helpers/types/type-extractor.d.ts +1 -1
- package/dist/helpers/types/type-extractor.js +3 -2
- package/dist/helpers/types/type-parser.js +22 -21
- package/dist/helpers/types/type-uploader.js +19 -15
- package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.d.ts +1 -1
- package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.js +46 -28
- package/dist/helpers/workflow-templates/helper.d.ts +3 -3
- package/dist/helpers/workflow-templates/helper.js +33 -23
- package/dist/interface-converters.spec.js +15 -15
- package/dist/interfaces.d.ts +6 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.js +32 -0
- package/dist/templates/typescript/src/actions/logItem.ts +9 -4
- package/dist/templates/typescript/src/main.ts +13 -8
- package/oclif.manifest.json +861 -31
- package/package.json +10 -7
package/dist/api/apps.js
CHANGED
|
@@ -7,8 +7,8 @@ async function getWorkflowTemplateDefinitionsForAppVersion(options) {
|
|
|
7
7
|
return await new sdk_1.Entities().get({
|
|
8
8
|
entityName: 'event-workflow-template-definition',
|
|
9
9
|
criteria: {
|
|
10
|
-
ownerKey: `appVersion:${options.appVersionId}
|
|
11
|
-
}
|
|
10
|
+
ownerKey: `appVersion:${options.appVersionId}`,
|
|
11
|
+
},
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
exports.getWorkflowTemplateDefinitionsForAppVersion = getWorkflowTemplateDefinitionsForAppVersion;
|
|
@@ -16,8 +16,8 @@ async function getAppVersions(app) {
|
|
|
16
16
|
return await new sdk_1.Entities().get({
|
|
17
17
|
entityName: 'app-version',
|
|
18
18
|
criteria: {
|
|
19
|
-
appId: app.id
|
|
20
|
-
}
|
|
19
|
+
appId: app.id,
|
|
20
|
+
},
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
exports.getAppVersions = getAppVersions;
|
|
@@ -26,22 +26,22 @@ async function upgradeAppVersion(appOrg, appVersionId) {
|
|
|
26
26
|
entityName: 'app-org',
|
|
27
27
|
id: appOrg.id,
|
|
28
28
|
object: {
|
|
29
|
-
appVersionId: appVersionId
|
|
30
|
-
}
|
|
29
|
+
appVersionId: appVersionId,
|
|
30
|
+
},
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
exports.upgradeAppVersion = upgradeAppVersion;
|
|
34
34
|
async function deleteAppOrg(appOrgId) {
|
|
35
35
|
return await new sdk_1.Entities().delete({
|
|
36
36
|
entityName: 'app-org',
|
|
37
|
-
id: appOrgId
|
|
37
|
+
id: appOrgId,
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
exports.deleteAppOrg = deleteAppOrg;
|
|
41
41
|
async function getInstalledApps() {
|
|
42
42
|
return await new sdk_1.Entities().get({
|
|
43
43
|
entityName: 'app-org',
|
|
44
|
-
relations: ['app', 'appApiKey']
|
|
44
|
+
relations: ['app', 'appApiKey'],
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
exports.getInstalledApps = getInstalledApps;
|
|
@@ -50,8 +50,8 @@ async function installAppToOrg(app, configProperties) {
|
|
|
50
50
|
entityName: 'app-org',
|
|
51
51
|
object: {
|
|
52
52
|
appId: app.id,
|
|
53
|
-
appConfig: configProperties
|
|
54
|
-
}
|
|
53
|
+
appConfig: configProperties,
|
|
54
|
+
},
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
exports.installAppToOrg = installAppToOrg;
|
|
@@ -59,23 +59,23 @@ async function getAvailableApps(options) {
|
|
|
59
59
|
var _a;
|
|
60
60
|
const orgId = (_a = options === null || options === void 0 ? void 0 : options.orgId) !== null && _a !== void 0 ? _a : auth_1.Auth.config.orgId;
|
|
61
61
|
const apps = [];
|
|
62
|
-
apps.push(...await new sdk_1.Entities().get({
|
|
62
|
+
apps.push(...(await new sdk_1.Entities().get({
|
|
63
63
|
entityName: 'app',
|
|
64
64
|
criteria: {
|
|
65
65
|
orgId,
|
|
66
66
|
private: true,
|
|
67
67
|
...options,
|
|
68
68
|
},
|
|
69
|
-
}));
|
|
70
|
-
apps.push(...await new sdk_1.Entities().get({
|
|
69
|
+
})));
|
|
70
|
+
apps.push(...(await new sdk_1.Entities().get({
|
|
71
71
|
entityName: 'app',
|
|
72
72
|
criteria: {
|
|
73
73
|
orgId,
|
|
74
74
|
private: false,
|
|
75
75
|
hidden: true,
|
|
76
|
-
...options
|
|
76
|
+
...options,
|
|
77
77
|
},
|
|
78
|
-
}));
|
|
78
|
+
})));
|
|
79
79
|
return apps;
|
|
80
80
|
}
|
|
81
81
|
exports.getAvailableApps = getAvailableApps;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { EventWorkflowActionDefinition } from '../interfaces';
|
|
2
|
-
export declare function getEventWorkflowActionDefinition(criteria: any): Promise<
|
|
2
|
+
export declare function getEventWorkflowActionDefinition(criteria: any): Promise<EventWorkflowActionDefinition[]>;
|
|
3
3
|
export declare function getEventWorkflowActionDefinitionById(id: string): Promise<EventWorkflowActionDefinition>;
|
|
@@ -5,7 +5,7 @@ const sdk_1 = require("@contrail/sdk");
|
|
|
5
5
|
async function getEventWorkflowActionDefinition(criteria) {
|
|
6
6
|
return await new sdk_1.Entities().get({
|
|
7
7
|
entityName: 'event-workflow-action-definition',
|
|
8
|
-
criteria
|
|
8
|
+
criteria,
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
exports.getEventWorkflowActionDefinition = getEventWorkflowActionDefinition;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { WorkflowDefinition } from '../interfaces';
|
|
2
|
+
export declare function createWorkflowTemplateDefinition(object: any): Promise<WorkflowDefinition>;
|
|
2
3
|
export declare function updateWorkflowTemplateDefinition(options: {
|
|
3
4
|
id: string;
|
|
4
5
|
updates: any;
|
|
5
|
-
}): Promise<
|
|
6
|
-
export declare function deleteWorkflowTemplateDefinition(templateId: string): Promise<
|
|
6
|
+
}): Promise<WorkflowDefinition>;
|
|
7
|
+
export declare function deleteWorkflowTemplateDefinition(templateId: string): Promise<void>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
1
|
+
import { WorkflowTemplate } from '../interfaces';
|
|
2
|
+
export declare function getExistingWorkflowTemplates(): Promise<WorkflowTemplate[]>;
|
|
3
|
+
export declare function createWorkflowTemplate(object: any): Promise<WorkflowTemplate>;
|
|
4
|
+
export declare function deleteWorkflowTemplate(id: string): Promise<void>;
|
|
4
5
|
export declare function updateWorkflowTemplate(options: {
|
|
5
6
|
id: string;
|
|
6
7
|
updates: any;
|
|
7
|
-
}): Promise<
|
|
8
|
+
}): Promise<WorkflowTemplate>;
|
|
@@ -4,14 +4,14 @@ exports.updateWorkflowTemplate = exports.deleteWorkflowTemplate = exports.create
|
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
5
|
async function getExistingWorkflowTemplates() {
|
|
6
6
|
return await new sdk_1.Entities().get({
|
|
7
|
-
entityName: 'event-workflow-template'
|
|
7
|
+
entityName: 'event-workflow-template',
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
exports.getExistingWorkflowTemplates = getExistingWorkflowTemplates;
|
|
11
11
|
async function createWorkflowTemplate(object) {
|
|
12
12
|
return await new sdk_1.Entities().create({
|
|
13
13
|
entityName: 'event-workflow-template',
|
|
14
|
-
object
|
|
14
|
+
object,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
exports.createWorkflowTemplate = createWorkflowTemplate;
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare function getOptionSets(): Promise<any>;
|
|
2
|
-
export declare function getOptionSetHierarchies(): Promise<any>;
|
|
3
|
-
export declare function getOptionSetHierarchyLinks(): Promise<any>;
|
|
4
|
-
export declare function getRuleSets(): Promise<any>;
|
|
5
|
-
export declare function getRuleSetLinks(): Promise<any>;
|
|
6
|
-
export declare function getUsageInfo(): Promise<any>;
|
|
7
|
-
export declare function getTypePropertyPolicies(): Promise<any>;
|
|
8
|
-
export declare function getTypePropertyPolicyLinks(): Promise<any>;
|
|
9
|
-
export declare function getTypePolicies(): Promise<any>;
|
|
10
|
-
export declare function getTypePolicyLinks(): Promise<any>;
|
|
1
|
+
export declare function getOptionSets(): Promise<any[]>;
|
|
2
|
+
export declare function getOptionSetHierarchies(): Promise<any[]>;
|
|
3
|
+
export declare function getOptionSetHierarchyLinks(): Promise<any[]>;
|
|
4
|
+
export declare function getRuleSets(): Promise<any[]>;
|
|
5
|
+
export declare function getRuleSetLinks(): Promise<any[]>;
|
|
6
|
+
export declare function getUsageInfo(): Promise<any[]>;
|
|
7
|
+
export declare function getTypePropertyPolicies(): Promise<any[]>;
|
|
8
|
+
export declare function getTypePropertyPolicyLinks(): Promise<any[]>;
|
|
9
|
+
export declare function getTypePolicies(): Promise<any[]>;
|
|
10
|
+
export declare function getTypePolicyLinks(): Promise<any[]>;
|
package/dist/api/users.js
CHANGED
|
@@ -4,13 +4,15 @@ exports.getGroups = exports.getUserOrgs = void 0;
|
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
5
|
async function getUserOrgs(options) {
|
|
6
6
|
return new sdk_1.Entities().get({
|
|
7
|
-
entityName: 'user-org',
|
|
7
|
+
entityName: 'user-org',
|
|
8
|
+
...options,
|
|
8
9
|
});
|
|
9
10
|
}
|
|
10
11
|
exports.getUserOrgs = getUserOrgs;
|
|
11
12
|
async function getGroups(options) {
|
|
12
13
|
return new sdk_1.Entities().get({
|
|
13
|
-
entityName: 'group',
|
|
14
|
+
entityName: 'group',
|
|
15
|
+
...options,
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
exports.getGroups = getGroups;
|
package/dist/auth/login.js
CHANGED
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentUser = exports.authUser = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const amazon_cognito_identity_js_1 = require("amazon-cognito-identity-js");
|
|
6
6
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
7
|
const sdk_1 = require("@contrail/sdk");
|
|
8
8
|
const auth_1 = require("./auth");
|
|
9
9
|
const config_1 = require("../helpers/config/config");
|
|
10
|
+
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
10
11
|
const CONFIGURATION = {
|
|
11
12
|
userPoolId: 'us-east-1_qIaNZdUfm',
|
|
12
13
|
clientId: process.env.CONTRAIL_COGNITO_CLIENT_ID || '7knkt34gfacbgd0ghnuspefdfg',
|
|
13
14
|
};
|
|
14
15
|
async function authUser() {
|
|
15
|
-
|
|
16
|
+
logger_1.default.debug('authorizing user...');
|
|
16
17
|
const config = await (0, config_1.getConfig)();
|
|
17
|
-
if (config &&
|
|
18
|
-
|
|
19
|
-
config.apiGateway &&
|
|
20
|
-
config.orgSlug) {
|
|
21
|
-
console.debug('populating auth config from fs config...');
|
|
18
|
+
if (config && config.apiUserToken && config.apiGateway && config.orgSlug) {
|
|
19
|
+
logger_1.default.debug('populating auth config from fs config...');
|
|
22
20
|
auth_1.Auth.config = {
|
|
23
21
|
apiUserToken: config.apiUserToken,
|
|
24
22
|
apiGateway: config.apiGateway,
|
|
@@ -29,7 +27,7 @@ async function authUser() {
|
|
|
29
27
|
return await refreshCurrentUserOrg();
|
|
30
28
|
}
|
|
31
29
|
catch (e) {
|
|
32
|
-
|
|
30
|
+
logger_1.default.info('Token expired. Requesting auth credentials...');
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
const questions = [];
|
|
@@ -70,17 +68,17 @@ async function authUser() {
|
|
|
70
68
|
UserPoolId: CONFIGURATION.userPoolId,
|
|
71
69
|
ClientId: CONFIGURATION.clientId,
|
|
72
70
|
};
|
|
73
|
-
const userPool = new
|
|
71
|
+
const userPool = new amazon_cognito_identity_js_1.CognitoUserPool(poolData);
|
|
74
72
|
const authData = {
|
|
75
73
|
Username: params.email,
|
|
76
74
|
Password: params.password,
|
|
77
75
|
};
|
|
78
|
-
const authDetails = new
|
|
76
|
+
const authDetails = new amazon_cognito_identity_js_1.AuthenticationDetails(authData);
|
|
79
77
|
const userData = {
|
|
80
78
|
Username: params.email,
|
|
81
79
|
Pool: userPool,
|
|
82
80
|
};
|
|
83
|
-
const cognitoUser = new
|
|
81
|
+
const cognitoUser = new amazon_cognito_identity_js_1.CognitoUser(userData);
|
|
84
82
|
return new Promise((resolve, reject) => {
|
|
85
83
|
cognitoUser.authenticateUser(authDetails, {
|
|
86
84
|
onSuccess: async (result) => {
|
|
@@ -98,7 +96,7 @@ exports.authUser = authUser;
|
|
|
98
96
|
async function setAuthContext(user, params) {
|
|
99
97
|
const config = await (0, config_1.getConfig)();
|
|
100
98
|
let apiGateway;
|
|
101
|
-
|
|
99
|
+
logger_1.default.info(config.environments);
|
|
102
100
|
if (config.environments) {
|
|
103
101
|
const questions = [];
|
|
104
102
|
questions.push({
|
|
@@ -135,12 +133,12 @@ async function getCurrentUser() {
|
|
|
135
133
|
}
|
|
136
134
|
exports.getCurrentUser = getCurrentUser;
|
|
137
135
|
async function refreshCurrentUserOrg() {
|
|
138
|
-
|
|
136
|
+
logger_1.default.debug('refreshing current user org...');
|
|
139
137
|
const currentUser = await getCurrentUser();
|
|
140
138
|
if (!currentUser) {
|
|
141
139
|
throw Error('Could not get current user');
|
|
142
140
|
}
|
|
143
|
-
const org = currentUser.orgs.find(o => o.orgSlug === auth_1.Auth.config.orgSlug);
|
|
141
|
+
const org = currentUser.orgs.find((o) => o.orgSlug === auth_1.Auth.config.orgSlug);
|
|
144
142
|
if (org) {
|
|
145
143
|
auth_1.Auth.config.orgId = org.orgId || org.id;
|
|
146
144
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class CreateApp extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class CreateApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
run(): Promise<void>;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
4
|
const setup_template_1 = require("../../helpers/app/setup-template");
|
|
6
5
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
6
|
const login_1 = require("../../auth/login");
|
|
8
7
|
const sdk_1 = require("@contrail/sdk");
|
|
9
8
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
|
-
|
|
9
|
+
const basecommand_1 = require("../basecommand");
|
|
10
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
11
|
+
class CreateApp extends basecommand_1.BaseCommand {
|
|
11
12
|
async run() {
|
|
13
|
+
const { flags } = await this.parse(CreateApp);
|
|
14
|
+
await super.setLogLevel(flags.logLevel);
|
|
12
15
|
await (0, login_1.authUser)();
|
|
13
16
|
const currentUser = await (0, login_1.getCurrentUser)();
|
|
14
17
|
const username = currentUser.email.split('@')[0];
|
|
@@ -16,34 +19,36 @@ class CreateApp extends core_1.Command {
|
|
|
16
19
|
const defaultAppIdentifier = `@${username}/hello-world`;
|
|
17
20
|
const defaultAppDescription = `Hello world app by ${currentUser.email}`;
|
|
18
21
|
const defaultAppPublisher = `${currentUser.email}`;
|
|
19
|
-
const answers = await inquirer_1.default.prompt([
|
|
22
|
+
const answers = await inquirer_1.default.prompt([
|
|
23
|
+
{
|
|
20
24
|
type: 'input',
|
|
21
25
|
name: 'appName',
|
|
22
26
|
message: 'What is the Name of your app?',
|
|
23
27
|
default: defaultAppName,
|
|
24
|
-
required: true
|
|
28
|
+
required: true,
|
|
25
29
|
},
|
|
26
30
|
{
|
|
27
31
|
type: 'input',
|
|
28
32
|
name: 'appIdentifier',
|
|
29
33
|
message: 'App Identifier (must be unique):',
|
|
30
34
|
default: defaultAppIdentifier,
|
|
31
|
-
required: true
|
|
35
|
+
required: true,
|
|
32
36
|
},
|
|
33
37
|
{
|
|
34
38
|
type: 'input',
|
|
35
39
|
name: 'appDescription',
|
|
36
40
|
message: 'App description:',
|
|
37
41
|
default: defaultAppDescription,
|
|
38
|
-
required: true
|
|
42
|
+
required: true,
|
|
39
43
|
},
|
|
40
44
|
{
|
|
41
45
|
type: 'input',
|
|
42
46
|
name: 'appPublisher',
|
|
43
47
|
message: 'App Publisher:',
|
|
44
48
|
default: defaultAppPublisher,
|
|
45
|
-
required: true
|
|
46
|
-
}
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
47
52
|
let sanitizedIdentifier = answers.appIdentifier;
|
|
48
53
|
if (!sanitizedIdentifier.startsWith('@')) {
|
|
49
54
|
sanitizedIdentifier = `@${sanitizedIdentifier}`;
|
|
@@ -61,13 +66,13 @@ class CreateApp extends core_1.Command {
|
|
|
61
66
|
await new sdk_1.Entities().create({ entityName: 'app', object: newApp });
|
|
62
67
|
}
|
|
63
68
|
catch (e) {
|
|
64
|
-
|
|
69
|
+
logger_1.default.error(`%s Failed to create new app: ${answers.appIdentifier}`, chalk_1.default.red.bold('APP'));
|
|
65
70
|
this.exit(1);
|
|
66
71
|
}
|
|
67
72
|
await (0, setup_template_1.setUpTemplate)({
|
|
68
73
|
appName: answers.appName,
|
|
69
74
|
appIdentifier: sanitizedIdentifier,
|
|
70
|
-
appDescription: answers.appDescription
|
|
75
|
+
appDescription: answers.appDescription,
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DeleteApp extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class DeleteApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static strict: boolean;
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
5
|
const login_1 = require("../../auth/login");
|
|
6
|
-
const core_1 = require("@oclif/core");
|
|
7
6
|
const load_app_config_1 = require("../../helpers/app/load-app-config");
|
|
8
7
|
const app_deployer_1 = require("../../helpers/app/app-deployer");
|
|
9
|
-
|
|
8
|
+
const basecommand_1 = require("../basecommand");
|
|
9
|
+
class DeleteApp extends basecommand_1.BaseCommand {
|
|
10
10
|
async run() {
|
|
11
|
+
const { flags } = await this.parse(DeleteApp);
|
|
12
|
+
await super.setLogLevel(flags.logLevel);
|
|
11
13
|
let appDeclaration;
|
|
12
14
|
try {
|
|
13
15
|
appDeclaration = (0, load_app_config_1.loadAppConfig)();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class GetAPIKeyApp extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class GetAPIKeyApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -5,32 +5,38 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const apps_1 = require("../../api/apps");
|
|
6
6
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
7
|
const login_1 = require("../../auth/login");
|
|
8
|
-
|
|
8
|
+
const basecommand_1 = require("../basecommand");
|
|
9
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
10
|
+
class GetAPIKeyApp extends basecommand_1.BaseCommand {
|
|
9
11
|
async run() {
|
|
10
12
|
const { flags } = await this.parse(GetAPIKeyApp);
|
|
13
|
+
await super.setLogLevel(flags.logLevel);
|
|
11
14
|
await (0, login_1.authUser)();
|
|
12
15
|
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
13
16
|
if (!flags.appIdentifier) {
|
|
14
|
-
const questions = [
|
|
17
|
+
const questions = [
|
|
18
|
+
{
|
|
15
19
|
type: 'list',
|
|
16
20
|
name: 'appApiKey',
|
|
17
21
|
message: 'For which app would you like to retrieve the API key?',
|
|
18
|
-
choices: installedApps.map(x => {
|
|
22
|
+
choices: installedApps.map((x) => {
|
|
19
23
|
return {
|
|
20
|
-
name: x.app.name,
|
|
24
|
+
name: x.app.name,
|
|
25
|
+
value: x.apiKey.apiKey,
|
|
21
26
|
};
|
|
22
|
-
})
|
|
23
|
-
}
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
];
|
|
24
30
|
const answers = await inquirer_1.default.prompt(questions);
|
|
25
|
-
|
|
31
|
+
logger_1.default.info(`App API key: (app:${answers.appApiKey})`);
|
|
26
32
|
}
|
|
27
33
|
else {
|
|
28
|
-
const appFound = installedApps.find(x => x.app.identifier === flags.appIdentifier);
|
|
34
|
+
const appFound = installedApps.find((x) => x.app.identifier === flags.appIdentifier);
|
|
29
35
|
if (!appFound) {
|
|
30
|
-
|
|
36
|
+
logger_1.default.info('You do not have such an app installed');
|
|
31
37
|
return;
|
|
32
38
|
}
|
|
33
|
-
|
|
39
|
+
logger_1.default.info(`App API key: (app:${appFound.apiKey.apiKey})`);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
}
|
|
@@ -41,5 +47,5 @@ GetAPIKeyApp.examples = [
|
|
|
41
47
|
`,
|
|
42
48
|
];
|
|
43
49
|
GetAPIKeyApp.flags = {
|
|
44
|
-
appIdentifier: core_1.Flags.string({ char: 'a', description: 'The app identifier', required: false })
|
|
50
|
+
appIdentifier: core_1.Flags.string({ char: 'a', description: 'The app identifier', required: false }),
|
|
45
51
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class InstallApp extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class InstallApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static strict: boolean;
|
|
@@ -8,73 +8,79 @@ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
|
8
8
|
const sdk_1 = require("@contrail/sdk");
|
|
9
9
|
const apps_1 = require("../../api/apps");
|
|
10
10
|
const workflow_template_definition_deployer_1 = require("../../helpers/workflow-template-definitions/workflow-template-definition-deployer");
|
|
11
|
-
|
|
11
|
+
const basecommand_1 = require("../basecommand");
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
13
|
+
const common_1 = require("../../common");
|
|
14
|
+
class InstallApp extends basecommand_1.BaseCommand {
|
|
12
15
|
async run() {
|
|
13
16
|
const { flags } = await this.parse(InstallApp);
|
|
17
|
+
await super.setLogLevel(flags.logLevel);
|
|
14
18
|
await (0, login_1.authUser)();
|
|
15
19
|
const apps = await (0, apps_1.getAvailableApps)({ hidden: flags.showHidden });
|
|
16
20
|
if (!apps.length) {
|
|
17
21
|
throw new Error('No apps are available to install...');
|
|
18
22
|
}
|
|
19
23
|
const installedApps = await (0, apps_1.getInstalledApps)();
|
|
20
|
-
const installedAppsIds = installedApps.map(x => x.app.id);
|
|
21
|
-
const installableApps = apps.filter(x => !installedAppsIds.includes(x.id));
|
|
24
|
+
const installedAppsIds = installedApps.map((x) => x.app.id);
|
|
25
|
+
const installableApps = apps.filter((x) => !installedAppsIds.includes(x.id));
|
|
22
26
|
if (!flags.appIdentifier) {
|
|
23
|
-
|
|
27
|
+
logger_1.default.info(chalk_1.default.yellow.bold('Installed Apps:'));
|
|
24
28
|
for (const appOrg of installedApps) {
|
|
25
|
-
|
|
29
|
+
logger_1.default.info(chalk_1.default.yellow.bold(`${appOrg.app.name}: ${appOrg.app.identifier}`));
|
|
26
30
|
}
|
|
27
31
|
const questions = [];
|
|
28
32
|
questions.push({
|
|
29
33
|
type: 'list',
|
|
30
34
|
name: 'appIdentifier',
|
|
31
35
|
message: 'Which app would you like to install?',
|
|
32
|
-
choices: installableApps.map(x => x.identifier)
|
|
36
|
+
choices: installableApps.map((x) => x.identifier),
|
|
33
37
|
});
|
|
34
38
|
const answers = await inquirer_1.default.prompt(questions);
|
|
35
39
|
flags.appIdentifier = answers.appIdentifier;
|
|
36
40
|
}
|
|
37
|
-
const app = installableApps.find(x => x.identifier === flags.appIdentifier);
|
|
41
|
+
const app = installableApps.find((x) => x.identifier === flags.appIdentifier);
|
|
38
42
|
if (!app) {
|
|
39
|
-
|
|
43
|
+
logger_1.default.error(chalk_1.default.red.bold(`App ${flags.appIdentifier} not found`));
|
|
40
44
|
throw new Error(`App ${flags.appIdentifier} not found`);
|
|
41
45
|
}
|
|
42
46
|
let configProperties;
|
|
43
47
|
if (app.configProperties) {
|
|
44
48
|
configProperties = await getConfigProperties(app);
|
|
45
49
|
}
|
|
46
|
-
|
|
50
|
+
logger_1.default.info('%s Installing apps', chalk_1.default.green.bold('APP INSTALLATION'));
|
|
47
51
|
const appOrg = await (0, apps_1.installAppToOrg)(app, configProperties);
|
|
48
52
|
// eslint-disable-next-line no-constant-condition
|
|
49
53
|
while (true) {
|
|
50
|
-
await delay(1000);
|
|
54
|
+
await (0, common_1.delay)(1000);
|
|
51
55
|
try {
|
|
52
56
|
const installingApp = await new sdk_1.Entities().get({ entityName: 'app-org', id: appOrg.id });
|
|
53
57
|
if (installingApp.status === 'READY') {
|
|
54
|
-
|
|
58
|
+
logger_1.default.info('%s App installed', chalk_1.default.green.bold('APP INSTALLATION'));
|
|
55
59
|
break;
|
|
56
60
|
}
|
|
57
61
|
if (installingApp.status === 'FAILED_INSTALLING') {
|
|
58
|
-
|
|
62
|
+
logger_1.default.info('%s App installation failed', chalk_1.default.red.bold('APP INSTALLATION'));
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
process.stdout.write('.');
|
|
62
66
|
}
|
|
63
67
|
catch (e) {
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
logger_1.default.info('%s App installation failed', chalk_1.default.red.bold('APP INSTALLATION'));
|
|
69
|
+
logger_1.default.info('Error is:', e);
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
if (!flags.installWorkflowTemplates) {
|
|
70
|
-
const answers = await inquirer_1.default.prompt([
|
|
74
|
+
const answers = await inquirer_1.default.prompt([
|
|
75
|
+
{
|
|
71
76
|
type: 'confirm',
|
|
72
77
|
name: 'shouldInstallWorkflows',
|
|
73
78
|
message: 'Would you like to install the Workflows associated with this app?',
|
|
74
|
-
default: false
|
|
75
|
-
}
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
76
82
|
if (!answers.shouldInstallWorkflows) {
|
|
77
|
-
|
|
83
|
+
logger_1.default.info('%s Not installing associated app workflows', chalk_1.default.yellow.bold('APP INSTALLATION'));
|
|
78
84
|
flags.installWorkflowTemplates = false;
|
|
79
85
|
}
|
|
80
86
|
else {
|
|
@@ -82,7 +88,9 @@ class InstallApp extends core_1.Command {
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
if (flags.installWorkflowTemplates) {
|
|
85
|
-
const workflowTemplateDefinitions = await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({
|
|
91
|
+
const workflowTemplateDefinitions = await (0, apps_1.getWorkflowTemplateDefinitionsForAppVersion)({
|
|
92
|
+
appVersionId: appOrg.appVersionId,
|
|
93
|
+
});
|
|
86
94
|
if (!workflowTemplateDefinitions.length) {
|
|
87
95
|
return;
|
|
88
96
|
}
|
|
@@ -99,9 +107,21 @@ InstallApp.examples = [
|
|
|
99
107
|
// variable argument length
|
|
100
108
|
InstallApp.strict = true;
|
|
101
109
|
InstallApp.flags = {
|
|
102
|
-
appIdentifier: core_1.Flags.string({
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
appIdentifier: core_1.Flags.string({
|
|
111
|
+
char: 'i',
|
|
112
|
+
description: 'The identifier of the app to install',
|
|
113
|
+
required: false,
|
|
114
|
+
}),
|
|
115
|
+
installWorkflowTemplates: core_1.Flags.boolean({
|
|
116
|
+
char: 'w',
|
|
117
|
+
description: '"Install the app\'s accompanying workflows"',
|
|
118
|
+
required: false,
|
|
119
|
+
}),
|
|
120
|
+
showHidden: core_1.Flags.boolean({
|
|
121
|
+
char: 'h',
|
|
122
|
+
description: 'Show the option to install public but hidden apps',
|
|
123
|
+
required: false,
|
|
124
|
+
}),
|
|
105
125
|
};
|
|
106
126
|
async function getConfigProperties(app) {
|
|
107
127
|
const config = {};
|
|
@@ -120,6 +140,3 @@ async function getConfigProperties(app) {
|
|
|
120
140
|
}
|
|
121
141
|
return config;
|
|
122
142
|
}
|
|
123
|
-
function delay(ms) {
|
|
124
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
125
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class PublishApp extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class PublishApp extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static strict: boolean;
|