@liquidcommercedev/rmn-sdk 1.5.0-beta.16 → 1.5.0-beta.18
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +221 -111
- package/dist/index.esm.js +221 -111
- package/dist/types/common/helpers/extract-deep.helper.d.ts +14 -0
- package/dist/types/common/helpers/index.d.ts +1 -0
- package/dist/types/common/helpers/utils.helper.d.ts +13 -16
- package/dist/types/modules/monitor/monitor.interface.d.ts +1 -0
- package/dist/types/modules/selection/selection.interface.d.ts +7 -1
- package/dist/types/modules/selection/selection.service.d.ts +1 -0
- package/dist/types/rmn-client.d.ts +1 -0
- package/dist/types/rmn-client.helper.d.ts +1 -0
- package/package.json +1 -1
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
package/dist/index.esm.js
CHANGED
@@ -6128,6 +6128,120 @@ function getEventTypeFromRawEvent(event) {
|
|
6128
6128
|
return null;
|
6129
6129
|
}
|
6130
6130
|
|
6131
|
+
// Configuration object with target field names
|
6132
|
+
const extractorConfig = {
|
6133
|
+
ids: [
|
6134
|
+
// Universal product identifiers
|
6135
|
+
'gtin',
|
6136
|
+
'gtin8',
|
6137
|
+
'gtin12',
|
6138
|
+
'gtin13',
|
6139
|
+
'gtin14',
|
6140
|
+
'mpn',
|
6141
|
+
'sku',
|
6142
|
+
'upc',
|
6143
|
+
'ean',
|
6144
|
+
'isbn',
|
6145
|
+
'isbn10',
|
6146
|
+
'isbn13',
|
6147
|
+
'asin',
|
6148
|
+
// Product codes and references
|
6149
|
+
'coupon',
|
6150
|
+
'barcode',
|
6151
|
+
'product_code',
|
6152
|
+
'part_number',
|
6153
|
+
'model_number',
|
6154
|
+
'item_variant',
|
6155
|
+
'item_number',
|
6156
|
+
'article_number',
|
6157
|
+
'reference',
|
6158
|
+
'groupingId',
|
6159
|
+
],
|
6160
|
+
price: [
|
6161
|
+
'price',
|
6162
|
+
'unitPrice',
|
6163
|
+
'cost',
|
6164
|
+
'current_price',
|
6165
|
+
'sale_price',
|
6166
|
+
'price_value',
|
6167
|
+
'sale_price_value',
|
6168
|
+
'regular_price',
|
6169
|
+
'discount_price',
|
6170
|
+
'unit_price',
|
6171
|
+
'original_price',
|
6172
|
+
'final_price',
|
6173
|
+
'retail_price',
|
6174
|
+
],
|
6175
|
+
};
|
6176
|
+
/**
|
6177
|
+
* Extracts deep values from an object based on specified target type
|
6178
|
+
* @param data - The source data object to extract values from
|
6179
|
+
* @param target - The type of values to extract ('ids' or 'price')
|
6180
|
+
* @param options - Optional configuration for the extraction process
|
6181
|
+
* @returns Array of extracted values or a single value if onlyFirst is true
|
6182
|
+
*/
|
6183
|
+
function extractDeepValues(data, target, options = {}) {
|
6184
|
+
const {
|
6185
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
6186
|
+
onlyFirst = false, shouldIncludeZero = false, } = options;
|
6187
|
+
const values = [];
|
6188
|
+
const targetProperties = new Set(extractorConfig[target].map((name) => name.toLowerCase()));
|
6189
|
+
/**
|
6190
|
+
* Checks if a property name matches the target criteria
|
6191
|
+
*/
|
6192
|
+
const isTargetField = (key) => {
|
6193
|
+
const normalizedKey = key.toLowerCase();
|
6194
|
+
const hasTarget = targetProperties.has(normalizedKey);
|
6195
|
+
if (target === 'ids') {
|
6196
|
+
return normalizedKey.endsWith('id') || normalizedKey.endsWith('ids') || hasTarget;
|
6197
|
+
}
|
6198
|
+
return hasTarget;
|
6199
|
+
};
|
6200
|
+
/**
|
6201
|
+
* Validates and normalizes extracted values
|
6202
|
+
*/
|
6203
|
+
const validateValue = (value) => {
|
6204
|
+
if (typeof value === 'string') {
|
6205
|
+
return value.trim().length > 0;
|
6206
|
+
}
|
6207
|
+
if (typeof value === 'number') {
|
6208
|
+
return !isNaN(value) && (shouldIncludeZero || value !== 0);
|
6209
|
+
}
|
6210
|
+
return false;
|
6211
|
+
};
|
6212
|
+
/**
|
6213
|
+
* Processes a value and extracts matching fields
|
6214
|
+
*/
|
6215
|
+
const processValue = (value, currentKey) => {
|
6216
|
+
// Early exit conditions
|
6217
|
+
if (value == null || (onlyFirst && values.length > 0))
|
6218
|
+
return;
|
6219
|
+
// Process current value if it matches target criteria
|
6220
|
+
if (currentKey && isTargetField(currentKey)) {
|
6221
|
+
if (Array.isArray(value)) {
|
6222
|
+
const validValues = value.filter(validateValue);
|
6223
|
+
values.push(...validValues);
|
6224
|
+
}
|
6225
|
+
else if (validateValue(value)) {
|
6226
|
+
values.push(value);
|
6227
|
+
}
|
6228
|
+
return;
|
6229
|
+
}
|
6230
|
+
// Recursive processing for nested structures
|
6231
|
+
if (Array.isArray(value)) {
|
6232
|
+
value.forEach((item) => processValue(item));
|
6233
|
+
}
|
6234
|
+
else if (typeof value === 'object') {
|
6235
|
+
Object.entries(value).forEach(([key, val]) => processValue(val, key));
|
6236
|
+
}
|
6237
|
+
};
|
6238
|
+
processValue(data);
|
6239
|
+
// Return based on options
|
6240
|
+
if (values.length === 0)
|
6241
|
+
return undefined;
|
6242
|
+
return onlyFirst ? values[0] : values;
|
6243
|
+
}
|
6244
|
+
|
6131
6245
|
class SingletonManager {
|
6132
6246
|
/**
|
6133
6247
|
* Retrieves an instance of the specified class using the provided instance creator function.
|
@@ -6293,97 +6407,6 @@ class ObjectHelper {
|
|
6293
6407
|
}
|
6294
6408
|
}
|
6295
6409
|
|
6296
|
-
/**
|
6297
|
-
* Recursively extracts ID values from a nested data structure.
|
6298
|
-
* Searches for specified property names and collects their primitive values (strings/numbers).
|
6299
|
-
* Captures properties ending with 'id' and any additional specified property names.
|
6300
|
-
*
|
6301
|
-
* @param data - The data structure to search through (can be nested objects/arrays)
|
6302
|
-
* @param propertyNames - Array of additional property names to look for (optional)
|
6303
|
-
* @returns Array of extracted ID values (strings/numbers only)
|
6304
|
-
*
|
6305
|
-
* @example
|
6306
|
-
* const data = {
|
6307
|
-
* id: [1, 2, 3],
|
6308
|
-
* nested: { id: 'abc', userId: 123 },
|
6309
|
-
* items: [{ id: 456, productId: '789', sku: 'ABC123' }]
|
6310
|
-
* };
|
6311
|
-
* extractDeepIds(data); // Returns [1, 2, 3, 'abc', 123, 456, '789', 'ABC123']
|
6312
|
-
*/
|
6313
|
-
function extractDeepIds(data, propertyNames) {
|
6314
|
-
const ids = [];
|
6315
|
-
const defaultPropertyNames = [
|
6316
|
-
// Universal product identifiers
|
6317
|
-
'gtin', // Global Trade Item Number
|
6318
|
-
'gtin8', // 8-digit GTIN
|
6319
|
-
'gtin12', // 12-digit GTIN (UPC)
|
6320
|
-
'gtin13', // 13-digit GTIN (EAN)
|
6321
|
-
'gtin14', // 14-digit GTIN
|
6322
|
-
'mpn', // Manufacturer Part Number
|
6323
|
-
'sku', // Stock Keeping Unit
|
6324
|
-
'upc', // Universal Product Code
|
6325
|
-
'ean', // European Article Number
|
6326
|
-
'isbn', // International Standard Book Number
|
6327
|
-
'isbn10', // 10-digit ISBN
|
6328
|
-
'isbn13', // 13-digit ISBN
|
6329
|
-
'asin', // Amazon Standard Identification Number
|
6330
|
-
// Product codes and references
|
6331
|
-
'coupon',
|
6332
|
-
'barcode',
|
6333
|
-
'product_code',
|
6334
|
-
'part_number',
|
6335
|
-
'model_number',
|
6336
|
-
'item_variant',
|
6337
|
-
'item_number',
|
6338
|
-
'article_number',
|
6339
|
-
'reference',
|
6340
|
-
'groupingId',
|
6341
|
-
];
|
6342
|
-
// Convert property names to lowercase for consistent comparison
|
6343
|
-
const additionalProperties = new Set((defaultPropertyNames).map((name) => name.toLowerCase()));
|
6344
|
-
/**
|
6345
|
-
* Checks if a property name is an ID field
|
6346
|
-
* @param key - The property name to check
|
6347
|
-
* @returns boolean indicating if the key is an ID field
|
6348
|
-
*/
|
6349
|
-
const isIdField = (key) => {
|
6350
|
-
const lowercaseKey = key.toLowerCase();
|
6351
|
-
return lowercaseKey.endsWith('id') || additionalProperties.has(lowercaseKey);
|
6352
|
-
};
|
6353
|
-
/**
|
6354
|
-
* Processes a value and extracts IDs if it matches criteria
|
6355
|
-
* @param value - The value to process
|
6356
|
-
* @param currentKey - The property name of the current value
|
6357
|
-
*/
|
6358
|
-
const processValue = (value, currentKey) => {
|
6359
|
-
// Early exit for null/undefined values
|
6360
|
-
if (value == null)
|
6361
|
-
return;
|
6362
|
-
// If current key matches our target properties
|
6363
|
-
if (currentKey && isIdField(currentKey)) {
|
6364
|
-
if (Array.isArray(value)) {
|
6365
|
-
// Filter and push valid array values in one pass
|
6366
|
-
ids.push(...value.filter((item) => typeof item === 'string' || typeof item === 'number'));
|
6367
|
-
}
|
6368
|
-
else if (typeof value === 'string' || typeof value === 'number') {
|
6369
|
-
ids.push(value);
|
6370
|
-
}
|
6371
|
-
return; // Stop processing this branch after handling the ID
|
6372
|
-
}
|
6373
|
-
// Recursively process nested structures
|
6374
|
-
if (Array.isArray(value)) {
|
6375
|
-
value.forEach((item) => processValue(item));
|
6376
|
-
}
|
6377
|
-
else if (typeof value === 'object') {
|
6378
|
-
// Process all enumerable properties
|
6379
|
-
for (const [key, val] of Object.entries(value)) {
|
6380
|
-
processValue(val, key);
|
6381
|
-
}
|
6382
|
-
}
|
6383
|
-
};
|
6384
|
-
processValue(data);
|
6385
|
-
return ids;
|
6386
|
-
}
|
6387
6410
|
// Fallback method using fetch if sendBeacon isn't available
|
6388
6411
|
async function fallbackEventFire(url) {
|
6389
6412
|
try {
|
@@ -6409,22 +6432,49 @@ async function fallbackEventFire(url) {
|
|
6409
6432
|
return false;
|
6410
6433
|
}
|
6411
6434
|
}
|
6435
|
+
/**
|
6436
|
+
* Helper function to decode base64 string and parse JSON
|
6437
|
+
*
|
6438
|
+
* @param {string} base64String - The base64 encoded JSON string
|
6439
|
+
* @returns {T | null} - Decoded and parsed object or null if invalid
|
6440
|
+
*/
|
6441
|
+
function decodeBase64Json(base64String) {
|
6442
|
+
try {
|
6443
|
+
return JSON.parse(atob(base64String));
|
6444
|
+
}
|
6445
|
+
catch (_a) {
|
6446
|
+
return null;
|
6447
|
+
}
|
6448
|
+
}
|
6412
6449
|
/**
|
6413
6450
|
* Extracts and decodes a URL from a base64-encoded query parameter.
|
6414
6451
|
*
|
6415
6452
|
* @param {string} url - The URL containing the base64-encoded query parameter.
|
6416
6453
|
* @returns {string | null} - The decoded URL or null if not found or invalid.
|
6454
|
+
* @throws {Error} - If URL is malformed or payload is invalid.
|
6417
6455
|
*/
|
6418
6456
|
function getRedirectUrlFromPayload(url) {
|
6457
|
+
if (!url)
|
6458
|
+
return null;
|
6419
6459
|
try {
|
6420
|
-
|
6421
|
-
|
6460
|
+
// Extract initial payload
|
6461
|
+
const payload = new URL(url).searchParams.get('p');
|
6462
|
+
if (!payload)
|
6422
6463
|
return null;
|
6423
|
-
|
6424
|
-
const
|
6425
|
-
|
6464
|
+
// Decode first layer
|
6465
|
+
const decodedData = decodeBase64Json(payload);
|
6466
|
+
if (!(decodedData === null || decodedData === void 0 ? void 0 : decodedData.u))
|
6467
|
+
return null;
|
6468
|
+
// Extract URL from nested query
|
6469
|
+
const eventPayload = new URLSearchParams(decodedData.u).get('e');
|
6470
|
+
if (!eventPayload)
|
6471
|
+
return null;
|
6472
|
+
// Decode second layer
|
6473
|
+
const eventData = decodeBase64Json(eventPayload);
|
6474
|
+
return (eventData === null || eventData === void 0 ? void 0 : eventData.ur) || null;
|
6426
6475
|
}
|
6427
6476
|
catch (_a) {
|
6477
|
+
console.warn('RmnSdk: Failed to extract redirect URL from payload.');
|
6428
6478
|
return null;
|
6429
6479
|
}
|
6430
6480
|
}
|
@@ -6484,6 +6534,23 @@ function calculateScaleFactor(elementScale) {
|
|
6484
6534
|
// Math.max ensures the value isn't less than minScale
|
6485
6535
|
return Math.max(minScale, Math.min(maxScale, scaleFactor));
|
6486
6536
|
}
|
6537
|
+
/**
|
6538
|
+
* Converts an object to a query string.
|
6539
|
+
*
|
6540
|
+
* @param {Record<string, string|number|undefined|null>} obj - The object to be converted to a query string.
|
6541
|
+
* @returns {string} - The query string.
|
6542
|
+
*/
|
6543
|
+
function objectToQueryParams(obj) {
|
6544
|
+
return Object.entries(obj !== null && obj !== void 0 ? obj : {})
|
6545
|
+
.map(([key, value]) => {
|
6546
|
+
if (value == null) {
|
6547
|
+
return '';
|
6548
|
+
}
|
6549
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
6550
|
+
})
|
6551
|
+
.filter(Boolean)
|
6552
|
+
.join('&');
|
6553
|
+
}
|
6487
6554
|
|
6488
6555
|
class UniqueIdGenerator {
|
6489
6556
|
/**
|
@@ -15781,7 +15848,11 @@ class LocalStorageService {
|
|
15781
15848
|
}
|
15782
15849
|
// ======================== Utility functions ======================== //
|
15783
15850
|
getUserId() {
|
15784
|
-
|
15851
|
+
const key = LocalStorageService.localStorageKey;
|
15852
|
+
if (!key) {
|
15853
|
+
this.setUserId();
|
15854
|
+
}
|
15855
|
+
return key.replace(`${LocalStorageService.localStorageKeyPrefix}_`, '');
|
15785
15856
|
}
|
15786
15857
|
/**
|
15787
15858
|
* Sets the user ID in the local storage.
|
@@ -18652,11 +18723,27 @@ class DataLayerMonitor {
|
|
18652
18723
|
if (!eventName) {
|
18653
18724
|
return null;
|
18654
18725
|
}
|
18655
|
-
const productIds =
|
18656
|
-
|
18726
|
+
const productIds = extractDeepValues(data, 'ids', {
|
18727
|
+
onlyFirst: false,
|
18728
|
+
shouldIncludeZero: true,
|
18729
|
+
});
|
18730
|
+
if (Array.isArray(productIds) && productIds.length === 0) {
|
18731
|
+
return null;
|
18732
|
+
}
|
18733
|
+
const normalizedData = {
|
18657
18734
|
event: eventName,
|
18658
18735
|
productIds,
|
18659
18736
|
};
|
18737
|
+
if (eventName === RMN_SPOT_EVENT.PURCHASE) {
|
18738
|
+
const productPrice = extractDeepValues(data, 'price', {
|
18739
|
+
onlyFirst: true,
|
18740
|
+
shouldIncludeZero: true,
|
18741
|
+
});
|
18742
|
+
if (productPrice) {
|
18743
|
+
normalizedData.productPrice = productPrice;
|
18744
|
+
}
|
18745
|
+
}
|
18746
|
+
return normalizedData;
|
18660
18747
|
}
|
18661
18748
|
stop() {
|
18662
18749
|
if (this.originalPush) {
|
@@ -18710,16 +18797,19 @@ class MonitorService {
|
|
18710
18797
|
if (!spot.productIds.length)
|
18711
18798
|
continue;
|
18712
18799
|
const hasCommonProductIds = spot.productIds.find((productId) => eventProductIds.has(String(productId)));
|
18713
|
-
if (hasCommonProductIds) {
|
18714
|
-
|
18715
|
-
await this.fireAndPublishSpotEvent({
|
18716
|
-
spotEvent: eventData.event,
|
18717
|
-
eventUrl: (_b = (_a = spot.events.find((event) => event.event === eventData.event)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '',
|
18718
|
-
placementId: spot.placementId,
|
18719
|
-
spotId: spot.spotId,
|
18720
|
-
});
|
18721
|
-
}
|
18800
|
+
if (!hasCommonProductIds || !Object.values(RMN_SPOT_EVENT).includes(eventData.event)) {
|
18801
|
+
continue;
|
18722
18802
|
}
|
18803
|
+
const eventUrl = (_b = (_a = spot.events.find((event) => event.event === eventData.event)) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '';
|
18804
|
+
const additionalQueryParams = objectToQueryParams({
|
18805
|
+
override: eventData.productPrice,
|
18806
|
+
});
|
18807
|
+
await this.fireAndPublishSpotEvent({
|
18808
|
+
spotEvent: eventData.event,
|
18809
|
+
eventUrl: `${eventUrl}${additionalQueryParams ? `&${additionalQueryParams}` : ''}`,
|
18810
|
+
placementId: spot.placementId,
|
18811
|
+
spotId: spot.spotId,
|
18812
|
+
});
|
18723
18813
|
}
|
18724
18814
|
}
|
18725
18815
|
async fireAndPublishSpotEvent({ spotEvent, eventUrl, placementId, spotId, }) {
|
@@ -18943,6 +19033,9 @@ class SelectionService extends BaseApi {
|
|
18943
19033
|
* @return {Promise<ISpots | { error: string }>} - The spots response object.
|
18944
19034
|
*/
|
18945
19035
|
async spotSelection(data) {
|
19036
|
+
if (data.userId === undefined) {
|
19037
|
+
data.userId = this.getUserId();
|
19038
|
+
}
|
18946
19039
|
const { isOk, val, isErr } = await this.post(SELECTION_API_PATH, data, {});
|
18947
19040
|
if (isErr) {
|
18948
19041
|
return { error: `There was an error during spot selection: (${isErr === null || isErr === void 0 ? void 0 : isErr.errorMessage})` };
|
@@ -18954,6 +19047,14 @@ class SelectionService extends BaseApi {
|
|
18954
19047
|
}
|
18955
19048
|
return { error: 'Spot selection response was not successful' };
|
18956
19049
|
}
|
19050
|
+
getUserId() {
|
19051
|
+
const isWeb = typeof window !== 'undefined';
|
19052
|
+
if (isWeb) {
|
19053
|
+
const localStorageService = LocalStorageService.getInstance();
|
19054
|
+
return localStorageService.getUserId();
|
19055
|
+
}
|
19056
|
+
return undefined;
|
19057
|
+
}
|
18957
19058
|
}
|
18958
19059
|
|
18959
19060
|
const SPOT_EVENTS_EXAMPLE = [
|
@@ -19619,9 +19720,18 @@ async function waitForDOM() {
|
|
19619
19720
|
});
|
19620
19721
|
});
|
19621
19722
|
}
|
19723
|
+
// Sets the id for the user who is browsing the website
|
19724
|
+
// This id is used to identify the user and provide personalized content
|
19725
|
+
function setUserId() {
|
19726
|
+
if (isBrowserEnvironment()) {
|
19727
|
+
const localStorageService = LocalStorageService.getInstance();
|
19728
|
+
localStorageService.setUserId();
|
19729
|
+
}
|
19730
|
+
}
|
19622
19731
|
|
19623
19732
|
/**
|
19624
19733
|
* LiquidCommerce Rmn Client
|
19734
|
+
*
|
19625
19735
|
* @class
|
19626
19736
|
*/
|
19627
19737
|
class LiquidCommerceRmnClient {
|
@@ -19750,7 +19860,8 @@ class LiquidCommerceRmnClient {
|
|
19750
19860
|
* If it is near, make the spot selection request.
|
19751
19861
|
*/
|
19752
19862
|
this.intersectionObserver.observe(placement, spotPlacementIsNearCallback, {
|
19753
|
-
rootMargin: '
|
19863
|
+
rootMargin: '1000px',
|
19864
|
+
threshold: 0,
|
19754
19865
|
});
|
19755
19866
|
}
|
19756
19867
|
}
|
@@ -19926,7 +20037,6 @@ class LiquidCommerceRmnClient {
|
|
19926
20037
|
*/
|
19927
20038
|
async injectSpotSelectionRequest(params) {
|
19928
20039
|
const { inject, filter, config } = params;
|
19929
|
-
const localStorageService = LocalStorageService.getInstance();
|
19930
20040
|
const spots = inject.map((item) => ({
|
19931
20041
|
placementId: item.placementId,
|
19932
20042
|
spot: item.spotType,
|
@@ -19934,7 +20044,6 @@ class LiquidCommerceRmnClient {
|
|
19934
20044
|
...item === null || item === void 0 ? void 0 : item.filter,
|
19935
20045
|
}));
|
19936
20046
|
const request = {
|
19937
|
-
userId: localStorageService.getUserId(),
|
19938
20047
|
url: config === null || config === void 0 ? void 0 : config.url,
|
19939
20048
|
filter,
|
19940
20049
|
spots,
|
@@ -19953,6 +20062,7 @@ class LiquidCommerceRmnClient {
|
|
19953
20062
|
async function RmnClient(apiKey, config) {
|
19954
20063
|
const authService = AuthService.getInstance(apiKey, config.env);
|
19955
20064
|
const credentials = await authService.initialize();
|
20065
|
+
setUserId();
|
19956
20066
|
return new LiquidCommerceRmnClient(credentials);
|
19957
20067
|
}
|
19958
20068
|
/**
|
@@ -0,0 +1,14 @@
|
|
1
|
+
type ExtractorTarget = 'ids' | 'price';
|
2
|
+
type ExtractedValue = string | number;
|
3
|
+
/**
|
4
|
+
* Extracts deep values from an object based on specified target type
|
5
|
+
* @param data - The source data object to extract values from
|
6
|
+
* @param target - The type of values to extract ('ids' or 'price')
|
7
|
+
* @param options - Optional configuration for the extraction process
|
8
|
+
* @returns Array of extracted values or a single value if onlyFirst is true
|
9
|
+
*/
|
10
|
+
export declare function extractDeepValues(data: unknown, target: ExtractorTarget, options?: {
|
11
|
+
onlyFirst?: boolean;
|
12
|
+
shouldIncludeZero?: boolean;
|
13
|
+
}): ExtractedValue[] | ExtractedValue | undefined;
|
14
|
+
export {};
|
@@ -1,28 +1,18 @@
|
|
1
1
|
import type { IFireEventParams } from 'modules/event';
|
2
|
+
export declare function fallbackEventFire(url: string): Promise<boolean>;
|
2
3
|
/**
|
3
|
-
*
|
4
|
-
* Searches for specified property names and collects their primitive values (strings/numbers).
|
5
|
-
* Captures properties ending with 'id' and any additional specified property names.
|
6
|
-
*
|
7
|
-
* @param data - The data structure to search through (can be nested objects/arrays)
|
8
|
-
* @param propertyNames - Array of additional property names to look for (optional)
|
9
|
-
* @returns Array of extracted ID values (strings/numbers only)
|
4
|
+
* Helper function to decode base64 string and parse JSON
|
10
5
|
*
|
11
|
-
* @
|
12
|
-
*
|
13
|
-
* id: [1, 2, 3],
|
14
|
-
* nested: { id: 'abc', userId: 123 },
|
15
|
-
* items: [{ id: 456, productId: '789', sku: 'ABC123' }]
|
16
|
-
* };
|
17
|
-
* extractDeepIds(data); // Returns [1, 2, 3, 'abc', 123, 456, '789', 'ABC123']
|
6
|
+
* @param {string} base64String - The base64 encoded JSON string
|
7
|
+
* @returns {T | null} - Decoded and parsed object or null if invalid
|
18
8
|
*/
|
19
|
-
export declare function
|
20
|
-
export declare function fallbackEventFire(url: string): Promise<boolean>;
|
9
|
+
export declare function decodeBase64Json<T>(base64String: string): T | null;
|
21
10
|
/**
|
22
11
|
* Extracts and decodes a URL from a base64-encoded query parameter.
|
23
12
|
*
|
24
13
|
* @param {string} url - The URL containing the base64-encoded query parameter.
|
25
14
|
* @returns {string | null} - The decoded URL or null if not found or invalid.
|
15
|
+
* @throws {Error} - If URL is malformed or payload is invalid.
|
26
16
|
*/
|
27
17
|
export declare function getRedirectUrlFromPayload(url: string): string | null;
|
28
18
|
/**
|
@@ -36,3 +26,10 @@ export declare function getRedirectUrlFromPayload(url: string): string | null;
|
|
36
26
|
*/
|
37
27
|
export declare function fireEvent({ event, eventUrl }: IFireEventParams): Promise<void>;
|
38
28
|
export declare function calculateScaleFactor(elementScale: number): number;
|
29
|
+
/**
|
30
|
+
* Converts an object to a query string.
|
31
|
+
*
|
32
|
+
* @param {Record<string, string|number|undefined|null>} obj - The object to be converted to a query string.
|
33
|
+
* @returns {string} - The query string.
|
34
|
+
*/
|
35
|
+
export declare function objectToQueryParams(obj?: Record<string, string | number | undefined | null>): string;
|
@@ -2,14 +2,20 @@ import type { RMN_SPOT_EVENT, RMN_SPOT_TYPE } from 'enums';
|
|
2
2
|
import type { PlacementIdType, SpotVariantType } from 'modules/selection';
|
3
3
|
import type { RmnFilterType, RmnSpotType } from 'types';
|
4
4
|
export interface ISpotSelectionParams {
|
5
|
-
url?: string;
|
6
5
|
spots: RmnSpotType[];
|
7
6
|
filter?: Partial<RmnFilterType>;
|
7
|
+
userId?: string;
|
8
|
+
url?: string;
|
8
9
|
}
|
9
10
|
export interface ISpotEvent {
|
10
11
|
event: RMN_SPOT_EVENT;
|
11
12
|
url: string;
|
12
13
|
}
|
14
|
+
export interface ISpotEventPayload {
|
15
|
+
e: number;
|
16
|
+
u: string;
|
17
|
+
ss: string;
|
18
|
+
}
|
13
19
|
export interface ISpot {
|
14
20
|
id: string;
|
15
21
|
events: ISpotEvent[];
|
@@ -4,6 +4,7 @@ import type { ISpot, ISpots, ISpotSelectionParams } from 'modules/selection';
|
|
4
4
|
import type { IRmnClient, IRmnConfig, IRmnEventManager } from 'types';
|
5
5
|
/**
|
6
6
|
* LiquidCommerce Rmn Client
|
7
|
+
*
|
7
8
|
* @class
|
8
9
|
*/
|
9
10
|
export declare class LiquidCommerceRmnClient implements IRmnClient {
|
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.18",
|
6
6
|
"homepage": "https://docs.liquidcommerce.co/rmn-sdk",
|
7
7
|
"main": "./dist/index.cjs",
|
8
8
|
"module": "./dist/index.esm.js",
|