@contrail/cli 1.0.8 → 1.0.11
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/app-deployer.js +22 -4
- package/lib/types/interfaces.d.ts +4 -1
- package/lib/types/option-set-uploader.js +4 -0
- package/lib/types/types-extractor.js +2 -0
- package/lib/types/types-uploader.js +8 -0
- package/package.json +1 -1
- package/src/apps/deploy-app/app-deployer.ts +28 -4
- package/src/types/interfaces.ts +3 -0
- package/src/types/option-set-uploader.ts +4 -0
- package/src/types/types-extractor.ts +2 -0
- package/src/types/types-uploader.ts +8 -0
|
@@ -7,9 +7,11 @@ export class AppDeployer {
|
|
|
7
7
|
async deploy(appDeclaration) {
|
|
8
8
|
let app = await this.getExistingApp(appDeclaration);
|
|
9
9
|
if (!app) {
|
|
10
|
+
console.log(`%s Creating new app.`, chalk.yellow.bold('APP'));
|
|
10
11
|
app = await this.createNewApp(appDeclaration);
|
|
11
12
|
}
|
|
12
13
|
else {
|
|
14
|
+
console.log(`%s Updating existing app.`, chalk.yellow.bold('APP'));
|
|
13
15
|
app = await this.updateExistingApp(appDeclaration, app);
|
|
14
16
|
}
|
|
15
17
|
await new ActionsDeployer().deployActions(appDeclaration, app);
|
|
@@ -34,6 +36,14 @@ export class AppDeployer {
|
|
|
34
36
|
return apps.find(app => app.identifier === appDeclaration.appIdentifier);
|
|
35
37
|
}
|
|
36
38
|
async createNewApp(appDeclaration) {
|
|
39
|
+
let configProperties;
|
|
40
|
+
if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.appConfiguration) {
|
|
41
|
+
configProperties = ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration);
|
|
42
|
+
}
|
|
43
|
+
let triggerKeyDefinitions;
|
|
44
|
+
if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.triggers) {
|
|
45
|
+
triggerKeyDefinitions = TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration);
|
|
46
|
+
}
|
|
37
47
|
const newApp = {
|
|
38
48
|
identifier: appDeclaration.appIdentifier,
|
|
39
49
|
name: appDeclaration.appName,
|
|
@@ -43,14 +53,22 @@ export class AppDeployer {
|
|
|
43
53
|
thumbnail: appDeclaration.thumbnail,
|
|
44
54
|
eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
|
|
45
55
|
keywords: appDeclaration.keywords,
|
|
46
|
-
configProperties
|
|
47
|
-
triggerKeyDefinitions
|
|
56
|
+
configProperties,
|
|
57
|
+
triggerKeyDefinitions,
|
|
48
58
|
};
|
|
49
59
|
const app = await new Entities().create({ entityName: 'app', object: newApp });
|
|
50
60
|
console.log(`%s Created new app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
51
61
|
return app;
|
|
52
62
|
}
|
|
53
63
|
async updateExistingApp(appDeclaration, existingApp) {
|
|
64
|
+
let configProperties;
|
|
65
|
+
if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.appConfiguration) {
|
|
66
|
+
configProperties = ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration);
|
|
67
|
+
}
|
|
68
|
+
let triggerKeyDefinitions;
|
|
69
|
+
if (appDeclaration === null || appDeclaration === void 0 ? void 0 : appDeclaration.triggers) {
|
|
70
|
+
triggerKeyDefinitions = TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration);
|
|
71
|
+
}
|
|
54
72
|
const updates = {
|
|
55
73
|
name: appDeclaration.appName,
|
|
56
74
|
public: appDeclaration.visibility === 'public',
|
|
@@ -59,8 +77,8 @@ export class AppDeployer {
|
|
|
59
77
|
thumbnail: appDeclaration.thumbnail,
|
|
60
78
|
eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
|
|
61
79
|
keywords: appDeclaration.keywords,
|
|
62
|
-
configProperties
|
|
63
|
-
triggerKeyDefinitions
|
|
80
|
+
configProperties,
|
|
81
|
+
triggerKeyDefinitions,
|
|
64
82
|
};
|
|
65
83
|
const app = await new Entities().update({ entityName: 'app', id: existingApp.id, object: updates });
|
|
66
84
|
console.log(`%s Updated app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
@@ -19,6 +19,8 @@ export interface ReducedTypeProperties {
|
|
|
19
19
|
defaultValue: string;
|
|
20
20
|
propertyLevel: string;
|
|
21
21
|
inherited: boolean;
|
|
22
|
+
formulaFunction?: string;
|
|
23
|
+
validationFunction?: string;
|
|
22
24
|
}
|
|
23
25
|
export interface ReducedOptionSet {
|
|
24
26
|
name: string;
|
|
@@ -46,5 +48,6 @@ export declare enum PropertyType {
|
|
|
46
48
|
Constant = "constant",
|
|
47
49
|
Composite = "composite",
|
|
48
50
|
UserList = "userList",
|
|
49
|
-
Image = "image"
|
|
51
|
+
Image = "image",
|
|
52
|
+
Json = "json"
|
|
50
53
|
}
|
|
@@ -30,6 +30,10 @@ export async function uploadOptionSets() {
|
|
|
30
30
|
try {
|
|
31
31
|
const found = currentOptionSetsByName[optionSet.name];
|
|
32
32
|
if (!found) {
|
|
33
|
+
if (!optionSet.optionSet) {
|
|
34
|
+
console.log('No OptionSet for: ', optionSet.name);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
33
37
|
console.log('Creating: ', optionSet.name);
|
|
34
38
|
await new Entities().create({
|
|
35
39
|
entityName: 'type-property-option-set',
|
|
@@ -75,6 +75,8 @@ async function getReducedTypes(optionSets) {
|
|
|
75
75
|
defaultValue: typeProperty.defaultValue,
|
|
76
76
|
propertyLevel: typeProperty.propertyLevel,
|
|
77
77
|
inherited: typeProperty.inherited,
|
|
78
|
+
formulaFunction: typeProperty.formulaFunction,
|
|
79
|
+
validationFunction: typeProperty.validationFunction,
|
|
78
80
|
};
|
|
79
81
|
reducedTypeProperties.push(reducedTypeProperty);
|
|
80
82
|
}
|
|
@@ -146,6 +146,8 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
146
146
|
referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug,
|
|
147
147
|
defaultValue: newPropertyType.defaultValue,
|
|
148
148
|
propertyLevel: newPropertyType.propertyLevel,
|
|
149
|
+
formulaFunction: newPropertyType.formulaFunction,
|
|
150
|
+
validationFunction: newPropertyType.validationFunction,
|
|
149
151
|
}),
|
|
150
152
|
headers: {
|
|
151
153
|
'Accept': 'application/json',
|
|
@@ -170,6 +172,8 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
170
172
|
referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug,
|
|
171
173
|
defaultValue: newPropertyType.defaultValue,
|
|
172
174
|
propertyLevel: newPropertyType.propertyLevel,
|
|
175
|
+
formulaFunction: newPropertyType.formulaFunction,
|
|
176
|
+
validationFunction: newPropertyType.validationFunction,
|
|
173
177
|
},
|
|
174
178
|
});
|
|
175
179
|
}
|
|
@@ -210,6 +214,8 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName) {
|
|
|
210
214
|
referencedTypeRootSlug: typeProperty1.referencedTypeRootSlug,
|
|
211
215
|
defaultValue: typeProperty1.defaultValue,
|
|
212
216
|
propertyLevel: typeProperty1.propertyLevel,
|
|
217
|
+
formulaFunction: typeProperty1.formulaFunction,
|
|
218
|
+
validationFunction: typeProperty1.validationFunction,
|
|
213
219
|
};
|
|
214
220
|
const reducedProperty2 = {
|
|
215
221
|
isArchived: typeProperty2.isArchived,
|
|
@@ -223,6 +229,8 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName) {
|
|
|
223
229
|
referencedTypeRootSlug: typeProperty2.referencedTypeRootSlug,
|
|
224
230
|
defaultValue: typeProperty2.defaultValue,
|
|
225
231
|
propertyLevel: typeProperty2.propertyLevel,
|
|
232
|
+
formulaFunction: typeProperty2.formulaFunction,
|
|
233
|
+
validationFunction: typeProperty2.validationFunction,
|
|
226
234
|
};
|
|
227
235
|
return _.isEqual(reducedProperty1, reducedProperty2);
|
|
228
236
|
}
|
package/package.json
CHANGED
|
@@ -9,8 +9,10 @@ export class AppDeployer {
|
|
|
9
9
|
public async deploy(appDeclaration: AppDeclaration) {
|
|
10
10
|
let app = await this.getExistingApp(appDeclaration);
|
|
11
11
|
if (!app) {
|
|
12
|
+
console.log(`%s Creating new app.`, chalk.yellow.bold('APP'));
|
|
12
13
|
app = await this.createNewApp(appDeclaration);
|
|
13
14
|
} else {
|
|
15
|
+
console.log(`%s Updating existing app.`, chalk.yellow.bold('APP'));
|
|
14
16
|
app = await this.updateExistingApp(appDeclaration, app);
|
|
15
17
|
}
|
|
16
18
|
await new ActionsDeployer().deployActions(appDeclaration, app);
|
|
@@ -39,6 +41,17 @@ export class AppDeployer {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
private async createNewApp(appDeclaration: AppDeclaration) {
|
|
44
|
+
|
|
45
|
+
let configProperties;
|
|
46
|
+
if (appDeclaration?.appConfiguration) {
|
|
47
|
+
configProperties = ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let triggerKeyDefinitions;
|
|
51
|
+
if (appDeclaration?.triggers) {
|
|
52
|
+
triggerKeyDefinitions = TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration);
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
const newApp = {
|
|
43
56
|
identifier: appDeclaration.appIdentifier,
|
|
44
57
|
name: appDeclaration.appName,
|
|
@@ -48,8 +61,8 @@ export class AppDeployer {
|
|
|
48
61
|
thumbnail: appDeclaration.thumbnail,
|
|
49
62
|
eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
|
|
50
63
|
keywords: appDeclaration.keywords,
|
|
51
|
-
configProperties
|
|
52
|
-
triggerKeyDefinitions
|
|
64
|
+
configProperties,
|
|
65
|
+
triggerKeyDefinitions,
|
|
53
66
|
};
|
|
54
67
|
const app = await new Entities().create({ entityName: 'app', object: newApp });
|
|
55
68
|
console.log(`%s Created new app: ${app.name}`, chalk.yellow.bold('APP'));
|
|
@@ -57,6 +70,17 @@ export class AppDeployer {
|
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
public async updateExistingApp(appDeclaration: AppDeclaration, existingApp) {
|
|
73
|
+
|
|
74
|
+
let configProperties;
|
|
75
|
+
if (appDeclaration?.appConfiguration) {
|
|
76
|
+
configProperties = ConfigPropertiesParser.getConfigProperties(appDeclaration.appConfiguration);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let triggerKeyDefinitions;
|
|
80
|
+
if (appDeclaration?.triggers) {
|
|
81
|
+
triggerKeyDefinitions = TriggerKeyDefinitionParser.buildTriggersArray(appDeclaration);
|
|
82
|
+
}
|
|
83
|
+
|
|
60
84
|
const updates = {
|
|
61
85
|
name: appDeclaration.appName,
|
|
62
86
|
public: appDeclaration.visibility === 'public',
|
|
@@ -65,8 +89,8 @@ export class AppDeployer {
|
|
|
65
89
|
thumbnail: appDeclaration.thumbnail,
|
|
66
90
|
eventWorkflowTriggerKeyMapping: appDeclaration.eventWorkflowTriggerKeyMapping,
|
|
67
91
|
keywords: appDeclaration.keywords,
|
|
68
|
-
configProperties
|
|
69
|
-
triggerKeyDefinitions
|
|
92
|
+
configProperties,
|
|
93
|
+
triggerKeyDefinitions,
|
|
70
94
|
};
|
|
71
95
|
const app = await new Entities().update({ entityName: 'app', id: existingApp.id, object: updates });
|
|
72
96
|
console.log(`%s Updated app: ${app.name}`, chalk.yellow.bold('APP'));
|
package/src/types/interfaces.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface ReducedTypeProperties {
|
|
|
20
20
|
defaultValue: string;
|
|
21
21
|
propertyLevel: string;
|
|
22
22
|
inherited: boolean;
|
|
23
|
+
formulaFunction?: string;
|
|
24
|
+
validationFunction?: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export interface ReducedOptionSet {
|
|
@@ -50,4 +52,5 @@ export declare enum PropertyType {
|
|
|
50
52
|
Composite = 'composite',
|
|
51
53
|
UserList = 'userList',
|
|
52
54
|
Image = 'image',
|
|
55
|
+
Json = 'json',
|
|
53
56
|
}
|
|
@@ -37,6 +37,10 @@ export async function uploadOptionSets() {
|
|
|
37
37
|
try {
|
|
38
38
|
const found = currentOptionSetsByName[optionSet.name];
|
|
39
39
|
if (!found) {
|
|
40
|
+
if (!optionSet.optionSet) {
|
|
41
|
+
console.log('No OptionSet for: ', optionSet.name);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
40
44
|
console.log('Creating: ', optionSet.name);
|
|
41
45
|
await new Entities().create({
|
|
42
46
|
entityName: 'type-property-option-set',
|
|
@@ -95,6 +95,8 @@ async function getReducedTypes(optionSets) {
|
|
|
95
95
|
defaultValue: typeProperty.defaultValue,
|
|
96
96
|
propertyLevel: typeProperty.propertyLevel,
|
|
97
97
|
inherited: typeProperty.inherited,
|
|
98
|
+
formulaFunction: typeProperty.formulaFunction,
|
|
99
|
+
validationFunction: typeProperty.validationFunction,
|
|
98
100
|
};
|
|
99
101
|
|
|
100
102
|
reducedTypeProperties.push(reducedTypeProperty);
|
|
@@ -173,6 +173,8 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
173
173
|
referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug,
|
|
174
174
|
defaultValue: newPropertyType.defaultValue,
|
|
175
175
|
propertyLevel: newPropertyType.propertyLevel,
|
|
176
|
+
formulaFunction: newPropertyType.formulaFunction,
|
|
177
|
+
validationFunction: newPropertyType.validationFunction,
|
|
176
178
|
}),
|
|
177
179
|
headers: {
|
|
178
180
|
'Accept': 'application/json',
|
|
@@ -197,6 +199,8 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
197
199
|
referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug,
|
|
198
200
|
defaultValue: newPropertyType.defaultValue,
|
|
199
201
|
propertyLevel: newPropertyType.propertyLevel,
|
|
202
|
+
formulaFunction: newPropertyType.formulaFunction,
|
|
203
|
+
validationFunction: newPropertyType.validationFunction,
|
|
200
204
|
},
|
|
201
205
|
});
|
|
202
206
|
}
|
|
@@ -241,6 +245,8 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName): b
|
|
|
241
245
|
referencedTypeRootSlug: typeProperty1.referencedTypeRootSlug,
|
|
242
246
|
defaultValue: typeProperty1.defaultValue,
|
|
243
247
|
propertyLevel: typeProperty1.propertyLevel,
|
|
248
|
+
formulaFunction: typeProperty1.formulaFunction,
|
|
249
|
+
validationFunction: typeProperty1.validationFunction,
|
|
244
250
|
};
|
|
245
251
|
|
|
246
252
|
const reducedProperty2 = {
|
|
@@ -255,6 +261,8 @@ function typePropertiesEqual(typeProperty1, typeProperty2, optionSetIdByName): b
|
|
|
255
261
|
referencedTypeRootSlug: typeProperty2.referencedTypeRootSlug,
|
|
256
262
|
defaultValue: typeProperty2.defaultValue,
|
|
257
263
|
propertyLevel: typeProperty2.propertyLevel,
|
|
264
|
+
formulaFunction: typeProperty2.formulaFunction,
|
|
265
|
+
validationFunction: typeProperty2.validationFunction,
|
|
258
266
|
};
|
|
259
267
|
|
|
260
268
|
return _.isEqual(reducedProperty1, reducedProperty2);
|