@contrail/cli 1.0.28 → 1.0.30
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/lib/apps/deploy-app/actions-deployer.d.ts +1 -0
- package/lib/apps/deploy-app/actions-deployer.js +7 -4
- package/lib/apps/deploy-app/app-deployer.js +6 -1
- package/lib/apps/deploy-app/docker-action-builder.d.ts +10 -0
- package/lib/apps/deploy-app/docker-action-builder.js +97 -0
- package/lib/apps/deploy-app/interfaces.d.ts +76 -0
- package/lib/apps/deploy-app/interfaces.js +4 -0
- package/lib/apps/deploy-app/workflow-deployer.d.ts +10 -0
- package/lib/apps/deploy-app/workflow-deployer.js +87 -0
- package/lib/interfaces.d.ts +1 -0
- package/package.json +3 -3
- package/src/apps/deploy-app/actions-deployer.ts +8 -4
- package/src/apps/deploy-app/app-deployer.ts +7 -1
- package/src/auth/login.ts +1 -1
- package/src/interfaces.ts +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { App, AppDeclaration, AppActionDeclaration } from '../../interfaces';
|
|
2
2
|
export declare function getActionsForApp(app: App): Promise<any>;
|
|
3
3
|
export declare function getActionDeclarationIdentifier(actionKey: any, app: App): string;
|
|
4
|
+
export declare function deleteAction(actionId: any): Promise<any>;
|
|
4
5
|
export declare class ActionsDeployer {
|
|
5
6
|
deployActions(appDeclaration: AppDeclaration, app: App): Promise<void>;
|
|
6
7
|
deployAction(actionKey: string, actionDeclaration: AppActionDeclaration, app: App, existingActions: Array<any>): Promise<void>;
|
|
@@ -12,6 +12,9 @@ export async function getActionsForApp(app) {
|
|
|
12
12
|
export function getActionDeclarationIdentifier(actionKey, app) {
|
|
13
13
|
return app.identifier + ':' + actionKey;
|
|
14
14
|
}
|
|
15
|
+
export async function deleteAction(actionId) {
|
|
16
|
+
return await new Entities().delete({ entityName: 'event-workflow-action-definition', id: actionId });
|
|
17
|
+
}
|
|
15
18
|
export class ActionsDeployer {
|
|
16
19
|
async deployActions(appDeclaration, app) {
|
|
17
20
|
// FETCH ALL ACTIONS FROM THE API.
|
|
@@ -35,7 +38,7 @@ export class ActionsDeployer {
|
|
|
35
38
|
await this.createNewActionDefinition(actionKey, actionDeclaration, app);
|
|
36
39
|
}
|
|
37
40
|
else {
|
|
38
|
-
await this.updateActionDefinition(existingDefinition, actionDeclaration);
|
|
41
|
+
await this.updateActionDefinition(existingDefinition, actionDeclaration, app);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
async createNewActionDefinition(actionKey, actionDeclaration, app) {
|
|
@@ -47,7 +50,7 @@ export class ActionsDeployer {
|
|
|
47
50
|
identifier: getActionDeclarationIdentifier(actionKey, app),
|
|
48
51
|
name: actionDeclaration.name,
|
|
49
52
|
ownerKey: `app:${app.id}`,
|
|
50
|
-
public: app.public,
|
|
53
|
+
public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
|
|
51
54
|
configProperties,
|
|
52
55
|
};
|
|
53
56
|
const functionString = await this.getFunction(actionDeclaration);
|
|
@@ -61,7 +64,7 @@ export class ActionsDeployer {
|
|
|
61
64
|
console.log(`%s Created new action definition: ${actionKey}`, chalk.yellow.bold('APP'));
|
|
62
65
|
return actionDefinition;
|
|
63
66
|
}
|
|
64
|
-
async updateActionDefinition(existingActionDefinition, actionDeclaration) {
|
|
67
|
+
async updateActionDefinition(existingActionDefinition, actionDeclaration, app) {
|
|
65
68
|
let configProperties;
|
|
66
69
|
if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
|
|
67
70
|
configProperties = ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
|
|
@@ -71,7 +74,7 @@ export class ActionsDeployer {
|
|
|
71
74
|
}
|
|
72
75
|
const updates = {
|
|
73
76
|
name: actionDeclaration.name,
|
|
74
|
-
|
|
77
|
+
public: 'public' in actionDeclaration ? actionDeclaration.public : app.public,
|
|
75
78
|
configProperties,
|
|
76
79
|
};
|
|
77
80
|
const functionString = await this.getFunction(actionDeclaration);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Entities } from '@contrail/sdk';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { Auth } from '../../auth/auth';
|
|
4
|
-
import { ActionsDeployer } from './actions-deployer';
|
|
4
|
+
import { ActionsDeployer, getActionsForApp, deleteAction } from './actions-deployer';
|
|
5
5
|
import { TriggerKeyDefinitionParser, ConfigPropertiesParser } from './app-template-parsers';
|
|
6
6
|
import { WorkflowDefinitionDeployer } from './workflow-definition-deployer';
|
|
7
7
|
export class AppDeployer {
|
|
@@ -92,6 +92,11 @@ export class AppDeployer {
|
|
|
92
92
|
async remove(appDeclaration) {
|
|
93
93
|
let app = await this.getExistingApp(appDeclaration);
|
|
94
94
|
if (app) {
|
|
95
|
+
const actions = await getActionsForApp(app);
|
|
96
|
+
for (const action of actions) {
|
|
97
|
+
console.log(`%s Deleting action: ${action.identifier}`, chalk.yellow.bold('APP'));
|
|
98
|
+
await deleteAction(action.id);
|
|
99
|
+
}
|
|
95
100
|
app = await new Entities().delete({ entityName: 'app', id: app.id });
|
|
96
101
|
console.log(`%s Deleted app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
97
102
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { App, AppDeclaration, AppActionDeclaration } from '../../interfaces';
|
|
2
|
+
export declare class ActionsDeployer {
|
|
3
|
+
deployActions(appDeclaration: AppDeclaration, app: App): Promise<void>;
|
|
4
|
+
getActionsForApp(app: App): Promise<any>;
|
|
5
|
+
deployAction(actionKey: string, actionDeclaration: AppActionDeclaration, app: App, existingActions: Array<any>): Promise<void>;
|
|
6
|
+
private createNewActionDefinition;
|
|
7
|
+
private updateActionDefinition;
|
|
8
|
+
getActionDeclarationIdentifier(actionKey: any, app: App): string;
|
|
9
|
+
getFunction(actionDeclaration: AppActionDeclaration): Promise<string>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Entities } from '@contrail/sdk';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { ConfigPropertiesParser } from './app-template-parsers';
|
|
4
|
+
import { getSeparatorByPlatform } from '../../common';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
export class ActionsDeployer {
|
|
7
|
+
async deployActions(appDeclaration, app) {
|
|
8
|
+
// FETCH ALL ACTIONS FROM THE API.
|
|
9
|
+
const existingActions = await this.getActionsForApp(app);
|
|
10
|
+
// UPSERT / DELETE BASED ON ACTION IDENTIFIER
|
|
11
|
+
console.log('%s \tDeploying actions.', chalk.yellow.bold('ACTION'));
|
|
12
|
+
for (const actionKey of Object.keys(appDeclaration.actions)) {
|
|
13
|
+
await this.deployAction(actionKey, appDeclaration.actions[actionKey], app, existingActions);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async getActionsForApp(app) {
|
|
17
|
+
return await new Entities().get({
|
|
18
|
+
entityName: 'event-workflow-action-definition',
|
|
19
|
+
criteria: { ownerKey: `app:${app.id}` },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async deployAction(actionKey, actionDeclaration, app, existingActions) {
|
|
23
|
+
console.log(`%s \tDeploying action: ${actionKey}`, chalk.yellow.bold('ACTION'));
|
|
24
|
+
const identifier = this.getActionDeclarationIdentifier(actionKey, app);
|
|
25
|
+
const existingDefinition = existingActions.find(ad => ad.identifier === identifier);
|
|
26
|
+
if (!existingDefinition) {
|
|
27
|
+
await this.createNewActionDefinition(actionKey, actionDeclaration, app);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
await this.updateActionDefinition(existingDefinition, actionDeclaration);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async createNewActionDefinition(actionKey, actionDeclaration, app) {
|
|
34
|
+
let configProperties;
|
|
35
|
+
if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
|
|
36
|
+
configProperties = ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
|
|
37
|
+
}
|
|
38
|
+
const newObject = {
|
|
39
|
+
identifier: this.getActionDeclarationIdentifier(actionKey, app),
|
|
40
|
+
name: actionDeclaration.name,
|
|
41
|
+
ownerKey: `app:${app.id}`,
|
|
42
|
+
public: app.public,
|
|
43
|
+
configProperties,
|
|
44
|
+
};
|
|
45
|
+
const functionString = await this.getFunction(actionDeclaration);
|
|
46
|
+
if (functionString) {
|
|
47
|
+
newObject.executeFunctionString = functionString;
|
|
48
|
+
}
|
|
49
|
+
const actionDefinition = await new Entities().create({
|
|
50
|
+
entityName: 'event-workflow-action-definition',
|
|
51
|
+
object: newObject,
|
|
52
|
+
});
|
|
53
|
+
console.log(`%s Created new action definition: ${actionKey}`, chalk.yellow.bold('APP'));
|
|
54
|
+
return actionDefinition;
|
|
55
|
+
}
|
|
56
|
+
async updateActionDefinition(existingActionDefinition, actionDeclaration) {
|
|
57
|
+
let configProperties;
|
|
58
|
+
if (actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) {
|
|
59
|
+
configProperties = ConfigPropertiesParser.getConfigProperties(actionDeclaration.actionConfiguration);
|
|
60
|
+
}
|
|
61
|
+
else if (!(actionDeclaration === null || actionDeclaration === void 0 ? void 0 : actionDeclaration.actionConfiguration) && existingActionDefinition.configProperties) {
|
|
62
|
+
configProperties = null;
|
|
63
|
+
}
|
|
64
|
+
const updates = {
|
|
65
|
+
name: actionDeclaration.name,
|
|
66
|
+
// public: actionDeclaration.public, // TODO - an actions visibility is allowed to change
|
|
67
|
+
configProperties,
|
|
68
|
+
};
|
|
69
|
+
const functionString = await this.getFunction(actionDeclaration);
|
|
70
|
+
if (functionString) {
|
|
71
|
+
updates.executeFunctionString = functionString;
|
|
72
|
+
}
|
|
73
|
+
const actionDefinition = await new Entities().update({
|
|
74
|
+
entityName: 'event-workflow-action-definition',
|
|
75
|
+
id: existingActionDefinition.id,
|
|
76
|
+
object: updates,
|
|
77
|
+
});
|
|
78
|
+
console.log(`%s Updated existing action definition: ${actionDefinition.identifier}`, chalk.yellow.bold('APP'));
|
|
79
|
+
return actionDefinition;
|
|
80
|
+
}
|
|
81
|
+
getActionDeclarationIdentifier(actionKey, app) {
|
|
82
|
+
return app.identifier + ':' + actionKey;
|
|
83
|
+
}
|
|
84
|
+
async getFunction(actionDeclaration) {
|
|
85
|
+
if (!actionDeclaration.handler) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!actionDeclaration.handler.endsWith('.js')) {
|
|
89
|
+
throw new Error('Action handler must be a .js file.');
|
|
90
|
+
}
|
|
91
|
+
const CURRENT_DIR = process.cwd();
|
|
92
|
+
const separator = getSeparatorByPlatform();
|
|
93
|
+
const functionLocation = CURRENT_DIR + separator + actionDeclaration.handler;
|
|
94
|
+
const content = fs.readFileSync(functionLocation);
|
|
95
|
+
return content.toString();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Describes the derivative JSON / object represented
|
|
2
|
+
* in app.yml file.
|
|
3
|
+
*/
|
|
4
|
+
export interface AppDeclaration {
|
|
5
|
+
appIdentifier: string;
|
|
6
|
+
appName: string;
|
|
7
|
+
appDescription?: string;
|
|
8
|
+
visibility: 'private' | 'public';
|
|
9
|
+
publisher: string;
|
|
10
|
+
version: string;
|
|
11
|
+
eventWorkflowTriggerKeyMapping: string;
|
|
12
|
+
thumbnail?: string;
|
|
13
|
+
keywords?: Array<string>;
|
|
14
|
+
actions?: {
|
|
15
|
+
[key: string]: AppActionDeclaration;
|
|
16
|
+
};
|
|
17
|
+
appConfiguration: ConfigPropertyElements;
|
|
18
|
+
triggers: {
|
|
19
|
+
[key: string]: AppTriggerDeclaration;
|
|
20
|
+
};
|
|
21
|
+
isDockerBased?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ConfigPropertyElements {
|
|
24
|
+
[key: string]: ConfigPropertyElement;
|
|
25
|
+
}
|
|
26
|
+
export interface ConfigPropertyElement {
|
|
27
|
+
propertyType: string;
|
|
28
|
+
options?: any[];
|
|
29
|
+
label: string;
|
|
30
|
+
}
|
|
31
|
+
export interface AppActionDeclaration {
|
|
32
|
+
handler: string;
|
|
33
|
+
name: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
actionConfiguration?: ConfigPropertyElements;
|
|
36
|
+
}
|
|
37
|
+
export interface AppTriggerDeclaration {
|
|
38
|
+
key: string;
|
|
39
|
+
name: string;
|
|
40
|
+
external?: boolean;
|
|
41
|
+
description?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface App {
|
|
44
|
+
id: string;
|
|
45
|
+
identifier: string;
|
|
46
|
+
name: string;
|
|
47
|
+
public: boolean;
|
|
48
|
+
description?: string;
|
|
49
|
+
publisher: string;
|
|
50
|
+
thumbnail: string;
|
|
51
|
+
eventWorkflowTriggerKeyMapping: string;
|
|
52
|
+
configProperties?: ConfigProperty[];
|
|
53
|
+
triggerKeyDefinitions?: TriggerKeyDefinition[];
|
|
54
|
+
}
|
|
55
|
+
export declare class ConfigProperty {
|
|
56
|
+
slug: string;
|
|
57
|
+
propertyType: string;
|
|
58
|
+
options?: any[];
|
|
59
|
+
label: string;
|
|
60
|
+
}
|
|
61
|
+
export interface EventWorkflowActionDefinition {
|
|
62
|
+
id?: string;
|
|
63
|
+
identifier?: string;
|
|
64
|
+
name?: string;
|
|
65
|
+
executeFunctionString?: string;
|
|
66
|
+
ownerKey?: string;
|
|
67
|
+
public?: boolean;
|
|
68
|
+
configProperties?: ConfigProperty[];
|
|
69
|
+
isDockerBased?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare class TriggerKeyDefinition {
|
|
72
|
+
name: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
triggerKey: string;
|
|
75
|
+
external?: boolean;
|
|
76
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { App, AppDeclaration, WorkflowTemplateDeclaration } from './interfaces';
|
|
2
|
+
export declare class WorkflowDeployer {
|
|
3
|
+
deployWorkflows(appDeclaration: AppDeclaration, app: App): Promise<void>;
|
|
4
|
+
getWorkflowsForApp(app: App): Promise<any>;
|
|
5
|
+
deployWorkflow(workflowKey: string, workflow: WorkflowTemplateDeclaration, app: App, existingWorkflows: Array<any>, appDeclaration: AppDeclaration): Promise<any>;
|
|
6
|
+
private createNewWorkflowDefinition;
|
|
7
|
+
private populateActionIds;
|
|
8
|
+
private updateWorkflowDefinition;
|
|
9
|
+
getWorkflowDeclarationIdentifier(actionKey: any, app: App): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Entities } from '@contrail/sdk';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { getActionDeclarationIdentifier, getActionsForApp } from './actions-deployer';
|
|
4
|
+
export class WorkflowDeployer {
|
|
5
|
+
async deployWorkflows(appDeclaration, app) {
|
|
6
|
+
// FETCH ALL WORKFLOWS FROM THE API.
|
|
7
|
+
const existingWorkflows = await this.getWorkflowsForApp(app);
|
|
8
|
+
// UPSERT / DELETE BASED ON WORKFLOW IDENTIFIER
|
|
9
|
+
console.log('%s \tDeploying workflows.', chalk.yellow.bold('WORKFLOW'));
|
|
10
|
+
for (const workflowKey of Object.keys(appDeclaration.workflows)) {
|
|
11
|
+
await this.deployWorkflow(workflowKey, appDeclaration.workflows[workflowKey], app, existingWorkflows, appDeclaration);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async getWorkflowsForApp(app) {
|
|
15
|
+
return await new Entities().get({
|
|
16
|
+
entityName: 'event-workflow-template',
|
|
17
|
+
criteria: { ownerKey: `app:${app.id}` },
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async deployWorkflow(workflowKey, workflow, app, existingWorkflows, appDeclaration) {
|
|
21
|
+
console.log(`%s \tDeploying workflow: ${workflowKey}`, chalk.yellow.bold('WORKFLOW'));
|
|
22
|
+
const identifier = this.getWorkflowDeclarationIdentifier(workflowKey, app);
|
|
23
|
+
const existingDefinition = existingWorkflows.find(ad => ad.identifier === identifier);
|
|
24
|
+
if (existingDefinition) {
|
|
25
|
+
return await this.updateWorkflowDefinition(existingDefinition, workflow, app, appDeclaration);
|
|
26
|
+
}
|
|
27
|
+
return await this.createNewWorkflowDefinition(workflowKey, workflow, app, appDeclaration);
|
|
28
|
+
}
|
|
29
|
+
async createNewWorkflowDefinition(workflowKey, workflowDeclaration, app, appDeclaration) {
|
|
30
|
+
await this.populateActionIds(workflowDeclaration, appDeclaration, app);
|
|
31
|
+
const newObject = {
|
|
32
|
+
identifier: this.getWorkflowDeclarationIdentifier(workflowKey, app),
|
|
33
|
+
name: workflowDeclaration.name,
|
|
34
|
+
ownerKey: `app:${app.id}`,
|
|
35
|
+
triggerKey: workflowDeclaration.triggerKey,
|
|
36
|
+
workflowDefinition: workflowDeclaration.workflowDefinition,
|
|
37
|
+
isActive: workflowDeclaration.isActive,
|
|
38
|
+
supportingAppId: workflowDeclaration.supportingAppId,
|
|
39
|
+
messageGroupId: workflowDeclaration.messageGroupId,
|
|
40
|
+
parallelWorkerCount: workflowDeclaration.parallelWorkerCount,
|
|
41
|
+
};
|
|
42
|
+
const workflowTemplate = await new Entities().create({
|
|
43
|
+
entityName: 'event-workflow-template',
|
|
44
|
+
object: newObject,
|
|
45
|
+
});
|
|
46
|
+
console.log(`%s Created new workflow definition: ${workflowKey}`, chalk.yellow.bold('WORKFLOW'));
|
|
47
|
+
return workflowTemplate;
|
|
48
|
+
}
|
|
49
|
+
async populateActionIds(workflowDeclaration, appDeclaration, app) {
|
|
50
|
+
var _a;
|
|
51
|
+
let availableAppActions = await getActionsForApp(app);
|
|
52
|
+
if (!((_a = workflowDeclaration.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
for (const path of workflowDeclaration.workflowDefinition.paths) {
|
|
56
|
+
if (!(path === null || path === void 0 ? void 0 : path.actionDefinitionConfigs)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
for (const actionConfiguration of path.actionDefinitionConfigs) {
|
|
60
|
+
const actionKey = actionConfiguration.action;
|
|
61
|
+
const action = availableAppActions.find(action => action.identifier === getActionDeclarationIdentifier(actionKey, app));
|
|
62
|
+
if (!action) {
|
|
63
|
+
throw new Error(`Could not find action ${actionKey} declared in ${workflowDeclaration.name}`);
|
|
64
|
+
}
|
|
65
|
+
actionConfiguration.id = action.id;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async updateWorkflowDefinition(existingWorkflowDefinition, workflowDeclaration, app, appDeclaration) {
|
|
70
|
+
await this.populateActionIds(workflowDeclaration, appDeclaration, app);
|
|
71
|
+
const updates = Object.assign(new Object(), {
|
|
72
|
+
name: workflowDeclaration.name,
|
|
73
|
+
triggerKey: workflowDeclaration.triggerKey,
|
|
74
|
+
workflowDefinition: workflowDeclaration.workflowDefinition
|
|
75
|
+
});
|
|
76
|
+
const updatedWorkflowDefinition = await new Entities().update({
|
|
77
|
+
entityName: 'event-workflow-template',
|
|
78
|
+
id: existingWorkflowDefinition.id,
|
|
79
|
+
object: updates,
|
|
80
|
+
});
|
|
81
|
+
console.log(`%s Updated existing workflow definition: ${updatedWorkflowDefinition.identifier}`, chalk.yellow.bold('WORKFLOW'));
|
|
82
|
+
return updatedWorkflowDefinition;
|
|
83
|
+
}
|
|
84
|
+
getWorkflowDeclarationIdentifier(actionKey, app) {
|
|
85
|
+
return app.identifier + ':' + actionKey;
|
|
86
|
+
}
|
|
87
|
+
}
|
package/lib/interfaces.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "VibeIQ's Contrail Platform CLI.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"@types/jest": "^23.3.14",
|
|
46
46
|
"@types/lodash": "^4.14.178",
|
|
47
47
|
"@types/node": "^14.6.4",
|
|
48
|
-
"jest": "^
|
|
48
|
+
"jest": "^29.3.1",
|
|
49
49
|
"prettier": "^1.19.1",
|
|
50
|
-
"ts-jest": "^
|
|
50
|
+
"ts-jest": "^29.0.3",
|
|
51
51
|
"tslint": "^5.11.0",
|
|
52
52
|
"tslint-config-prettier": "^1.18.0",
|
|
53
53
|
"typescript": "^3.0.1"
|
|
@@ -19,6 +19,10 @@ export function getActionDeclarationIdentifier(actionKey, app: App) {
|
|
|
19
19
|
return app.identifier + ':' + actionKey;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export async function deleteAction(actionId): Promise<any>{
|
|
23
|
+
return await new Entities().delete({ entityName: 'event-workflow-action-definition', id: actionId });
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
export class ActionsDeployer {
|
|
23
27
|
async deployActions(appDeclaration: AppDeclaration, app: App) {
|
|
24
28
|
|
|
@@ -46,7 +50,7 @@ export class ActionsDeployer {
|
|
|
46
50
|
if (!existingDefinition) {
|
|
47
51
|
await this.createNewActionDefinition(actionKey, actionDeclaration, app);
|
|
48
52
|
} else {
|
|
49
|
-
await this.updateActionDefinition(existingDefinition, actionDeclaration);
|
|
53
|
+
await this.updateActionDefinition(existingDefinition, actionDeclaration, app);
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -59,7 +63,7 @@ export class ActionsDeployer {
|
|
|
59
63
|
identifier: getActionDeclarationIdentifier(actionKey, app),
|
|
60
64
|
name: actionDeclaration.name,
|
|
61
65
|
ownerKey: `app:${app.id}`,
|
|
62
|
-
public:
|
|
66
|
+
public: 'public' in actionDeclaration? actionDeclaration.public: app.public,
|
|
63
67
|
configProperties,
|
|
64
68
|
};
|
|
65
69
|
|
|
@@ -78,7 +82,7 @@ export class ActionsDeployer {
|
|
|
78
82
|
return actionDefinition;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
private async updateActionDefinition(existingActionDefinition: EventWorkflowActionDefinition, actionDeclaration: AppActionDeclaration) {
|
|
85
|
+
private async updateActionDefinition(existingActionDefinition: EventWorkflowActionDefinition, actionDeclaration: AppActionDeclaration, app: App) {
|
|
82
86
|
|
|
83
87
|
let configProperties;
|
|
84
88
|
if (actionDeclaration?.actionConfiguration) {
|
|
@@ -90,7 +94,7 @@ export class ActionsDeployer {
|
|
|
90
94
|
|
|
91
95
|
const updates: EventWorkflowActionDefinition = {
|
|
92
96
|
name: actionDeclaration.name,
|
|
93
|
-
|
|
97
|
+
public: 'public' in actionDeclaration? actionDeclaration.public: app.public,
|
|
94
98
|
configProperties,
|
|
95
99
|
};
|
|
96
100
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Entities } from '@contrail/sdk';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { Auth } from '../../auth/auth';
|
|
4
|
-
import { ActionsDeployer } from './actions-deployer';
|
|
4
|
+
import { ActionsDeployer, getActionsForApp, deleteAction } from './actions-deployer';
|
|
5
5
|
import { App, AppDeclaration } from '../../interfaces';
|
|
6
6
|
import { TriggerKeyDefinitionParser, ConfigPropertiesParser } from './app-template-parsers';
|
|
7
7
|
import { WorkflowDefinitionDeployer } from './workflow-definition-deployer';
|
|
@@ -105,6 +105,12 @@ export class AppDeployer {
|
|
|
105
105
|
public async remove(appDeclaration: AppDeclaration) {
|
|
106
106
|
let app = await this.getExistingApp(appDeclaration);
|
|
107
107
|
if (app) {
|
|
108
|
+
const actions = await getActionsForApp(app)
|
|
109
|
+
for(const action of actions)
|
|
110
|
+
{
|
|
111
|
+
console.log(`%s Deleting action: ${action.identifier}`, chalk.yellow.bold('APP'));
|
|
112
|
+
await deleteAction(action.id);
|
|
113
|
+
}
|
|
108
114
|
app = await new Entities().delete({ entityName: 'app', id: app.id });
|
|
109
115
|
console.log(`%s Deleted app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
110
116
|
} else {
|
package/src/auth/login.ts
CHANGED