@softwear/latestcollectioncore 1.0.195 → 1.0.197
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/consts.d.ts +4 -0
- package/dist/consts.js +4 -0
- package/dist/dataRetention.d.ts +4 -0
- package/dist/dataRetention.js +27 -0
- package/dist/imageBinder.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/src/consts.ts +4 -0
- package/src/dataRetention.ts +23 -0
- package/src/imageBinder.ts +16 -0
- package/src/index.ts +1 -0
- package/test/dataRetention.spec.ts +21 -0
package/dist/consts.d.ts
CHANGED
|
@@ -4,21 +4,25 @@ declare const SUBSCRIPTION_LIMITS: {
|
|
|
4
4
|
readonly maxBarcodes: 1000;
|
|
5
5
|
readonly maxDownloadBarcodes: 1000;
|
|
6
6
|
readonly maxCustomers: 0;
|
|
7
|
+
readonly maxDataRetentionYears: 3;
|
|
7
8
|
};
|
|
8
9
|
readonly basiq: {
|
|
9
10
|
readonly maxBarcodes: 100000;
|
|
10
11
|
readonly maxDownloadBarcodes: 10000;
|
|
11
12
|
readonly maxCustomers: 1000;
|
|
13
|
+
readonly maxDataRetentionYears: 3;
|
|
12
14
|
};
|
|
13
15
|
readonly pro: {
|
|
14
16
|
readonly maxBarcodes: 200000;
|
|
15
17
|
readonly maxDownloadBarcodes: 20000;
|
|
16
18
|
readonly maxCustomers: 10000;
|
|
19
|
+
readonly maxDataRetentionYears: 5;
|
|
17
20
|
};
|
|
18
21
|
readonly ultimate: {
|
|
19
22
|
readonly maxBarcodes: 500000;
|
|
20
23
|
readonly maxDownloadBarcodes: 50000;
|
|
21
24
|
readonly maxCustomers: 100000;
|
|
25
|
+
readonly maxDataRetentionYears: 7;
|
|
22
26
|
};
|
|
23
27
|
};
|
|
24
28
|
declare const latestCollectionGLN: "8719332204995";
|
package/dist/consts.js
CHANGED
|
@@ -22,21 +22,25 @@ const SUBSCRIPTION_LIMITS = {
|
|
|
22
22
|
maxBarcodes: 1000,
|
|
23
23
|
maxDownloadBarcodes: 1000,
|
|
24
24
|
maxCustomers: 0,
|
|
25
|
+
maxDataRetentionYears: 3,
|
|
25
26
|
},
|
|
26
27
|
basiq: {
|
|
27
28
|
maxBarcodes: 100000,
|
|
28
29
|
maxDownloadBarcodes: 10000,
|
|
29
30
|
maxCustomers: 1000,
|
|
31
|
+
maxDataRetentionYears: 3,
|
|
30
32
|
},
|
|
31
33
|
pro: {
|
|
32
34
|
maxBarcodes: 200000,
|
|
33
35
|
maxDownloadBarcodes: 20000,
|
|
34
36
|
maxCustomers: 10000,
|
|
37
|
+
maxDataRetentionYears: 5,
|
|
35
38
|
},
|
|
36
39
|
ultimate: {
|
|
37
40
|
maxBarcodes: 500000,
|
|
38
41
|
maxDownloadBarcodes: 50000,
|
|
39
42
|
maxCustomers: 100000,
|
|
43
|
+
maxDataRetentionYears: 7,
|
|
40
44
|
},
|
|
41
45
|
};
|
|
42
46
|
exports.SUBSCRIPTION_LIMITS = SUBSCRIPTION_LIMITS;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function getMaxDataRetentionYears(subscription: string): number;
|
|
2
|
+
export declare function getEarliestAllowedYear(maxRetentionYears: number, thisYear?: number): number;
|
|
3
|
+
export declare function isYearWithinDataRetention(year: number | string, maxRetentionYears: number, thisYear?: number): boolean;
|
|
4
|
+
export declare function isDateWithinDataRetention(date: string, maxRetentionYears: number, thisYear?: number): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDateWithinDataRetention = exports.isYearWithinDataRetention = exports.getEarliestAllowedYear = exports.getMaxDataRetentionYears = void 0;
|
|
4
|
+
const consts_1 = require("./consts");
|
|
5
|
+
function getMaxDataRetentionYears(subscription) {
|
|
6
|
+
var _a;
|
|
7
|
+
const limits = consts_1.SUBSCRIPTION_LIMITS[subscription];
|
|
8
|
+
return (_a = limits === null || limits === void 0 ? void 0 : limits.maxDataRetentionYears) !== null && _a !== void 0 ? _a : consts_1.SUBSCRIPTION_LIMITS.basiq.maxDataRetentionYears;
|
|
9
|
+
}
|
|
10
|
+
exports.getMaxDataRetentionYears = getMaxDataRetentionYears;
|
|
11
|
+
function getEarliestAllowedYear(maxRetentionYears, thisYear = new Date().getFullYear()) {
|
|
12
|
+
return thisYear - maxRetentionYears + 1;
|
|
13
|
+
}
|
|
14
|
+
exports.getEarliestAllowedYear = getEarliestAllowedYear;
|
|
15
|
+
function isYearWithinDataRetention(year, maxRetentionYears, thisYear = new Date().getFullYear()) {
|
|
16
|
+
const parsedYear = parseInt(String(year), 10);
|
|
17
|
+
if (Number.isNaN(parsedYear))
|
|
18
|
+
return true;
|
|
19
|
+
return parsedYear >= getEarliestAllowedYear(maxRetentionYears, thisYear);
|
|
20
|
+
}
|
|
21
|
+
exports.isYearWithinDataRetention = isYearWithinDataRetention;
|
|
22
|
+
function isDateWithinDataRetention(date, maxRetentionYears, thisYear = new Date().getFullYear()) {
|
|
23
|
+
if (!date)
|
|
24
|
+
return true;
|
|
25
|
+
return isYearWithinDataRetention(parseInt(date.substring(0, 4), 10), maxRetentionYears, thisYear);
|
|
26
|
+
}
|
|
27
|
+
exports.isDateWithinDataRetention = isDateWithinDataRetention;
|
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/dist/index.d.ts
CHANGED
|
@@ -25,5 +25,6 @@ export * from './pdf';
|
|
|
25
25
|
export type { GenPdfAlert, GenPdfOptions, PdfFontDefinition, PdfFontVariant, PdfImageAsset } from './reports';
|
|
26
26
|
export * from './types';
|
|
27
27
|
export * from './consts';
|
|
28
|
+
export * from './dataRetention';
|
|
28
29
|
export { default as lcAxios, createAxiosInstance, axiosRetry, exponentialDelay, isAxiosError, } from './lcAxios';
|
|
29
30
|
export type { AxiosRequestConfig, AxiosResponse, AxiosPromise, AxiosError, AxiosTransformer, AxiosRetryOptions, AxiosRequestConfigAny, } from './lcAxios';
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ Object.defineProperty(exports, "shouldSuppressZeroField", { enumerable: true, ge
|
|
|
69
69
|
__exportStar(require("./pdf"), exports);
|
|
70
70
|
__exportStar(require("./types"), exports);
|
|
71
71
|
__exportStar(require("./consts"), exports);
|
|
72
|
+
__exportStar(require("./dataRetention"), exports);
|
|
72
73
|
var lcAxios_1 = require("./lcAxios");
|
|
73
74
|
Object.defineProperty(exports, "lcAxios", { enumerable: true, get: function () { return __importDefault(lcAxios_1).default; } });
|
|
74
75
|
Object.defineProperty(exports, "createAxiosInstance", { enumerable: true, get: function () { return lcAxios_1.createAxiosInstance; } });
|
package/package.json
CHANGED
package/src/consts.ts
CHANGED
|
@@ -18,21 +18,25 @@ const SUBSCRIPTION_LIMITS = {
|
|
|
18
18
|
maxBarcodes: 1000,
|
|
19
19
|
maxDownloadBarcodes: 1000,
|
|
20
20
|
maxCustomers: 0,
|
|
21
|
+
maxDataRetentionYears: 3,
|
|
21
22
|
},
|
|
22
23
|
basiq: {
|
|
23
24
|
maxBarcodes: 100000,
|
|
24
25
|
maxDownloadBarcodes: 10000,
|
|
25
26
|
maxCustomers: 1000,
|
|
27
|
+
maxDataRetentionYears: 3,
|
|
26
28
|
},
|
|
27
29
|
pro: {
|
|
28
30
|
maxBarcodes: 200000,
|
|
29
31
|
maxDownloadBarcodes: 20000,
|
|
30
32
|
maxCustomers: 10000,
|
|
33
|
+
maxDataRetentionYears: 5,
|
|
31
34
|
},
|
|
32
35
|
ultimate: {
|
|
33
36
|
maxBarcodes: 500000,
|
|
34
37
|
maxDownloadBarcodes: 50000,
|
|
35
38
|
maxCustomers: 100000,
|
|
39
|
+
maxDataRetentionYears: 7,
|
|
36
40
|
},
|
|
37
41
|
} as const
|
|
38
42
|
const latestCollectionGLN = '8719332204995' as const
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SUBSCRIPTION_LIMITS } from './consts'
|
|
2
|
+
|
|
3
|
+
type SubscriptionKey = keyof typeof SUBSCRIPTION_LIMITS
|
|
4
|
+
|
|
5
|
+
export function getMaxDataRetentionYears(subscription: string): number {
|
|
6
|
+
const limits = SUBSCRIPTION_LIMITS[subscription as SubscriptionKey]
|
|
7
|
+
return limits?.maxDataRetentionYears ?? SUBSCRIPTION_LIMITS.basiq.maxDataRetentionYears
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getEarliestAllowedYear(maxRetentionYears: number, thisYear = new Date().getFullYear()): number {
|
|
11
|
+
return thisYear - maxRetentionYears + 1
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isYearWithinDataRetention(year: number | string, maxRetentionYears: number, thisYear = new Date().getFullYear()): boolean {
|
|
15
|
+
const parsedYear = parseInt(String(year), 10)
|
|
16
|
+
if (Number.isNaN(parsedYear)) return true
|
|
17
|
+
return parsedYear >= getEarliestAllowedYear(maxRetentionYears, thisYear)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isDateWithinDataRetention(date: string, maxRetentionYears: number, thisYear = new Date().getFullYear()): boolean {
|
|
21
|
+
if (!date) return true
|
|
22
|
+
return isYearWithinDataRetention(parseInt(date.substring(0, 4), 10), maxRetentionYears, thisYear)
|
|
23
|
+
}
|
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('')
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from './pdf'
|
|
|
25
25
|
export type { GenPdfAlert, GenPdfOptions, PdfFontDefinition, PdfFontVariant, PdfImageAsset } from './reports'
|
|
26
26
|
export * from './types'
|
|
27
27
|
export * from './consts'
|
|
28
|
+
export * from './dataRetention'
|
|
28
29
|
export {
|
|
29
30
|
default as lcAxios,
|
|
30
31
|
createAxiosInstance,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { getEarliestAllowedYear, getMaxDataRetentionYears, isDateWithinDataRetention, isYearWithinDataRetention } from '../src/dataRetention'
|
|
3
|
+
|
|
4
|
+
describe('dataRetention', () => {
|
|
5
|
+
const thisYear = 2026
|
|
6
|
+
|
|
7
|
+
it('returns retention years per subscription', () => {
|
|
8
|
+
expect(getMaxDataRetentionYears('basiq')).toBe(3)
|
|
9
|
+
expect(getMaxDataRetentionYears('pro')).toBe(5)
|
|
10
|
+
expect(getMaxDataRetentionYears('ultimate')).toBe(7)
|
|
11
|
+
expect(getMaxDataRetentionYears('unknown')).toBe(3)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('checks year and date access against retention', () => {
|
|
15
|
+
expect(getEarliestAllowedYear(3, thisYear)).toBe(2024)
|
|
16
|
+
expect(isYearWithinDataRetention(2024, 3, thisYear)).toBe(true)
|
|
17
|
+
expect(isYearWithinDataRetention(2023, 3, thisYear)).toBe(false)
|
|
18
|
+
expect(isDateWithinDataRetention('2023-12-31', 3, thisYear)).toBe(false)
|
|
19
|
+
expect(isDateWithinDataRetention('2024-01-01', 3, thisYear)).toBe(true)
|
|
20
|
+
})
|
|
21
|
+
})
|