@contrail/cli 2.0.5 → 2.0.7

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 CHANGED
@@ -15,7 +15,7 @@ $ npm install -g @contrail/cli
15
15
  $ contrail COMMAND
16
16
  running command...
17
17
  $ contrail (--version)
18
- @contrail/cli/2.0.5 darwin-arm64 node-v18.13.0
18
+ @contrail/cli/2.0.7 darwin-arm64 node-v18.13.0
19
19
  $ contrail --help [COMMAND]
20
20
  USAGE
21
21
  $ contrail COMMAND
@@ -388,11 +388,12 @@ Exports an data of an instance including types and users
388
388
 
389
389
  ```
390
390
  USAGE
391
- $ contrail instance export [--outDir <value>] [--overwrite]
391
+ $ contrail instance export [-d <value>] [-f]
392
392
 
393
393
  FLAGS
394
- --outDir=<value> [default: .] The directory to which to export the instance data. Defaults to the current directory
395
- --overwrite Replaces any existing export files in outDir
394
+ -d, --outDir=<value> [default: .] The directory to which to export the instance data. Defaults to the current
395
+ directory
396
+ -f, --overwrite Replaces any existing export files in outDir
396
397
 
397
398
  DESCRIPTION
398
399
  Exports an data of an instance including types and users
package/dist/api/apps.js CHANGED
@@ -17,6 +17,7 @@ async function getAllAvailableApps(options) {
17
17
  criteria: {
18
18
  orgId: options.orgId,
19
19
  private: false,
20
+ hidden: true,
20
21
  },
21
22
  }));
22
23
  return apps;
@@ -19,6 +19,6 @@ ExportInstance.examples = [
19
19
  `,
20
20
  ];
21
21
  ExportInstance.flags = {
22
- outDir: core_1.Flags.string({ description: 'The directory to which to export the instance data. Defaults to the current directory', required: false, default: '.' }),
23
- overwrite: core_1.Flags.boolean({ description: 'Replaces any existing export files in outDir', required: false, default: false })
22
+ outDir: core_1.Flags.string({ char: 'd', description: 'The directory to which to export the instance data. Defaults to the current directory', required: false, default: '.' }),
23
+ overwrite: core_1.Flags.boolean({ char: 'f', description: 'Replaces any existing export files in outDir', required: false, default: false })
24
24
  };
@@ -182,7 +182,12 @@ function reduceTypes(dataHolder) {
182
182
  slug: type.slug,
183
183
  label: type.label,
184
184
  isArchived: type.isArchived,
185
- typeProperties: reducedTypeProperties,
185
+ typeProperties: reducedTypeProperties.map(x => {
186
+ delete x['id'];
187
+ return {
188
+ ...x
189
+ };
190
+ }),
186
191
  };
187
192
  reducedTypes.push(reducedType);
188
193
  }
@@ -131,8 +131,8 @@ async function uploadRuleSetLinkObjects(loadedRuleSetLinks) {
131
131
  const hash = `${loadedLink.type}|${loadedLink.ruleSet}`;
132
132
  reducedLinksByHashes[hash] = loadedLink;
133
133
  }
