@contrail/cli 1.0.42 → 1.0.44
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/api/event-workflow-template-definition.d.ts +1 -0
- package/lib/api/event-workflow-template-definition.js +6 -0
- package/lib/types/interfaces.d.ts +1 -0
- package/lib/types/types-extractor.js +1 -0
- package/lib/types/types-uploader.js +4 -0
- package/lib/workflow-template-definitions/workflow-template-definition-deployer.js +17 -14
- package/lib/workflow-templates/workflow-template-commands.d.ts +1 -1
- package/lib/workflow-templates/workflow-template-deployer.d.ts +1 -1
- package/lib/workflow-templates/workflow-template-deployer.js +3 -2
- package/package.json +1 -1
- package/src/api/event-workflow-template-definition.ts +7 -0
- package/src/types/interfaces.ts +1 -0
- package/src/types/types-extractor.ts +1 -0
- package/src/types/types-uploader.ts +4 -0
- package/src/workflow-template-definitions/workflow-template-definition-deployer.ts +18 -16
- package/src/workflow-templates/workflow-template-deployer.ts +3 -2
|
@@ -12,3 +12,9 @@ export async function updateWorkflowTemplateDefinition(options) {
|
|
|
12
12
|
object: options.updates,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
+
export async function deleteWorkflowTemplateDefinition(templateId) {
|
|
16
|
+
return await new Entities().delete({
|
|
17
|
+
entityName: 'event-workflow-template-definition',
|
|
18
|
+
id: templateId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -72,6 +72,7 @@ export async function getReducedTypes(optionSets) {
|
|
|
72
72
|
propertyType: typeProperty.propertyType,
|
|
73
73
|
label: typeProperty.label,
|
|
74
74
|
editable: typeProperty.editable,
|
|
75
|
+
searchable: typeProperty.searchable,
|
|
75
76
|
core: typeProperty.core,
|
|
76
77
|
typePropertyOptionSetName: optionSetNameById[typeProperty.typePropertyOptionSetId],
|
|
77
78
|
formula: typeProperty.formula,
|
|
@@ -136,6 +136,7 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
136
136
|
slug: newPropertyType.slug,
|
|
137
137
|
label: newPropertyType.label,
|
|
138
138
|
editable: newPropertyType.editable,
|
|
139
|
+
searchable: newPropertyType.searchable,
|
|
139
140
|
core: newPropertyType.core,
|
|
140
141
|
typePropertyOptionSetId: optionSetIdByName[newPropertyType.typePropertyOptionSetName],
|
|
141
142
|
formula: newPropertyType.formula,
|
|
@@ -162,6 +163,7 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
162
163
|
slug: newPropertyType.slug,
|
|
163
164
|
label: newPropertyType.label,
|
|
164
165
|
editable: newPropertyType.editable,
|
|
166
|
+
searchable: newPropertyType.searchable,
|
|
165
167
|
core: newPropertyType.core,
|
|
166
168
|
typePropertyOptionSetId: optionSetIdByName[newPropertyType.typePropertyOptionSetName],
|
|
167
169
|
formula: newPropertyType.formula,
|
|
@@ -204,6 +206,7 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName) {
|
|
|
204
206
|
slug: typeProperty1.slug,
|
|
205
207
|
label: typeProperty1.label,
|
|
206
208
|
editable: typeProperty1.editable,
|
|
209
|
+
searchable: typeProperty1.searchable,
|
|
207
210
|
core: typeProperty1.core,
|
|
208
211
|
typePropertyOptionSetId: optionSetIdByName[typeProperty1.typePropertyOptionSetName],
|
|
209
212
|
formula: typeProperty1.formula,
|
|
@@ -219,6 +222,7 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName) {
|
|
|
219
222
|
slug: typeProperty2.slug,
|
|
220
223
|
label: typeProperty2.label,
|
|
221
224
|
editable: typeProperty2.editable,
|
|
225
|
+
searchable: typeProperty2.searchable,
|
|
222
226
|
core: typeProperty2.core,
|
|
223
227
|
typePropertyOptionSetId: optionSetIdByName[typeProperty2.typePropertyOptionSetName],
|
|
224
228
|
formula: typeProperty2.formula,
|
|
@@ -2,7 +2,7 @@ import inquirer from 'inquirer';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { getInstalledApps, getWorkflowTemplateDefinitionsForApp } from '../api/apps';
|
|
4
4
|
import { createWorkflowTemplate } from '../api/event-workflow-templates';
|
|
5
|
-
import { createWorkflowTemplateDefinition, updateWorkflowTemplateDefinition as apiUpdateWorkflowTemplateDefinition } from '../api/event-workflow-template-definition';
|
|
5
|
+
import { createWorkflowTemplateDefinition, deleteWorkflowTemplateDefinition, updateWorkflowTemplateDefinition as apiUpdateWorkflowTemplateDefinition } from '../api/event-workflow-template-definition';
|
|
6
6
|
import { getActionDeclarationIdentifier, getActionsForApp } from '../apps/deploy-app/actions-deployer';
|
|
7
7
|
export class WorkflowTemplateDefinitionDeployer {
|
|
8
8
|
async cliInstallWorkflowTemplateDefinitions() {
|
|
@@ -11,7 +11,7 @@ export class WorkflowTemplateDefinitionDeployer {
|
|
|
11
11
|
console.log('%s \nNo apps are currently installed. You must install an app before installing its associated workflow template definitions.', chalk.red.bold('WORKFLOW DEFINITION'));
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const answers = await inquirer.prompt([{
|
|
15
15
|
type: 'list',
|
|
16
16
|
name: 'appIdentifier',
|
|
17
17
|
message: 'Which app\'s workflow would you like to install?',
|
|
@@ -22,27 +22,24 @@ export class WorkflowTemplateDefinitionDeployer {
|
|
|
22
22
|
for (const definition of workflowTemplateDefinitions) {
|
|
23
23
|
console.log(chalk.yellow.bold(`- ${definition.name}`));
|
|
24
24
|
}
|
|
25
|
-
answers = await inquirer.prompt([{
|
|
26
|
-
type: 'confirm',
|
|
27
|
-
name: 'shouldInstall',
|
|
28
|
-
message: 'Confirmation: would you like to install these workflows? (yes)',
|
|
29
|
-
default: true,
|
|
30
|
-
}]);
|
|
31
|
-
if (!answers.shouldInstall) {
|
|
32
|
-
console.log('%s Canceling installing workflows template definitions.', chalk.yellow.bold('WORKFLOW DEFINITION TEMPLATE'));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
25
|
await this.installWorkflowTemplateDefinitions(workflowTemplateDefinitions);
|
|
36
26
|
}
|
|
37
27
|
async installWorkflowTemplateDefinitions(workflowTemplateDefinitions) {
|
|
38
|
-
|
|
28
|
+
let answers = await inquirer.prompt([{
|
|
29
|
+
type: 'checkbox',
|
|
30
|
+
name: 'workflowTemplateDefinitionsToInstall',
|
|
31
|
+
message: 'Which workflow templates would you like to install?',
|
|
32
|
+
choices: workflowTemplateDefinitions.map(x => { return { value: x.identifier, name: x.name }; }),
|
|
33
|
+
}]);
|
|
34
|
+
const workflowTemplateDefinitionsToInstall = workflowTemplateDefinitions.filter(x => answers.workflowTemplateDefinitionsToInstall.includes(x.identifier));
|
|
35
|
+
answers = await inquirer.prompt([{
|
|
39
36
|
type: 'confirm',
|
|
40
37
|
name: 'makeActive',
|
|
41
38
|
message: 'Should the workflows be active ?(yes)',
|
|
42
39
|
default: true,
|
|
43
40
|
}]);
|
|
44
41
|
const makeActive = answers.makeActive;
|
|
45
|
-
for (const definition of
|
|
42
|
+
for (const definition of workflowTemplateDefinitionsToInstall) {
|
|
46
43
|
const newObject = {
|
|
47
44
|
name: definition.name,
|
|
48
45
|
triggerKey: definition.triggerKey,
|
|
@@ -81,6 +78,12 @@ export class WorkflowTemplateDefinitionDeployer {
|
|
|
81
78
|
await this.deployWorkflow(workflowKey, appDeclaration.workflows[workflowKey], app, existingWorkflows);
|
|
82
79
|
}
|
|
83
80
|
}
|
|
81
|
+
// remove old templates that were removed by the app publisher
|
|
82
|
+
const localIdentifiers = localWorkflows.map(x => this.getWorkflowDeclarationIdentifier(x, app));
|
|
83
|
+
const workflowTemplateDefinitionsToDelete = existingWorkflows.filter(x => !localIdentifiers.includes(x.identifier));
|
|
84
|
+
for (const templateToDelete of workflowTemplateDefinitionsToDelete) {
|
|
85
|
+
await deleteWorkflowTemplateDefinition(templateToDelete.id);
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
async deployWorkflow(workflowKey, workflow, app, existingWorkflows) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function deleteWorkflowTemplates(): Promise<void>;
|
|
2
2
|
export declare function localDeleteWorkflowTemplate(): Promise<void>;
|
|
3
3
|
export declare function localDeployWorkflowTemplate(): Promise<void>;
|
|
4
|
-
export declare function listWorkflowTemplate(): Promise<
|
|
4
|
+
export declare function listWorkflowTemplate(): Promise<void>;
|
|
@@ -19,7 +19,8 @@ export class WorkflowTemplateDeployer {
|
|
|
19
19
|
}
|
|
20
20
|
async listExistingWorkflowTemplates() {
|
|
21
21
|
const templates = await getExistingWorkflowTemplates();
|
|
22
|
-
console.log(
|
|
23
|
-
|
|
22
|
+
console.log('(Date Created) (active) workflow name');
|
|
23
|
+
console.log('------------------------');
|
|
24
|
+
console.log(chalk.green.bold(templates.map(x => `(${x.createdOn}) (${x.isActive ? 'active' : 'inactive'}) ${x.name} `).join('\n')));
|
|
24
25
|
}
|
|
25
26
|
}
|
package/package.json
CHANGED
|
@@ -13,4 +13,11 @@ export async function updateWorkflowTemplateDefinition(options: {id: string, upd
|
|
|
13
13
|
id: options.id,
|
|
14
14
|
object: options.updates,
|
|
15
15
|
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function deleteWorkflowTemplateDefinition(templateId: string) {
|
|
19
|
+
return await new Entities().delete({
|
|
20
|
+
entityName: 'event-workflow-template-definition',
|
|
21
|
+
id: templateId,
|
|
22
|
+
});
|
|
16
23
|
}
|
package/src/types/interfaces.ts
CHANGED
|
@@ -92,6 +92,7 @@ export async function getReducedTypes(optionSets) {
|
|
|
92
92
|
propertyType: typeProperty.propertyType,
|
|
93
93
|
label: typeProperty.label,
|
|
94
94
|
editable: typeProperty.editable,
|
|
95
|
+
searchable: typeProperty.searchable,
|
|
95
96
|
core: typeProperty.core,
|
|
96
97
|
typePropertyOptionSetName: optionSetNameById[typeProperty.typePropertyOptionSetId],
|
|
97
98
|
formula: typeProperty.formula,
|
|
@@ -162,6 +162,7 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
162
162
|
slug: newPropertyType.slug,
|
|
163
163
|
label: newPropertyType.label,
|
|
164
164
|
editable: newPropertyType.editable,
|
|
165
|
+
searchable: newPropertyType.searchable,
|
|
165
166
|
core: newPropertyType.core,
|
|
166
167
|
typePropertyOptionSetId: optionSetIdByName[newPropertyType.typePropertyOptionSetName],
|
|
167
168
|
formula: newPropertyType.formula,
|
|
@@ -188,6 +189,7 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
188
189
|
slug: newPropertyType.slug,
|
|
189
190
|
label: newPropertyType.label,
|
|
190
191
|
editable: newPropertyType.editable,
|
|
192
|
+
searchable: newPropertyType.searchable,
|
|
191
193
|
core: newPropertyType.core,
|
|
192
194
|
typePropertyOptionSetId: optionSetIdByName[newPropertyType.typePropertyOptionSetName],
|
|
193
195
|
formula: newPropertyType.formula,
|
|
@@ -234,6 +236,7 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName): b
|
|
|
234
236
|
slug: typeProperty1.slug,
|
|
235
237
|
label: typeProperty1.label,
|
|
236
238
|
editable: typeProperty1.editable,
|
|
239
|
+
searchable: typeProperty1.searchable,
|
|
237
240
|
core: typeProperty1.core,
|
|
238
241
|
typePropertyOptionSetId: optionSetIdByName[typeProperty1.typePropertyOptionSetName],
|
|
239
242
|
formula: typeProperty1.formula,
|
|
@@ -250,6 +253,7 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName): b
|
|
|
250
253
|
slug: typeProperty2.slug,
|
|
251
254
|
label: typeProperty2.label,
|
|
252
255
|
editable: typeProperty2.editable,
|
|
256
|
+
searchable: typeProperty2.searchable,
|
|
253
257
|
core: typeProperty2.core,
|
|
254
258
|
typePropertyOptionSetId: optionSetIdByName[typeProperty2.typePropertyOptionSetName],
|
|
255
259
|
formula: typeProperty2.formula,
|
|
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import { App, AppDeclaration, WorkflowDefinition, WorkflowTemplate } from '../interfaces';
|
|
4
4
|
import { getInstalledApps, getWorkflowTemplateDefinitionsForApp } from '../api/apps';
|
|
5
5
|
import { createWorkflowTemplate } from '../api/event-workflow-templates';
|
|
6
|
-
import { createWorkflowTemplateDefinition, updateWorkflowTemplateDefinition as apiUpdateWorkflowTemplateDefinition } from '../api/event-workflow-template-definition';
|
|
6
|
+
import { createWorkflowTemplateDefinition, deleteWorkflowTemplateDefinition, updateWorkflowTemplateDefinition as apiUpdateWorkflowTemplateDefinition } from '../api/event-workflow-template-definition';
|
|
7
7
|
import { getActionDeclarationIdentifier, getActionsForApp } from '../apps/deploy-app/actions-deployer';
|
|
8
8
|
|
|
9
9
|
export class WorkflowTemplateDefinitionDeployer {
|
|
@@ -15,7 +15,7 @@ export class WorkflowTemplateDefinitionDeployer {
|
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const answers = await inquirer.prompt([{
|
|
19
19
|
type: 'list',
|
|
20
20
|
name: 'appIdentifier',
|
|
21
21
|
message: 'Which app\'s workflow would you like to install?',
|
|
@@ -26,31 +26,26 @@ export class WorkflowTemplateDefinitionDeployer {
|
|
|
26
26
|
for (const definition of workflowTemplateDefinitions) {
|
|
27
27
|
console.log(chalk.yellow.bold(`- ${definition.name}`));
|
|
28
28
|
}
|
|
29
|
-
answers = await inquirer.prompt([{
|
|
30
|
-
type: 'confirm',
|
|
31
|
-
name: 'shouldInstall',
|
|
32
|
-
message: 'Confirmation: would you like to install these workflows? (yes)',
|
|
33
|
-
default: true,
|
|
34
|
-
}]);
|
|
35
|
-
|
|
36
|
-
if (!answers.shouldInstall) {
|
|
37
|
-
console.log('%s Canceling installing workflows template definitions.', chalk.yellow.bold('WORKFLOW DEFINITION TEMPLATE'));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
29
|
await this.installWorkflowTemplateDefinitions(workflowTemplateDefinitions);
|
|
42
30
|
}
|
|
43
31
|
|
|
44
32
|
async installWorkflowTemplateDefinitions(workflowTemplateDefinitions: WorkflowTemplate[]) {
|
|
33
|
+
let answers = await inquirer.prompt([{
|
|
34
|
+
type: 'checkbox',
|
|
35
|
+
name: 'workflowTemplateDefinitionsToInstall',
|
|
36
|
+
message: 'Which workflow templates would you like to install?',
|
|
37
|
+
choices: workflowTemplateDefinitions.map(x => {return {value: x.identifier, name: x.name};}),
|
|
38
|
+
}]);
|
|
45
39
|
|
|
46
|
-
const
|
|
40
|
+
const workflowTemplateDefinitionsToInstall = workflowTemplateDefinitions.filter(x => answers.workflowTemplateDefinitionsToInstall.includes(x.identifier));
|
|
41
|
+
answers = await inquirer.prompt([{
|
|
47
42
|
type: 'confirm',
|
|
48
43
|
name: 'makeActive',
|
|
49
44
|
message: 'Should the workflows be active ?(yes)',
|
|
50
45
|
default: true,
|
|
51
46
|
}]);
|
|
52
47
|
const makeActive = answers.makeActive;
|
|
53
|
-
for (const definition of
|
|
48
|
+
for (const definition of workflowTemplateDefinitionsToInstall) {
|
|
54
49
|
const newObject: WorkflowTemplate = {
|
|
55
50
|
name: definition.name,
|
|
56
51
|
triggerKey: definition.triggerKey,
|
|
@@ -100,6 +95,13 @@ export class WorkflowTemplateDefinitionDeployer {
|
|
|
100
95
|
);
|
|
101
96
|
}
|
|
102
97
|
}
|
|
98
|
+
|
|
99
|
+
// remove old templates that were removed by the app publisher
|
|
100
|
+
const localIdentifiers = localWorkflows.map(x=> this.getWorkflowDeclarationIdentifier(x, app));
|
|
101
|
+
const workflowTemplateDefinitionsToDelete = existingWorkflows.filter(x=> !localIdentifiers.includes(x.identifier));
|
|
102
|
+
for(const templateToDelete of workflowTemplateDefinitionsToDelete) {
|
|
103
|
+
await deleteWorkflowTemplateDefinition(templateToDelete.id);
|
|
104
|
+
}
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
|
|
@@ -23,7 +23,8 @@ export class WorkflowTemplateDeployer {
|
|
|
23
23
|
|
|
24
24
|
public async listExistingWorkflowTemplates() {
|
|
25
25
|
const templates = await getExistingWorkflowTemplates();
|
|
26
|
-
console.log(
|
|
27
|
-
|
|
26
|
+
console.log('(Date Created) (active) workflow name');
|
|
27
|
+
console.log('------------------------');
|
|
28
|
+
console.log(chalk.green.bold(templates.map(x => `(${x.createdOn}) (${x.isActive? 'active': 'inactive'}) ${x.name} `).join('\n')));
|
|
28
29
|
}
|
|
29
30
|
}
|