feed-common 1.11.0 → 1.12.0
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/CHANGELOG.md +14 -0
- package/dist/constants/profile.constants.d.ts +1 -1
- package/dist/constants/profile.constants.d.ts.map +1 -1
- package/dist/constants/profile.constants.js +147 -159
- package/dist/constants/profile.constants.js.map +1 -1
- package/dist/types/profile.types.d.ts +1 -0
- package/dist/types/profile.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants/profile.constants.ts +387 -404
- package/src/types/profile.types.ts +1 -0
- package/tests/profile.spec.ts +70 -43
package/tests/profile.spec.ts
CHANGED
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
sanitizeUploadProfile,
|
13
13
|
sortMappings,
|
14
14
|
} from '../src/utils/profile.js';
|
15
|
-
import {
|
15
|
+
import { ProductUploadMapping, ProductUploadProfile } from '../src/types/profile.types.js';
|
16
16
|
|
17
17
|
describe('Rules duplication', () => {
|
18
18
|
test('no match', () => {
|
@@ -79,8 +79,8 @@ describe('Alwaysness', () => {
|
|
79
79
|
describe('Rules deadlock', () => {
|
80
80
|
test('match #1', () => {
|
81
81
|
const rulesList = [
|
82
|
-
{ ruleItems: [{ id: '1', attribute: 'attr1', operator: 'equals', value: '1' }] },
|
83
|
-
{ ruleItems: [{ id: '5', attribute: 'attr1', operator: 'notEquals', value: '1' }] },
|
82
|
+
{ id: '1', ruleItems: [{ id: '1', attribute: 'attr1', operator: 'equals', value: '1' }] },
|
83
|
+
{ id: '1', ruleItems: [{ id: '5', attribute: 'attr1', operator: 'notEquals', value: '1' }] },
|
84
84
|
];
|
85
85
|
|
86
86
|
expect(checkRuleDeadlocks(rulesList)).toEqual(['1', '5']);
|
@@ -89,18 +89,21 @@ describe('Rules deadlock', () => {
|
|
89
89
|
test('match #2', () => {
|
90
90
|
const rulesList = [
|
91
91
|
{
|
92
|
+
id: '1',
|
92
93
|
ruleItems: [
|
93
94
|
{ id: '1', attribute: 'attr1', operator: 'equals', value: '1' },
|
94
95
|
{ id: '2', attribute: 'attr3', operator: 'equals', value: '1' },
|
95
96
|
],
|
96
97
|
},
|
97
98
|
{
|
99
|
+
id: '1',
|
98
100
|
ruleItems: [
|
99
101
|
{ id: '3', attribute: 'attr1', operator: 'notEquals', value: '1' },
|
100
102
|
{ id: '4', attribute: 'attr2', operator: 'notEquals', value: '1' },
|
101
103
|
],
|
102
104
|
},
|
103
105
|
{
|
106
|
+
id: '1',
|
104
107
|
ruleItems: [
|
105
108
|
{ id: '5', attribute: 'attr2', operator: 'equals', value: '1' },
|
106
109
|
{ id: '6', attribute: 'attr3', operator: 'notEquals', value: '1' },
|
@@ -114,6 +117,7 @@ describe('Rules deadlock', () => {
|
|
114
117
|
test('match #3', () => {
|
115
118
|
const rulesList = [
|
116
119
|
{
|
120
|
+
id: '1',
|
117
121
|
ruleItems: [
|
118
122
|
{ id: '1', attribute: 'attr1', operator: 'equals', value: '1' },
|
119
123
|
{ id: '2', attribute: 'attr3', operator: 'equals', value: '1' },
|
@@ -121,12 +125,14 @@ describe('Rules deadlock', () => {
|
|
121
125
|
],
|
122
126
|
},
|
123
127
|
{
|
128
|
+
id: '1',
|
124
129
|
ruleItems: [
|
125
130
|
{ id: '3', attribute: 'attr1', operator: 'notEquals', value: '1' },
|
126
131
|
{ id: '4', attribute: 'attr2', operator: 'notEquals', value: '1' },
|
127
132
|
],
|
128
133
|
},
|
129
134
|
{
|
135
|
+
id: '1',
|
130
136
|
ruleItems: [
|
131
137
|
{ id: '5', attribute: 'attr2', operator: 'equals', value: '1' },
|
132
138
|
{ id: '6', attribute: 'attr3', operator: 'notEquals', value: '1' },
|
@@ -140,6 +146,7 @@ describe('Rules deadlock', () => {
|
|
140
146
|
test('match #4', () => {
|
141
147
|
const rulesList = [
|
142
148
|
{
|
149
|
+
id: '1',
|
143
150
|
ruleItems: [
|
144
151
|
{ id: '1', attribute: 'attr1', operator: 'equals', value: '1' },
|
145
152
|
{ id: '2', attribute: 'attr3', operator: 'equals', value: '1' },
|
@@ -147,6 +154,7 @@ describe('Rules deadlock', () => {
|
|
147
154
|
],
|
148
155
|
},
|
149
156
|
{
|
157
|
+
id: '1',
|
150
158
|
ruleItems: [
|
151
159
|
{ id: '3', attribute: 'attr1', operator: 'notEquals', value: '1' },
|
152
160
|
{ id: '4', attribute: 'attr2', operator: 'notEquals', value: '1' },
|
@@ -154,6 +162,7 @@ describe('Rules deadlock', () => {
|
|
154
162
|
],
|
155
163
|
},
|
156
164
|
{
|
165
|
+
id: '1',
|
157
166
|
ruleItems: [
|
158
167
|
{ id: '5', attribute: 'attr2', operator: 'equals', value: '1' },
|
159
168
|
{ id: '6', attribute: 'attr3', operator: 'notEquals', value: '1' },
|
@@ -167,6 +176,7 @@ describe('Rules deadlock', () => {
|
|
167
176
|
test('no match', () => {
|
168
177
|
const rulesList = [
|
169
178
|
{
|
179
|
+
id: '1',
|
170
180
|
ruleItems: [
|
171
181
|
{ id: '1', attribute: 'attr1', operator: 'equals', value: '1' },
|
172
182
|
{ id: '2', attribute: 'attr3', operator: 'equals', value: '1' },
|
@@ -174,6 +184,7 @@ describe('Rules deadlock', () => {
|
|
174
184
|
],
|
175
185
|
},
|
176
186
|
{
|
187
|
+
id: '1',
|
177
188
|
ruleItems: [
|
178
189
|
{ id: '3', attribute: 'attr1', operator: 'notEquals', value: '1' },
|
179
190
|
{ id: '4', attribute: 'attr2', operator: 'notEquals', value: '1' },
|
@@ -181,6 +192,7 @@ describe('Rules deadlock', () => {
|
|
181
192
|
],
|
182
193
|
},
|
183
194
|
{
|
195
|
+
id: '1',
|
184
196
|
ruleItems: [
|
185
197
|
{ id: '5', attribute: 'attr2', operator: 'equals', value: '1' },
|
186
198
|
{ id: '6', attribute: 'attr3', operator: 'notEquals', value: '1' },
|
@@ -246,13 +258,23 @@ describe('Has rules', () => {
|
|
246
258
|
test('match', () => {
|
247
259
|
expect(
|
248
260
|
hasRules({
|
249
|
-
sections: [
|
261
|
+
sections: [
|
262
|
+
{ id: '1', ruleItems: [] },
|
263
|
+
{ id: '1', ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
264
|
+
],
|
250
265
|
})
|
251
266
|
).toBe(true);
|
252
267
|
});
|
253
268
|
|
254
269
|
test('no match', () => {
|
255
|
-
expect(
|
270
|
+
expect(
|
271
|
+
hasRules({
|
272
|
+
sections: [
|
273
|
+
{ id: '1', ruleItems: [] },
|
274
|
+
{ id: '1', ruleItems: [] },
|
275
|
+
],
|
276
|
+
})
|
277
|
+
).toBe(false);
|
256
278
|
});
|
257
279
|
});
|
258
280
|
|
@@ -260,8 +282,8 @@ describe('Compare rules', () => {
|
|
260
282
|
test('match #1', () => {
|
261
283
|
expect(
|
262
284
|
compareRules(
|
263
|
-
{ sections: [{ ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] }] },
|
264
|
-
{ sections: [{ ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] }] }
|
285
|
+
{ sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] }] },
|
286
|
+
{ sections: [{ id: '1', ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] }] }
|
265
287
|
)
|
266
288
|
).toBe(true);
|
267
289
|
});
|
@@ -271,11 +293,11 @@ describe('Compare rules', () => {
|
|
271
293
|
compareRules(
|
272
294
|
{
|
273
295
|
sections: [
|
274
|
-
{ ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
275
|
-
{ ruleItems: [] },
|
296
|
+
{ id: '1', ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
297
|
+
{ id: '1', ruleItems: [] },
|
276
298
|
],
|
277
299
|
},
|
278
|
-
{ sections: [{ ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] }] }
|
300
|
+
{ sections: [{ id: '1', ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] }] }
|
279
301
|
)
|
280
302
|
).toBe(true);
|
281
303
|
});
|
@@ -285,14 +307,14 @@ describe('Compare rules', () => {
|
|
285
307
|
compareRules(
|
286
308
|
{
|
287
309
|
sections: [
|
288
|
-
{ ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
289
|
-
{ ruleItems: [] },
|
310
|
+
{ id: '1', ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
311
|
+
{ id: '1', ruleItems: [] },
|
290
312
|
],
|
291
313
|
},
|
292
314
|
{
|
293
315
|
sections: [
|
294
|
-
{ ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] },
|
295
|
-
{ ruleItems: [] },
|
316
|
+
{ id: '1', ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] },
|
317
|
+
{ id: '1', ruleItems: [] },
|
296
318
|
],
|
297
319
|
}
|
298
320
|
)
|
@@ -303,12 +325,12 @@ describe('Compare rules', () => {
|
|
303
325
|
expect(
|
304
326
|
compareRules(
|
305
327
|
{
|
306
|
-
sections: [{ ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] }],
|
328
|
+
sections: [{ id: '1', ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] }],
|
307
329
|
},
|
308
330
|
{
|
309
331
|
sections: [
|
310
|
-
{ ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] },
|
311
|
-
{ ruleItems: [] },
|
332
|
+
{ id: '1', ruleItems: [{ id: '2', attribute: 'a', operator: 'b', value: 'c' }] },
|
333
|
+
{ id: '1', ruleItems: [] },
|
312
334
|
],
|
313
335
|
}
|
314
336
|
)
|
@@ -320,15 +342,15 @@ describe('Compare rules', () => {
|
|
320
342
|
compareRules(
|
321
343
|
{
|
322
344
|
sections: [
|
323
|
-
{ ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
324
|
-
{ ruleItems: [{ id: '2', attribute: 'b', operator: 'c', value: 'd' }] },
|
325
|
-
{ ruleItems: [] },
|
345
|
+
{ id: '1', ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
346
|
+
{ id: '1', ruleItems: [{ id: '2', attribute: 'b', operator: 'c', value: 'd' }] },
|
347
|
+
{ id: '1', ruleItems: [] },
|
326
348
|
],
|
327
349
|
},
|
328
350
|
{
|
329
351
|
sections: [
|
330
|
-
{ ruleItems: [{ id: '3', attribute: 'a', operator: 'b', value: 'c' }] },
|
331
|
-
{ ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
352
|
+
{ id: '1', ruleItems: [{ id: '3', attribute: 'a', operator: 'b', value: 'c' }] },
|
353
|
+
{ id: '1', ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
332
354
|
],
|
333
355
|
}
|
334
356
|
)
|
@@ -341,24 +363,26 @@ describe('Compare rules', () => {
|
|
341
363
|
{
|
342
364
|
sections: [
|
343
365
|
{
|
366
|
+
id: '1',
|
344
367
|
ruleItems: [
|
345
368
|
{ id: '1', attribute: 'a', operator: 'b', value: ['c', 'd'] },
|
346
369
|
{ id: '5', attribute: 'c', operator: 'd', value: 'e' },
|
347
370
|
],
|
348
371
|
},
|
349
|
-
{ ruleItems: [{ id: '2', attribute: 'b', operator: 'c', value: 'd' }] },
|
350
|
-
{ ruleItems: [] },
|
372
|
+
{ id: '1', ruleItems: [{ id: '2', attribute: 'b', operator: 'c', value: 'd' }] },
|
373
|
+
{ id: '1', ruleItems: [] },
|
351
374
|
],
|
352
375
|
},
|
353
376
|
{
|
354
377
|
sections: [
|
355
378
|
{
|
379
|
+
id: '1',
|
356
380
|
ruleItems: [
|
357
381
|
{ id: '3', attribute: 'a', operator: 'b', value: ['d', 'c'] },
|
358
382
|
{ id: '6', attribute: 'c', operator: 'd', value: 'e' },
|
359
383
|
],
|
360
384
|
},
|
361
|
-
{ ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
385
|
+
{ id: '1', ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
362
386
|
],
|
363
387
|
}
|
364
388
|
)
|
@@ -370,27 +394,27 @@ describe('Compare rules', () => {
|
|
370
394
|
compareRules(
|
371
395
|
{
|
372
396
|
sections: [
|
397
|
+
{ id: '1', ruleItems: [{ id: '1', attribute: 'a', operator: 'b', value: 'c' }] },
|
373
398
|
{
|
374
|
-
|
375
|
-
},
|
376
|
-
{
|
399
|
+
id: '1',
|
377
400
|
ruleItems: [
|
378
401
|
{ id: '2', attribute: 'b', operator: 'c', value: 'd' },
|
379
402
|
{ id: '5', attribute: 'c', operator: 'd', value: 'e' },
|
380
403
|
],
|
381
404
|
},
|
382
|
-
{ ruleItems: [] },
|
405
|
+
{ id: '1', ruleItems: [] },
|
383
406
|
],
|
384
407
|
},
|
385
408
|
{
|
386
409
|
sections: [
|
387
410
|
{
|
411
|
+
id: '1',
|
388
412
|
ruleItems: [
|
389
413
|
{ id: '3', attribute: 'a', operator: 'b', value: 'c' },
|
390
414
|
{ id: '6', attribute: 'c', operator: 'd', value: 'e' },
|
391
415
|
],
|
392
416
|
},
|
393
|
-
{ ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
417
|
+
{ id: '1', ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
394
418
|
],
|
395
419
|
}
|
396
420
|
)
|
@@ -403,29 +427,32 @@ describe('Compare rules', () => {
|
|
403
427
|
{
|
404
428
|
sections: [
|
405
429
|
{
|
430
|
+
id: '1',
|
406
431
|
ruleItems: [
|
407
432
|
{ id: '1', attribute: 'a', operator: 'b', value: 'c' },
|
408
433
|
{ id: '5', attribute: 'c', operator: 'd', value: 'e' },
|
409
434
|
],
|
410
435
|
},
|
411
436
|
{
|
437
|
+
id: '1',
|
412
438
|
ruleItems: [
|
413
439
|
{ id: '2', attribute: 'b', operator: 'c', value: 'd' },
|
414
440
|
{ id: '8', attribute: 'c', operator: 'd', value: 'e' },
|
415
441
|
],
|
416
442
|
},
|
417
|
-
{ ruleItems: [] },
|
443
|
+
{ id: '1', ruleItems: [] },
|
418
444
|
],
|
419
445
|
},
|
420
446
|
{
|
421
447
|
sections: [
|
422
448
|
{
|
449
|
+
id: '1',
|
423
450
|
ruleItems: [
|
424
451
|
{ id: '3', attribute: 'a', operator: 'b', value: 'c' },
|
425
452
|
{ id: '6', attribute: 'c', operator: 'd', value: 'e' },
|
426
453
|
],
|
427
454
|
},
|
428
|
-
{ ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
455
|
+
{ id: '1', ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
429
456
|
],
|
430
457
|
}
|
431
458
|
)
|
@@ -438,26 +465,26 @@ describe('Compare rules', () => {
|
|
438
465
|
{
|
439
466
|
sections: [
|
440
467
|
{
|
468
|
+
id: '1',
|
441
469
|
ruleItems: [
|
442
470
|
{ id: '1', attribute: 'a', operator: 'b', value: 'c' },
|
443
471
|
{ id: '5', attribute: 'c', operator: 'd', value: 'e' },
|
444
472
|
],
|
445
473
|
},
|
446
|
-
{
|
447
|
-
|
448
|
-
},
|
449
|
-
{ ruleItems: [{ id: '10', attribute: 'a', operator: 'b', value: 'c' }] },
|
474
|
+
{ id: '1', ruleItems: [{ id: '2', attribute: 'b', operator: 'c', value: 'd' }] },
|
475
|
+
{ id: '1', ruleItems: [{ id: '10', attribute: 'a', operator: 'b', value: 'c' }] },
|
450
476
|
],
|
451
477
|
},
|
452
478
|
{
|
453
479
|
sections: [
|
454
480
|
{
|
481
|
+
id: '1',
|
455
482
|
ruleItems: [
|
456
483
|
{ id: '3', attribute: 'a', operator: 'b', value: 'c' },
|
457
484
|
{ id: '6', attribute: 'c', operator: 'd', value: 'e' },
|
458
485
|
],
|
459
486
|
},
|
460
|
-
{ ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
487
|
+
{ id: '1', ruleItems: [{ id: '4', attribute: 'b', operator: 'c', value: 'd' }] },
|
461
488
|
],
|
462
489
|
}
|
463
490
|
)
|
@@ -468,11 +495,11 @@ describe('Compare rules', () => {
|
|
468
495
|
describe('Compare mappings', () => {
|
469
496
|
test('match #1', () => {
|
470
497
|
const mappingsA = [
|
471
|
-
{ attribute: 'contentLanguage', value: 'en', rules: { sections: [{ ruleItems: [] }] } },
|
498
|
+
{ id: '1', attribute: 'contentLanguage', value: 'en', rules: { sections: [{ id: '1', ruleItems: [] }] } },
|
472
499
|
] as ProductUploadMapping[];
|
473
500
|
|
474
501
|
const mappingsB = [
|
475
|
-
{ attribute: 'contentLanguage', value: 'en', rules: { sections: [{ ruleItems: [] }] } },
|
502
|
+
{ id: '1', attribute: 'contentLanguage', value: 'en', rules: { sections: [{ id: '1', ruleItems: [] }] } },
|
476
503
|
] as ProductUploadMapping[];
|
477
504
|
|
478
505
|
expect(compareMappings(mappingsA, mappingsB)).toBe(true);
|
@@ -534,11 +561,11 @@ describe('Compare mappings', () => {
|
|
534
561
|
|
535
562
|
test('no match #1', () => {
|
536
563
|
const mappingsA = [
|
537
|
-
{ attribute: 'contentLanguage', value: 'uk', rules: { sections: [{ ruleItems: [] }] } },
|
564
|
+
{ id: '1', attribute: 'contentLanguage', value: 'uk', rules: { sections: [{ id: '1', ruleItems: [] }] } },
|
538
565
|
] as ProductUploadMapping[];
|
539
566
|
|
540
567
|
const mappingsB = [
|
541
|
-
{ attribute: 'contentLanguage', value: 'en', rules: { sections: [{ ruleItems: [] }] } },
|
568
|
+
{ id: '1', attribute: 'contentLanguage', value: 'en', rules: { sections: [{ id: '1', ruleItems: [] }] } },
|
542
569
|
] as ProductUploadMapping[];
|
543
570
|
|
544
571
|
expect(compareMappings(mappingsA, mappingsB)).toBe(false);
|
@@ -546,11 +573,11 @@ describe('Compare mappings', () => {
|
|
546
573
|
|
547
574
|
test('no match #2', () => {
|
548
575
|
const mappingsA = [
|
549
|
-
{ attribute: 'title', value: 'en', rules: { sections: [{ ruleItems: [] }] } },
|
576
|
+
{ id: '1', attribute: 'title', value: 'en', rules: { sections: [{ id: '1', ruleItems: [] }] } },
|
550
577
|
] as ProductUploadMapping[];
|
551
578
|
|
552
579
|
const mappingsB = [
|
553
|
-
{ attribute: 'contentLanguage', value: 'en', rules: { sections: [{ ruleItems: [] }] } },
|
580
|
+
{ id: '1', attribute: 'contentLanguage', value: 'en', rules: { sections: [{ id: '1', ruleItems: [] }] } },
|
554
581
|
] as ProductUploadMapping[];
|
555
582
|
|
556
583
|
expect(compareMappings(mappingsA, mappingsB)).toBe(false);
|