@contrail/cli 3.5.4-alpha.f60c4df → 3.5.5-alpha.177136f

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.
Files changed (65) hide show
  1. package/README.md +112 -23
  2. package/dist/api/feature-flags.d.ts +3 -0
  3. package/dist/api/feature-flags.js +29 -0
  4. package/dist/api/org-config.d.ts +3 -0
  5. package/dist/api/org-config.js +28 -0
  6. package/dist/api/users.d.ts +1 -0
  7. package/dist/api/users.js +10 -1
  8. package/dist/commands/feature-flags/export.d.ts +19 -0
  9. package/dist/commands/feature-flags/export.js +66 -0
  10. package/dist/commands/feature-flags/export.spec.d.ts +1 -0
  11. package/dist/commands/feature-flags/export.spec.js +109 -0
  12. package/dist/commands/feature-flags/import.d.ts +42 -0
  13. package/dist/commands/feature-flags/import.js +191 -0
  14. package/dist/commands/feature-flags/import.spec.d.ts +1 -0
  15. package/dist/commands/feature-flags/import.spec.js +194 -0
  16. package/dist/commands/groups/export.js +1 -13
  17. package/dist/commands/groups/import.js +2 -15
  18. package/dist/commands/instance/export.d.ts +9 -0
  19. package/dist/commands/instance/export.js +18 -3
  20. package/dist/commands/instance/export.spec.d.ts +1 -0
  21. package/dist/commands/instance/export.spec.js +32 -0
  22. package/dist/commands/instance/import.d.ts +17 -0
  23. package/dist/commands/instance/import.js +32 -5
  24. package/dist/commands/instance/import.spec.d.ts +1 -0
  25. package/dist/commands/instance/import.spec.js +61 -0
  26. package/dist/commands/org-config/export.d.ts +13 -0
  27. package/dist/commands/org-config/export.js +74 -0
  28. package/dist/commands/org-config/import.d.ts +12 -0
  29. package/dist/commands/org-config/import.js +63 -0
  30. package/dist/commands/types/getAll.js +2 -0
  31. package/dist/commands/types/loadAll.d.ts +13 -1
  32. package/dist/commands/types/loadAll.js +41 -4
  33. package/dist/commands/types/loadAll.spec.d.ts +1 -0
  34. package/dist/commands/types/loadAll.spec.js +77 -0
  35. package/dist/commands/types/mergeOptionSets.js +2 -9
  36. package/dist/commands/types/mergeTypeProperties.js +2 -6
  37. package/dist/commands/types/parseOptionSetsLocalFiles.js +3 -7
  38. package/dist/commands/types/uploadTypeOverrides.d.ts +10 -0
  39. package/dist/commands/types/uploadTypeOverrides.js +19 -8
  40. package/dist/commands/types/uploadTypeOverrides.spec.d.ts +1 -0
  41. package/dist/commands/types/uploadTypeOverrides.spec.js +60 -0
  42. package/dist/commands/users/export.js +1 -13
  43. package/dist/commands/users/import.js +2 -15
  44. package/dist/commands/workflow-templates/export.d.ts +2 -3
  45. package/dist/commands/workflow-templates/export.js +23 -122
  46. package/dist/commands/workflow-templates/load.d.ts +0 -2
  47. package/dist/commands/workflow-templates/load.js +6 -63
  48. package/dist/helpers/app/app-config-validators.d.ts +5 -0
  49. package/dist/helpers/app/app-config-validators.js +102 -3
  50. package/dist/helpers/app/app-config-validators.spec.js +46 -0
  51. package/dist/helpers/app/extensions-deployer.d.ts +10 -2
  52. package/dist/helpers/app/extensions-deployer.js +31 -37
  53. package/dist/helpers/app/extensions-deployer.spec.d.ts +1 -0
  54. package/dist/helpers/app/extensions-deployer.spec.js +29 -0
  55. package/dist/helpers/error-helpers.d.ts +9 -0
  56. package/dist/helpers/error-helpers.js +35 -0
  57. package/dist/helpers/file-helpers.d.ts +2 -0
  58. package/dist/helpers/file-helpers.js +25 -1
  59. package/dist/helpers/projects/helpers.js +2 -6
  60. package/dist/helpers/types/type-parser.js +9 -15
  61. package/dist/helpers/workflow-templates/helper.d.ts +1 -2
  62. package/dist/helpers/workflow-templates/helper.js +6 -36
  63. package/dist/interfaces.d.ts +37 -1
  64. package/oclif.manifest.json +236 -30
  65. package/package.json +7 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExtensionsDeployer = exports.getExtensionDefinitionsForAppVersion = void 0;
