@softwear/latestcollectioncore 1.0.152 → 1.0.158

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.
@@ -41,7 +41,7 @@ function default_1(brands, strategy) {
41
41
  });
42
42
  if (strategy == 'clean')
43
43
  return function (sku) {
44
- const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
44
+ const brand = sku.brandhash || (0, index_1.hashBrand)(sku.brand);
45
45
  const mapping = indexedByBrandPropertyMapping[brand];
46
46
  mappingPairs.forEach((pair) => {
47
47
  var _a;
@@ -56,7 +56,7 @@ function default_1(brands, strategy) {
56
56
  };
57
57
  if (strategy == 'markMissingMapping')
58
58
  return function (sku) {
59
- const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
59
+ const brand = sku.brandhash || (0, index_1.hashBrand)(sku.brand);
60
60
  const mapping = indexedByBrandPropertyMapping[brand];
61
61
  mappingPairs.forEach((pair) => {
62
62
  var _a, _b, _c, _d, _e;
@@ -70,7 +70,7 @@ function default_1(brands, strategy) {
70
70
  return sku;
71
71
  };
72
72
  return function (sku) {
73
- const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
73
+ const brand = sku.brandhash || (0, index_1.hashBrand)(sku.brand);
74
74
  const mapping = indexedByBrandPropertyMapping[brand];
75
75
  mappingPairs.forEach((pair) => {
76
76
  var _a, _b, _c, _d, _e, _f;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { Buffer } from 'buffer';
4
3
  export declare function encrypt(plain: string, KEY: Buffer): string;
5
4
  export declare function decrypt(enc: string, KEY: Buffer): string;
@@ -1,31 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decrypt = exports.encrypt = void 0;
4
- const buffer_1 = require("buffer");
4
+ /**
5
+ * Node-only AES-GCM. Import from `@softwear/latestcollectioncore/cryptography` (not the main package).
6
+ * Uses global `Buffer` and bare `crypto` so bundlers need not resolve `node:` URLs.
7
+ */
5
8
  const crypto_1 = require("crypto");
9
+ function assertNodeOnly() {
10
+ var _a;
11
+ if (typeof process === 'undefined' || !((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
12
+ throw new Error('@softwear/latestcollectioncore/cryptography is Node-only');
13
+ }
14
+ }
6
15
  function encrypt(plain, KEY) {
16
+ assertNodeOnly();
7
17
  const iv = (0, crypto_1.randomBytes)(12);
8
18
  const cipher = (0, crypto_1.createCipheriv)('aes-256-gcm', KEY, iv);
9
- const ciphertext = buffer_1.Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()]);
19
+ const ciphertext = Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()]);
10
20
  const tag = cipher.getAuthTag();
11
21
  const b64 = (b) => b.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
12
22
  return `v1:${b64(iv)}:${b64(ciphertext)}:${b64(tag)}`;
13
23
  }
14
24
  exports.encrypt = encrypt;
15
25
  function decrypt(enc, KEY) {
26
+ assertNodeOnly();
16
27
  const [version, ivB64, ctB64, tagB64] = enc.split(':');
17
28
  if (version !== 'v1')
18
29
  throw new Error('Unsupported version');
19
30
  const fromB64 = (s) => {
20
31
  const pad = s.length % 4 ? '='.repeat(4 - (s.length % 4)) : '';
21
- return buffer_1.Buffer.from(s.replace(/-/g, '+').replace(/_/g, '/') + pad, 'base64');
32
+ return Buffer.from(s.replace(/-/g, '+').replace(/_/g, '/') + pad, 'base64');
22
33
  };
23
34
  const iv = fromB64(ivB64);
24
35
  const ct = fromB64(ctB64);
25
36
  const tag = fromB64(tagB64);
26
37
  const decipher = (0, crypto_1.createDecipheriv)('aes-256-gcm', KEY, iv);
27
38
  decipher.setAuthTag(tag);
28
- const plain = buffer_1.Buffer.concat([decipher.update(ct), decipher.final()]);
39
+ const plain = Buffer.concat([decipher.update(ct), decipher.final()]);
29
40
  return plain.toString('utf8');
30
41
  }
31
42
  exports.decrypt = decrypt;
@@ -80,7 +80,7 @@ function prepFilterSkusImages(filteredSkus, merge = true, fileNames) {
80
80
  return;
81
81
  }
82
82
  for (const fieldName in sku) {
83
- if (fieldName == '__created' || fieldName == '__modified' || fieldName == 'images' || fieldName == 'BRANDHASH' || (merge == true && fieldName == 'colorFamily'))
83
+ if (fieldName == '__created' || fieldName == '__modified' || fieldName == 'images' || fieldName == 'brandhash' || (merge == true && fieldName == 'colorFamily'))
84
84
  continue;
85
85
  let fieldVal = sku[fieldName];
86
86
  if (fieldVal == '')
@@ -505,7 +505,7 @@ function testBatch(brand) {
505
505
  const [skusModule, imagesModule, matchedModule] = yield Promise.all([
506
506
  (_a = `../test/imageBinderTestData/brandSkus/${brand}.json`, Promise.resolve().then(() => __importStar(require(_a)))),
507
507
  (_b = `../test/imageBinderTestData/brandImages/${brand}.json`, Promise.resolve().then(() => __importStar(require(_b)))),
508
- (_c = `../test/imageBinderTestData/brandDataMatched/${brand}.json`, Promise.resolve().then(() => __importStar(require(_c))))
508
+ (_c = `../test/imageBinderTestData/brandDataMatched/${brand}.json`, Promise.resolve().then(() => __importStar(require(_c)))),
509
509
  ]);
510
510
  const fileNames = imagesModule.default;
511
511
  const filteredSkus = skusModule.default;
@@ -536,14 +536,14 @@ function testBatch(brand) {
536
536
  }
537
537
  }
538
538
  return {
539
- 'Brand': brand,
540
- 'Files': fileNames.length,
541
- 'Skus': filteredSkus.length,
542
- 'Mismatches': mismatchCount,
543
- 'Time': Number(((t1 - t0) / 1000).toFixed(3)),
544
- 'QuickSearch': imageBinderResult.quickCount,
545
- 'FallbackSearch': imageBinderResult.fallbackCount,
546
- 'Patterns': imageBinderResult.patternCounter,
539
+ Brand: brand,
540
+ Files: fileNames.length,
541
+ Skus: filteredSkus.length,
542
+ Mismatches: mismatchCount,
543
+ Time: Number(((t1 - t0) / 1000).toFixed(3)),
544
+ QuickSearch: imageBinderResult.quickCount,
545
+ FallbackSearch: imageBinderResult.fallbackCount,
546
+ Patterns: imageBinderResult.patternCounter,
547
547
  };
548
548
  });
549
549
  }
package/dist/index.d.ts CHANGED
@@ -17,4 +17,5 @@ export { default as sizeToMap } from './sizeToMap';
17
17
  export { default as transaction } from './transaction';
18
18
  export * from './types';
19
19
  export * from './consts';
20
- export * from './cryptography';
20
+ export { default as lcAxios, createAxiosInstance, axiosRetry, exponentialDelay, isAxiosError, } from './lcAxios';
21
+ export type { AxiosRequestConfig, AxiosResponse, AxiosPromise, AxiosError, AxiosTransformer, AxiosRetryOptions, AxiosRequestConfigAny, } 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.transaction = exports.sizeToMap = exports.round2 = exports.pivotTable = exports.isean13 = exports.imageBinder = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.getBrandName = exports.findSkuByBarcode = 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.pivotTable = exports.isean13 = exports.imageBinder = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.getBrandName = exports.findSkuByBarcode = 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");
@@ -54,4 +54,9 @@ var transaction_1 = require("./transaction");
54
54
  Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return __importDefault(transaction_1).default; } });
55
55
  __exportStar(require("./types"), exports);
56
56
  __exportStar(require("./consts"), exports);
57
- __exportStar(require("./cryptography"), exports);
57
+ var lcAxios_1 = require("./lcAxios");
58
+ Object.defineProperty(exports, "lcAxios", { enumerable: true, get: function () { return __importDefault(lcAxios_1).default; } });
59
+ Object.defineProperty(exports, "createAxiosInstance", { enumerable: true, get: function () { return lcAxios_1.createAxiosInstance; } });
60
+ Object.defineProperty(exports, "axiosRetry", { enumerable: true, get: function () { return lcAxios_1.axiosRetry; } });
61
+ Object.defineProperty(exports, "exponentialDelay", { enumerable: true, get: function () { return lcAxios_1.exponentialDelay; } });
62
+ Object.defineProperty(exports, "isAxiosError", { enumerable: true, get: function () { return lcAxios_1.isAxiosError; } });
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Fetch-based axios-compatible client (minimal surface used by apps).
3
+ * Zero extra npm deps: uses global fetch, URL, Headers, AbortController.
4
+ *
5
+ * `decompress` on the request config is accepted for axios API compatibility only;
6
+ * it is ignored at runtime — fetch already returns decompressed response bodies for typical reads.
7
+ */
8
+ export interface AxiosRequestConfig<D = any> {
9
+ url?: string;
10
+ baseURL?: string;
11
+ method?: string;
12
+ data?: D;
13
+ params?: Record<string, any>;
14
+ headers?: Record<string, string | undefined> | any;
15
+ timeout?: number;
16
+ responseType?: 'json' | 'text' | 'blob' | 'arraybuffer';
17
+ validateStatus?: (status: number) => boolean;
18
+ transformRequest?: AxiosTransformer | AxiosTransformer[];
19
+ transformResponse?: AxiosTransformer | AxiosTransformer[];
20
+ withCredentials?: boolean;
21
+ /** Axios-only; ignored — fetch handles Content-Encoding when reading the body */
22
+ decompress?: boolean;
23
+ }
24
+ export type AxiosTransformer = (data: any, headers?: any) => any | Promise<any>;
25
+ export interface AxiosResponse<T = any, D = any> {
26
+ data: T;
27
+ status: number;
28
+ statusText: string;
29
+ headers: Record<string, string>;
30
+ config: AxiosRequestConfig<D>;
31
+ }
32
+ export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
33
+ export interface AxiosError<T = any, D = any> extends Error {
34
+ isAxiosError: true;
35
+ config?: AxiosRequestConfig<D>;
36
+ response?: AxiosResponse<T, D>;
37
+ request?: any;
38
+ }
39
+ export type AxiosRequestConfigAny = AxiosRequestConfig;
40
+ declare function isAxiosError(payload: any): payload is AxiosError;
41
+ export declare function exponentialDelay(retryNumber?: number): number;
42
+ export interface AxiosRetryOptions {
43
+ retries?: number;
44
+ retryDelay?: (retryCount: number) => number;
45
+ retryCondition?: (error: any) => boolean;
46
+ }
47
+ export declare function axiosRetry(instance: any, options?: AxiosRetryOptions): any;
48
+ export declare function createAxiosInstance(initialDefaults?: AxiosRequestConfig): any;
49
+ declare const lcAxios: any;
50
+ export default lcAxios;
51
+ export { lcAxios, isAxiosError };
@@ -0,0 +1,330 @@
1
+ "use strict";
2
+ /**
3
+ * Fetch-based axios-compatible client (minimal surface used by apps).
4
+ * Zero extra npm deps: uses global fetch, URL, Headers, AbortController.
5
+ *
6
+ * `decompress` on the request config is accepted for axios API compatibility only;
7
+ * it is ignored at runtime — fetch already returns decompressed response bodies for typical reads.
8
+ */
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.isAxiosError = exports.lcAxios = exports.createAxiosInstance = exports.axiosRetry = exports.exponentialDelay = void 0;
20
+ function isAxiosError(payload) {
21
+ return payload && payload.isAxiosError === true;
22
+ }
23
+ exports.isAxiosError = isAxiosError;
24
+ function mergeDeep(base, patch) {
25
+ if (patch === undefined || patch === null)
26
+ return base;
27
+ if (base === undefined || base === null) {
28
+ if (typeof patch === 'object' && patch !== null && !Array.isArray(patch)) {
29
+ return mergeDeep({}, patch);
30
+ }
31
+ return patch;
32
+ }
33
+ if (Array.isArray(patch))
34
+ return patch.slice();
35
+ const out = Object.assign({}, base);
36
+ for (const k of Object.keys(patch)) {
37
+ const pv = patch[k];
38
+ const bv = base[k];
39
+ if (pv && typeof pv === 'object' && !Array.isArray(pv) && pv.constructor === Object && bv && typeof bv === 'object' && !Array.isArray(bv)) {
40
+ out[k] = mergeDeep(bv, pv);
41
+ }
42
+ else if (pv !== undefined) {
43
+ out[k] = pv;
44
+ }
45
+ }
46
+ return out;
47
+ }
48
+ /** Like axios mergeConfig: concat transformRequest / transformResponse arrays */
49
+ function mergeRequestConfig(defaults, config) {
50
+ const m = mergeDeep(mergeDeep({}, defaults), config);
51
+ const dt = defaults.transformRequest;
52
+ const ct = config.transformRequest;
53
+ if (dt && ct) {
54
+ m.transformRequest = [].concat(Array.isArray(dt) ? dt : [dt]).concat(Array.isArray(ct) ? ct : [ct]);
55
+ }
56
+ const dtr = defaults.transformResponse;
57
+ const ctr = config.transformResponse;
58
+ if (dtr && ctr) {
59
+ m.transformResponse = [].concat(Array.isArray(dtr) ? dtr : [dtr]).concat(Array.isArray(ctr) ? ctr : [ctr]);
60
+ }
61
+ return m;
62
+ }
63
+ function buildURL(baseURL, url, params) {
64
+ const path = joinURL(baseURL, url || '');
65
+ if (!params || !Object.keys(params).length)
66
+ return path;
67
+ let u;
68
+ if (/^https?:\/\//i.test(path)) {
69
+ u = new URL(path);
70
+ }
71
+ else if (typeof window !== 'undefined' && window.location) {
72
+ u = new URL(path, window.location.href);
73
+ }
74
+ else {
75
+ u = new URL(path, 'http://127.0.0.1');
76
+ }
77
+ for (const [k, v] of Object.entries(params)) {
78
+ if (v === undefined || v === null)
79
+ continue;
80
+ if (Array.isArray(v))
81
+ v.forEach((item) => u.searchParams.append(k, String(item)));
82
+ else
83
+ u.searchParams.set(k, String(v));
84
+ }
85
+ if (/^https?:\/\//i.test(path))
86
+ return u.toString();
87
+ return `${u.pathname}${u.search}${u.hash}`;
88
+ }
89
+ function joinURL(baseURL, url) {
90
+ if (!baseURL)
91
+ return url;
92
+ if (!url)
93
+ return baseURL.replace(/\/$/, '');
94
+ const b = baseURL.replace(/\/$/, '');
95
+ const p = url.startsWith('/') ? url : `/${url}`;
96
+ return `${b}${p}`;
97
+ }
98
+ function flattenHeaders(h, method) {
99
+ const out = {};
100
+ if (!h)
101
+ return out;
102
+ const common = h.common || {};
103
+ const byMethod = (h[method.toLowerCase()] || h[method] || {});
104
+ for (const s of [common, byMethod, h]) {
105
+ if (!s || typeof s !== 'object')
106
+ continue;
107
+ for (const [k, v] of Object.entries(s)) {
108
+ if (['common', 'get', 'post', 'put', 'patch', 'delete', 'head'].includes(k))
109
+ continue;
110
+ if (v != null && v !== '')
111
+ out[k] = String(v);
112
+ }
113
+ }
114
+ return out;
115
+ }
116
+ function applyTransformRequest(fns, data, headers) {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ if (!fns)
119
+ return data;
120
+ const list = Array.isArray(fns) ? fns : [fns];
121
+ let d = data;
122
+ for (const fn of list) {
123
+ d = yield Promise.resolve(fn(d, headers));
124
+ }
125
+ return d;
126
+ });
127
+ }
128
+ function applyTransformResponse(fns, data, headers) {
129
+ if (!fns)
130
+ return data;
131
+ const list = Array.isArray(fns) ? fns : [fns];
132
+ let d = data;
133
+ for (const fn of list) {
134
+ d = fn(d, headers);
135
+ }
136
+ return d;
137
+ }
138
+ function headersFromFetch(h) {
139
+ const o = {};
140
+ h.forEach((v, k) => {
141
+ o[k] = v;
142
+ });
143
+ return o;
144
+ }
145
+ function exponentialDelay(retryNumber = 0) {
146
+ const delay = Math.pow(2, retryNumber) * 1000;
147
+ const randomSum = delay * 0.2 * Math.random() * 2 - 1;
148
+ return delay + randomSum;
149
+ }
150
+ exports.exponentialDelay = exponentialDelay;
151
+ function axiosRetry(instance, options = {}) {
152
+ var _a, _b, _c;
153
+ const retries = (_a = options.retries) !== null && _a !== void 0 ? _a : 3;
154
+ const retryDelay = (_b = options.retryDelay) !== null && _b !== void 0 ? _b : exponentialDelay;
155
+ const retryCondition = (_c = options.retryCondition) !== null && _c !== void 0 ? _c : (() => false);
156
+ const original = instance.request.bind(instance);
157
+ instance.request = function axiosRetryRequest(req) {
158
+ return __awaiter(this, void 0, void 0, function* () {
159
+ let attempt = 0;
160
+ while (true) {
161
+ try {
162
+ return yield original(req);
163
+ }
164
+ catch (err) {
165
+ if (attempt >= retries || !retryCondition(err))
166
+ throw err;
167
+ yield new Promise((r) => setTimeout(r, retryDelay(attempt)));
168
+ attempt++;
169
+ }
170
+ }
171
+ });
172
+ };
173
+ return instance;
174
+ }
175
+ exports.axiosRetry = axiosRetry;
176
+ const defaultValidateStatus = (status) => status >= 200 && status < 300;
177
+ function getDefaultDefaults() {
178
+ return {
179
+ headers: { common: {} },
180
+ transformRequest: [
181
+ function defaultTransformRequest(data, headers) {
182
+ var _a, _b;
183
+ if (data == null)
184
+ return data;
185
+ if (typeof data === 'string')
186
+ return data;
187
+ if (typeof FormData !== 'undefined' && data instanceof FormData)
188
+ return data;
189
+ if (typeof Blob !== 'undefined' && data instanceof Blob)
190
+ return data;
191
+ if (typeof Buffer !== 'undefined' && ((_b = (_a = Buffer).isBuffer) === null || _b === void 0 ? void 0 : _b.call(_a, data)))
192
+ return data;
193
+ // JSON.stringify on Uint8Array produces {"0":byte,...} — never do that; binary must pass through
194
+ if (typeof ArrayBuffer !== 'undefined' && data instanceof ArrayBuffer)
195
+ return data;
196
+ if (typeof Uint8Array !== 'undefined' && data instanceof Uint8Array)
197
+ return data;
198
+ if (typeof data === 'object') {
199
+ if (!headers['Content-Type'] && !headers['content-type']) {
200
+ headers['Content-Type'] = 'application/json';
201
+ }
202
+ return JSON.stringify(data);
203
+ }
204
+ return data;
205
+ },
206
+ ],
207
+ transformResponse: [
208
+ function defaultTransformResponse(data) {
209
+ return data;
210
+ },
211
+ ],
212
+ };
213
+ }
214
+ function createAxiosInstance(initialDefaults) {
215
+ const defaults = initialDefaults
216
+ ? mergeRequestConfig(mergeDeep({}, getDefaultDefaults()), initialDefaults)
217
+ : mergeDeep({}, getDefaultDefaults());
218
+ function dispatchRequest(config) {
219
+ return __awaiter(this, void 0, void 0, function* () {
220
+ const merged = mergeRequestConfig(defaults, config);
221
+ const method = (merged.method || 'get').toUpperCase();
222
+ const url = buildURL(merged.baseURL, merged.url, merged.params);
223
+ const headers = Object.assign({}, flattenHeaders(merged.headers, method));
224
+ let data = merged.data;
225
+ data = yield applyTransformRequest(merged.transformRequest, data, headers);
226
+ const validateStatus = merged.validateStatus || defaultValidateStatus;
227
+ const controller = new AbortController();
228
+ const t = merged.timeout;
229
+ let timer;
230
+ if (t != null && t > 0) {
231
+ timer = setTimeout(() => controller.abort(), t);
232
+ }
233
+ const init = {
234
+ method,
235
+ headers,
236
+ signal: controller.signal,
237
+ };
238
+ if (merged.withCredentials) {
239
+ init.credentials = 'include';
240
+ }
241
+ if (method !== 'GET' && method !== 'HEAD' && data !== undefined) {
242
+ init.body = data;
243
+ }
244
+ let res;
245
+ try {
246
+ res = yield fetch(url, init);
247
+ }
248
+ catch (e) {
249
+ if (timer)
250
+ clearTimeout(timer);
251
+ const err = new Error((e === null || e === void 0 ? void 0 : e.name) === 'AbortError' ? 'timeout of ' + t + 'ms exceeded' : 'Network Error');
252
+ err.isAxiosError = true;
253
+ err.config = merged;
254
+ err.request = { aborted: (e === null || e === void 0 ? void 0 : e.name) === 'AbortError' };
255
+ throw err;
256
+ }
257
+ if (timer)
258
+ clearTimeout(timer);
259
+ const resHeaders = headersFromFetch(res.headers);
260
+ const ct = res.headers.get('content-type') || '';
261
+ const rt = merged.responseType || 'json';
262
+ let parsed;
263
+ if (rt === 'blob') {
264
+ parsed = yield res.blob();
265
+ }
266
+ else if (rt === 'arraybuffer') {
267
+ parsed = yield res.arrayBuffer();
268
+ }
269
+ else if (rt === 'text') {
270
+ parsed = yield res.text();
271
+ }
272
+ else if (ct.includes('application/json')) {
273
+ // Declared JSON: empty body → null; invalid JSON → raw string (axios-like)
274
+ const text = yield res.text();
275
+ try {
276
+ parsed = text ? JSON.parse(text) : null;
277
+ }
278
+ catch (_a) {
279
+ parsed = text;
280
+ }
281
+ }
282
+ else {
283
+ // Other content-types: still try JSON.parse so mislabeled JSON works; empty body → '' (not null)
284
+ const text = yield res.text();
285
+ try {
286
+ parsed = text ? JSON.parse(text) : text;
287
+ }
288
+ catch (_b) {
289
+ parsed = text;
290
+ }
291
+ }
292
+ parsed = applyTransformResponse(merged.transformResponse, parsed, resHeaders);
293
+ const response = {
294
+ data: parsed,
295
+ status: res.status,
296
+ statusText: res.statusText,
297
+ headers: resHeaders,
298
+ config: merged,
299
+ };
300
+ if (!validateStatus(res.status)) {
301
+ const err = new Error('Request failed with status code ' + res.status);
302
+ err.isAxiosError = true;
303
+ err.config = merged;
304
+ err.response = response;
305
+ throw err;
306
+ }
307
+ return response;
308
+ });
309
+ }
310
+ const instance = function request(configOrUrl, maybe) {
311
+ if (typeof configOrUrl === 'string') {
312
+ return instance.request(Object.assign(Object.assign({}, (maybe || {})), { url: configOrUrl }));
313
+ }
314
+ return instance.request(configOrUrl);
315
+ };
316
+ instance.defaults = defaults;
317
+ instance.request = (c) => dispatchRequest(mergeRequestConfig(defaults, c));
318
+ instance.get = (url, c) => instance.request(Object.assign(Object.assign({}, (c || {})), { url, method: 'GET' }));
319
+ instance.delete = (url, c) => instance.request(Object.assign(Object.assign({}, (c || {})), { url, method: 'DELETE' }));
320
+ instance.head = (url, c) => instance.request(Object.assign(Object.assign({}, (c || {})), { url, method: 'HEAD' }));
321
+ instance.post = (url, data, c) => instance.request(Object.assign(Object.assign({}, (c || {})), { url, method: 'POST', data }));
322
+ instance.put = (url, data, c) => instance.request(Object.assign(Object.assign({}, (c || {})), { url, method: 'PUT', data }));
323
+ instance.patch = (url, data, c) => instance.request(Object.assign(Object.assign({}, (c || {})), { url, method: 'PATCH', data }));
324
+ instance.create = (cfg) => createAxiosInstance(mergeRequestConfig(mergeDeep({}, defaults), cfg || {}));
325
+ return instance;
326
+ }
327
+ exports.createAxiosInstance = createAxiosInstance;
328
+ const lcAxios = createAxiosInstance();
329
+ exports.lcAxios = lcAxios;
330
+ exports.default = lcAxios;
package/dist/types.d.ts CHANGED
@@ -126,7 +126,7 @@ interface SkuI {
126
126
  tagType?: tagTypeE;
127
127
  directDelivery?: boolean;
128
128
  care?: CareI;
129
- BRANDHASH?: string;
129
+ brandhash?: string;
130
130
  ATTRIBUTES?: object;
131
131
  IMAGES?: Array<ImageI>;
132
132
  SIZES?: unknown;
package/package.json CHANGED
@@ -1,35 +1,44 @@
1
1
  {
2
- "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.152",
4
- "description": "Core functions for LatestCollections applications",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc -p tsconfig.json",
9
- "build:watch": "tsc -p tsconfig.json --watch",
10
- "test": "vitest run",
11
- "test:watch": "vitest",
12
- "dev": "concurrently \"npm:build:watch\" \"npm:test:watch\""
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+ssh://git@gitlab.com/softwearconnect/latestcollectioncore.git"
17
- },
18
- "author": "Jeroen de Vries",
19
- "license": "ISC",
20
- "bugs": {
21
- "url": "https://gitlab.com/softwearconnect/latestcollectioncore/issues"
22
- },
23
- "homepage": "https://gitlab.com/softwearconnect/latestcollectioncore#readme",
24
- "devDependencies": {
25
- "@types/node": "^18.11.17",
26
- "concurrently": "^9.2.1",
27
- "typescript": "^4.9.4",
28
- "vitest": "^1.0.0"
29
- },
2
+ "name": "@softwear/latestcollectioncore",
3
+ "version": "1.0.158",
4
+ "description": "Core functions for LatestCollections applications",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./cryptography": {
13
+ "types": "./dist/cryptography.d.ts",
14
+ "default": "./dist/cryptography.js"
15
+ }
16
+ },
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.json",
19
+ "build:watch": "tsc -p tsconfig.json --watch",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest",
22
+ "dev": "concurrently \"npm:build:watch\" \"npm:test:watch\""
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+ssh://git@gitlab.com/softwearconnect/latestcollectioncore.git"
27
+ },
28
+ "author": "Jeroen de Vries",
29
+ "license": "ISC",
30
+ "bugs": {
31
+ "url": "https://gitlab.com/softwearconnect/latestcollectioncore/issues"
32
+ },
33
+ "homepage": "https://gitlab.com/softwearconnect/latestcollectioncore#readme",
34
+ "devDependencies": {
35
+ "@types/node": "^18.11.17",
36
+ "concurrently": "^9.2.1",
37
+ "typescript": "^4.9.4",
38
+ "vitest": "^1.0.0"
39
+ },
30
40
  "dependencies": {
31
- "buffer": "^6.0.3",
32
41
  "date-fns": "^2.29.3",
33
- "filtrex": "^2.2.3"
34
- }
35
- }
42
+ "filtrex": "^2.2.3"
43
+ }
44
+ }
@@ -47,7 +47,7 @@ export default function (brands: Array<BrandSettingI>, strategy: mappingStrategy
47
47
  })
