@contrail/cli 2.3.3 → 2.3.5

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.
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const parseOptionSetsLocalFiles_1 = require("../../commands/types/parseOptionSetsLocalFiles");
4
+ describe('parseNameAndLabelAndKey', () => {
5
+ it('should parse Name, Value, and Display, Disabled columns correctly if they are all present', () => {
6
+ const input = [
7
+ {
8
+ Name: 'Category',
9
+ Value: 'bottoms',
10
+ Display: 'Bottoms',
11
+ Disabled: 'false',
12
+ },
13
+ {
14
+ Name: 'Category',
15
+ Value: 'dresses',
16
+ Display: 'Dresses',
17
+ Disabled: 'true',
18
+ },
19
+ {
20
+ Name: 'Category',
21
+ Value: 'jacket',
22
+ Display: 'Jacket',
23
+ Disabled: 'true',
24
+ },
25
+ { Name: 'Fit', Value: 'active', Display: 'Active', Disabled: 'TRUE' },
26
+ ];
27
+ const expectedOutput = [
28
+ {
29
+ name: 'Category',
30
+ slug: 'category',
31
+ isArchived: false,
32
+ optionSet: [
33
+ {
34
+ value: 'bottoms',
35
+ display: 'Bottoms',
36
+ disabled: false,
37
+ },
38
+ {
39
+ value: 'dresses',
40
+ display: 'Dresses',
41
+ disabled: true,
42
+ },
43
+ {
44
+ value: 'jacket',
45
+ display: 'Jacket',
46
+ disabled: true,
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ name: 'Fit',
52
+ slug: 'fit',
53
+ isArchived: false,
54
+ optionSet: [
55
+ {
56
+ value: 'active',
57
+ display: 'Active',
58
+ disabled: true,
59
+ },
60
+ ],
61
+ },
62
+ ];
63
+ const result = (0, parseOptionSetsLocalFiles_1.parseNameAndLabelAndKey)(input);
64
+ expect(result).toEqual(expectedOutput);
65
+ });
66
+ it('should skip invalid rows or rows with incorrect number of columns', () => {
67
+ const input = [
68
+ {
69
+ Name: 'Category',
70
+ Value: 'dresses',
71
+ Display: 'Dresses',
72
+ },
73
+ {
74
+ Name: 'Category',
75
+ Value: 'bottoms',
76
+ Display: 'Bottoms',
77
+ Disabled: '', // this is invalid row which should be skipped
78
+ },
79
+ {
80
+ Name: 'Category',
81
+ Value: 'jacket',
82
+ },
83
+ { Name: 'Fit', Value: 'active', Display: 'Active', Disabled: 'true' },
84
+ ];
85
+ const expectedOutput = [
86
+ {
87
+ name: 'Category',
88
+ slug: 'category',
89
+ isArchived: false,
90
+ optionSet: [
91
+ {
92
+ value: 'dresses',
93
+ display: 'Dresses',
94
+ disabled: false,
95
+ },
96
+ ],
97
+ },
98
+ {
99
+ name: 'Fit',
100
+ slug: 'fit',
101
+ isArchived: false,
102
+ optionSet: [
103
+ {
104
+ value: 'active',
105
+ display: 'Active',
106
+ disabled: true,
107
+ },
108
+ ],
109
+ },
110
+ ];
111
+ const result = (0, parseOptionSetsLocalFiles_1.parseNameAndLabelAndKey)(input);
112
+ expect(result).toEqual(expectedOutput);
113
+ });
114
+ it('should set disabled value to default value of false for invalid row values', () => {
115
+ const input = [
116
+ {
117
+ Name: 'Category',
118
+ Value: 'bottoms',
119
+ Display: 'Bottoms',
120
+ Disabled: 'false',
121
+ },
122
+ {
123
+ Name: 'Category',
124
+ Value: 'dresses',
125
+ Display: 'Dresses',
126
+ Disabled: 'test',
127
+ },
128
+ {
129
+ Name: 'Category',
130
+ Value: 'jacket',
131
+ Display: 'Jacket',
132
+ Disabled: 'abc',
133
+ },
134
+ { Name: 'Fit', Value: 'active', Display: 'Active', Disabled: 'true' },
135
+ ];
136
+ const expectedOutput = [
137
+ {
138
+ name: 'Category',
139
+ slug: 'category',
140
+ isArchived: false,
141
+ optionSet: [
142
+ {
143
+ value: 'bottoms',
144
+ display: 'Bottoms',
145
+ disabled: false,
146
+ },
147
+ {
148
+ value: 'dresses',
149
+ display: 'Dresses',
150
+ disabled: false,
151
+ },
152
+ {
153
+ value: 'jacket',
154
+ display: 'Jacket',
155
+ disabled: false,
156
+ },
157
+ ],
158
+ },
159
+ {
160
+ name: 'Fit',
161
+ slug: 'fit',
162
+ isArchived: false,
163
+ optionSet: [
164
+ {
165
+ value: 'active',
166
+ display: 'Active',
167
+ disabled: true,
168
+ },
169
+ ],
170
+ },
171
+ ];
172
+ const result = (0, parseOptionSetsLocalFiles_1.parseNameAndLabelAndKey)(input);
173
+ expect(result).toEqual(expectedOutput);
174
+ });
175
+ it('should handle missing disabled field correctly', () => {
176
+ const input = [
177
+ {
178
+ Name: 'Category',
179
+ Value: 'dresses',
180
+ Display: 'Dresses',
181
+ },
182
+ { Name: 'Fit', Value: 'active', Display: 'Active' },
183
+ ];
184
+ const expectedOutput = [
185
+ {
186
+ name: 'Category',
187
+ slug: 'category',
188
+ isArchived: false,
189
+ optionSet: [
190
+ {
191
+ value: 'dresses',
192
+ display: 'Dresses',
193
+ disabled: false,
194
+ },
195
+ ],
196
+ },
197
+ {
198
+ name: 'Fit',
199
+ slug: 'fit',
200
+ isArchived: false,
201
+ optionSet: [
202
+ {
203
+ value: 'active',
204
+ display: 'Active',
205
+ disabled: false,
206
+ },
207
+ ],
208
+ },
209
+ ];
210
+ const result = (0, parseOptionSetsLocalFiles_1.parseNameAndLabelAndKey)(input);
211
+ expect(result).toEqual(expectedOutput);
212
+ });
213
+ it('should convert number value to string', () => {
214
+ const input = [
215
+ {
216
+ Name: 'Category',
217
+ Value: 123,
218
+ Display: 'Category',
219
+ Disabled: 'false',
220
+ },
221
+ ];
222
+ const expectedOutput = [
223
+ {
224
+ name: 'Category',
225
+ slug: 'category',
226
+ isArchived: false,
227
+ optionSet: [
228
+ {
229
+ value: '123',
230
+ display: 'Category',
231
+ disabled: false,
232
+ },
233
+ ],
234
+ },
235
+ ];
236
+ const result = (0, parseOptionSetsLocalFiles_1.parseNameAndLabelAndKey)(input);
237
+ expect(result).toEqual(expectedOutput);
238
+ });
239
+ describe('parseDisabledValue', () => {
240
+ it('should return true for valid "true" string', () => {
241
+ const input = 'true';
242
+ const result = (0, parseOptionSetsLocalFiles_1.parseDisabledValue)(input);
243
+ expect(result).toBe(true);
244
+ });
245
+ it('should return true for valid case insensitive "true" string', () => {
246
+ const input = 'TRUE';
247
+ const result = (0, parseOptionSetsLocalFiles_1.parseDisabledValue)(input);
248
+ expect(result).toBe(true);
249
+ });
250
+ it('should return false for valid "false" string', () => {
251
+ const input = 'false';
252
+ const result = (0, parseOptionSetsLocalFiles_1.parseDisabledValue)(input);
253
+ expect(result).toBe(false);
254
+ });
255
+ it('should return true for valid case insensitive "false" string', () => {
256
+ const input = 'FALSE';
257
+ const result = (0, parseOptionSetsLocalFiles_1.parseDisabledValue)(input);
258
+ expect(result).toBe(false);
259
+ });
260
+ it('should return false for invalid string', () => {
261
+ const input = 'invalid';
262
+ const result = (0, parseOptionSetsLocalFiles_1.parseDisabledValue)(input);
263
+ expect(result).toBe(false);
264
+ });
265
+ });
266
+ });
267
+ describe('parseLabelsInColumn', () => {
268
+ it('should parse option sets with number values as strings', () => {
269
+ const input = [{ Gender: 1 }, { Gender: 2 }, { Gender: 3 }];
270
+ const expectedOutput = [
271
+ {
272
+ name: 'Gender',
273
+ slug: 'gender',
274
+ isArchived: false,
275
+ optionSet: [
276
+ { value: '1', display: '1' },
277
+ { value: '2', display: '2' },
278
+ { value: '3', display: '3' },
279
+ ],
280
+ },
281
+ ];
282
+ const result = (0, parseOptionSetsLocalFiles_1.parseLabelsInColumn)(input);
283
+ expect(result).toEqual(expectedOutput);
284
+ });
285
+ });
@@ -53,13 +53,13 @@ async function uploadReducedTypes(dir) {
53
53
  });
54
54
  currentTypes.push(typeWithProperties);
55
55
  }