3
+ exports.ExtensionsDeployer = exports.buildExtensionDefinition = exports.getExtensionDefinitionsForAppVersion = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const sdk_1 = require("@contrail/sdk");
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -13,6 +13,28 @@ async function getExtensionDefinitionsForAppVersion(app) {
13
13
  });
14
14
  }
15
15
  exports.getExtensionDefinitionsForAppVersion = getExtensionDefinitionsForAppVersion;
16
+ /** The definition published for an app.yml extension, for a new version or an update alike. */
17
+ function buildExtensionDefinition(extension, app, appName) {
18
+ return {
19
+ identifier: util_1.AppUtil.createExtensionIdentifier({
20
+ extensionIdentifier: extension?.identifier,
21
+ appIdentifier: app.identifier,
22
+ }),
23
+ name: extension.name,
24
+ appId: app.id,
25
+ appVersionId: app.latestAppVersionId,
26
+ extensionType: extension.extensionType,
27
+ userApps: extension.userApps,
28
+ /** @deprecated since entity-types v1.5.1, use display instead */
29
+ modalDimensions: extension.modalDimensions,
30
+ display: extension.display,
31
+ iframeUrl: extension.iframeUrl,
32
+ icon: extension.icon,
33
+ appliesTo: extension.appliesTo,
34
+ group: extension.group ?? appName,
35
+ };
36
+ }
37
+ exports.buildExtensionDefinition = buildExtensionDefinition;
16
38
  class ExtensionsDeployer {
17
39
  async deployExtensions(appDeclaration, app) {
18
40
  // FETCH ALL EXTENSIONS FROM THE API.
@@ -26,11 +48,11 @@ class ExtensionsDeployer {
26
48
  logger_1.default.debug(appDeclaration.extensions);
27
49
  if (appDeclaration.extensions) {
28
50
  for (const extension of appDeclaration?.extensions ?? []) {
29
- await this.deployExtension(extension, app, existingExtensions);
51
+ await this.deployExtension(extension, app, existingExtensions, appDeclaration.appName);
30
52
  }
31
53
  }
32
54
  }
33
- async deployExtension(extension, app, existingExtensions) {
55
+ async deployExtension(extension, app, existingExtensions, appName) {
34
56
  logger_1.default.info(`${chalk_1.default.yellow.bold('EXTENSION')} \tDeploying extension: ${extension?.identifier}`);
35
57
  const identifier = util_1.AppUtil.createExtensionIdentifier({
36
58
  appIdentifier: app.identifier,
@@ -38,28 +60,14 @@ class ExtensionsDeployer {
38
60
  });
39
61
  const existingDefinition = existingExtensions.find((ad) => ad.identifier === identifier);
40
62
  if (!existingDefinition) {
41
- await this.createNewExtensionDefinition(extension, app);
63
+ await this.createNewExtensionDefinition(extension, app, appName);
42
64
  }
43
65
  else {
44
- await this.updateActionDefinition(existingDefinition, extension, app);
66
+ await this.updateActionDefinition(existingDefinition, extension, app, appName);
45
67
  }
46
68
  }
47
- async createNewExtensionDefinition(extension, app) {
48
- const newObject = {
49
- identifier: util_1.AppUtil.createExtensionIdentifier({
50
- extensionIdentifier: extension?.identifier,
51
- appIdentifier: app.identifier,
52
- }),
53
- name: extension.name,
54
- appId: app.id,
55
- appVersionId: app.latestAppVersionId,
56
- extensionType: extension.extensionType,
57
- userApps: extension.userApps,
58
- /** @deprecated since entity-types v1.5.1, use display instead */
59
- modalDimensions: extension.modalDimensions,
60
- display: extension.display,
61
- iframeUrl: extension.iframeUrl,
62
- };
69
+ async createNewExtensionDefinition(extension, app, appName) {
70
+ const newObject = buildExtensionDefinition(extension, app, appName);
63
71
  const actionDefinition = await new sdk_1.Entities().create({
64
72
  entityName: 'app-extension-definition',
65
73
  object: newObject,
@@ -67,22 +75,8 @@ class ExtensionsDeployer {
67
75
  logger_1.default.info(`${chalk_1.default.yellow.bold('EXTENSION')} Created new extension definition: ${extension?.identifier}`);
68
76
  return actionDefinition;
69
77
  }
70
- async updateActionDefinition(existingActionDefinition, extension, app) {
71
- const updates = {
72
- identifier: util_1.AppUtil.createExtensionIdentifier({
73
- extensionIdentifier: extension?.identifier,
74
- appIdentifier: app.identifier,
75
- }),
76
- name: extension.name,
77
- appId: app.id,
78
- appVersionId: app.latestAppVersionId,
79
- extensionType: extension.extensionType,
80
- userApps: extension.userApps,
81
- /** @deprecated since entity-types v1.5.1, use display instead */
82
- modalDimensions: extension.modalDimensions,
83
- display: extension.display,
84
- iframeUrl: extension.iframeUrl,
85
- };
78
+ async updateActionDefinition(existingActionDefinition, extension, app, appName) {
79
+ const updates = buildExtensionDefinition(extension, app, appName);
86
80
  const extensionDefinition = await new sdk_1.Entities().update({
87
81
  entityName: 'app-extension-definition',
88
82
  id: existingActionDefinition.id,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const extensions_deployer_1 = require("./extensions-deployer");
4
+ const app = {
5
+ id: 'app-1',
6
+ identifier: '@vibeiq.com/gap-design-poc',
7
+ latestAppVersionId: 'version-1',
8
+ };
9
+ describe('buildExtensionDefinition', () => {
10
+ it('should publish placement as declared, grouped under the app name', () => {
11
+ const definition = (0, extensions_deployer_1.buildExtensionDefinition)({
12
+ identifier: 'line-builder',
13
+ name: 'Line builder',
14
+ iframeUrl: 'http://localhost:4395/index.html#/line-builder',
15
+ icon: 'line-builder',
16
+ appliesTo: { typePaths: ['custom-entity:silhouette'], maxSelected: 20 },
17
+ }, app, 'Gap');
18
+ expect(definition).toMatchObject({
19
+ identifier: '@vibeiq.com/gap-design-poc:line-builder',
20
+ appVersionId: 'version-1',
21
+ icon: 'line-builder',
22
+ appliesTo: { typePaths: ['custom-entity:silhouette'], maxSelected: 20 },
23
+ group: 'Gap',
24
+ });
25
+ });
26
+ it("should keep an extension's own group", () => {
27
+ expect((0, extensions_deployer_1.buildExtensionDefinition)({ identifier: 'x', name: 'X', group: 'Tools' }, app, 'Gap').group).toBe('Tools');
28
+ });
29
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns a human readable message for an error thrown by the SDK or by the CLI.
3
+ *
4
+ * The SDK's ApiError is constructed with an undefined message and keeps the raw
5
+ * response body in `details` (usually a JSON string such as
6
+ * `{"message":"policy with identifier X not found","statusCode":400}`), so
7
+ * `${error}` only prints "Error". This digs the API message out of `details`.
8
+ */
9
+ export declare function describeError(error: any): string;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describeError = void 0;
4
+ /**
5
+ * Returns a human readable message for an error thrown by the SDK or by the CLI.
6
+ *
7
+ * The SDK's ApiError is constructed with an undefined message and keeps the raw
8
+ * response body in `details` (usually a JSON string such as
9
+ * `{"message":"policy with identifier X not found","statusCode":400}`), so
10
+ * `${error}` only prints "Error". This digs the API message out of `details`.
11
+ */
12
+ function describeError(error) {
13
+ const details = error?.details;
14
+ if (typeof details === 'string' && details.length) {
15
+ try {
16
+ const parsed = JSON.parse(details);
17
+ const message = parsed?.message;
18
+ if (Array.isArray(message)) {
19
+ return message.join(', ');
20
+ }
21
+ if (message) {
22
+ return String(message);
23
+ }
24
+ }
25
+ catch {
26
+ // not JSON, fall through and use the raw body
27
+ }
28
+ return details;
29
+ }
30
+ if (details?.message) {
31
+ return String(details.message);
32
+ }
33
+ return error?.message || String(error);
34
+ }
35
+ exports.describeError = describeError;
@@ -1,2 +1,4 @@
1
1
  export declare function safeFileOverwrite(fileLocation: string, overwrite: boolean): Promise<boolean>;
2
2
  export declare function parseCSVData(data: string): any;
3
+ export declare function saveData(data: any, fileLocation: string, overwrite: boolean): Promise<void>;
4
+ export declare function loadData(fileLocation: string): any;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCSVData = exports.safeFileOverwrite = void 0;
3
+ exports.loadData = exports.saveData = exports.parseCSVData = exports.safeFileOverwrite = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("path"));
6
+ const fs_1 = tslib_1.__importDefault(require("fs"));
5
7
  const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
6
9
  const logger_1 = tslib_1.__importDefault(require("../logger"));
7
10
  const sync_1 = require("csv-parse/sync");
8
11
  const PASS_FORCE_TO_OVERWRITE = 'Pass --overwrite to overwrite without prompting';
@@ -34,3 +37,24 @@ function parseCSVData(data) {
34
37
  });
35
38
  }
36
39
  exports.parseCSVData = parseCSVData;
40
+ //saves data as yaml to fileLocation (resolved against the current directory), prompting before overwriting unless overwrite is passed
41
+ async function saveData(data, fileLocation, overwrite) {
42
+ const yamlStr = js_yaml_1.default.dump(data);
43
+ const pathToWrite = path.resolve(fileLocation);
44
+ if (fs_1.default.existsSync(pathToWrite)) {
45
+ await safeFileOverwrite(pathToWrite, overwrite);
46
+ }
47
+ fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
48
+ }
49
+ exports.saveData = saveData;
50
+ //loads yaml data from fileLocation (resolved against the current directory)
51
+ function loadData(fileLocation) {
52
+ const pathToRead = path.resolve(fileLocation);
53
+ try {
54
+ return js_yaml_1.default.load(fs_1.default.readFileSync(pathToRead, 'utf8'));
55
+ }
56
+ catch (e) {
57
+ throw new Error(`ERROR PARSING YAML: ${e}`);
58
+ }
59
+ }
60
+ exports.loadData = loadData;
@@ -8,6 +8,7 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
8
8
  const sdk_1 = require("@contrail/sdk");
9
9
  const util_1 = require("@contrail/util");
10
10
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
11
+ const file_helpers_1 = require("../file-helpers");
11
12
  function getProjectFile(fileName) {
12
13
  const CURRENT_DIR = process.cwd();
13
14
  try {
@@ -42,7 +43,7 @@ async function exportProject(name) {
42
43
  const allAssortments = [];
43
44
  await getAssortmentsAndSubFolders(workspace.id, projectConfiguration.assortments, projectConfiguration.subFolders, allAssortments);
44
45
  await convertRelationshipsInFolders(projectConfiguration, allAssortments);
45
- saveData({ projectConfiguration: projectConfiguration }, name);
46
+ await (0, file_helpers_1.saveData)({ projectConfiguration: projectConfiguration }, `${name}-export.yml`, true);
46
47
  }
47
48
  exports.exportProject = exportProject;
48
49
  async function getAssortmentsAndSubFolders(parentId, assortments, subFolders, allAssortments) {
@@ -160,8 +161,3 @@ function deleteNonUserKeys(assortment) {
160
161
  delete assortment.updatedOn;
161
162
  delete assortment.workspaceId;
162
163
  }
163
- function saveData(data, name) {
164
- const yamlStr = js_yaml_1.default.dump(data);
165
- const CURRENT_DIR = process.cwd();
166
- fs_1.default.writeFileSync(path.join(CURRENT_DIR, `${name}-export.yml`), yamlStr, 'utf8');
167
- }
@@ -4,12 +4,11 @@ exports.parseTypesFromFiles = exports.parseTypesFromTemplateAndDataFromLocalFile
4
4
  const tslib_1 = require("tslib");
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const types_1 = require("@contrail/types");
7
- const fs_1 = tslib_1.__importDefault(require("fs"));
8
7
  const csvToJson = tslib_1.__importStar(require("csvtojson"));
9
8
  const login_1 = require("../../auth/login");
10
9
  const csv_parser_1 = require("../../helpers/types/csv-parser");
11
10
  const logger_1 = tslib_1.__importDefault(require("../../logger"));
12
- const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
11
+ const file_helpers_1 = require("../file-helpers");
13
12
  async function loadDataFromLocalCSV(fileName) {
14
13
  const CURRENT_DIR = process.cwd();
15
14
  try {
@@ -37,8 +36,8 @@ async function parseTypesFromLocalFiles(fileLocations) {
37
36
  }
38
37
  logger_1.default.info(`CSV imports were successful. ${csvJSONData?.length} total rows found.`);
39
38
  const suggestions = (0, types_1.GetSuggestedTypes)(csvJSONData);
40
- saveData(suggestions.OptionSets, 'parsed_optionSets.yml');
41
- saveData({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml');
39
+ await (0, file_helpers_1.saveData)(suggestions.OptionSets, 'parsed_optionSets.yml', true);
40
+ await (0, file_helpers_1.saveData)({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml', true);
42
41
  }
43
42
  exports.parseTypesFromLocalFiles = parseTypesFromLocalFiles;
44
43
  async function parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFileLocation) {
@@ -57,8 +56,8 @@ async function parseTypesFromTemplateFromLocalFiles(templateFileLocation, dataFi
57
56
  throw e;
58
57
  }
59
58
  const types = (0, types_1.GetTypesFromTemplate)(templateCSVData, dataCSVData);
60
- saveData(types.OptionSets, 'parsed_optionSets.yml');
61
- saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
59
+ await (0, file_helpers_1.saveData)(types.OptionSets, 'parsed_optionSets.yml', true);
60
+ await (0, file_helpers_1.saveData)({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml', true);
62
61
  }
63
62
  exports.parseTypesFromTemplateFromLocalFiles = parseTypesFromTemplateFromLocalFiles;
64
63
  async function parseTypesFromTemplateAndDataFromLocalFiles(templateFileLocation, dataFileLocations) {
@@ -86,8 +85,8 @@ async function parseTypesFromTemplateAndDataFromLocalFiles(templateFileLocation,
86
85
  }
87
86
  }
88
87
  const types = (0, types_1.GetTypesFromTemplateWithOptionSetsFromData)(templateCSVData, dataCSVData);
89
- saveData(types.OptionSets, 'parsed_optionSets.yml');
90
- saveData({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml');
88
+ await (0, file_helpers_1.saveData)(types.OptionSets, 'parsed_optionSets.yml', true);
89
+ await (0, file_helpers_1.saveData)({ TypePropertiesByEntity: types.TypePropertiesByEntity }, 'parsed_TypePropertiesByEntity.yml', true);
91
90
  }
92
91
  exports.parseTypesFromTemplateAndDataFromLocalFiles = parseTypesFromTemplateAndDataFromLocalFiles;
93
92
  async function parseTypesFromFiles(fileIds) {
@@ -108,12 +107,7 @@ async function parseTypesFromFiles(fileIds) {
108
107
  }
109
108
  logger_1.default.info(`CSV downloads were successful. ${csvJSONData?.length} total rows found.`);
110
109
  const suggestions = (0, types_1.GetSuggestedTypes)(csvJSONData);
111
- saveData(suggestions.OptionSets, 'parsed_optionSets.yml');
112
- saveData({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml');
110
+ await (0, file_helpers_1.saveData)(suggestions.OptionSets, 'parsed_optionSets.yml', true);
111
+ await (0, file_helpers_1.saveData)({ typeProperties: suggestions.TypeProperties }, 'parsed_typeProperties.yml', true);
113
112
  }
114
113
  exports.parseTypesFromFiles = parseTypesFromFiles;
115
- function saveData(data, name) {
116
- const yamlStr = js_yaml_1.default.dump(data);
117
- const CURRENT_DIR = process.cwd();
118
- fs_1.default.writeFileSync(path.resolve(path.join(CURRENT_DIR, name, yamlStr)), 'utf8');
119
- }
@@ -1,7 +1,7 @@
1
1
  import { EventWorkflowActionDefinition, WorkflowTemplate, WorkflowTemplateDeclaration } from '../../interfaces';
2
2
  export declare class LocalWorkflowTemplateDeployer {
3
3
  deployWorkflows(wtDeclaration: WorkflowTemplateDeclaration): Promise<void>;
4
- deployWorkflowTemplate(workflow: WorkflowTemplate, existingWorkflows: WorkflowTemplate[], appIdentifier: string | undefined): Promise<WorkflowTemplate>;
4
+ deployWorkflowTemplate(workflow: WorkflowTemplate, existingWorkflows: WorkflowTemplate[], appIdentifier: string): Promise<WorkflowTemplate>;
5
5
  private createNewWorkflowTemplate;
6
6
  private populateActionIds;
7
7
  createWorkflowSchedule(workflowTemplate: WorkflowTemplate, workflowId: string): Promise<any>;
@@ -18,4 +18,3 @@ export declare class WorkflowTemplateDeployer {
18
18
  export declare function deleteWorkflowTemplates(): Promise<void>;
19
19
  export declare function localDeployWorkflowTemplate(saveFileLocation: string): Promise<void>;
20
20
  export declare function populateActionIdentifiers(workflowTemplate: WorkflowTemplate): Promise<void>;
21
- export declare function extractShortActionKeys(workflowTemplate: WorkflowTemplate): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractShortActionKeys = exports.populateActionIdentifiers = exports.localDeployWorkflowTemplate = exports.deleteWorkflowTemplates = exports.WorkflowTemplateDeployer = exports.getActionByIdentifier = exports.getWorkflowTemplateIdentifier = exports.LocalWorkflowTemplateDeployer = void 0;
3
+ exports.populateActionIdentifiers = exports.localDeployWorkflowTemplate = exports.deleteWorkflowTemplates = exports.WorkflowTemplateDeployer = exports.getActionByIdentifier = exports.getWorkflowTemplateIdentifier = exports.LocalWorkflowTemplateDeployer = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const util_1 = require("@contrail/util");
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -35,17 +35,15 @@ class LocalWorkflowTemplateDeployer {
35
35
  return await this.createNewWorkflowTemplate(identifier, workflow, appIdentifier);
36
36
  }
37
37
  async createNewWorkflowTemplate(workflowKey, workflowTemplate, appIdentifier) {
38
- const appId = await this.populateActionIds(workflowTemplate, workflowKey, appIdentifier);
38
+ await this.populateActionIds(workflowTemplate, workflowKey, appIdentifier);
39
39
  const newObject = {
40
40
  identifier: getWorkflowTemplateIdentifier(workflowTemplate),
41
41
  name: workflowTemplate.name,
42
42
  triggerKey: workflowTemplate.triggerKey,
43
43
  workflowDefinition: workflowTemplate.workflowDefinition,
44
44
  isActive: workflowTemplate.isActive,
45
- supportingAppId: appId,
45
+ supportingAppId: workflowTemplate.supportingAppId,
46
46
  messageGroupId: workflowTemplate.messageGroupId,
47
- messageGroup: workflowTemplate.messageGroup,
48
- dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId,
49
47
  parallelWorkerCount: workflowTemplate.parallelWorkerCount,
50
48
  };
51
49
  const newWorkflowTemplate = await (0, event_workflow_templates_1.createWorkflowTemplate)(newObject);
@@ -56,18 +54,11 @@ class LocalWorkflowTemplateDeployer {
56
54
  return newWorkflowTemplate;
57
55
  }
58
56
  async populateActionIds(workflowTemplate, workflowKey, appIdentifier) {
59
- if (!appIdentifier) {
60
- logger_1.default.info(`WORKFLOW TEMPLATES No appIdentifier for "${workflowKey}" — skipping action ID resolution.`);
61
- return undefined;
62
- }
63
57
  const installedApps = await (0, apps_1.getInstalledApps)();
64
- const appOrg = installedApps.find((x) => x.app?.identifier === appIdentifier);
58
+ const appOrg = installedApps.find((x) => x.app.identifier === appIdentifier);
65
59
  logger_1.default.info('workflow template:', JSON.stringify(workflowTemplate, null, 2));
66
- if (!appOrg) {
67
- throw new Error(`Could not find installed app with identifier "${appIdentifier}". Make sure the app is installed in this org before importing workflows.`);
68
- }
69
60
  if (!workflowTemplate?.workflowDefinition?.paths) {
70
- return appOrg.appId;
61
+ return;
71
62
  }
72
63
  for (const path of workflowTemplate.workflowDefinition.paths) {
73
64
  if (!path?.actionDefinitionConfigs) {
@@ -93,10 +84,9 @@ class LocalWorkflowTemplateDeployer {
93
84
  }
94
85
  }
95
86
  }
96
- return appOrg.appId;
97
87
  }
98
88
  async createWorkflowSchedule(workflowTemplate, workflowId) {
99
- if (!workflowTemplate?.crons?.length) {
89
+ if (!workflowTemplate?.crons?.length || !workflowTemplate.id) {
100
90
  return;
101
91
  }
102
92
  const crons = [];
@@ -168,8 +158,6 @@ class LocalWorkflowTemplateDeployer {
168
158
  triggerKey: workflowTemplate.triggerKey,
169
159
  builtIn: workflowTemplate.builtIn,
170
160
  workflowDefinition: workflowTemplate.workflowDefinition,
171
- messageGroupId: workflowTemplate.messageGroupId ?? existingWorkflowTemplate.messageGroupId,
172
- messageGroup: workflowTemplate.messageGroup ?? existingWorkflowTemplate.messageGroup,
173
161
  dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId ?? existingWorkflowTemplate.dynamicMessageGroupId,
174
162
  parallelWorkerCount: workflowTemplate.parallelWorkerCount ?? existingWorkflowTemplate.parallelWorkerCount,
175
163
  });
@@ -295,21 +283,3 @@ async function populateActionIdentifiers(workflowTemplate) {
295
283
  }
296
284
  }
297
285
  exports.populateActionIdentifiers = populateActionIdentifiers;
298
- function extractShortActionKeys(workflowTemplate) {
299
- if (!workflowTemplate?.workflowDefinition?.paths) {
300
- return;
301
- }
302
- for (const wfPath of workflowTemplate.workflowDefinition.paths) {
303
- if (!wfPath?.actionDefinitionConfigs) {
304
- continue;
305
- }
306
- for (const actionConfig of wfPath.actionDefinitionConfigs) {
307
- if (actionConfig.action?.includes(':')) {
308
- // Full identifier format: "app-id@version:action-name" -> "action-name"
309
- actionConfig.action = actionConfig.action.split(':').pop() ?? actionConfig.action;
310
- }
311
- delete actionConfig.identifier;
312
- }
313
- }
314
- }
315
- exports.extractShortActionKeys = extractShortActionKeys;
@@ -55,6 +55,42 @@ export interface ExtensionDefinitionDeclaration {
55
55
  modalDimensions?: any;
56
56
  display?: AppExtensionDisplayConfiguration;
57
57
  iframeUrl?: string;
58
+ /** A default icon's name, `{ material: <icon name> }`, or `{ url: <one-color SVG, absolute or beside iframeUrl> }`.
59
+ * An extension without an icon shows none. */
60
+ icon?: ExtensionIconDeclaration;
61
+ /** What the extension acts on. Apps offer it beside a selection it fits (Boards: the property bar's app row and the
62
+ * top of the context menu); without it, it is offered as before. */
63
+ appliesTo?: ExtensionAppliesToDeclaration;
64
+ /** The name the app's extensions are grouped under; defaults to appName. */
65
+ group?: string;
66
+ }
67
+ export type ExtensionIconDeclaration = string | {
68
+ material: string;
69
+ } | {
70
+ url: string;
71
+ };
72
+ /** Which selected records a rule takes: by type path (with subtypes), exclusions, item role and how many. */
73
+ export interface ExtensionSelectionRuleDeclaration {
74
+ /** Type paths, each matching itself and its subtypes: item:product matches item:product:footwear. */
75
+ typePaths?: string[];
76
+ /** Type paths left out, with their subtypes: item:material. */
77
+ excludeTypePaths?: string[];
78
+ /** Item roles a record must have: family, option. */
79
+ roles?: string[];
80
+ /** Fewest records: 1 for a target, 0 for an input, unless set. */
81
+ minSelected?: number;
82
+ maxSelected?: number;
83
+ /** What to select, for hints and summaries: "a Design or BOM", "colors". */
84
+ label?: string;
85
+ }
86
+ /**
87
+ * A selection is a target (what the action acts on) plus optional inputs that come along with it (colors to build
88
+ * in). Every selected record must fit the target or an input. The flat form, the rule's fields with no target, is a
89
+ * target with no inputs.
90
+ */
91
+ export interface ExtensionAppliesToDeclaration extends ExtensionSelectionRuleDeclaration {
92
+ target?: ExtensionSelectionRuleDeclaration;
93
+ inputs?: ExtensionSelectionRuleDeclaration[];
58
94
  }
59
95
  export interface ConfigPropertyElements {
60
96
  [key: string]: ConfigPropertyElement;
@@ -98,7 +134,7 @@ export interface WorkflowDefinition {
98
134
  dynamicMessageGroupId?: string;
99
135
  }
100
136
  export interface WorkflowTemplateDeclaration {
101
- appIdentifier?: string;
137
+ appIdentifier: string;
102
138
  workflows?: WorkflowTemplate[];
103
139
  }
104
140
  export interface WorkflowTemplate {