48
48
  if (strategy == 'clean')
49
49
  return function (sku: SkuI): SkuI {
50
- const brand = sku.BRANDHASH || hashBrand(sku.brand)
50
+ const brand = sku.brandhash || hashBrand(sku.brand)
51
51
  const mapping = indexedByBrandPropertyMapping[brand]
52
52
  mappingPairs.forEach((pair) => {
53
53
  const from = evaluateFromExpr(sku, pair.from) || ''
@@ -59,7 +59,7 @@ export default function (brands: Array<BrandSettingI>, strategy: mappingStrategy
59
59
  }
60
60
  if (strategy == 'markMissingMapping')
61
61
  return function (sku: SkuI): SkuI {
62
- const brand = sku.BRANDHASH || hashBrand(sku.brand)
62
+ const brand = sku.brandhash || hashBrand(sku.brand)
63
63
  const mapping = indexedByBrandPropertyMapping[brand]
64
64
  mappingPairs.forEach((pair) => {
65
65
  const from = evaluateFromExpr(sku, pair.from) || ''
@@ -72,7 +72,7 @@ export default function (brands: Array<BrandSettingI>, strategy: mappingStrategy
72
72
  return sku
73
73
  }
74
74
  return function (sku: SkuI): SkuI {
75
- const brand = sku.BRANDHASH || hashBrand(sku.brand)
75
+ const brand = sku.brandhash || hashBrand(sku.brand)
76
76
  const mapping = indexedByBrandPropertyMapping[brand]
77
77
  mappingPairs.forEach((pair) => {
78
78
  if (sku[pair.to]) return // Do not replace sku-level-user-supplied values