@softwear/latestcollectioncore 1.0.195 → 1.0.196
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/dist/imageBinder.js +19 -0
- package/package.json +1 -1
- package/src/imageBinder.ts +16 -0
package/dist/imageBinder.js
CHANGED
|
@@ -61,6 +61,7 @@ const GLOBAL_PATTERNS = [
|
|
|
61
61
|
['colorCodeSupplier|colorSupplier', 'articleCode|articleCodeSupplier'],
|
|
62
62
|
['brand', 'collectionSupplier', 'colorCodeSupplier', 'articleCode|articleCodeSupplier'],
|
|
63
63
|
['brand', 'collectionSupplier', 'colorCodeSupplier', 'articleCode|articleCodeSupplier', 'buyPrice|valuePrice'],
|
|
64
|
+
['brand', 'articleDescription', 'colorSupplier'],
|
|
64
65
|
];
|
|
65
66
|
function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
|
|
66
67
|
const skusCopy = (0, deepCopy_1.default)(filteredSkus);
|
|
@@ -161,7 +162,25 @@ function checkWithoutLast(fileName) {
|
|
|
161
162
|
returnWithoutLast = true;
|
|
162
163
|
else if (lastToken.length <= 2 && /^[A-Za-zÀ-ÖØ-öø-ÿ0-9]+$/.test(lastToken))
|
|
163
164
|
returnWithoutLast = true;
|
|
165
|
+
const tokenLength = tokens.length;
|
|
164
166
|
if (returnWithoutLast) {
|
|
167
|
+
let sliceIndex = -1;
|
|
168
|
+
if (tokenLength > 3 && tokens[tokenLength - 3] == 'press' && ((tokens[tokenLength - 2] == 'pack') || (tokens[tokenLength - 2] == 'model')))
|
|
169
|
+
sliceIndex = -3;
|
|
170
|
+
else if (tokenLength > 2 && tokens[tokenLength - 2] == 'packshot')
|
|
171
|
+
sliceIndex = -2;
|
|
172
|
+
return tokens
|
|
173
|
+
.slice(0, sliceIndex)
|
|
174
|
+
.join('')
|
|
175
|
+
.replace(/[^\p{L}\p{N}]+/gu, '');
|
|
176
|
+
}
|
|
177
|
+
if (tokenLength > 2 && tokens[tokenLength - 2] == 'press' && ((tokens[tokenLength - 1] == 'pack') || (tokens[tokenLength - 1] == 'model'))) {
|
|
178
|
+
return tokens
|
|
179
|
+
.slice(0, -2)
|
|
180
|
+
.join('')
|
|
181
|
+
.replace(/[^\p{L}\p{N}]+/gu, '');
|
|
182
|
+
}
|
|
183
|
+
else if (tokenLength > 1 && tokens[tokenLength - 1] == 'packshot') {
|
|
165
184
|
return tokens
|
|
166
185
|
.slice(0, -1)
|
|
167
186
|
.join('')
|
package/package.json
CHANGED
package/src/imageBinder.ts
CHANGED
|
@@ -26,6 +26,7 @@ const GLOBAL_PATTERNS = [
|
|
|
26
26
|
['colorCodeSupplier|colorSupplier', 'articleCode|articleCodeSupplier'],
|
|
27
27
|
['brand', 'collectionSupplier', 'colorCodeSupplier', 'articleCode|articleCodeSupplier'],
|
|
28
28
|
['brand', 'collectionSupplier', 'colorCodeSupplier', 'articleCode|articleCodeSupplier', 'buyPrice|valuePrice'],
|
|
29
|
+
['brand', 'articleDescription', 'colorSupplier'],
|
|
29
30
|
]
|
|
30
31
|
|
|
31
32
|
function prepFilterSkusImages(filteredSkus: SkuI[], merge = true, fileNames: Array<string>) {
|
|
@@ -123,7 +124,22 @@ function checkWithoutLast(fileName: string) {
|
|
|
123
124
|
else if (Number(lastToken)) returnWithoutLast = true
|
|
124
125
|
else if (lastToken.length == 1 && /^[A-Za-zÀ-ÖØ-öø-ÿ]+$/.test(lastToken)) returnWithoutLast = true
|
|
125
126
|
else if (lastToken.length <= 2 && /^[A-Za-zÀ-ÖØ-öø-ÿ0-9]+$/.test(lastToken)) returnWithoutLast = true
|
|
127
|
+
const tokenLength = tokens.length
|
|
126
128
|
if (returnWithoutLast) {
|
|
129
|
+
let sliceIndex = -1
|
|
130
|
+
if (tokenLength > 3 && tokens[tokenLength - 3] == 'press' && ((tokens[tokenLength - 2] == 'pack') || (tokens[tokenLength - 2] == 'model'))) sliceIndex = -3
|
|
131
|
+
else if (tokenLength > 2 && tokens[tokenLength - 2] == 'packshot') sliceIndex = -2
|
|
132
|
+
return tokens
|
|
133
|
+
.slice(0, sliceIndex)
|
|
134
|
+
.join('')
|
|
135
|
+
.replace(/[^\p{L}\p{N}]+/gu, '')
|
|
136
|
+
}
|
|
137
|
+
if (tokenLength > 2 && tokens[tokenLength - 2] == 'press' && ((tokens[tokenLength - 1] == 'pack') || (tokens[tokenLength - 1] == 'model'))) {
|
|
138
|
+
return tokens
|
|
139
|
+
.slice(0, -2)
|
|
140
|
+
.join('')
|
|
141
|
+
.replace(/[^\p{L}\p{N}]+/gu, '')
|
|
142
|
+
} else if (tokenLength > 1 && tokens[tokenLength - 1] == 'packshot') {
|
|
127
143
|
return tokens
|
|
128
144
|
.slice(0, -1)
|
|
129
145
|
.join('')
|