@softwear/latestcollectioncore 1.0.174 → 1.0.176
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 +18 -12
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/pdf.d.ts +67 -0
- package/dist/pdf.js +2 -0
- package/dist/reports.d.ts +35 -0
- package/dist/reports.js +705 -0
- package/package.json +3 -2
- package/src/imageBinder.ts +18 -16
- package/src/index.ts +3 -0
- package/src/pdf.ts +76 -0
- package/src/reports.ts +831 -0
- package/test/imageBinder.spec.js +8 -8
- package/test/imageBinderTestData/brandDataMatched/dreamstar.json +6 -709
- package/test/imageBinderTestData/brandDataMatched/lowa.json +6 -1456
- package/test/imageBinderTestData/brandDataMatched/miraclesuit.json +838 -1721
- package/test/imageBinderTestData/brandDataMatched/vacanzeitaliane.json +1215 -2185
- package/test/imageBinderTestData/brandSkus/dreamstar.json +68 -34
- package/test/imageBinderTestData/brandSkus/lowa.json +168 -84
- package/test/imageBinderTestData/brandSkus/miraclesuit.json +78 -39
- package/test/imageBinderTestData/brandSkus/vacanzeitaliane.json +106 -53
- package/test/reports.spec.ts +74 -0
- package/test.pdf +0 -0
package/dist/imageBinder.js
CHANGED
|
@@ -66,19 +66,20 @@ function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
|
|
|
66
66
|
const skusCopy = (0, deepCopy_1.default)(filteredSkus);
|
|
67
67
|
const preppedSkus = [];
|
|
68
68
|
const fileNames2skip = [];
|
|
69
|
-
|
|
70
|
-
skusCopy.forEach((sku) => {
|
|
71
|
-
const fieldsToBeMerged = {};
|
|
69
|
+
skusCopy.forEach((sku, idx) => {
|
|
72
70
|
if (sku.images && sku.images.length > 0) {
|
|
73
71
|
// If a fileName is already matched, we skip it
|
|
74
72
|
fileNames.forEach((fileName) => {
|
|
75
73
|
var _a;
|
|
76
|
-
if (((_a = sku.images) === null || _a === void 0 ? void 0 : _a.includes(fileName)) &&
|
|
74
|
+
if (((_a = sku.images) === null || _a === void 0 ? void 0 : _a.includes(fileName)) && fileNames2skip.indexOf(fileName) == -1)
|
|
77
75
|
fileNames2skip.push(fileName);
|
|
78
76
|
});
|
|
79
77
|
// If a sku has images, we skip it
|
|
78
|
+
sku['skip'] = true;
|
|
79
|
+
preppedSkus.push(sku);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
+
const fieldsToBeMerged = {};
|
|
82
83
|
for (const fieldName in sku) {
|
|
83
84
|
if (fieldName == '__created' || fieldName == '__modified' || fieldName == 'images' || fieldName == 'brandhash' || (merge == true && fieldName == 'colorFamily'))
|
|
84
85
|
continue;
|
|
@@ -107,7 +108,6 @@ function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
|
|
|
107
108
|
else {
|
|
108
109
|
const newSku = {};
|
|
109
110
|
newSku['originalSku'] = filteredSkus[idx];
|
|
110
|
-
idx++;
|
|
111
111
|
for (const fieldVal in fieldsToBeMerged) {
|
|
112
112
|
const fieldNameArray = fieldsToBeMerged[fieldVal].sort();
|
|
113
113
|
if (fieldNameArray.length > 1) {
|
|
@@ -121,7 +121,7 @@ function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
const fileNames2Match = fileNames.filter((fileName) => {
|
|
124
|
-
return fileNames2skip.
|
|
124
|
+
return fileNames2skip.indexOf(fileName) == -1;
|
|
125
125
|
});
|
|
126
126
|
return { preppedSkus: preppedSkus, fileNames2Match: fileNames2Match };
|
|
127
127
|
}
|
|
@@ -150,7 +150,7 @@ function checkWithoutLast(fileName) {
|
|
|
150
150
|
.toLowerCase()
|
|
151
151
|
.split(/[_\-.\s()]+|%[0-9A-Fa-f]{2}/)
|
|
152
152
|
.slice(0, -1);
|
|
153
|
-
const lastToken = tokens.
|
|
153
|
+
const lastToken = tokens[tokens.length - 1];
|
|
154
154
|
let returnWithoutLast = false;
|
|
155
155
|
if (lastToken) {
|
|
156
156
|
if (lastToken.includes('front') || lastToken.includes('back') || lastToken.includes('side') || lastToken.includes('sole'))
|
|
@@ -201,7 +201,7 @@ function testQuickSearch(cleanedFileName, fileName, fileNameWithoutLast, quickSe
|
|
|
201
201
|
indicesToReturn.push(idx);
|
|
202
202
|
patternStringFound = quickSearchPattern;
|
|
203
203
|
}
|
|
204
|
-
else if (indicesToReturn.length == 0 && pair[0] == fileNameWithoutLast &&
|
|
204
|
+
else if (indicesToReturn.length == 0 && pair[0] == fileNameWithoutLast && indicesWithoutLast.indexOf(idx) == -1) {
|
|
205
205
|
indicesWithoutLast.push(idx);
|
|
206
206
|
patternStringFound = quickSearchPattern;
|
|
207
207
|
}
|
|
@@ -224,6 +224,8 @@ function prepQuickSearch(preppedSkus) {
|
|
|
224
224
|
patternStrings.push(pattern.join('-'));
|
|
225
225
|
});
|
|
226
226
|
preppedSkus.forEach((sku, idx) => {
|
|
227
|
+
if (sku['skip'])
|
|
228
|
+
return;
|
|
227
229
|
GLOBAL_PATTERNS.forEach((pattern, patternIndex) => {
|
|
228
230
|
const proposedFilename = pattern.reduce((out, field) => out + (field in sku ? sku[field] : ''), '');
|
|
229
231
|
if (proposedFilename) {
|
|
@@ -240,12 +242,12 @@ function prepQuickSearch(preppedSkus) {
|
|
|
240
242
|
}
|
|
241
243
|
function addNewPatternToQuickSearch(preppedSkus, pattern, quickSearch) {
|
|
242
244
|
const newQuickSearchArray = [];
|
|
243
|
-
|
|
244
|
-
|
|
245
|
+
preppedSkus.forEach((sku, idx) => {
|
|
246
|
+
if (sku['skip'])
|
|
247
|
+
return;
|
|
245
248
|
const proposedFilename = pattern.reduce((out, field) => out + (field in sku ? sku[field] : ''), '');
|
|
246
249
|
if (proposedFilename)
|
|
247
250
|
newQuickSearchArray.push([proposedFilename, idx]);
|
|
248
|
-
idx++;
|
|
249
251
|
});
|
|
250
252
|
quickSearch[pattern.join('-')] = newQuickSearchArray;
|
|
251
253
|
return quickSearch;
|
|
@@ -258,6 +260,8 @@ function fallbackSearch(cleanedFileName, fileNameWithoutLast, preppedSkus) {
|
|
|
258
260
|
let currentBestSubstringPatterns = {};
|
|
259
261
|
let maxPatternlength = 0;
|
|
260
262
|
preppedSkus.forEach((sku, idx) => {
|
|
263
|
+
if (sku['skip'])
|
|
264
|
+
return;
|
|
261
265
|
if (pattern_found.length > 0) {
|
|
262
266
|
// In case a new pattern has been found in one sku, test that on the remaining skus. If they don't match the pattern, skip them.
|
|
263
267
|
const proposedFilename = pattern_found.reduce((out, field) => out + (field in sku ? sku[field] : ''), '');
|
|
@@ -359,7 +363,7 @@ function fallbackSearch(cleanedFileName, fileNameWithoutLast, preppedSkus) {
|
|
|
359
363
|
const sku = preppedSkus[idx];
|
|
360
364
|
pattern.forEach((fieldName) => {
|
|
361
365
|
const fieldVal = sku[fieldName];
|
|
362
|
-
if (fieldVal &&
|
|
366
|
+
if (fieldVal && uniqueFieldVals.indexOf(fieldVal) == -1)
|
|
363
367
|
uniqueFieldVals.push(fieldVal);
|
|
364
368
|
});
|
|
365
369
|
});
|
|
@@ -407,6 +411,8 @@ function imageBinder(fileNames, filteredSkus, brand, specifiedPattern, test = fa
|
|
|
407
411
|
const fileNameWithoutLast = checkWithoutLast(fileName);
|
|
408
412
|
fileNameIndexMatch[fileName] = [];
|
|
409
413
|
preppedSkus.forEach((sku, idx) => {
|
|
414
|
+
if (sku['skip'])
|
|
415
|
+
return;
|
|
410
416
|
let skuStillMatches = true;
|
|
411
417
|
specifiedPattern.every((fieldName) => {
|
|
412
418
|
if (!(fieldName in sku))
|
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,12 @@ export { default as hasOnlyDigits } from './hasOnlyDigits';
|
|
|
14
14
|
export { default as imageBinder } from './imageBinder';
|
|
15
15
|
export { default as isean13 } from './isean13';
|
|
16
16
|
export { default as pivotTable } from './pivotTable';
|
|
17
|
+
export { default as reports, genPDF } from './reports';
|
|
17
18
|
export { default as round2 } from './round2';
|
|
18
19
|
export { default as sizeToMap } from './sizeToMap';
|
|
19
20
|
export { default as transaction } from './transaction';
|
|
21
|
+
export * from './pdf';
|
|
22
|
+
export type { GenPdfAlert, GenPdfOptions, PdfFontDefinition, PdfFontVariant, PdfImageAsset } from './reports';
|
|
20
23
|
export * from './types';
|
|
21
24
|
export * from './consts';
|
|
22
25
|
export { default as lcAxios, createAxiosInstance, axiosRetry, exponentialDelay, isAxiosError, } from './lcAxios';
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.isAxiosError = exports.exponentialDelay = exports.axiosRetry = exports.createAxiosInstance = exports.lcAxios = exports.transaction = exports.sizeToMap = exports.round2 = exports.pivotTable = exports.isean13 = exports.imageBinder = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.getBrandName = exports.findMetaBrandSetting = exports.findSkuByBarcode = exports.ensureImpliedProperties = exports.ensureArray = exports.edifact = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = exports.articleStatus = void 0;
|
|
20
|
+
exports.isAxiosError = exports.exponentialDelay = exports.axiosRetry = exports.createAxiosInstance = exports.lcAxios = exports.transaction = exports.sizeToMap = exports.round2 = exports.genPDF = exports.reports = exports.pivotTable = exports.isean13 = exports.imageBinder = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.getBrandName = exports.findMetaBrandSetting = exports.findSkuByBarcode = exports.ensureImpliedProperties = exports.ensureArray = exports.edifact = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = exports.articleStatus = void 0;
|
|
21
21
|
var articleStatus_1 = require("./articleStatus");
|
|
22
22
|
Object.defineProperty(exports, "articleStatus", { enumerable: true, get: function () { return __importDefault(articleStatus_1).default; } });
|
|
23
23
|
var buildPropertyMappingFn_1 = require("./buildPropertyMappingFn");
|
|
@@ -50,12 +50,16 @@ var isean13_1 = require("./isean13");
|
|
|
50
50
|
Object.defineProperty(exports, "isean13", { enumerable: true, get: function () { return __importDefault(isean13_1).default; } });
|
|
51
51
|
var pivotTable_1 = require("./pivotTable");
|
|
52
52
|
Object.defineProperty(exports, "pivotTable", { enumerable: true, get: function () { return __importDefault(pivotTable_1).default; } });
|
|
53
|
+
var reports_1 = require("./reports");
|
|
54
|
+
Object.defineProperty(exports, "reports", { enumerable: true, get: function () { return __importDefault(reports_1).default; } });
|
|
55
|
+
Object.defineProperty(exports, "genPDF", { enumerable: true, get: function () { return reports_1.genPDF; } });
|
|
53
56
|
var round2_1 = require("./round2");
|
|
54
57
|
Object.defineProperty(exports, "round2", { enumerable: true, get: function () { return __importDefault(round2_1).default; } });
|
|
55
58
|
var sizeToMap_1 = require("./sizeToMap");
|
|
56
59
|
Object.defineProperty(exports, "sizeToMap", { enumerable: true, get: function () { return __importDefault(sizeToMap_1).default; } });
|
|
57
60
|
var transaction_1 = require("./transaction");
|
|
58
61
|
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return __importDefault(transaction_1).default; } });
|
|
62
|
+
__exportStar(require("./pdf"), exports);
|
|
59
63
|
__exportStar(require("./types"), exports);
|
|
60
64
|
__exportStar(require("./consts"), exports);
|
|
61
65
|
var lcAxios_1 = require("./lcAxios");
|
package/dist/pdf.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface PaperSize {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
footerHeight: number;
|
|
5
|
+
}
|
|
6
|
+
export type TextAlign = 1 | 2 | 3;
|
|
7
|
+
export type ObjectType = 'text' | 'field' | 'rectangle' | 'image' | 'container';
|
|
8
|
+
export type RepeatContainer = 'horizontal' | 'vertical' | undefined;
|
|
9
|
+
export interface BaseLayoutObject {
|
|
10
|
+
type: ObjectType;
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
active?: boolean;
|
|
16
|
+
snapToBottom?: boolean;
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TextLayoutObject extends BaseLayoutObject {
|
|
20
|
+
type: 'text';
|
|
21
|
+
text: string;
|
|
22
|
+
textAlign?: TextAlign;
|
|
23
|
+
fontFamily: string;
|
|
24
|
+
fontSize: number;
|
|
25
|
+
fontStyle: number;
|
|
26
|
+
case?: 1 | 2;
|
|
27
|
+
}
|
|
28
|
+
export interface FieldLayoutObject extends BaseLayoutObject {
|
|
29
|
+
type: 'field';
|
|
30
|
+
source?: string;
|
|
31
|
+
format?: 'date' | 'currency';
|
|
32
|
+
textAlign?: TextAlign;
|
|
33
|
+
fontFamily: string;
|
|
34
|
+
fontSize: number;
|
|
35
|
+
fontStyle: number;
|
|
36
|
+
case?: 1 | 2;
|
|
37
|
+
}
|
|
38
|
+
export interface RectangleLayoutObject extends BaseLayoutObject {
|
|
39
|
+
type: 'rectangle';
|
|
40
|
+
}
|
|
41
|
+
export interface ImageLayoutObject extends BaseLayoutObject {
|
|
42
|
+
type: 'image';
|
|
43
|
+
url?: string;
|
|
44
|
+
image?: HTMLImageElement;
|
|
45
|
+
}
|
|
46
|
+
export interface ContainerLayoutObject extends BaseLayoutObject {
|
|
47
|
+
type: 'container';
|
|
48
|
+
source: string;
|
|
49
|
+
children: LayoutObject[];
|
|
50
|
+
repeatContainer?: RepeatContainer;
|
|
51
|
+
repeatOnOverflow?: boolean;
|
|
52
|
+
pageBreak?: boolean;
|
|
53
|
+
/** Minimum mm of remaining space before drawing next item; if less, break to next page first */
|
|
54
|
+
minHeightBeforeBreak?: number;
|
|
55
|
+
/** When true, container and children are drawn only once at the end of the report, not on every page */
|
|
56
|
+
printOnlyAtEnd?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export type LayoutObject = TextLayoutObject | FieldLayoutObject | RectangleLayoutObject | ImageLayoutObject | ContainerLayoutObject;
|
|
59
|
+
export interface Layout {
|
|
60
|
+
name?: string;
|
|
61
|
+
group?: string;
|
|
62
|
+
paperSize: PaperSize;
|
|
63
|
+
objects: LayoutObject[];
|
|
64
|
+
active?: boolean;
|
|
65
|
+
/** Default font for text/field objects that have no fontFamily. E.g. 'Inter', 'Helvetica'. */
|
|
66
|
+
defaultFontFamily?: string;
|
|
67
|
+
}
|
package/dist/pdf.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsPDF } from 'jspdf';
|
|
2
|
+
import { Layout } from './pdf';
|
|
3
|
+
export interface GenPdfAlert {
|
|
4
|
+
header: string;
|
|
5
|
+
body?: string;
|
|
6
|
+
type?: 'warning' | 'error' | 'success' | 'info';
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface PdfFontVariant {
|
|
10
|
+
style: 'normal' | 'bold' | 'italic' | 'bolditalic';
|
|
11
|
+
url: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PdfFontDefinition {
|
|
14
|
+
family: string;
|
|
15
|
+
variants: PdfFontVariant[];
|
|
16
|
+
}
|
|
17
|
+
export interface PdfImageAsset {
|
|
18
|
+
dataUrl: string;
|
|
19
|
+
format: 'PNG' | 'JPEG';
|
|
20
|
+
width?: number;
|
|
21
|
+
height?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface GenPdfOptions {
|
|
24
|
+
onAlert?: (alert: GenPdfAlert) => void;
|
|
25
|
+
translate?: (key: string) => string;
|
|
26
|
+
resolveLogoUrl?: () => string | undefined;
|
|
27
|
+
isCustomPdfFont?: (fontFamily: string) => boolean;
|
|
28
|
+
getPdfFontDefinition?: (fontFamily: string) => PdfFontDefinition | undefined;
|
|
29
|
+
loadImage?: (url: string) => Promise<PdfImageAsset | undefined>;
|
|
30
|
+
}
|
|
31
|
+
export declare function genPDF(layout: Layout, printBuffer: any, options?: GenPdfOptions): Promise<jsPDF>;
|
|
32
|
+
declare const _default: {
|
|
33
|
+
genPDF: typeof genPDF;
|
|
34
|
+
};
|
|
35
|
+
export default _default;
|