@contrail/cli 3.6.0-alpha.f45f126 → 3.7.0-alpha.0d7ff29
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 +405 -71
- package/dist/api/types.d.ts +35 -0
- package/dist/api/types.js +49 -1
- package/dist/auth/login.d.ts +1 -1
- package/dist/auth/login.js +47 -29
- package/dist/auth/login.spec.js +48 -15
- package/dist/auth/sign-in-error.d.ts +7 -0
- package/dist/auth/sign-in-error.js +24 -0
- package/dist/auth/sign-in-error.spec.d.ts +1 -0
- package/dist/auth/sign-in-error.spec.js +22 -0
- package/dist/auth/sso.d.ts +5 -3
- package/dist/auth/sso.js +34 -18
- package/dist/auth/sso.spec.js +63 -10
- package/dist/baseFlags.d.ts +4 -0
- package/dist/baseFlags.js +9 -1
- package/dist/basecommand.d.ts +5 -0
- package/dist/basecommand.js +17 -4
- package/dist/basecommand.spec.d.ts +1 -0
- package/dist/basecommand.spec.js +69 -0
- package/dist/commands/app/create.d.ts +1 -0
- package/dist/commands/app/delete.d.ts +1 -0
- package/dist/commands/app/extension/deploy.d.ts +1 -0
- package/dist/commands/app/extension/deployment/list.d.ts +1 -0
- package/dist/commands/app/getApiKey.d.ts +1 -0
- package/dist/commands/app/getApiKey.js +2 -2
- package/dist/commands/app/init.d.ts +1 -0
- package/dist/commands/app/install.d.ts +1 -0
- package/dist/commands/app/publish.d.ts +1 -0
- package/dist/commands/app/uninstall.d.ts +1 -0
- package/dist/commands/app/upgrade.d.ts +1 -0
- package/dist/commands/app/version/major.d.ts +1 -0
- package/dist/commands/app/version/minor.d.ts +1 -0
- package/dist/commands/app/version/patch.d.ts +1 -0
- package/dist/commands/config/create.d.ts +2 -0
- package/dist/commands/config/create.js +1 -0
- package/dist/commands/config/describe.d.ts +2 -0
- package/dist/commands/config/describe.js +7 -4
- package/dist/commands/config/list.d.ts +2 -0
- package/dist/commands/config/list.js +2 -3
- package/dist/commands/config/set.d.ts +1 -0
- package/dist/commands/config/set.js +11 -6
- package/dist/commands/config/use.d.ts +2 -0
- package/dist/commands/config/use.js +4 -0
- package/dist/commands/entities/create.d.ts +50 -0
- package/dist/commands/entities/create.js +618 -0
- package/dist/commands/entities/create.spec.d.ts +1 -0
- package/dist/commands/entities/create.spec.js +581 -0
- package/dist/commands/entities/delete.d.ts +21 -0
- package/dist/commands/entities/delete.js +146 -0
- package/dist/commands/entities/get.d.ts +26 -0
- package/dist/commands/entities/get.js +298 -0
- package/dist/commands/entities/grammar.spec.d.ts +1 -0
- package/dist/commands/entities/grammar.spec.js +79 -0
- package/dist/commands/entities/output.spec.d.ts +1 -0
- package/dist/commands/entities/output.spec.js +72 -0
- package/dist/commands/entities/update.d.ts +33 -0
- package/dist/commands/entities/update.js +212 -0
- package/dist/commands/feature-flags/export.d.ts +1 -0
- package/dist/commands/feature-flags/import.d.ts +1 -0
- package/dist/commands/file/upload.d.ts +1 -0
- package/dist/commands/groups/export.d.ts +1 -0
- package/dist/commands/groups/import.d.ts +1 -0
- package/dist/commands/instance/export.d.ts +1 -0
- package/dist/commands/instance/import.d.ts +1 -0
- package/dist/commands/load/colors.d.ts +1 -0
- package/dist/commands/load/custom-entity.d.ts +1 -0
- package/dist/commands/load/line-sheet.d.ts +1 -0
- package/dist/commands/load/upload-and-load.d.ts +1 -0
- package/dist/commands/load-local/index.d.ts +1 -0
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.js +1 -1
- package/dist/commands/org-config/export.d.ts +1 -0
- package/dist/commands/org-config/import.d.ts +1 -0
- package/dist/commands/projects/export.d.ts +1 -0
- package/dist/commands/projects/list.d.ts +1 -0
- package/dist/commands/projects/load.d.ts +1 -0
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +1 -0
- package/dist/commands/types/getAll.d.ts +1 -0
- package/dist/commands/types/getOptionSets.d.ts +1 -0
- package/dist/commands/types/loadAll.d.ts +1 -0
- package/dist/commands/types/mergeOptionSets.d.ts +1 -0
- package/dist/commands/types/mergeTypeProperties.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +1 -0
- package/dist/commands/types/parseTypesFromFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +1 -0
- package/dist/commands/types/uploadOptionSets.d.ts +1 -0
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +1 -0
- package/dist/commands/types/uploadRuleSets.d.ts +1 -0
- package/dist/commands/types/uploadTypeOverrides.d.ts +1 -0
- package/dist/commands/types/uploadTypePolicies.d.ts +1 -0
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +1 -0
- package/dist/commands/types/uploadTypes.d.ts +1 -0
- package/dist/commands/users/export.d.ts +1 -0
- package/dist/commands/users/import.d.ts +1 -0
- package/dist/commands/webhooks/create.d.ts +1 -0
- package/dist/commands/webhooks/delete.d.ts +1 -0
- package/dist/commands/webhooks/delete.js +2 -3
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +1 -0
- package/dist/commands/webhooks/list.d.ts +1 -0
- package/dist/commands/workflow-template-definitions/install.d.ts +1 -0
- package/dist/commands/workflow-template-definitions/list.d.ts +1 -0
- package/dist/commands/workflow-templates/delete.d.ts +1 -0
- package/dist/commands/workflow-templates/export.d.ts +1 -0
- package/dist/commands/workflow-templates/list.d.ts +1 -0
- package/dist/commands/workflow-templates/load.d.ts +1 -0
- package/dist/common.d.ts +10 -1
- package/dist/common.js +37 -1
- package/dist/common.spec.d.ts +1 -0
- package/dist/common.spec.js +40 -0
- package/dist/helpers/config/config.d.ts +4 -3
- package/dist/helpers/config/config.js +52 -45
- package/dist/helpers/config/config.spec.d.ts +1 -0
- package/dist/helpers/config/config.spec.js +79 -0
- package/dist/helpers/config/redact-tokens.d.ts +1 -0
- package/dist/helpers/config/redact-tokens.js +14 -0
- package/dist/helpers/config/redact-tokens.spec.d.ts +1 -0
- package/dist/helpers/config/redact-tokens.spec.js +24 -0
- package/dist/helpers/entities/assortment-items.d.ts +11 -0
- package/dist/helpers/entities/assortment-items.js +76 -0
- package/dist/helpers/entities/batchFetch.d.ts +11 -0
- package/dist/helpers/entities/batchFetch.js +50 -0
- package/dist/helpers/entities/index.d.ts +3 -0
- package/dist/helpers/entities/index.js +6 -0
- package/dist/helpers/entities/items.d.ts +6 -0
- package/dist/helpers/entities/items.js +60 -0
- package/dist/helpers/entities/items.spec.d.ts +1 -0
- package/dist/helpers/entities/items.spec.js +19 -0
- package/dist/helpers/entities/project-items.d.ts +2 -0
- package/dist/helpers/entities/project-items.js +44 -0
- package/dist/helpers/file-helpers.d.ts +1 -0
- package/dist/helpers/file-helpers.js +20 -3
- package/dist/helpers/propertySpecifications/dateRanges.d.ts +34 -0
- package/dist/helpers/propertySpecifications/dateRanges.js +91 -0
- package/dist/helpers/propertySpecifications/dateRanges.spec.d.ts +1 -0
- package/dist/helpers/propertySpecifications/dateRanges.spec.js +97 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +39 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.js +102 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +1 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +387 -0
- package/dist/helpers/propertySpecifications/propertyValues.d.ts +31 -0
- package/dist/helpers/propertySpecifications/propertyValues.js +132 -0
- package/dist/helpers/propertySpecifications/propertyValues.spec.d.ts +1 -0
- package/dist/helpers/propertySpecifications/propertyValues.spec.js +156 -0
- package/dist/logger.js +4 -1
- package/dist/logger.spec.d.ts +1 -0
- package/dist/logger.spec.js +12 -0
- package/node_modules/@contrail/entity-compare/package.json +6 -3
- package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
- package/node_modules/@contrail/loader/lib/constants.d.ts +0 -8
- package/node_modules/@contrail/loader/lib/constants.js +1 -9
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +0 -4
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +0 -57
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +34 -492
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +52 -2
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +85 -0
- package/node_modules/@contrail/loader/package.json +2 -2
- package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +1 -4
- package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
- package/node_modules/@contrail/sdk/lib/config/config.d.ts +3 -0
- package/node_modules/@contrail/sdk/lib/config/config.js +13 -7
- package/node_modules/@contrail/sdk/lib/core/request.js +6 -2
- package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +2 -0
- package/node_modules/@contrail/sdk/lib/entities/entities.client.js +3 -1
- package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +1 -0
- package/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +34 -0
- package/node_modules/@contrail/sdk/lib/image-search/image-search.js +42 -0
- package/node_modules/@contrail/sdk/lib/image-search/index.d.ts +1 -0
- package/node_modules/@contrail/sdk/lib/image-search/index.js +17 -0
- package/node_modules/@contrail/sdk/lib/index.d.ts +1 -0
- package/node_modules/@contrail/sdk/lib/index.js +1 -0
- package/node_modules/@contrail/sdk/package.json +1 -1
- package/node_modules/@contrail/sdk/scripts/replicate-bug.js +69 -0
- package/oclif.manifest.json +969 -9
- package/package.json +6 -12
|
@@ -21,514 +21,56 @@ describe('Item Processor', () => {
|
|
|
21
21
|
],
|
|
22
22
|
};
|
|
23
23
|
describe('validateLoadFile', () => {
|
|
24
|
-
it('should
|
|
25
|
-
const
|
|
24
|
+
it('should throw error for the duplicate itemOptionFederatedId', () => {
|
|
25
|
+
const lineSheetData = [
|
|
26
26
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
input_col_2: 'value_2',
|
|
31
|
-
typePath: 'item',
|
|
27
|
+
itemName: 'foo',
|
|
28
|
+
itemFamilyFederatedId: '1',
|
|
29
|
+
itemOptionFederatedId: '11',
|
|
32
30
|
},
|
|
33
31
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
input_col_2: 'value_4',
|
|
38
|
-
typePath: 'item',
|
|
32
|
+
itemName: 'foo',
|
|
33
|
+
itemFamilyFederatedId: '1',
|
|
34
|
+
itemOptionFederatedId: '11',
|
|
39
35
|
},
|
|
40
36
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
input_col_2: 'value_6',
|
|
45
|
-
typePath: 'item',
|
|
37
|
+
itemName: 'bar',
|
|
38
|
+
itemFamilyFederatedId: '2',
|
|
39
|
+
itemOptionFederatedId: '12',
|
|
46
40
|
},
|
|
47
41
|
];
|
|
48
42
|
const config = {
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
loadType: ['ITEM'],
|
|
44
|
+
federatedMappings: {
|
|
45
|
+
name: 'itemName',
|
|
46
|
+
itemFamilyFederatedId: 'itemFamilyFederatedId',
|
|
47
|
+
},
|
|
51
48
|
};
|
|
52
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(
|
|
53
|
-
expect(result.
|
|
49
|
+
const result = item_processor_1.ItemProcessor.validateLoadFile(lineSheetData, config);
|
|
50
|
+
expect(result.errors).toEqual([
|
|
54
51
|
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
]);
|
|
59
|
-
});
|
|
60
|
-
describe('validate typepath', () => {
|
|
61
|
-
it('should throw general error if typePath is incorrect', () => {
|
|
62
|
-
const data = [
|
|
63
|
-
{
|
|
64
|
-
name: 'item1',
|
|
65
|
-
family_federated_id: 'family_1',
|
|
66
|
-
input_col_1: 'value_1',
|
|
67
|
-
input_col_2: 'value_2',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'item2',
|
|
71
|
-
family_federated_id: 'family_2',
|
|
72
|
-
input_col_1: 'value_3',
|
|
73
|
-
input_col_2: 'value_4',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: 'item3',
|
|
77
|
-
family_federated_id: 'family_3',
|
|
78
|
-
input_col_1: 'value_5',
|
|
79
|
-
input_col_2: 'value_6',
|
|
80
|
-
},
|
|
81
|
-
];
|
|
82
|
-
const config = {
|
|
83
|
-
...loaderProcess,
|
|
84
|
-
conditionalColumns: [
|
|
52
|
+
rowNumber: 2,
|
|
53
|
+
columnIssues: [
|
|
85
54
|
{
|
|
86
|
-
|
|
87
|
-
|
|
55
|
+
columnName: 'itemOptionFederatedId',
|
|
56
|
+
message: 'Duplicate federatedId found: 11',
|
|
57
|
+
issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
|
|
58
|
+
data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
|
|
88
59
|
},
|
|
89
60
|
],
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
95
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
96
|
-
},
|
|
97
|
-
]);
|
|
98
|
-
});
|
|
99
|
-
it('should throw error if typepath is present in the config file but have incorrect typePath', () => {
|
|
100
|
-
const data = [
|
|
101
|
-
{
|
|
102
|
-
name: 'item1',
|
|
103
|
-
family_federated_id: 'family_1',
|
|
104
|
-
input_col_1: 'value_1',
|
|
105
|
-
input_col_2: 'value_2',
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: 'item2',
|
|
109
|
-
family_federated_id: 'family_2',
|
|
110
|
-
input_col_1: 'value_3',
|
|
111
|
-
input_col_2: 'value_4',
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'item3',
|
|
115
|
-
family_federated_id: 'family_3',
|
|
116
|
-
input_col_1: 'value_5',
|
|
117
|
-
input_col_2: 'value_6',
|
|
118
|
-
},
|
|
119
|
-
];
|
|
120
|
-
const config = {
|
|
121
|
-
...loaderProcess,
|
|
122
|
-
conditionalColumns: [
|
|
123
|
-
{
|
|
124
|
-
toProperty: 'typePath',
|
|
125
|
-
default: 'custom-entity1',
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
};
|
|
129
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
130
|
-
expect(result.generalErrors).toEqual([
|
|
131
|
-
{
|
|
132
|
-
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
133
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
134
|
-
},
|
|
135
|
-
]);
|
|
136
|
-
});
|
|
137
|
-
it('should throw error if typepath is present in the csv header but have incorrect typePath', () => {
|
|
138
|
-
const data = [
|
|
139
|
-
{
|
|
140
|
-
name: 'item1',
|
|
141
|
-
family_federated_id: 'family_1',
|
|
142
|
-
input_col_1: 'value_1',
|
|
143
|
-
input_col_2: 'value_2',
|
|
144
|
-
typePath: 'custom-entity1',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
name: 'item2',
|
|
148
|
-
family_federated_id: 'family_2',
|
|
149
|
-
input_col_1: 'value_3',
|
|
150
|
-
input_col_2: 'value_4',
|
|
151
|
-
typePath: 'custom-entity1',
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: 'item3',
|
|
155
|
-
family_federated_id: 'family_3',
|
|
156
|
-
input_col_1: 'value_5',
|
|
157
|
-
input_col_2: 'value_6',
|
|
158
|
-
typePath: 'custom-entity1',
|
|
159
|
-
},
|
|
160
|
-
];
|
|
161
|
-
const config = {
|
|
162
|
-
...loaderProcess,
|
|
163
|
-
conditionalColumns: [],
|
|
164
|
-
};
|
|
165
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
166
|
-
expect(result.generalErrors).toEqual([
|
|
167
|
-
{
|
|
168
|
-
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
169
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
170
|
-
},
|
|
171
|
-
]);
|
|
172
|
-
});
|
|
173
|
-
it('should throw error if typepath is not present in csv header', () => {
|
|
174
|
-
const data = [
|
|
175
|
-
{
|
|
176
|
-
name: 'item1',
|
|
177
|
-
family_federated_id: 'family_1',
|
|
178
|
-
input_col_1: 'value_1',
|
|
179
|
-
input_col_2: 'value_2',
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
name: 'item2',
|
|
183
|
-
family_federated_id: 'family_2',
|
|
184
|
-
input_col_1: 'value_3',
|
|
185
|
-
input_col_2: 'value_4',
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
name: 'item3',
|
|
189
|
-
family_federated_id: 'family_3',
|
|
190
|
-
input_col_1: 'value_5',
|
|
191
|
-
input_col_2: 'value_6',
|
|
192
|
-
},
|
|
193
|
-
];
|
|
194
|
-
const config = {
|
|
195
|
-
...loaderProcess,
|
|
196
|
-
conditionalColumns: [],
|
|
197
|
-
};
|
|
198
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
199
|
-
expect(result.generalErrors).toEqual([
|
|
200
|
-
{
|
|
201
|
-
message: constants_1.ITEM_PROCESSOR_ERRORS.TYPEPATH_INVALID,
|
|
202
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
203
|
-
},
|
|
204
|
-
]);
|
|
205
|
-
});
|
|
206
|
-
it('should not throw error if every row has a valid typePath', () => {
|
|
207
|
-
const data = [
|
|
208
|
-
{
|
|
209
|
-
name: 'item1',
|
|
210
|
-
family_federated_id: 'family_1',
|
|
211
|
-
input_col_1: 'value_1',
|
|
212
|
-
input_col_2: 'value_2',
|
|
213
|
-
typePath: 'item',
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
name: 'item2',
|
|
217
|
-
family_federated_id: 'family_2',
|
|
218
|
-
input_col_1: 'value_3',
|
|
219
|
-
input_col_2: 'value_4',
|
|
220
|
-
typePath: 'item:material:fabric:yarn',
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
name: 'item3',
|
|
224
|
-
family_federated_id: 'family_3',
|
|
225
|
-
input_col_1: 'value_5',
|
|
226
|
-
input_col_2: 'value_6',
|
|
227
|
-
typePath: 'item:material:fabric:leather',
|
|
228
|
-
},
|
|
229
|
-
];
|
|
230
|
-
const config = {
|
|
231
|
-
...loaderProcess,
|
|
232
|
-
conditionalColumns: [],
|
|
233
|
-
};
|
|
234
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
235
|
-
expect(result.generalErrors).toEqual([]);
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
describe('validate itemOptionFederatedId', () => {
|
|
239
|
-
it('should validate optionFederatedId in conditional columns', () => {
|
|
240
|
-
const data = [{ name: 'test1', optionName: 'Test Option 1' }];
|
|
241
|
-
const config = {
|
|
242
|
-
...loaderProcess,
|
|
243
|
-
conditionalColumns: [
|
|
244
|
-
{
|
|
245
|
-
toProperty: 'itemFamilyFederatedId',
|
|
246
|
-
default: 'test-{name}',
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
toProperty: 'itemOptionFederatedId',
|
|
250
|
-
default: 'test-{optionName}',
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
};
|
|
254
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
255
|
-
expect(result.generalWarnings).not.toContainEqual({
|
|
256
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
|
|
257
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
it('should validate federatedId in CSV data', () => {
|
|
261
|
-
const data = [
|
|
262
|
-
{
|
|
263
|
-
itemFamilyFederatedId: 'test1',
|
|
264
|
-
itemOptionFederatedId: 'option1',
|
|
265
|
-
name: 'Test 1',
|
|
266
|
-
},
|
|
267
|
-
];
|
|
268
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, loaderProcess);
|
|
269
|
-
expect(result.generalErrors).not.toContainEqual({
|
|
270
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
|
|
271
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
it('should validate federatedId in federatedMapping', () => {
|
|
275
|
-
const data = [{ code: 'test1', option: 'option1', name: 'Test 1' }];
|
|
276
|
-
const config = {
|
|
277
|
-
...loaderProcess,
|
|
278
|
-
federatedMappings: {
|
|
279
|
-
itemFamilyFederatedId: 'code',
|
|
280
|
-
itemOptionFederatedId: 'option',
|
|
281
|
-
},
|
|
282
|
-
};
|
|
283
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
284
|
-
expect(result.generalErrors).not.toContainEqual({
|
|
285
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
|
|
286
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
it('should warning error if itemOptionfederatedId is missing in federatedmapping config, csv header and conditional column', () => {
|
|
290
|
-
const data = [{ name: 'color1', option: 'option1' }];
|
|
291
|
-
const config = {
|
|
292
|
-
id: 'mock-loader-process-id',
|
|
293
|
-
loadFileId: 'mock-load-file-id',
|
|
294
|
-
loadType: [entity_types_1.LoadType.COLOR],
|
|
295
|
-
status: entity_types_1.LoadStatus.COMPLETE,
|
|
296
|
-
conditionalColumns: [
|
|
297
|
-
{
|
|
298
|
-
toProperty: 'typePath',
|
|
299
|
-
default: 'color',
|
|
300
|
-
},
|
|
301
|
-
],
|
|
302
|
-
federatedMappings: {
|
|
303
|
-
name: 'name',
|
|
304
|
-
optionName: 'option',
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
308
|
-
expect(result.generalWarnings).toEqual([
|
|
309
|
-
{
|
|
310
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_UNMAPPED,
|
|
311
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
312
|
-
},
|
|
313
|
-
]);
|
|
314
|
-
});
|
|
315
|
-
it('should return error if itemOptionFederatedId is mapped incorrectly in federatedMappings', () => {
|
|
316
|
-
const lineSheetData = [{ header1: 'value1', test1: 'test1' }];
|
|
317
|
-
const config = {
|
|
318
|
-
loadType: ['ITEM'],
|
|
319
|
-
federatedMappings: {
|
|
320
|
-
name: 'header1',
|
|
321
|
-
itemFamilyFederatedId: 'someId',
|
|
322
|
-
optionName: 'test1',
|
|
323
|
-
itemOptionFederatedId: 'test2',
|
|
324
|
-
},
|
|
325
|
-
};
|
|
326
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(lineSheetData, config);
|
|
327
|
-
expect(result.generalWarnings).toEqual([
|
|
328
|
-
{
|
|
329
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTION_FEDERATED_ID_NOT_FOUND('test2'),
|
|
330
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
331
|
-
},
|
|
332
|
-
]);
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
describe('validate itemOptionName', () => {
|
|
336
|
-
it('should validate optionName in conditional columns', () => {
|
|
337
|
-
const data = [{ federatedId: 'test1' }];
|
|
338
|
-
const config = {
|
|
339
|
-
...loaderProcess,
|
|
340
|
-
federatedMappings: {},
|
|
341
|
-
conditionalColumns: [
|
|
342
|
-
{
|
|
343
|
-
toProperty: 'name',
|
|
344
|
-
default: 'Test {federatedId}',
|
|
345
|
-
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
rowNumber: 3,
|
|
64
|
+
columnIssues: [
|
|
346
65
|
{
|
|
347
|
-
|
|
348
|
-
|
|
66
|
+
columnName: 'itemOptionFederatedId',
|
|
67
|
+
message: 'Duplicate federatedId found: 11',
|
|
68
|
+
issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
|
|
69
|
+
data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
|
|
349
70
|
},
|
|
350
71
|
],
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
console.log(JSON.stringify(result, null, 2));
|
|
354
|
-
expect(result.generalWarnings).not.toContainEqual({
|
|
355
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
|
|
356
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
it('should validate name in CSV data', () => {
|
|
360
|
-
const data = [{ federatedId: 'test1', name: 'Test 1', optionName: 'Option 1' }];
|
|
361
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, loaderProcess);
|
|
362
|
-
expect(result.generalWarnings).not.toContainEqual({
|
|
363
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
|
|
364
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
it('should return warning if optionName is missing in federatedMappings, config and conditional column', () => {
|
|
368
|
-
const data = [{ id: 'custom-entity1', optionId: 'option1' }];
|
|
369
|
-
const config = {
|
|
370
|
-
...loaderProcess,
|
|
371
|
-
loadType: [entity_types_1.LoadType.CUSTOM_ENTITY],
|
|
372
|
-
federatedMappings: {
|
|
373
|
-
federatedId: 'id',
|
|
374
|
-
itemOptionFederatedId: 'optionId',
|
|
375
|
-
},
|
|
376
|
-
};
|
|
377
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
378
|
-
expect(result.generalWarnings).toEqual([
|
|
379
|
-
{
|
|
380
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
|
|
381
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
382
|
-
},
|
|
383
|
-
]);
|
|
384
|
-
});
|
|
385
|
-
it('should validate name in federatedMapping', () => {
|
|
386
|
-
const data = [
|
|
387
|
-
{
|
|
388
|
-
federatedId: 'test1',
|
|
389
|
-
display_name: 'Test 1',
|
|
390
|
-
display_option: 'Option 1',
|
|
391
|
-
},
|
|
392
|
-
];
|
|
393
|
-
const config = {
|
|
394
|
-
...loaderProcess,
|
|
395
|
-
federatedMappings: {
|
|
396
|
-
name: 'display_name',
|
|
397
|
-
optionName: 'display_option',
|
|
398
|
-
},
|
|
399
|
-
};
|
|
400
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
401
|
-
expect(result.generalWarnings).not.toContainEqual({
|
|
402
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
|
|
403
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
it('should return a warning if optionName is not mapped in federatedMappings', () => {
|
|
407
|
-
const data = [
|
|
408
|
-
{
|
|
409
|
-
name: 'item1',
|
|
410
|
-
family_federated_id: 'family_1',
|
|
411
|
-
input_col_1: 'value_1',
|
|
412
|
-
input_col_2: 'value_2',
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
name: 'item2',
|
|
416
|
-
family_federated_id: 'family_2',
|
|
417
|
-
input_col_1: 'value_3',
|
|
418
|
-
input_col_2: 'value_4',
|
|
419
|
-
},
|
|
420
|
-
{
|
|
421
|
-
name: 'item3',
|
|
422
|
-
family_federated_id: 'family_3',
|
|
423
|
-
input_col_1: 'value_5',
|
|
424
|
-
input_col_2: 'value_6',
|
|
425
|
-
},
|
|
426
|
-
];
|
|
427
|
-
const config = {
|
|
428
|
-
...loaderProcess,
|
|
429
|
-
conditionalColumns: [],
|
|
430
|
-
federatedMappings: {
|
|
431
|
-
itemFamilyFederatedId: 'family_federated_id',
|
|
432
|
-
itemOptionFederatedId: 'input_col_1',
|
|
433
|
-
},
|
|
434
|
-
};
|
|
435
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
436
|
-
expect(result.generalWarnings).toEqual([
|
|
437
|
-
{
|
|
438
|
-
message: constants_1.ITEM_PROCESSOR_WARNINGS.OPTIONNAME_UNMAPPED,
|
|
439
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
440
|
-
},
|
|
441
|
-
]);
|
|
442
|
-
});
|
|
443
|
-
it('should return a warning if optionName is mapped incorrectly in federatedMappings', () => {
|
|
444
|
-
const data = [
|
|
445
|
-
{
|
|
446
|
-
name: 'item1',
|
|
447
|
-
family_federated_id: 'family_1',
|
|
448
|
-
input_col_1: 'value_1',
|
|
449
|
-
input_col_2: 'value_2',
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
name: 'item2',
|
|
453
|
-
family_federated_id: 'family_2',
|
|
454
|
-
input_col_1: 'value_3',
|
|
455
|
-
input_col_2: 'value_4',
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
name: 'item3',
|
|
459
|
-
family_federated_id: 'family_3',
|
|
460
|
-
input_col_1: 'value_5',
|
|
461
|
-
input_col_2: 'value_6',
|
|
462
|
-
},
|
|
463
|
-
];
|
|
464
|
-
const config = {
|
|
465
|
-
...loaderProcess,
|
|
466
|
-
conditionalColumns: [],
|
|
467
|
-
federatedMappings: {
|
|
468
|
-
itemFamilyFederatedId: 'family_federated_id',
|
|
469
|
-
itemOptionFederatedId: 'input_col_1',
|
|
470
|
-
optionName: 'input_col_3',
|
|
471
|
-
},
|
|
472
|
-
};
|
|
473
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(data, config);
|
|
474
|
-
expect(result.generalWarnings).toEqual([
|
|
475
|
-
{
|
|
476
|
-
message: '"input_col_3" column not found in the CSV file',
|
|
477
|
-
issueType: entity_types_1.IssueType.CONFIG,
|
|
478
|
-
},
|
|
479
|
-
]);
|
|
480
|
-
});
|
|
481
|
-
it('should throw error for the duplicate itemOptionFederatedId', () => {
|
|
482
|
-
const lineSheetData = [
|
|
483
|
-
{
|
|
484
|
-
itemName: 'foo',
|
|
485
|
-
itemFamilyFederatedId: '1',
|
|
486
|
-
itemOptionFederatedId: '11',
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
itemName: 'foo',
|
|
490
|
-
itemFamilyFederatedId: '1',
|
|
491
|
-
itemOptionFederatedId: '11',
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
itemName: 'bar',
|
|
495
|
-
itemFamilyFederatedId: '2',
|
|
496
|
-
itemOptionFederatedId: '12',
|
|
497
|
-
},
|
|
498
|
-
];
|
|
499
|
-
const config = {
|
|
500
|
-
loadType: ['ITEM'],
|
|
501
|
-
federatedMappings: {
|
|
502
|
-
name: 'itemName',
|
|
503
|
-
itemFamilyFederatedId: 'itemFamilyFederatedId',
|
|
504
|
-
},
|
|
505
|
-
};
|
|
506
|
-
const result = item_processor_1.ItemProcessor.validateLoadFile(lineSheetData, config);
|
|
507
|
-
expect(result.errors).toEqual([
|
|
508
|
-
{
|
|
509
|
-
rowNumber: 2,
|
|
510
|
-
columnIssues: [
|
|
511
|
-
{
|
|
512
|
-
columnName: 'itemOptionFederatedId',
|
|
513
|
-
message: 'Duplicate federatedId found: 11',
|
|
514
|
-
issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
|
|
515
|
-
data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
|
|
516
|
-
},
|
|
517
|
-
],
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
rowNumber: 3,
|
|
521
|
-
columnIssues: [
|
|
522
|
-
{
|
|
523
|
-
columnName: 'itemOptionFederatedId',
|
|
524
|
-
message: 'Duplicate federatedId found: 11',
|
|
525
|
-
issueType: entity_types_1.IssueType.DUPLICATE_FEDERATED_ID,
|
|
526
|
-
data: '{"itemName":"foo","itemFamilyFederatedId":"1","itemOptionFederatedId":"11"}',
|
|
527
|
-
},
|
|
528
|
-
],
|
|
529
|
-
},
|
|
530
|
-
]);
|
|
531
|
-
});
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
532
74
|
});
|
|
533
75
|
describe('validate duplicate optionName within family', () => {
|
|
534
76
|
it('should return errors when options in the same family have duplicate optionNames', () => {
|
|
@@ -49,6 +49,8 @@ async function validate(rows, config, columnAnalysis, client) {
|
|
|
49
49
|
}
|
|
50
50
|
const processorIssues = runProcessorValidation(rows, config);
|
|
51
51
|
issues.push(...processorIssues);
|
|
52
|
+
const itemTypePathIssues = validateItemTypePath(rows, config);
|
|
53
|
+
issues.push(...itemTypePathIssues);
|
|
52
54
|
const itemNameIssues = validateItemNames(rows, config);
|
|
53
55
|
issues.push(...itemNameIssues);
|
|
54
56
|
const identifierConflictIssues = validateStaticIdentifierConflicts(config);
|
|
@@ -135,7 +137,7 @@ function runProcessorValidation(rows, config) {
|
|
|
135
137
|
for (const error of validationResult?.generalErrors ?? []) {
|
|
136
138
|
issues.push({
|
|
137
139
|
severity: types_2.PreValidationSeverity.ERROR,
|
|
138
|
-
category:
|
|
140
|
+
category: issueTypeToCategory(error.issueType),
|
|
139
141
|
columnName: '',
|
|
140
142
|
propertySlug: '',
|
|
141
143
|
propertyType: '',
|
|
@@ -146,7 +148,7 @@ function runProcessorValidation(rows, config) {
|
|
|
146
148
|
for (const warning of validationResult?.generalWarnings ?? []) {
|
|
147
149
|
issues.push({
|
|
148
150
|
severity: types_2.PreValidationSeverity.WARNING,
|
|
149
|
-
category:
|
|
151
|
+
category: issueTypeToCategory(warning.issueType),
|
|
150
152
|
columnName: '',
|
|
151
153
|
propertySlug: '',
|
|
152
154
|
propertyType: '',
|
|
@@ -396,6 +398,54 @@ function validateMultiSelectFormats(rows, typePropertyMaps) {
|
|
|
396
398
|
}
|
|
397
399
|
return issues;
|
|
398
400
|
}
|
|
401
|
+
function validateItemTypePath(rows, config) {
|
|
402
|
+
const isItemCreate = config.loadType.includes(types_2.LoadType.ITEM);
|
|
403
|
+
const isCustomEntity = config.loadType.includes(types_2.LoadType.CUSTOM_ENTITY);
|
|
404
|
+
if (!isItemCreate && !isCustomEntity)
|
|
405
|
+
return [];
|
|
406
|
+
const issues = [];
|
|
407
|
+
if (isItemCreate) {
|
|
408
|
+
const invalidRows = [];
|
|
409
|
+
forEachRow(rows, (row, rowNumber) => {
|
|
410
|
+
const tp = row.typePath;
|
|
411
|
+
const valid = tp === 'item' || (typeof tp === 'string' && tp.startsWith('item:') && tp.split(':')[1]?.length > 0);
|
|
412
|
+
if (!valid)
|
|
413
|
+
invalidRows.push({ row: rowNumber, value: String(tp ?? '') });
|
|
414
|
+
});
|
|
415
|
+
if (invalidRows.length > 0) {
|
|
416
|
+
issues.push({
|
|
417
|
+
severity: types_2.PreValidationSeverity.ERROR,
|
|
418
|
+
category: MISSING_REQUIRED_FIELD_CATEGORY,
|
|
419
|
+
columnName: 'typePath',
|
|
420
|
+
propertySlug: 'typePath',
|
|
421
|
+
propertyType: 'string',
|
|
422
|
+
message: `"typePath" must be "item" or "item:<subtypepath>". ${invalidRows.length} row(s) have an invalid or missing typePath.`,
|
|
423
|
+
affectedRows: invalidRows,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (isCustomEntity) {
|
|
428
|
+
const invalidRows = [];
|
|
429
|
+
forEachRow(rows, (row, rowNumber) => {
|
|
430
|
+
const tp = row.typePath;
|
|
431
|
+
const valid = typeof tp === 'string' && tp.startsWith('custom-entity:') && tp.slice('custom-entity:'.length).length > 0;
|
|
432
|
+
if (!valid)
|
|
433
|
+
invalidRows.push({ row: rowNumber, value: String(tp ?? '') });
|
|
434
|
+
});
|
|
435
|
+
if (invalidRows.length > 0) {
|
|
436
|
+
issues.push({
|
|
437
|
+
severity: types_2.PreValidationSeverity.ERROR,
|
|
438
|
+
category: MISSING_REQUIRED_FIELD_CATEGORY,
|
|
439
|
+
columnName: 'typePath',
|
|
440
|
+
propertySlug: 'typePath',
|
|
441
|
+
propertyType: 'string',
|
|
442
|
+
message: `"typePath" must be "custom-entity:<subtypepath>". ${invalidRows.length} row(s) have an invalid or missing typePath.`,
|
|
443
|
+
affectedRows: invalidRows,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return issues;
|
|
448
|
+
}
|
|
399
449
|
function validateItemNames(rows, config) {
|
|
400
450
|
const itemBasedLoadTypes = [types_2.LoadType.ITEM, types_2.LoadType.PROJECT_ITEM, types_2.LoadType.ASSORTMENT];
|
|
401
451
|
const isItemBased = config.loadType.some((lt) => itemBasedLoadTypes.includes(lt));
|