@liquidcommercedev/rmn-sdk 1.5.0-beta.19 → 1.5.0-beta.20
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/index.cjs
CHANGED
|
@@ -6133,6 +6133,7 @@ function getEventTypeFromRawEvent(event) {
|
|
|
6133
6133
|
// Configuration object with target field names
|
|
6134
6134
|
const extractorConfig = {
|
|
6135
6135
|
ids: [
|
|
6136
|
+
// Ps: The function handles all the variations of keywords that end with "id" or "ids"
|
|
6136
6137
|
// Universal product identifiers
|
|
6137
6138
|
'gtin',
|
|
6138
6139
|
'gtin8',
|
|
@@ -6157,7 +6158,6 @@ const extractorConfig = {
|
|
|
6157
6158
|
'item_number',
|
|
6158
6159
|
'article_number',
|
|
6159
6160
|
'reference',
|
|
6160
|
-
'groupingId',
|
|
6161
6161
|
],
|
|
6162
6162
|
price: [
|
|
6163
6163
|
'price',
|
|
@@ -6243,6 +6243,39 @@ function extractDeepValues(data, target, options = {}) {
|
|
|
6243
6243
|
return undefined;
|
|
6244
6244
|
return onlyFirst ? values[0] : values;
|
|
6245
6245
|
}
|
|
6246
|
+
/**
|
|
6247
|
+
* Cleans and normalizes an array of product IDs by:
|
|
6248
|
+
* 1. Converting all IDs to strings
|
|
6249
|
+
* 2. Trimming whitespace
|
|
6250
|
+
* 3. Removing leading zeros while preserving single "0"
|
|
6251
|
+
* 4. Filtering out empty/invalid values
|
|
6252
|
+
*
|
|
6253
|
+
* @param productIds - Array of product IDs that can be either strings or numbers
|
|
6254
|
+
* @returns Array of cleaned string IDs
|
|
6255
|
+
*
|
|
6256
|
+
* @example
|
|
6257
|
+
* cleanProductIds(["001", " 123 ", 456, "0"]) // ["1", "123", "456", "0"]
|
|
6258
|
+
*/
|
|
6259
|
+
function cleanProductIds(productIds) {
|
|
6260
|
+
if (!Array.isArray(productIds)) {
|
|
6261
|
+
return [];
|
|
6262
|
+
}
|
|
6263
|
+
return productIds
|
|
6264
|
+
.map((id) => {
|
|
6265
|
+
// Guard against null/undefined
|
|
6266
|
+
if (id == null) {
|
|
6267
|
+
return '';
|
|
6268
|
+
}
|
|
6269
|
+
// Convert to string and trim
|
|
6270
|
+
const stringId = String(id).trim();
|
|
6271
|
+
if (!stringId) {
|
|
6272
|
+
return '';
|
|
6273
|
+
}
|
|
6274
|
+
// Remove leading zeros while preserving single "0"
|
|
6275
|
+
return stringId === '0' ? '0' : stringId.replace(/^0+/, '');
|
|
6276
|
+
})
|
|
6277
|
+
.filter((id) => id !== ''); // Remove empty strings
|
|
6278
|
+
}
|
|
6246
6279
|
|
|
6247
6280
|
class SingletonManager {
|
|
6248
6281
|
/**
|
|
@@ -15947,7 +15980,7 @@ class LocalStorageService {
|
|
|
15947
15980
|
LocalStorageService.localStorageKeyPrefix = 'lc_rmn';
|
|
15948
15981
|
LocalStorageService.localStorageKey = '';
|
|
15949
15982
|
LocalStorageService.spotExpirationTime = 1000 * 60 * 60 * 24 * 7; // 7 days
|
|
15950
|
-
LocalStorageService.encryptData =
|
|
15983
|
+
LocalStorageService.encryptData = true;
|
|
15951
15984
|
|
|
15952
15985
|
/**
|
|
15953
15986
|
* PubsubService class
|
|
@@ -19256,11 +19289,11 @@ class MonitorService {
|
|
|
19256
19289
|
var _a, _b;
|
|
19257
19290
|
if (!spots)
|
|
19258
19291
|
return;
|
|
19259
|
-
const eventProductIds = new Set(eventData.productIds
|
|
19292
|
+
const eventProductIds = new Set(cleanProductIds(eventData.productIds));
|
|
19260
19293
|
for (const spot of Object.values(spots)) {
|
|
19261
19294
|
if (!spot.productIds.length)
|
|
19262
19295
|
continue;
|
|
19263
|
-
const hasCommonProductIds = spot.productIds.find((productId) => eventProductIds.has(
|
|
19296
|
+
const hasCommonProductIds = cleanProductIds(spot.productIds).find((productId) => eventProductIds.has(productId));
|
|
19264
19297
|
if (!hasCommonProductIds || !Object.values(exports.RMN_SPOT_EVENT).includes(eventData.event)) {
|
|
19265
19298
|
continue;
|
|
19266
19299
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -6131,6 +6131,7 @@ function getEventTypeFromRawEvent(event) {
|
|
|
6131
6131
|
// Configuration object with target field names
|
|
6132
6132
|
const extractorConfig = {
|
|
6133
6133
|
ids: [
|
|
6134
|
+
// Ps: The function handles all the variations of keywords that end with "id" or "ids"
|
|
6134
6135
|
// Universal product identifiers
|
|
6135
6136
|
'gtin',
|
|
6136
6137
|
'gtin8',
|
|
@@ -6155,7 +6156,6 @@ const extractorConfig = {
|
|
|
6155
6156
|
'item_number',
|
|
6156
6157
|
'article_number',
|
|
6157
6158
|
'reference',
|
|
6158
|
-
'groupingId',
|
|
6159
6159
|
],
|
|
6160
6160
|
price: [
|
|
6161
6161
|
'price',
|
|
@@ -6241,6 +6241,39 @@ function extractDeepValues(data, target, options = {}) {
|
|
|
6241
6241
|
return undefined;
|
|
6242
6242
|
return onlyFirst ? values[0] : values;
|
|
6243
6243
|
}
|
|
6244
|
+
/**
|
|
6245
|
+
* Cleans and normalizes an array of product IDs by:
|
|
6246
|
+
* 1. Converting all IDs to strings
|
|
6247
|
+
* 2. Trimming whitespace
|
|
6248
|
+
* 3. Removing leading zeros while preserving single "0"
|
|
6249
|
+
* 4. Filtering out empty/invalid values
|
|
6250
|
+
*
|
|
6251
|
+
* @param productIds - Array of product IDs that can be either strings or numbers
|
|
6252
|
+
* @returns Array of cleaned string IDs
|
|
6253
|
+
*
|
|
6254
|
+
* @example
|
|
6255
|
+
* cleanProductIds(["001", " 123 ", 456, "0"]) // ["1", "123", "456", "0"]
|
|
6256
|
+
*/
|
|
6257
|
+
function cleanProductIds(productIds) {
|
|
6258
|
+
if (!Array.isArray(productIds)) {
|
|
6259
|
+
return [];
|
|
6260
|
+
}
|
|
6261
|
+
return productIds
|
|
6262
|
+
.map((id) => {
|
|
6263
|
+
// Guard against null/undefined
|
|
6264
|
+
if (id == null) {
|
|
6265
|
+
return '';
|
|
6266
|
+
}
|
|
6267
|
+
// Convert to string and trim
|
|
6268
|
+
const stringId = String(id).trim();
|
|
6269
|
+
if (!stringId) {
|
|
6270
|
+
return '';
|
|
6271
|
+
}
|
|
6272
|
+
// Remove leading zeros while preserving single "0"
|
|
6273
|
+
return stringId === '0' ? '0' : stringId.replace(/^0+/, '');
|
|
6274
|
+
})
|
|
6275
|
+
.filter((id) => id !== ''); // Remove empty strings
|
|
6276
|
+
}
|
|
6244
6277
|
|
|
6245
6278
|
class SingletonManager {
|
|
6246
6279
|
/**
|
|
@@ -15945,7 +15978,7 @@ class LocalStorageService {
|
|
|
15945
15978
|
LocalStorageService.localStorageKeyPrefix = 'lc_rmn';
|
|
15946
15979
|
LocalStorageService.localStorageKey = '';
|
|
15947
15980
|
LocalStorageService.spotExpirationTime = 1000 * 60 * 60 * 24 * 7; // 7 days
|
|
15948
|
-
LocalStorageService.encryptData =
|
|
15981
|
+
LocalStorageService.encryptData = true;
|
|
15949
15982
|
|
|
15950
15983
|
/**
|
|
15951
15984
|
* PubsubService class
|
|
@@ -19254,11 +19287,11 @@ class MonitorService {
|
|
|
19254
19287
|
var _a, _b;
|
|
19255
19288
|
if (!spots)
|
|
19256
19289
|
return;
|
|
19257
|
-
const eventProductIds = new Set(eventData.productIds
|
|
19290
|
+
const eventProductIds = new Set(cleanProductIds(eventData.productIds));
|
|
19258
19291
|
for (const spot of Object.values(spots)) {
|
|
19259
19292
|
if (!spot.productIds.length)
|
|
19260
19293
|
continue;
|
|
19261
|
-
const hasCommonProductIds = spot.productIds.find((productId) => eventProductIds.has(
|
|
19294
|
+
const hasCommonProductIds = cleanProductIds(spot.productIds).find((productId) => eventProductIds.has(productId));
|
|
19262
19295
|
if (!hasCommonProductIds || !Object.values(RMN_SPOT_EVENT).includes(eventData.event)) {
|
|
19263
19296
|
continue;
|
|
19264
19297
|
}
|
|
@@ -11,4 +11,18 @@ export declare function extractDeepValues(data: unknown, target: ExtractorTarget
|
|
|
11
11
|
onlyFirst?: boolean;
|
|
12
12
|
shouldIncludeZero?: boolean;
|
|
13
13
|
}): ExtractedValue[] | ExtractedValue | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Cleans and normalizes an array of product IDs by:
|
|
16
|
+
* 1. Converting all IDs to strings
|
|
17
|
+
* 2. Trimming whitespace
|
|
18
|
+
* 3. Removing leading zeros while preserving single "0"
|
|
19
|
+
* 4. Filtering out empty/invalid values
|
|
20
|
+
*
|
|
21
|
+
* @param productIds - Array of product IDs that can be either strings or numbers
|
|
22
|
+
* @returns Array of cleaned string IDs
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* cleanProductIds(["001", " 123 ", 456, "0"]) // ["1", "123", "456", "0"]
|
|
26
|
+
*/
|
|
27
|
+
export declare function cleanProductIds(productIds: Array<string | number>): string[];
|
|
14
28
|
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@liquidcommercedev/rmn-sdk",
|
|
3
3
|
"description": "LiquidCommerce RMN SDK",
|
|
4
4
|
"author": "LiquidCommerce Tech",
|
|
5
|
-
"version": "1.5.0-beta.
|
|
5
|
+
"version": "1.5.0-beta.20",
|
|
6
6
|
"homepage": "https://docs.liquidcommerce.co/rmn-sdk",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.esm.js",
|