134
- console.debug('current rule set links:', currentLinksHashes);
135
- console.debug('reduced rule set links:', reducedLinksByHashes);
134
+ // console.debug('reduced rule set links:', reducedLinksByHashes);
135
+ // console.debug('current rule set links:', currentLinksHashes);
136
136
  for (const loadedRuleSetLink of loadedRuleSetLinks) {
137
137
  try {
138
138
  const found = currentLinksHashes[`${loadedRuleSetLink.type}|${loadedRuleSetLink.ruleSet}`];
@@ -69,8 +69,8 @@ async function uploadTPPolicyObjects(reducedTypePropertyPolicies) {
69
69
  for (const loadedTPP of reducedTypePropertyPolicies) {
70
70
  loadedTPPByName[loadedTPP.label] = loadedTPP;
71
71
  }
72
- console.debug('current tp policy:', currentTPPolicies);
73
- console.debug('reduced tp policy:', reducedTypePropertyPolicies);
72
+ // console.debug('current tp policy:', currentTPPolicies);
73
+ // console.debug('reduced tp policy:', reducedTypePropertyPolicies);
74
74
  for (const [label, loadedTPP] of Object.entries(loadedTPPByName)) {
75
75
  try {
76
76
  const found = currentTPPByLabel[label];
@@ -8,6 +8,7 @@ const apps_1 = require("../../api/apps");
8
8
  const event_workflow_templates_1 = require("../../api/event-workflow-templates");
9
9
  const event_workflow_template_definition_1 = require("../../api/event-workflow-template-definition");
10
10
  const actions_deployer_1 = require("../app/actions-deployer");
11
+ const interface_converters_1 = require("../../interface-converters");
11
12
  class WorkflowTemplateDefinitionDeployer {
12
13
  async cliInstallWorkflowTemplateDefinitions() {
13
14
  const installedApps = await (0, apps_1.getInstalledApps)();
@@ -94,6 +95,7 @@ class WorkflowTemplateDefinitionDeployer {
94
95
  console.log(`%s \tDeploying workflow definitions: ${workflowKey}`, chalk_1.default.yellow.bold('WORKFLOW DEFINITION'));
95
96
  const identifier = this.getWorkflowDeclarationIdentifier(workflowKey, app);
96
97
  const existingDefinition = existingWorkflows.find(ad => ad.identifier === identifier);
98
+ (0, interface_converters_1.convertWorkflow)(workflow);
97
99
  if (existingDefinition) {
98
100
  return await this.updateWorkflowTemplateDefinition(existingDefinition, workflow, app);
99
101
  }
@@ -9,6 +9,7 @@ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
9
9
  const event_workflow_action_definition_1 = require("../../api/event-workflow-action-definition");
10
10
  const event_workflow_templates_1 = require("../../api/event-workflow-templates");
11
11
  const login_1 = require("../../auth/login");
12
+ const interface_converters_1 = require("../../interface-converters");
12
13
  const yaml = require('js-yaml');
13
14
  class LocalWorkflowTemplateDeployer {
14
15
  async deployWorkflows(wtDeclaration) {
@@ -24,6 +25,7 @@ class LocalWorkflowTemplateDeployer {
24
25
  console.log(`%s \tDeploying workflow: ${workflowKey}`, chalk_1.default.yellow.bold('WORKFLOW TEMPLATES'));
25
26
  const identifier = getWorkflowTemplateIdentifier(workflowKey);
26
27
  const existingTemplate = existingWorkflows.find(ad => ad.identifier === identifier);
28
+ (0, interface_converters_1.convertWorkflow)(workflow);
27
29
  if (existingTemplate) {
28
30
  return await this.updateWorkflowTemplate(workflowKey, existingTemplate, workflow);
29
31
  }
@@ -47,6 +49,7 @@ class LocalWorkflowTemplateDeployer {
47
49
  }
48
50
  async populateActionIds(workflowTemplate, workflowKey) {
49
51
  var _a;
52
+ console.log('workflow tempalate:', JSON.stringify(workflowTemplate, null, 2));
50
53
  if (!((_a = workflowTemplate === null || workflowTemplate === void 0 ? void 0 : workflowTemplate.workflowDefinition) === null || _a === void 0 ? void 0 : _a.paths)) {
51
54
  return;
52
55
  }
@@ -70,11 +73,14 @@ class LocalWorkflowTemplateDeployer {
70
73
  }
71
74
  }
72
75
  async updateWorkflowTemplate(workflowKey, existingWorkflowTemplate, workflowTemplate) {
76
+ var _a, _b;
73
77
  await this.populateActionIds(workflowTemplate, workflowKey);
74
78
  const updates = Object.assign(new Object(), {
75
79
  name: workflowTemplate.name,
76
80
  triggerKey: workflowTemplate.triggerKey,
77
- workflowDefinition: workflowTemplate.workflowDefinition
81
+ workflowDefinition: workflowTemplate.workflowDefinition,
82
+ messageGroupId: (_a = workflowTemplate.messageGroupId) !== null && _a !== void 0 ? _a : existingWorkflowTemplate.messageGroupId,
83
+ parallelWorkerCount: (_b = workflowTemplate.parallelWorkerCount) !== null && _b !== void 0 ? _b : existingWorkflowTemplate.parallelWorkerCount,
78
84
  });
79
85
  const updatedWorkflowTemplate = await (0, event_workflow_templates_1.updateWorkflowTemplate)({ id: existingWorkflowTemplate.id, updates });
80
86
  console.log(`%s Updated existing workflow template: ${updatedWorkflowTemplate.identifier}`, chalk_1.default.yellow.bold('WORKFLOW TEMPLATES'));
@@ -157,7 +163,6 @@ function loadTemplateConfig(saveFile) {
157
163
  const TARGET_DIR = process.cwd();
158
164
  try {
159
165
  const doc = yaml.load(fs_1.default.readFileSync(path.resolve(path.join(TARGET_DIR, saveFile)), 'utf8'));
160
- console.log(doc);
161
166
  return doc;
162
167
  }
163
168
  catch (e) {
@@ -0,0 +1,3 @@
1
+ import { WorkflowDefinition, WorkflowTemplate } from './interfaces';
2
+ export declare const DEFAULT_WORKFLOW_PARALLELISM = 1;
3
+ export declare function convertWorkflow(workflow: WorkflowDefinition | WorkflowTemplate): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertWorkflow = exports.DEFAULT_WORKFLOW_PARALLELISM = void 0;
4
+ exports.DEFAULT_WORKFLOW_PARALLELISM = 1;
5
+ // parses the user-facing interface of the workflow and converts it to the cloud-facing format in-place.
6
+ function convertWorkflow(workflow) {
7
+ var _a;
8
+ workflow.parallelWorkerCount = (_a = workflow.parallelism) !== null && _a !== void 0 ? _a : exports.DEFAULT_WORKFLOW_PARALLELISM;
9
+ workflow.messageGroupId = workflow.groupId;
10
+ }
11
+ exports.convertWorkflow = convertWorkflow;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const interface_converters_1 = require("./interface-converters");
4
+ describe('Workflow Template converter tests', () => {
5
+ it('should use default parallelism', () => {
6
+ const workflow = {
7
+ identifier: 'identifier',
8
+ name: 'name1',
9
+ triggerKey: 'foo|bar',
10
+ workflowDefinition: {
11
+ paths: [
12
+ {
13
+ conditional: 'true',
14
+ actionDefinitionConfigs: [
15
+ {
16
+ action: 'logItem',
17
+ name: 'Log Item'
18
+ }
19
+ ]
20
+ }
21
+ ]
22
+ },
23
+ ownerKey: 'app:123',
24
+ isActive: true,
25
+ public: true,
26
+ // parallelism: 3,
27
+ };
28
+ (0, interface_converters_1.convertWorkflow)(workflow);
29
+ expect(workflow.parallelWorkerCount).toEqual(interface_converters_1.DEFAULT_WORKFLOW_PARALLELISM);
30
+ expect(workflow['concurrency']).toBeUndefined();
31
+ expect(workflow.messageGroupId).toBeUndefined();
32
+ });
33
+ it('should pass user concurrency as parallel count', () => {
34
+ const workflow = {
35
+ identifier: 'identifier',
36
+ name: 'name1',
37
+ triggerKey: 'foo|bar',
38
+ workflowDefinition: {
39
+ paths: [
40
+ {
41
+ conditional: 'true',
42
+ actionDefinitionConfigs: [
43
+ {
44
+ action: 'logItem',
45
+ name: 'Log Item'
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ },
51
+ ownerKey: 'app:123',
52
+ isActive: true,
53
+ public: true,
54
+ parallelism: 3,
55
+ };
56
+ (0, interface_converters_1.convertWorkflow)(workflow);
57
+ expect(workflow.parallelWorkerCount).toEqual(3);
58
+ expect(workflow['concurrency']).toBeUndefined();
59
+ expect(workflow.messageGroupId).toBeUndefined();
60
+ });
61
+ it('should ignore concurrency if we pass group ID or ', () => {
62
+ const workflow = {
63
+ identifier: 'identifier',
64
+ name: 'name1',
65
+ triggerKey: 'foo|bar',
66
+ workflowDefinition: {
67
+ paths: [
68
+ {
69
+ conditional: 'true',
70
+ actionDefinitionConfigs: [
71
+ {
72
+ action: 'logItem',
73
+ name: 'Log Item'
74
+ }
75
+ ]
76
+ }
77
+ ]
78
+ },
79
+ ownerKey: 'app:123',
80
+ isActive: true,
81
+ public: true,
82
+ parallelism: 3,
83
+ };
84
+ (0, interface_converters_1.convertWorkflow)(workflow);
85
+ expect(workflow.parallelWorkerCount).toEqual(3);
86
+ expect(workflow['concurrency']).toBeUndefined();
87
+ expect(workflow.messageGroupId).toBeUndefined();
88
+ });
89
+ });
@@ -57,6 +57,8 @@ export interface WorkflowDefinition {
57
57
  isActive: boolean;
58
58
  public: boolean;
59
59
  supportingAppId?: string;
60
+ parallelism?: number;
61
+ groupId?: string;
60
62
  messageGroupId?: string;
61
63
  parallelWorkerCount?: number;
62
64
  }
@@ -74,6 +76,8 @@ export interface WorkflowTemplate {
74
76
  isActive: boolean;
75
77
  ownerKey?: string;
76
78
  supportingAppId?: string;
79
+ parallelism?: number;
80
+ groupId?: string;
77
81
  messageGroupId?: string;
78
82
  parallelWorkerCount?: number;
79
83
  }
@@ -34,6 +34,7 @@ workflows:
34
34
  triggerKey: item|update
35
35
  isActive: true
36
36
  public: true
37
+ concurrency: 3 # The maximum number of concurrent jobs to run for this workflow. Defaults to 5
37
38
  workflowDefinition:
38
39
  paths:
39
40
  - conditional: "true"
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.5",
2
+ "version": "2.0.7",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -361,6 +361,7 @@
361
361
  "outDir": {
362
362
  "name": "outDir",
363
363
  "type": "option",
364
+ "char": "d",
364
365
  "description": "The directory to which to export the instance data. Defaults to the current directory",
365
366
  "required": false,
366
367
  "multiple": false,
@@ -369,6 +370,7 @@
369
370
  "overwrite": {
370
371
  "name": "overwrite",
371
372
  "type": "boolean",
373
+ "char": "f",
372
374
  "description": "Replaces any existing export files in outDir",
373
375
  "required": false,
374
376
  "allowNo": false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",
@@ -50,16 +50,17 @@
50
50
  "devDependencies": {
51
51
  "@oclif/test": "^2.3.8",
52
52
  "@types/chai": "^4",
53
- "@types/mocha": "^9.0.0",
53
+ "@types/jest": "^29.5.0",
54
54
  "@types/node": "^16.18.14",
55
55
  "chai": "^4",
56
56
  "eslint": "^8.35.0",
57
57
  "eslint-config-oclif": "^4",
58
58
  "eslint-config-oclif-typescript": "^1.0.3",
59
59
  "eslint-plugin-unused-imports": "^2.0.0",
60
- "mocha": "^9",
60
+ "jest": "^29.5.0",
61
61
  "oclif": "^3",
62
62
  "shx": "^0.3.3",
63
+ "ts-jest": "^29.0.5",
63
64
  "ts-node": "^10.9.1",
64
65
  "tslib": "^2.5.0",
65
66
  "typescript": "^4.9.5"
@@ -106,16 +107,29 @@
106
107
  },
107
108
  "scripts": {
108
109
  "build": "shx rm -rf dist && tsc -b && npm run copy-templates",
109
- "lint": "eslint . --ext .ts --config .eslintrc",
110
+ "lint": "eslint . --ext .ts --config .eslintrc.js",
110
111
  "copy-templates": "cp -r templates/ dist/templates",
111
112
  "postpack": "shx rm -f oclif.manifest.json",
112
- "posttest": "yarn lint",
113
113
  "prepack": "yarn build && oclif manifest && oclif readme",
114
- "test": "mocha --forbid-only \"test/**/*.test.ts\"",
114
+ "test": "jest",
115
115
  "version": "oclif readme && git add README.md"
116
116
  },
117
117
  "engines": {
118
118
  "node": ">=12.0.0"
119
119
  },
120
- "types": "dist/index.d.ts"
120
+ "types": "dist/index.d.ts",
121
+ "jest": {
122
+ "moduleFileExtensions": [
123
+ "js",
124
+ "json",
125
+ "ts"
126
+ ],
127
+ "rootDir": "src",
128
+ "testRegex": ".spec.ts$",
129
+ "transform": {
130
+ "^.+\\.(t|j)s$": "ts-jest"
131
+ },
132
+ "coverageDirectory": "../coverage",
133
+ "testEnvironment": "node"
134
+ }
121
135
  }