feed-common 1.68.6 → 1.68.7
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -0
- package/dist/utils/profile.d.ts +9 -9
- package/dist/utils/profile.d.ts.map +1 -1
- package/dist/utils/profile.js +8 -31
- package/dist/utils/profile.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/profile.ts +29 -59
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [1.68.7](https://github.com/advertikon/package-maxify-feed-common/compare/v1.68.6...v1.68.7) (2024-11-07)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* make profile utils readonly ([712eab7](https://github.com/advertikon/package-maxify-feed-common/commit/712eab76782bb4be493cc7672e2ac9e6cf91fea2))
|
7
|
+
|
1
8
|
## [1.68.6](https://github.com/advertikon/package-maxify-feed-common/compare/v1.68.5...v1.68.6) (2024-11-03)
|
2
9
|
|
3
10
|
|
package/dist/utils/profile.d.ts
CHANGED
@@ -5,39 +5,39 @@ import { MappingSourceValueType } from '../constants/profile.constants.js';
|
|
5
5
|
* @param rules
|
6
6
|
* @returns
|
7
7
|
*/
|
8
|
-
export declare function checkRuleDuplication(rules: ProductUploadRuleItem[]): string[];
|
8
|
+
export declare function checkRuleDuplication(rules: Readonly<ProductUploadRuleItem[]>): string[];
|
9
9
|
/**
|
10
10
|
* Check if rules mutually exclusive
|
11
11
|
* @param rules
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function checkRuleAlwaysness(rules: ProductUploadRuleItem[]): string[];
|
14
|
+
export declare function checkRuleAlwaysness(rules: Readonly<ProductUploadRuleItem[]>): string[];
|
15
15
|
/**
|
16
16
|
* Checks for contradictions in rules, e.g A == 1 and A != 1
|
17
17
|
* @param sections
|
18
18
|
* @returns
|
19
19
|
*/
|
20
|
-
export declare function checkRuleDeadlocks(input: ProductUploadRuleSection[]): string[];
|
20
|
+
export declare function checkRuleDeadlocks(input: Readonly<ProductUploadRuleSection[]>): string[];
|
21
21
|
export declare function getOperatorCounterpart(operator: keyof RuleOperatorsType): keyof RuleOperatorsType;
|
22
|
-
export declare function getEmptyRuleItem(attribute?: ProductUploadRuleFilterType['value']): ProductUploadRuleItem;
|
23
|
-
export declare function hasRules(rules: ProductUploadRules): boolean;
|
22
|
+
export declare function getEmptyRuleItem(attribute?: Readonly<ProductUploadRuleFilterType['value']>): ProductUploadRuleItem;
|
23
|
+
export declare function hasRules(rules: Readonly<ProductUploadRules>): boolean;
|
24
24
|
/**
|
25
25
|
* Checks if two rules are the same
|
26
26
|
* @param a
|
27
27
|
* @param b
|
28
28
|
* @returns
|
29
29
|
*/
|
30
|
-
export declare function compareRules(a?: ProductUploadRules
|
31
|
-
export declare function compareMappings(a: ProductUploadMapping[]
|
30
|
+
export declare function compareRules(a?: Readonly<ProductUploadRules>, b?: Readonly<ProductUploadRules>): boolean;
|
31
|
+
export declare function compareMappings(a: Readonly<ProductUploadMapping[]>, b: Readonly<ProductUploadMapping[]>): boolean;
|
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
|
35
|
+
export declare function detectProfileChange(a: Readonly<ProductUploadProfile>, b: Readonly<ProductUploadProfile>): {
|
36
36
|
name: boolean;
|
37
37
|
rules: boolean;
|
38
38
|
mappings: boolean;
|
39
39
|
id: boolean;
|
40
40
|
};
|
41
41
|
export declare function sanitizeUploadProfile(profile: ProductUploadProfile): ProductUploadProfile;
|
42
|
-
export declare function variableType(values: MappingSourceValueType[]): MappingSourceValueType;
|
42
|
+
export declare function variableType(values: Readonly<MappingSourceValueType[]>): MappingSourceValueType;
|
43
43
|
//# sourceMappingURL=profile.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":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,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CAAC,GAAG,OAAO,CA6BjH;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,MAAM,CAEnE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,cAAc,CAEzE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,eAAe,CAE3E;AAED,wBAAgB,mBAAmB,CAC/B,CAAC,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjC,CAAC,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAClC;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,CAAC,OAAO,EAAE,oBAAoB,GAAG,oBAAoB,CAczF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,sBAAsB,EAAE,CAAC,GAAG,sBAAsB,CAkB/F"}
|
package/dist/utils/profile.js
CHANGED
@@ -111,29 +111,6 @@ export function getOperatorCounterpart(operator) {
|
|
111
111
|
export function getEmptyRuleItem(attribute = '') {
|
112
112
|
return { attribute, operator: '', value: '', id: code() };
|
113
113
|
}
|
114
|
-
// export function sortMappings(a: ProductUploadMapping, b: ProductUploadMapping): number {
|
115
|
-
// if (!a.attribute) {
|
116
|
-
// return 1;
|
117
|
-
// }
|
118
|
-
// if (!b.attribute) {
|
119
|
-
// return -1;
|
120
|
-
// }
|
121
|
-
// const sourceA = ProductUploadMappings.find(m => m.attribute === a.attribute);
|
122
|
-
// const sourceB = ProductUploadMappings.find(m => m.attribute === b.attribute);
|
123
|
-
// if (sourceA?.required && !sourceB?.required) {
|
124
|
-
// return -1;
|
125
|
-
// }
|
126
|
-
// if (sourceB?.required && !sourceA?.required) {
|
127
|
-
// return 1;
|
128
|
-
// }
|
129
|
-
// if (a.attribute < b.attribute) {
|
130
|
-
// return -1;
|
131
|
-
// }
|
132
|
-
// if (a.attribute > b.attribute) {
|
133
|
-
// return 1;
|
134
|
-
// }
|
135
|
-
// return 0;
|
136
|
-
// }
|
137
114
|
export function hasRules(rules) {
|
138
115
|
return Array.isArray(rules?.sections) && rules.sections.some(section => section.ruleItems.length > 0);
|
139
116
|
}
|
@@ -148,18 +125,18 @@ export function compareRules(a = { sections: [] }, b = { sections: [] }) {
|
|
148
125
|
const sameRule = (rA, rB) => {
|
149
126
|
return rA.attribute === rB.attribute && rA.operator === rB.operator && compareValues(rA.value, rB.value);
|
150
127
|
};
|
151
|
-
|
152
|
-
|
153
|
-
if (
|
128
|
+
const sectionsA = a.sections.filter(s => s.ruleItems.length > 0);
|
129
|
+
const sectionsB = b.sections.filter(s => s.ruleItems.length > 0);
|
130
|
+
if (sectionsA.length !== sectionsB.length) {
|
154
131
|
return false;
|
155
132
|
}
|
156
|
-
for (let i = 0; i <
|
157
|
-
const rulesA =
|
158
|
-
for (let j = 0; j <
|
133
|
+
for (let i = 0; i < sectionsA.length; i++) {
|
134
|
+
const rulesA = sectionsA[i].ruleItems;
|
135
|
+
for (let j = 0; j < sectionsB.length; j++) {
|
159
136
|
if (matchedSections.includes(j)) {
|
160
137
|
continue;
|
161
138
|
}
|
162
|
-
const rulesB =
|
139
|
+
const rulesB = sectionsB[j].ruleItems;
|
163
140
|
if (rulesA.length !== rulesB.length) {
|
164
141
|
continue;
|
165
142
|
}
|
@@ -169,7 +146,7 @@ export function compareRules(a = { sections: [] }, b = { sections: [] }) {
|
|
169
146
|
}
|
170
147
|
}
|
171
148
|
}
|
172
|
-
return matchedSections.length ===
|
149
|
+
return matchedSections.length === sectionsA.length;
|
173
150
|
}
|
174
151
|
function compareValues(a, b) {
|
175
152
|
if (Array.isArray(a) && Array.isArray(b)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/utils/profile.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAC9G,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAwC;IACzE,OAAO,KAAK;SACP,GAAG,CAAC,CAAC,CAAC,EAAE;QACL,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IACI,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE;gBAChB,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS;gBAC9B,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ;gBAC5B,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,EACxB,CAAC;gBACC,OAAO,CAAC,CAAC,EAAE,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAa,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAwC;IACxE,OAAO,KAAK;SACP,GAAG,CAAC,CAAC,CAAC,EAAE;QACL,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,CAAC,EAAE,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAa,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kB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CAAC,CAAC,CAAC;QACpG,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAA0C;IACnE,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
@@ -10,6 +10,7 @@ import {
|
|
10
10
|
ProductUploadRuleItem,
|
11
11
|
ProductUploadRuleSection,
|
12
12
|
ProductUploadRules,
|
13
|
+
ValueType,
|
13
14
|
} from '../types/profile.types.js';
|
14
15
|
import { GmcApiConstAttrs, MappingSourceValueType, RULES_OPERATORS } from '../constants/profile.constants.js';
|
15
16
|
import { code } from './utils.js';
|
@@ -19,7 +20,7 @@ import { code } from './utils.js';
|
|
19
20
|
* @param rules
|
20
21
|
* @returns
|
21
22
|
*/
|
22
|
-
export function checkRuleDuplication
|
23
|
+
export function checkRuleDuplication(rules: Readonly<ProductUploadRuleItem[]>): string[] {
|
23
24
|
return rules
|
24
25
|
.map(r => {
|
25
26
|
for (const rule of rules) {
|
@@ -42,7 +43,7 @@ export function checkRuleDuplication (rules: ProductUploadRuleItem[]): string[]
|
|
42
43
|
* @param rules
|
43
44
|
* @returns
|
44
45
|
*/
|
45
|
-
export function checkRuleAlwaysness
|
46
|
+
export function checkRuleAlwaysness(rules: Readonly<ProductUploadRuleItem[]>): string[] {
|
46
47
|
return rules
|
47
48
|
.map(r => {
|
48
49
|
for (const rule of rules) {
|
@@ -60,7 +61,7 @@ export function checkRuleAlwaysness (rules: ProductUploadRuleItem[]): string[] {
|
|
60
61
|
* @param sections
|
61
62
|
* @returns
|
62
63
|
*/
|
63
|
-
export function checkRuleDeadlocks
|
64
|
+
export function checkRuleDeadlocks(input: Readonly<ProductUploadRuleSection[]>): string[] {
|
64
65
|
const totalList = [] as string[][];
|
65
66
|
const sections = structuredClone(input);
|
66
67
|
|
@@ -86,7 +87,7 @@ export function checkRuleDeadlocks (input: ProductUploadRuleSection[]): string[]
|
|
86
87
|
return sections.some(s => s.ruleItems.length === 0) ? totalList.flat() : [];
|
87
88
|
}
|
88
89
|
|
89
|
-
function isExclusive
|
90
|
+
function isExclusive(rule1: Readonly<ProductUploadRuleItem>, rule2: Readonly<ProductUploadRuleItem>): boolean {
|
90
91
|
return (
|
91
92
|
rule1.id !== rule2.id &&
|
92
93
|
rule1.attribute === rule2.attribute &&
|
@@ -95,7 +96,7 @@ function isExclusive (rule1: ProductUploadRuleItem, rule2: ProductUploadRuleItem
|
|
95
96
|
);
|
96
97
|
}
|
97
98
|
|
98
|
-
export function getOperatorCounterpart
|
99
|
+
export function getOperatorCounterpart(operator: keyof RuleOperatorsType): keyof RuleOperatorsType {
|
99
100
|
switch (operator) {
|
100
101
|
case RULES_OPERATORS.EQUALS:
|
101
102
|
return RULES_OPERATORS.NOT_EQUALS;
|
@@ -134,42 +135,11 @@ export function getOperatorCounterpart (operator: keyof RuleOperatorsType): keyo
|
|
134
135
|
}
|
135
136
|
}
|
136
137
|
|
137
|
-
export function getEmptyRuleItem
|
138
|
+
export function getEmptyRuleItem(attribute: Readonly<ProductUploadRuleFilterType['value']> = ''): ProductUploadRuleItem {
|
138
139
|
return { attribute, operator: '', value: '', id: code() };
|
139
140
|
}
|
140
141
|
|
141
|
-
|
142
|
-
// if (!a.attribute) {
|
143
|
-
// return 1;
|
144
|
-
// }
|
145
|
-
|
146
|
-
// if (!b.attribute) {
|
147
|
-
// return -1;
|
148
|
-
// }
|
149
|
-
|
150
|
-
// const sourceA = ProductUploadMappings.find(m => m.attribute === a.attribute);
|
151
|
-
// const sourceB = ProductUploadMappings.find(m => m.attribute === b.attribute);
|
152
|
-
|
153
|
-
// if (sourceA?.required && !sourceB?.required) {
|
154
|
-
// return -1;
|
155
|
-
// }
|
156
|
-
|
157
|
-
// if (sourceB?.required && !sourceA?.required) {
|
158
|
-
// return 1;
|
159
|
-
// }
|
160
|
-
|
161
|
-
// if (a.attribute < b.attribute) {
|
162
|
-
// return -1;
|
163
|
-
// }
|
164
|
-
|
165
|
-
// if (a.attribute > b.attribute) {
|
166
|
-
// return 1;
|
167
|
-
// }
|
168
|
-
|
169
|
-
// return 0;
|
170
|
-
// }
|
171
|
-
|
172
|
-
export function hasRules (rules: ProductUploadRules): boolean {
|
142
|
+
export function hasRules(rules: Readonly<ProductUploadRules>): boolean {
|
173
143
|
return Array.isArray(rules?.sections) && rules.sections.some(section => section.ruleItems.length > 0);
|
174
144
|
}
|
175
145
|
|
@@ -179,31 +149,31 @@ export function hasRules (rules: ProductUploadRules): boolean {
|
|
179
149
|
* @param b
|
180
150
|
* @returns
|
181
151
|
*/
|
182
|
-
export function compareRules
|
183
|
-
a: ProductUploadRules = { sections: [] },
|
184
|
-
b: ProductUploadRules = { sections: [] }
|
152
|
+
export function compareRules(
|
153
|
+
a: Readonly<ProductUploadRules> = { sections: [] },
|
154
|
+
b: Readonly<ProductUploadRules> = { sections: [] }
|
185
155
|
): boolean {
|
186
156
|
const matchedSections = [] as number[];
|
187
157
|
const sameRule = (rA: ProductUploadRuleItem, rB: ProductUploadRuleItem): boolean => {
|
188
158
|
return rA.attribute === rB.attribute && rA.operator === rB.operator && compareValues(rA.value, rB.value);
|
189
159
|
};
|
190
160
|
|
191
|
-
|
192
|
-
|
161
|
+
const sectionsA = a.sections.filter(s => s.ruleItems.length > 0);
|
162
|
+
const sectionsB = b.sections.filter(s => s.ruleItems.length > 0);
|
193
163
|
|
194
|
-
if (
|
164
|
+
if (sectionsA.length !== sectionsB.length) {
|
195
165
|
return false;
|
196
166
|
}
|
197
167
|
|
198
|
-
for (let i = 0; i <
|
199
|
-
const rulesA =
|
168
|
+
for (let i = 0; i < sectionsA.length; i++) {
|
169
|
+
const rulesA = sectionsA[i].ruleItems;
|
200
170
|
|
201
|
-
for (let j = 0; j <
|
171
|
+
for (let j = 0; j < sectionsB.length; j++) {
|
202
172
|
if (matchedSections.includes(j)) {
|
203
173
|
continue;
|
204
174
|
}
|
205
175
|
|
206
|
-
const rulesB =
|
176
|
+
const rulesB = sectionsB[j].ruleItems;
|
207
177
|
|
208
178
|
if (rulesA.length !== rulesB.length) {
|
209
179
|
continue;
|
@@ -216,10 +186,10 @@ export function compareRules (
|
|
216
186
|
}
|
217
187
|
}
|
218
188
|
|
219
|
-
return matchedSections.length ===
|
189
|
+
return matchedSections.length === sectionsA.length;
|
220
190
|
}
|
221
191
|
|
222
|
-
function compareValues
|
192
|
+
function compareValues(a: Readonly<ValueType>, b: Readonly<ValueType>): boolean {
|
223
193
|
if (Array.isArray(a) && Array.isArray(b)) {
|
224
194
|
return a.length === b.length && a.every(i => b.includes(i));
|
225
195
|
}
|
@@ -227,7 +197,7 @@ function compareValues (a: any, b: any): boolean {
|
|
227
197
|
return a === b;
|
228
198
|
}
|
229
199
|
|
230
|
-
export function compareMappings
|
200
|
+
export function compareMappings(a: Readonly<ProductUploadMapping[]>, b: Readonly<ProductUploadMapping[]>): boolean {
|
231
201
|
const matchedMappings = [] as number[];
|
232
202
|
|
233
203
|
if (a.length !== b.length) {
|
@@ -258,21 +228,21 @@ export function compareMappings (a: ProductUploadMapping[], b: ProductUploadMapp
|
|
258
228
|
return matchedMappings.length === a.length;
|
259
229
|
}
|
260
230
|
|
261
|
-
export function optionIsString
|
231
|
+
export function optionIsString(option: OptionType): option is string {
|
262
232
|
return typeof option === 'string';
|
263
233
|
}
|
264
234
|
|
265
|
-
export function optionIsItem
|
235
|
+
export function optionIsItem(option: OptionType): option is OptionTypeItem {
|
266
236
|
return typeof option !== 'string' && 'value' in option;
|
267
237
|
}
|
268
238
|
|
269
|
-
export function optionIsGroup
|
239
|
+
export function optionIsGroup(option: OptionType): option is OptionTypeGroup {
|
270
240
|
return typeof option !== 'string' && 'options' in option;
|
271
241
|
}
|
272
242
|
|
273
|
-
export function detectProfileChange
|
274
|
-
a: ProductUploadProfile
|
275
|
-
b: ProductUploadProfile
|
243
|
+
export function detectProfileChange(
|
244
|
+
a: Readonly<ProductUploadProfile>,
|
245
|
+
b: Readonly<ProductUploadProfile>
|
276
246
|
): { name: boolean; rules: boolean; mappings: boolean; id: boolean } {
|
277
247
|
const changes = {
|
278
248
|
name: false,
|
@@ -306,7 +276,7 @@ export function detectProfileChange (
|
|
306
276
|
return changes;
|
307
277
|
}
|
308
278
|
|
309
|
-
export function sanitizeUploadProfile
|
279
|
+
export function sanitizeUploadProfile(profile: ProductUploadProfile): ProductUploadProfile {
|
310
280
|
if (profile.rules?.sections) {
|
311
281
|
profile.rules.sections = profile.rules.sections.filter(section => section.ruleItems.length > 0);
|
312
282
|
}
|
@@ -322,7 +292,7 @@ export function sanitizeUploadProfile (profile: ProductUploadProfile): ProductUp
|
|
322
292
|
return profile;
|
323
293
|
}
|
324
294
|
|
325
|
-
export function variableType
|
295
|
+
export function variableType(values: Readonly<MappingSourceValueType[]>): MappingSourceValueType {
|
326
296
|
if (values.some(v => v === MappingSourceValueType.STRING)) {
|
327
297
|
return MappingSourceValueType.STRING;
|
328
298
|
}
|