56
- const currentTypesBySlug = {};
56
+ const currentTypesByTypePath = {};
57
57
  for (const currentType of currentTypes) {
58
- currentTypesBySlug[currentType.slug] = currentType;
58
+ currentTypesByTypePath[currentType.typePath] = currentType;
59
59
  }
60
- const newTypesBySlug = {};
60
+ const newTypesByTypePath = {};
61
61
  for (const type of types) {
62
- newTypesBySlug[type.slug] = type;
62
+ newTypesByTypePath[type.typePath] = type;
63
63
  }
64
64
  const optionSets = await new sdk_1.Entities().get({
65
65
  entityName: 'type-property-option-set',
@@ -70,13 +70,13 @@ async function uploadReducedTypes(dir) {
70
70
  }
71
71
  for (const type of types) {
72
72
  try {
73
- const found = currentTypesBySlug[type.slug];
73
+ const found = currentTypesByTypePath[type.typePath];
74
74
  if (!found) {
75
75
  if (!type.typePath.includes(':')) {
76
76
  logger_1.default.info(`Cannot create a base type. Skipping: ${type.slug}`);
77
77
  continue;
78
78
  }
79
- logger_1.default.info(`Creating Type: ${type.slug}`);
79
+ logger_1.default.info(`Creating Type: ${type.typePath}`);
80
80
  const createdType = await new sdk_1.Entities().create({
81
81
  entityName: 'type',
82
82
  object: {
@@ -126,7 +126,7 @@ async function uploadReducedTypes(dir) {
126
126
  });
127
127
  }
128
128
  else {
129
- logger_1.default.debug(`Skipping empty update of type ${type.slug}`);
129
+ logger_1.default.debug(`Skipping empty update of type ${type.typePath}`);
130
130
  }
131
131
  await uploadReducedTypeProperties(updatedType, found.typeProperties, type.typeProperties, optionSets);
132
132
  }
@@ -171,6 +171,10 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
171
171
  carryOverDefault: newPropertyType.carryOverDefault,
172
172
  referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug,
173
173
  defaultValue: newPropertyType.defaultValue,
174
+ typePropertyUserListId: newPropertyType.typePropertyUserListId,
175
+ referencedTypeRole: newPropertyType.referencedTypeRole,
176
+ isUniqueProperty: newPropertyType.isUniqueProperty,
177
+ isUniquePropertyInFamily: newPropertyType.isUniquePropertyInFamily,
174
178
  propertyLevel: newPropertyType.propertyLevel,
175
179
  formulaFunction: newPropertyType.formulaFunction,
176
180
  validationFunction: newPropertyType.validationFunction,
@@ -203,6 +207,10 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
203
207
  referencedTypeRootSlug: newPropertyType.referencedTypeRootSlug ?? null,
204
208
  defaultValue: newPropertyType.defaultValue ?? null,
205
209
  propertyLevel: newPropertyType.propertyLevel ?? null,
210
+ typePropertyUserListId: newPropertyType.typePropertyUserListId ?? null,
211
+ referencedTypeRole: newPropertyType.referencedTypeRole ?? null,
212
+ isUniqueProperty: newPropertyType.isUniqueProperty ?? null,
213
+ isUniquePropertyInFamily: newPropertyType.isUniquePropertyInFamily ?? null,
206
214
  formulaFunction: newPropertyType.formulaFunction ?? null,
207
215
  validationFunction: newPropertyType.validationFunction ?? null,
208
216
  numberFormat: newPropertyType.numberFormat ?? null,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const uploadOptionSets_1 = require("../../commands/types/uploadOptionSets");
4
+ describe('parseOptionSetValuesToString', () => {
5
+ it('should convert all option set values to strings', () => {
6
+ const input = {
7
+ value1: 123,
8
+ value2: true,
9
+ value3: { nested: 'object' },
10
+ };
11
+ const expectedOutput = {
12
+ value1: '123',
13
+ value2: 'true',
14
+ value3: { nested: 'object' },
15
+ };
16
+ const result = (0, uploadOptionSets_1.parseOptionSetValuesToString)(input);
17
+ expect(result).toEqual(expectedOutput);
18
+ });
19
+ });
@@ -62,6 +62,8 @@ class WorkflowTemplateDefinitionDeployer {
62
62
  identifier: definition.identifier,
63
63
  builtIn: definition.builtIn,
64
64
  messageGroupId: definition.messageGroupId,
65
+ messageGroup: definition.messageGroup,
66
+ dynamicMessageGroupId: definition.dynamicMessageGroupId,
65
67
  parallelWorkerCount: definition.parallelWorkerCount,
66
68
  triggerKey: definition.triggerKey,
67
69
  workflowDefinition: definition.workflowDefinition,
@@ -115,6 +117,8 @@ class WorkflowTemplateDefinitionDeployer {
115
117
  public: workflowDeclaration.public,
116
118
  isActive: workflowDeclaration.isActive,
117
119
  messageGroupId: workflowDeclaration.messageGroupId,
120
+ messageGroup: workflowDeclaration.messageGroup,
121
+ dynamicMessageGroupId: workflowDeclaration.dynamicMessageGroupId,
118
122
  parallelWorkerCount: workflowDeclaration.parallelWorkerCount,
119
123
  };
120
124
  const workflowTemplate = await (0, event_workflow_template_definition_1.createWorkflowTemplateDefinition)(newObject);
@@ -44,6 +44,8 @@ class LocalWorkflowTemplateDeployer {
44
44
  isActive: workflowTemplate.isActive,
45
45
  supportingAppId: workflowTemplate.supportingAppId,
46
46
  messageGroupId: workflowTemplate.messageGroupId,
47
+ messageGroup: workflowTemplate.messageGroup,
48
+ dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId,
47
49
  parallelWorkerCount: workflowTemplate.parallelWorkerCount,
48
50
  };
49
51
  const newWorkflowTemplate = await (0, event_workflow_templates_1.createWorkflowTemplate)(newObject);
@@ -159,6 +161,8 @@ class LocalWorkflowTemplateDeployer {
159
161
  builtIn: workflowTemplate.builtIn,
160
162
  workflowDefinition: workflowTemplate.workflowDefinition,
161
163
  messageGroupId: workflowTemplate.messageGroupId ?? existingWorkflowTemplate.messageGroupId,
164
+ messageGroup: workflowTemplate.messageGroup ?? existingWorkflowTemplate.messageGroup,
165
+ dynamicMessageGroupId: workflowTemplate.dynamicMessageGroupId ?? existingWorkflowTemplate.dynamicMessageGroupId,
162
166
  parallelWorkerCount: workflowTemplate.parallelWorkerCount ?? existingWorkflowTemplate.parallelWorkerCount,
163
167
  });
164
168
  const updatedWorkflowTemplate = await (0, event_workflow_templates_1.updateWorkflowTemplate)({
@@ -73,6 +73,8 @@ export interface WorkflowDefinition {
73
73
  supportingAppId?: string;
74
74
  parallelWorkerCount?: number;
75
75
  messageGroupId?: string;
76
+ messageGroup?: string;
77
+ dynamicMessageGroupId?: string;
76
78
  }
77
79
  export interface WorkflowTemplateDeclaration {
78
80
  appIdentifier: string;
@@ -91,6 +93,8 @@ export interface WorkflowTemplate {
91
93
  supportingAppId?: string;
92
94
  parallelWorkerCount?: number;
93
95
  messageGroupId?: string;
96
+ messageGroup?: string;
97
+ dynamicMessageGroupId?: string;
94
98
  createdOn?: Date;
95
99
  updatedOn?: Date;
96
100
  createdById?: string;
@@ -330,6 +334,10 @@ export interface ReducedTypeProperty {
330
334
  typePropertyOptionSetSlug: string;
331
335
  formula: string;
332
336
  referencedTypePath: string;
337
+ referencedTypeRole: string;
338
+ typePropertyUserListId: string;
339
+ isUniqueProperty: boolean;
340
+ isUniquePropertyInFamily: boolean;
333
341
  referencedTypeRootSlug: string;
334
342
  defaultValue: string;
335
343
  propertyLevel: string;
@@ -34,7 +34,10 @@ 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
+ parallelWorkerCount: 5 # The maximum number of concurrent jobs to run for this workflow (Range 1-30). Defaults to 5
38
+ messageGroupId: # Optional. Used to group jobs in a specific queue. Allows multiple workflows to use the same queue. Not to be used with dynamicMessageGroupId
39
+ messageGroup: # Optional. Used with dynamicMessageGroupId to allow for dynamic queue assignment and allows for multiple workflows to use the same queue
40
+ dynamicMessageGroupId: # Optional. Allows for dynamic queue assignment based on the event data. Example usage: 'family-queue-{newData.itemFamilyId}'
38
41
  workflowDefinition:
39
42
  paths:
40
43
  - conditional: "true"