feed-common 1.49.4 → 1.49.5
Sign up to get free protection for your applications and to get access to all the features.
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/utils/profile.d.ts +6 -0
- package/dist/utils/profile.d.ts.map +1 -1
- package/dist/utils/profile.js +26 -34
- package/dist/utils/profile.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/profile.ts +47 -50
package/.vscode/settings.json
CHANGED
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.49.5](https://github.com/advertikon/package-maxify-feed-common/compare/v1.49.4...v1.49.5) (2024-10-03)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* change detectProfileChange function ([78d3494](https://github.com/advertikon/package-maxify-feed-common/commit/78d34944f2028fc52d803d14756a525577911053))
|
7
|
+
|
1
8
|
## [1.49.4](https://github.com/advertikon/package-maxify-feed-common/compare/v1.49.3...v1.49.4) (2024-10-03)
|
2
9
|
|
3
10
|
|
package/dist/utils/profile.d.ts
CHANGED
@@ -32,6 +32,12 @@ export declare function compareMappings(a: ProductUploadMapping[], b: ProductUpl
|
|
32
32
|
export declare function optionIsString(option: OptionType): option is string;
|
33
33
|
export declare function optionIsItem(option: OptionType): option is OptionTypeItem;
|
34
34
|
export declare function optionIsGroup(option: OptionType): option is OptionTypeGroup;
|
35
|
+
export declare function detectProfileChange(a: ProductUploadProfile, b: ProductUploadProfile): {
|
36
|
+
name: boolean;
|
37
|
+
rules: boolean;
|
38
|
+
mappings: boolean;
|
39
|
+
id: boolean;
|
40
|
+
};
|
35
41
|
export declare function sanitizeUploadProfile(profile: ProductUploadProfile): ProductUploadProfile;
|
36
42
|
export declare function variableType(values: MappingSourceValueType[]): MappingSourceValueType;
|
37
43
|
//# sourceMappingURL=profile.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"AACA,OAAO,EAC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,CAAE,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,MAAM,CAEpE;AAED,wBAAgB,YAAY,CAAE,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,cAAc,CAE1E;AAED,wBAAgB,aAAa,CAAE,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,eAAe,CAE5E;AAED,wBAAgB,mBAAmB,CAC/B,CAAC,EAAE,oBAAoB,EACvB,CAAC,EAAE,oBAAoB,GACxB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,CA+BnE;AAED,wBAAgB,qBAAqB,CAAE,OAAO,EAAE,oBAAoB,GAAG,oBAAoB,CAc1F;AAED,wBAAgB,YAAY,CAAE,MAAM,EAAE,sBAAsB,EAAE,GAAG,sBAAsB,CAkBtF"}
|
package/dist/utils/profile.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MappingSourceValueType, RULES_OPERATORS } from '../constants/profile.constants.js';
|
1
|
+
import { GmcApiConstAttrs, MappingSourceValueType, RULES_OPERATORS } from '../constants/profile.constants.js';
|
2
2
|
import { code } from './utils.js';
|
3
3
|
/**
|
4
4
|
* Check for rules duplication
|
@@ -208,39 +208,31 @@ export function optionIsItem(option) {
|
|
208
208
|
export function optionIsGroup(option) {
|
209
209
|
return typeof option !== 'string' && 'options' in option;
|
210
210
|
}
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
// const mappingsA = a.mappings?.filter(m => !requiredAttrs.includes(m.attribute));
|
237
|
-
// const mappingsB = b.mappings?.filter(m => !requiredAttrs.includes(m.attribute));
|
238
|
-
// changes.mappings = !compareMappings(mappingsA, mappingsB);
|
239
|
-
// if (!compareRules(a.rules, b.rules)) {
|
240
|
-
// changes.rules = true;
|
241
|
-
// }
|
242
|
-
// return changes;
|
243
|
-
// }
|
211
|
+
export function detectProfileChange(a, b) {
|
212
|
+
const changes = {
|
213
|
+
name: false,
|
214
|
+
rules: false,
|
215
|
+
mappings: false,
|
216
|
+
id: false,
|
217
|
+
};
|
218
|
+
if (a.name !== b.name) {
|
219
|
+
changes.name = true;
|
220
|
+
}
|
221
|
+
if (GmcApiConstAttrs.some(key => {
|
222
|
+
const mappingA = a.mappings?.filter(m => m.attribute === key) ?? [];
|
223
|
+
const mappingB = b.mappings?.filter(m => m.attribute === key) ?? [];
|
224
|
+
return !compareMappings(mappingA, mappingB);
|
225
|
+
})) {
|
226
|
+
changes.id = true;
|
227
|
+
}
|
228
|
+
const mappingsA = a.mappings?.filter(m => !GmcApiConstAttrs.includes(m.attribute));
|
229
|
+
const mappingsB = b.mappings?.filter(m => !GmcApiConstAttrs.includes(m.attribute));
|
230
|
+
changes.mappings = !compareMappings(mappingsA, mappingsB);
|
231
|
+
if (!compareRules(a.rules, b.rules)) {
|
232
|
+
changes.rules = true;
|
233
|
+
}
|
234
|
+
return changes;
|
235
|
+
}
|
244
236
|
export function sanitizeUploadProfile(profile) {
|
245
237
|
if (profile.rules?.sections) {
|
246
238
|
profile.rules.sections = profile.rules.sections.filter(section => section.ruleItems.length > 0);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MA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E,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpG,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,YAAY,CAAE,MAAgC;IAC1D,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,OAAO,sBAAsB,CAAC,MAAM,CAAC;IACzC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,OAAO,sBAAsB,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,sBAAsB,CAAC,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,sBAAsB,CAAC,GAAG,CAAC;IACtC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,OAAO,sBAAsB,CAAC,KAAK,CAAC;IACxC,CAAC;IAED,OAAO,sBAAsB,CAAC,GAAG,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED
package/src/utils/profile.ts
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
ProductUploadRuleSection,
|
12
12
|
ProductUploadRules,
|
13
13
|
} from '../types/profile.types.js';
|
14
|
-
import { MappingSourceValueType, RULES_OPERATORS } from '../constants/profile.constants.js';
|
14
|
+
import { GmcApiConstAttrs, MappingSourceValueType, RULES_OPERATORS } from '../constants/profile.constants.js';
|
15
15
|
import { code } from './utils.js';
|
16
16
|
|
17
17
|
/**
|
@@ -19,7 +19,7 @@ import { code } from './utils.js';
|
|
19
19
|
* @param rules
|
20
20
|
* @returns
|
21
21
|
*/
|
22
|
-
export function checkRuleDuplication(rules: ProductUploadRuleItem[]): string[] {
|
22
|
+
export function checkRuleDuplication (rules: ProductUploadRuleItem[]): string[] {
|
23
23
|
return rules
|
24
24
|
.map(r => {
|
25
25
|
for (const rule of rules) {
|
@@ -42,7 +42,7 @@ export function checkRuleDuplication(rules: ProductUploadRuleItem[]): string[] {
|
|
42
42
|
* @param rules
|
43
43
|
* @returns
|
44
44
|
*/
|
45
|
-
export function checkRuleAlwaysness(rules: ProductUploadRuleItem[]): string[] {
|
45
|
+
export function checkRuleAlwaysness (rules: ProductUploadRuleItem[]): string[] {
|
46
46
|
return rules
|
47
47
|
.map(r => {
|
48
48
|
for (const rule of rules) {
|
@@ -60,7 +60,7 @@ export function checkRuleAlwaysness(rules: ProductUploadRuleItem[]): string[] {
|
|
60
60
|
* @param sections
|
61
61
|
* @returns
|
62
62
|
*/
|
63
|
-
export function checkRuleDeadlocks(input: ProductUploadRuleSection[]): string[] {
|
63
|
+
export function checkRuleDeadlocks (input: ProductUploadRuleSection[]): string[] {
|
64
64
|
const totalList = [] as string[][];
|
65
65
|
const sections = structuredClone(input);
|
66
66
|
|
@@ -86,7 +86,7 @@ export function checkRuleDeadlocks(input: ProductUploadRuleSection[]): string[]
|
|
86
86
|
return sections.some(s => s.ruleItems.length === 0) ? totalList.flat() : [];
|
87
87
|
}
|
88
88
|
|
89
|
-
function isExclusive(rule1: ProductUploadRuleItem, rule2: ProductUploadRuleItem): boolean {
|
89
|
+
function isExclusive (rule1: ProductUploadRuleItem, rule2: ProductUploadRuleItem): boolean {
|
90
90
|
return (
|
91
91
|
rule1.id !== rule2.id &&
|
92
92
|
rule1.attribute === rule2.attribute &&
|
@@ -95,7 +95,7 @@ function isExclusive(rule1: ProductUploadRuleItem, rule2: ProductUploadRuleItem)
|
|
95
95
|
);
|
96
96
|
}
|
97
97
|
|
98
|
-
export function getOperatorCounterpart(operator: keyof RuleOperatorsType): keyof RuleOperatorsType {
|
98
|
+
export function getOperatorCounterpart (operator: keyof RuleOperatorsType): keyof RuleOperatorsType {
|
99
99
|
switch (operator) {
|
100
100
|
case RULES_OPERATORS.EQUALS:
|
101
101
|
return RULES_OPERATORS.NOT_EQUALS;
|
@@ -134,7 +134,7 @@ export function getOperatorCounterpart(operator: keyof RuleOperatorsType): keyof
|
|
134
134
|
}
|
135
135
|
}
|
136
136
|
|
137
|
-
export function getEmptyRuleItem(attribute: ProductUploadRuleFilterType['value'] = ''): ProductUploadRuleItem {
|
137
|
+
export function getEmptyRuleItem (attribute: ProductUploadRuleFilterType['value'] = ''): ProductUploadRuleItem {
|
138
138
|
return { attribute, operator: '', value: '', id: code() };
|
139
139
|
}
|
140
140
|
|
@@ -169,7 +169,7 @@ export function getEmptyRuleItem(attribute: ProductUploadRuleFilterType['value']
|
|
169
169
|
// return 0;
|
170
170
|
// }
|
171
171
|
|
172
|
-
export function hasRules(rules: ProductUploadRules): boolean {
|
172
|
+
export function hasRules (rules: ProductUploadRules): boolean {
|
173
173
|
return Array.isArray(rules?.sections) && rules.sections.some(section => section.ruleItems.length > 0);
|
174
174
|
}
|
175
175
|
|
@@ -179,7 +179,7 @@ export function hasRules(rules: ProductUploadRules): boolean {
|
|
179
179
|
* @param b
|
180
180
|
* @returns
|
181
181
|
*/
|
182
|
-
export function compareRules(
|
182
|
+
export function compareRules (
|
183
183
|
a: ProductUploadRules = { sections: [] },
|
184
184
|
b: ProductUploadRules = { sections: [] }
|
185
185
|
): boolean {
|
@@ -219,7 +219,7 @@ export function compareRules(
|
|
219
219
|
return matchedSections.length === a.sections.length;
|
220
220
|
}
|
221
221
|
|
222
|
-
function compareValues(a: any, b: any): boolean {
|
222
|
+
function compareValues (a: any, b: any): boolean {
|
223
223
|
if (Array.isArray(a) && Array.isArray(b)) {
|
224
224
|
return a.length === b.length && a.every(i => b.includes(i));
|
225
225
|
}
|
@@ -227,7 +227,7 @@ function compareValues(a: any, b: any): boolean {
|
|
227
227
|
return a === b;
|
228
228
|
}
|
229
229
|
|
230
|
-
export function compareMappings(a: ProductUploadMapping[], b: ProductUploadMapping[]): boolean {
|
230
|
+
export function compareMappings (a: ProductUploadMapping[], b: ProductUploadMapping[]): boolean {
|
231
231
|
const matchedMappings = [] as number[];
|
232
232
|
|
233
233
|
if (a.length !== b.length) {
|
@@ -258,58 +258,55 @@ export function compareMappings(a: ProductUploadMapping[], b: ProductUploadMappi
|
|
258
258
|
return matchedMappings.length === a.length;
|
259
259
|
}
|
260
260
|
|
261
|
-
export function optionIsString(option: OptionType): option is string {
|
261
|
+
export function optionIsString (option: OptionType): option is string {
|
262
262
|
return typeof option === 'string';
|
263
263
|
}
|
264
264
|
|
265
|
-
export function optionIsItem(option: OptionType): option is OptionTypeItem {
|
265
|
+
export function optionIsItem (option: OptionType): option is OptionTypeItem {
|
266
266
|
return typeof option !== 'string' && 'value' in option;
|
267
267
|
}
|
268
268
|
|
269
|
-
export function optionIsGroup(option: OptionType): option is OptionTypeGroup {
|
269
|
+
export function optionIsGroup (option: OptionType): option is OptionTypeGroup {
|
270
270
|
return typeof option !== 'string' && 'options' in option;
|
271
271
|
}
|
272
272
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
// if (a.name !== b.name) {
|
285
|
-
// changes.name = true;
|
286
|
-
// }
|
273
|
+
export function detectProfileChange (
|
274
|
+
a: ProductUploadProfile,
|
275
|
+
b: ProductUploadProfile
|
276
|
+
): { name: boolean; rules: boolean; mappings: boolean; id: boolean } {
|
277
|
+
const changes = {
|
278
|
+
name: false,
|
279
|
+
rules: false,
|
280
|
+
mappings: false,
|
281
|
+
id: false,
|
282
|
+
};
|
287
283
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
// .some(key => {
|
292
|
-
// const mappingA = a.mappings?.filter(m => m.attribute === key) ?? [];
|
293
|
-
// const mappingB = b.mappings?.filter(m => m.attribute === key) ?? [];
|
294
|
-
// return !compareMappings(mappingA, mappingB);
|
295
|
-
// })
|
296
|
-
// ) {
|
297
|
-
// changes.id = true;
|
298
|
-
// }
|
284
|
+
if (a.name !== b.name) {
|
285
|
+
changes.name = true;
|
286
|
+
}
|
299
287
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
288
|
+
if (
|
289
|
+
GmcApiConstAttrs.some(key => {
|
290
|
+
const mappingA = a.mappings?.filter(m => m.attribute === key) ?? [];
|
291
|
+
const mappingB = b.mappings?.filter(m => m.attribute === key) ?? [];
|
292
|
+
return !compareMappings(mappingA, mappingB);
|
293
|
+
})
|
294
|
+
) {
|
295
|
+
changes.id = true;
|
296
|
+
}
|
304
297
|
|
305
|
-
|
306
|
-
|
307
|
-
|
298
|
+
const mappingsA = a.mappings?.filter(m => !GmcApiConstAttrs.includes(m.attribute));
|
299
|
+
const mappingsB = b.mappings?.filter(m => !GmcApiConstAttrs.includes(m.attribute));
|
300
|
+
changes.mappings = !compareMappings(mappingsA, mappingsB);
|
308
301
|
|
309
|
-
|
310
|
-
|
302
|
+
if (!compareRules(a.rules, b.rules)) {
|
303
|
+
changes.rules = true;
|
304
|
+
}
|
305
|
+
|
306
|
+
return changes;
|
307
|
+
}
|
311
308
|
|
312
|
-
export function sanitizeUploadProfile(profile: ProductUploadProfile): ProductUploadProfile {
|
309
|
+
export function sanitizeUploadProfile (profile: ProductUploadProfile): ProductUploadProfile {
|
313
310
|
if (profile.rules?.sections) {
|
314
311
|
profile.rules.sections = profile.rules.sections.filter(section => section.ruleItems.length > 0);
|
315
312
|
}
|
@@ -325,7 +322,7 @@ export function sanitizeUploadProfile(profile: ProductUploadProfile): ProductUpl
|
|
325
322
|
return profile;
|
326
323
|
}
|
327
324
|
|
328
|
-
export function variableType(values: MappingSourceValueType[]): MappingSourceValueType {
|
325
|
+
export function variableType (values: MappingSourceValueType[]): MappingSourceValueType {
|
329
326
|
if (values.some(v => v === MappingSourceValueType.STRING)) {
|
330
327
|
return MappingSourceValueType.STRING;
|
331
328
|
}
|