@liquidcommercedev/rmn-sdk 1.5.0-beta.11 → 1.5.0-beta.12

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs CHANGED
@@ -584,6 +584,69 @@ const RB_SPOTS_SELECTION_EXAMPLE = {
584
584
  },
585
585
  ],
586
586
  };
587
+ const IAB_SPOTS_SELECTION_EXAMPLE = {
588
+ banner: [],
589
+ billboard: [
590
+ {
591
+ id: 'kol567',
592
+ spot: exports.RMN_SPOT_TYPE.BILLBOARD,
593
+ variant: `${exports.RMN_SPOT_TYPE.BILLBOARD}V2`,
594
+ width: 1140,
595
+ height: 640,
596
+ header: 'Holiday Gift Guide',
597
+ description: 'Perfect spirits for every occasion',
598
+ ctaText: 'Shop Gifts',
599
+ textColor: '#ffffff',
600
+ ctaTextColor: '#ffffff',
601
+ primaryImage: 'https://placehold.co/1140x640/png?text=Gift+Guide',
602
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Gifts',
603
+ events: SPOT_EVENTS_EXAMPLE,
604
+ productIds: [25, 26],
605
+ },
606
+ {
607
+ id: 'hpm390',
608
+ spot: exports.RMN_SPOT_TYPE.BILLBOARD,
609
+ variant: `${exports.RMN_SPOT_TYPE.BILLBOARD}V2`,
610
+ width: 1140,
611
+ height: 640,
612
+ header: 'Summer Wine Festival',
613
+ description: 'Refreshing wines for summer',
614
+ ctaText: 'Shop Festival',
615
+ textColor: '#ffffff',
616
+ ctaTextColor: '#ffffff',
617
+ primaryImage: 'https://placehold.co/1140x640/png?text=Wine+Festival',
618
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Festival',
619
+ events: SPOT_EVENTS_EXAMPLE,
620
+ productIds: [27, 28],
621
+ },
622
+ ],
623
+ button2: [],
624
+ featurePhoneLargeBanner: [],
625
+ featurePhoneMediumBanner: [],
626
+ featurePhoneSmallBanner: [],
627
+ halfPage: [],
628
+ inText: [],
629
+ largeLeaderboard: [],
630
+ largeRectangle: [],
631
+ leaderboard: [],
632
+ mediumRectangle: [],
633
+ microBar: [],
634
+ mobilePhoneInterstitial1: [],
635
+ mobilePhoneInterstitial2: [],
636
+ mobilePhoneInterstitial3: [],
637
+ popUp: [],
638
+ portrait: [],
639
+ rbProductUpcs: [],
640
+ skyscraper: [],
641
+ smallRectangle: [],
642
+ smallSquare: [],
643
+ smartphoneBanner1: [],
644
+ smartphoneBanner2: [],
645
+ square: [],
646
+ verticalBanner: [],
647
+ verticalRectangle: [],
648
+ wideSkyscraper: [],
649
+ };
587
650
 
588
651
  const REQUEST_CLOUD_PARTNER_SITE = 'X-Liquid-Partner-Site';
589
652
  const REQUEST_CLOUD_PROTECTED_KEY = 'X-Liquid-Protected';
@@ -16122,6 +16185,17 @@ var ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX;
16122
16185
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["PRODUCT_IDS"] = 4] = "PRODUCT_IDS";
16123
16186
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["CREATED_AT"] = 5] = "CREATED_AT";
16124
16187
  })(ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX || (ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX = {}));
16188
+ const LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX = {
16189
+ [exports.RMN_SPOT_EVENT.IMPRESSION]: 0,
16190
+ [exports.RMN_SPOT_EVENT.CLICK]: 1,
16191
+ [exports.RMN_SPOT_EVENT.PURCHASE]: 2,
16192
+ [exports.RMN_SPOT_EVENT.ADD_TO_CART]: 3,
16193
+ [exports.RMN_SPOT_EVENT.REMOVE_FROM_CART]: 4,
16194
+ [exports.RMN_SPOT_EVENT.ADD_TO_CART_FROM_DETAILS]: 5,
16195
+ [exports.RMN_SPOT_EVENT.ADD_TO_WISHLIST]: 6,
16196
+ [exports.RMN_SPOT_EVENT.EXPAND_PRODUCT]: 7,
16197
+ [exports.RMN_SPOT_EVENT.BUY_NOW]: 8,
16198
+ };
16125
16199
  class LocalStorageService {
16126
16200
  constructor() {
16127
16201
  if (typeof window.localStorage === 'undefined') {
@@ -16149,7 +16223,7 @@ class LocalStorageService {
16149
16223
  if (parsedData && typeof parsedData === 'object') {
16150
16224
  const data = {};
16151
16225
  for (const [key, value] of Object.entries(parsedData)) {
16152
- data[key] = this.arrayToObject(value);
16226
+ data[key] = this.spotArrayToObject(value);
16153
16227
  }
16154
16228
  this.spots = this.objectToMap(data);
16155
16229
  }
@@ -16189,7 +16263,7 @@ class LocalStorageService {
16189
16263
  const data = this.mapToObject(this.spots);
16190
16264
  const dataArray = {};
16191
16265
  for (const [key, value] of Object.entries(data)) {
16192
- dataArray[key] = this.objectToArray(value);
16266
+ dataArray[key] = this.spotObjectToArray(value);
16193
16267
  }
16194
16268
  try {
16195
16269
  const encryptedData = this.encryptData(JSON.stringify(dataArray));
@@ -16220,15 +16294,34 @@ class LocalStorageService {
16220
16294
  objectToMap(obj) {
16221
16295
  return new Map(Object.entries(obj));
16222
16296
  }
16223
- objectToArray(obj) {
16224
- return [obj.placementId, obj.spotId, obj.spotType, obj.events, obj.productIds, obj.createdAt];
16297
+ spotEventObjectToArray(events) {
16298
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => {
16299
+ const result = events.find((item) => item.event === type);
16300
+ return result && result.event === type ? result.url : '';
16301
+ });
16302
+ }
16303
+ spotEventArrayToObject(arr) {
16304
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => ({
16305
+ event: type,
16306
+ url: arr[LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX[type]],
16307
+ }));
16225
16308
  }
16226
- arrayToObject(arr) {
16309
+ spotObjectToArray(obj) {
16310
+ return [
16311
+ obj.placementId,
16312
+ obj.spotId,
16313
+ obj.spotType,
16314
+ this.spotEventObjectToArray(obj.events),
16315
+ obj.productIds,
16316
+ obj.createdAt,
16317
+ ];
16318
+ }
16319
+ spotArrayToObject(arr) {
16227
16320
  return {
16228
16321
  placementId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PLACEMENT_ID],
16229
16322
  spotId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_ID],
16230
16323
  spotType: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_TYPE],
16231
- events: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS],
16324
+ events: this.spotEventArrayToObject(arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS]),
16232
16325
  productIds: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PRODUCT_IDS],
16233
16326
  createdAt: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.CREATED_AT],
16234
16327
  };
@@ -16238,16 +16331,14 @@ class LocalStorageService {
16238
16331
  return data;
16239
16332
  // For now, we are using base64 encoding to encrypt the data
16240
16333
  // Later we will use Jose encryption
16241
- const encryptedData = btoa(data);
16242
- return encryptedData;
16334
+ return btoa(data);
16243
16335
  }
16244
16336
  decryptData(data) {
16245
16337
  if (!LocalStorageService.encryptData)
16246
16338
  return data;
16247
16339
  // For now, we are using base64 encoding to encrypt
16248
16340
  // Later we will use Jose encryption
16249
- const decryptedData = atob(data);
16250
- return decryptedData;
16341
+ return atob(data);
16251
16342
  }
16252
16343
  }
16253
16344
  LocalStorageService.localStorageKey = 'lc_rmn';
@@ -19560,7 +19651,7 @@ class LiquidCommerceRmnClient {
19560
19651
  }
19561
19652
  }
19562
19653
  useSpotSelectionExample(inject) {
19563
- const examples = RB_SPOTS_SELECTION_EXAMPLE;
19654
+ const examples = { ...RB_SPOTS_SELECTION_EXAMPLE, ...IAB_SPOTS_SELECTION_EXAMPLE };
19564
19655
  const data = {};
19565
19656
  inject.map((item) => {
19566
19657
  var _a, _b, _c;
package/dist/index.esm.js CHANGED
@@ -582,6 +582,69 @@ const RB_SPOTS_SELECTION_EXAMPLE = {
582
582
  },
583
583
  ],
584
584
  };
585
+ const IAB_SPOTS_SELECTION_EXAMPLE = {
586
+ banner: [],
587
+ billboard: [
588
+ {
589
+ id: 'kol567',
590
+ spot: RMN_SPOT_TYPE.BILLBOARD,
591
+ variant: `${RMN_SPOT_TYPE.BILLBOARD}V2`,
592
+ width: 1140,
593
+ height: 640,
594
+ header: 'Holiday Gift Guide',
595
+ description: 'Perfect spirits for every occasion',
596
+ ctaText: 'Shop Gifts',
597
+ textColor: '#ffffff',
598
+ ctaTextColor: '#ffffff',
599
+ primaryImage: 'https://placehold.co/1140x640/png?text=Gift+Guide',
600
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Gifts',
601
+ events: SPOT_EVENTS_EXAMPLE,
602
+ productIds: [25, 26],
603
+ },
604
+ {
605
+ id: 'hpm390',
606
+ spot: RMN_SPOT_TYPE.BILLBOARD,
607
+ variant: `${RMN_SPOT_TYPE.BILLBOARD}V2`,
608
+ width: 1140,
609
+ height: 640,
610
+ header: 'Summer Wine Festival',
611
+ description: 'Refreshing wines for summer',
612
+ ctaText: 'Shop Festival',
613
+ textColor: '#ffffff',
614
+ ctaTextColor: '#ffffff',
615
+ primaryImage: 'https://placehold.co/1140x640/png?text=Wine+Festival',
616
+ mobilePrimaryImage: 'https://placehold.co/640x640/png?text=Mobile+Festival',
617
+ events: SPOT_EVENTS_EXAMPLE,
618
+ productIds: [27, 28],
619
+ },
620
+ ],
621
+ button2: [],
622
+ featurePhoneLargeBanner: [],
623
+ featurePhoneMediumBanner: [],
624
+ featurePhoneSmallBanner: [],
625
+ halfPage: [],
626
+ inText: [],
627
+ largeLeaderboard: [],
628
+ largeRectangle: [],
629
+ leaderboard: [],
630
+ mediumRectangle: [],
631
+ microBar: [],
632
+ mobilePhoneInterstitial1: [],
633
+ mobilePhoneInterstitial2: [],
634
+ mobilePhoneInterstitial3: [],
635
+ popUp: [],
636
+ portrait: [],
637
+ rbProductUpcs: [],
638
+ skyscraper: [],
639
+ smallRectangle: [],
640
+ smallSquare: [],
641
+ smartphoneBanner1: [],
642
+ smartphoneBanner2: [],
643
+ square: [],
644
+ verticalBanner: [],
645
+ verticalRectangle: [],
646
+ wideSkyscraper: [],
647
+ };
585
648
 
586
649
  const REQUEST_CLOUD_PARTNER_SITE = 'X-Liquid-Partner-Site';
587
650
  const REQUEST_CLOUD_PROTECTED_KEY = 'X-Liquid-Protected';
@@ -16120,6 +16183,17 @@ var ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX;
16120
16183
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["PRODUCT_IDS"] = 4] = "PRODUCT_IDS";
16121
16184
  ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX["CREATED_AT"] = 5] = "CREATED_AT";
16122
16185
  })(ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX || (ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX = {}));
16186
+ const LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX = {
16187
+ [RMN_SPOT_EVENT.IMPRESSION]: 0,
16188
+ [RMN_SPOT_EVENT.CLICK]: 1,
16189
+ [RMN_SPOT_EVENT.PURCHASE]: 2,
16190
+ [RMN_SPOT_EVENT.ADD_TO_CART]: 3,
16191
+ [RMN_SPOT_EVENT.REMOVE_FROM_CART]: 4,
16192
+ [RMN_SPOT_EVENT.ADD_TO_CART_FROM_DETAILS]: 5,
16193
+ [RMN_SPOT_EVENT.ADD_TO_WISHLIST]: 6,
16194
+ [RMN_SPOT_EVENT.EXPAND_PRODUCT]: 7,
16195
+ [RMN_SPOT_EVENT.BUY_NOW]: 8,
16196
+ };
16123
16197
  class LocalStorageService {
16124
16198
  constructor() {
16125
16199
  if (typeof window.localStorage === 'undefined') {
@@ -16147,7 +16221,7 @@ class LocalStorageService {
16147
16221
  if (parsedData && typeof parsedData === 'object') {
16148
16222
  const data = {};
16149
16223
  for (const [key, value] of Object.entries(parsedData)) {
16150
- data[key] = this.arrayToObject(value);
16224
+ data[key] = this.spotArrayToObject(value);
16151
16225
  }
16152
16226
  this.spots = this.objectToMap(data);
16153
16227
  }
@@ -16187,7 +16261,7 @@ class LocalStorageService {
16187
16261
  const data = this.mapToObject(this.spots);
16188
16262
  const dataArray = {};
16189
16263
  for (const [key, value] of Object.entries(data)) {
16190
- dataArray[key] = this.objectToArray(value);
16264
+ dataArray[key] = this.spotObjectToArray(value);
16191
16265
  }
16192
16266
  try {
16193
16267
  const encryptedData = this.encryptData(JSON.stringify(dataArray));
@@ -16218,15 +16292,34 @@ class LocalStorageService {
16218
16292
  objectToMap(obj) {
16219
16293
  return new Map(Object.entries(obj));
16220
16294
  }
16221
- objectToArray(obj) {
16222
- return [obj.placementId, obj.spotId, obj.spotType, obj.events, obj.productIds, obj.createdAt];
16295
+ spotEventObjectToArray(events) {
16296
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => {
16297
+ const result = events.find((item) => item.event === type);
16298
+ return result && result.event === type ? result.url : '';
16299
+ });
16300
+ }
16301
+ spotEventArrayToObject(arr) {
16302
+ return Object.keys(LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX).map((type) => ({
16303
+ event: type,
16304
+ url: arr[LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX[type]],
16305
+ }));
16223
16306
  }
16224
- arrayToObject(arr) {
16307
+ spotObjectToArray(obj) {
16308
+ return [
16309
+ obj.placementId,
16310
+ obj.spotId,
16311
+ obj.spotType,
16312
+ this.spotEventObjectToArray(obj.events),
16313
+ obj.productIds,
16314
+ obj.createdAt,
16315
+ ];
16316
+ }
16317
+ spotArrayToObject(arr) {
16225
16318
  return {
16226
16319
  placementId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PLACEMENT_ID],
16227
16320
  spotId: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_ID],
16228
16321
  spotType: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.SPOT_TYPE],
16229
- events: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS],
16322
+ events: this.spotEventArrayToObject(arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.EVENTS]),
16230
16323
  productIds: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.PRODUCT_IDS],
16231
16324
  createdAt: arr[ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX.CREATED_AT],
16232
16325
  };
@@ -16236,16 +16329,14 @@ class LocalStorageService {
16236
16329
  return data;
16237
16330
  // For now, we are using base64 encoding to encrypt the data
16238
16331
  // Later we will use Jose encryption
16239
- const encryptedData = btoa(data);
16240
- return encryptedData;
16332
+ return btoa(data);
16241
16333
  }
16242
16334
  decryptData(data) {
16243
16335
  if (!LocalStorageService.encryptData)
16244
16336
  return data;
16245
16337
  // For now, we are using base64 encoding to encrypt
16246
16338
  // Later we will use Jose encryption
16247
- const decryptedData = atob(data);
16248
- return decryptedData;
16339
+ return atob(data);
16249
16340
  }
16250
16341
  }
16251
16342
  LocalStorageService.localStorageKey = 'lc_rmn';
@@ -19558,7 +19649,7 @@ class LiquidCommerceRmnClient {
19558
19649
  }
19559
19650
  }
19560
19651
  useSpotSelectionExample(inject) {
19561
- const examples = RB_SPOTS_SELECTION_EXAMPLE;
19652
+ const examples = { ...RB_SPOTS_SELECTION_EXAMPLE, ...IAB_SPOTS_SELECTION_EXAMPLE };
19562
19653
  const data = {};
19563
19654
  inject.map((item) => {
19564
19655
  var _a, _b, _c;
@@ -16,7 +16,7 @@ export type LocalStorageSpotArray = [
16
16
  string,
17
17
  string,
18
18
  RMN_SPOT_TYPE,
19
- ISpotEvent[],
19
+ string[],
20
20
  Array<string | number>,
21
21
  // PRODUCT_IDS = 4
22
22
  number | undefined
@@ -29,6 +29,17 @@ export declare enum ENUM_LOCAL_STORAGE_SPOT_ARRAY_INDEX {
29
29
  PRODUCT_IDS = 4,
30
30
  CREATED_AT = 5
31
31
  }
32
+ export declare const LOCAL_STORAGE_SPOT_EVENTS_ARRAY_INDEX: {
33
+ readonly IMPRESSION: 0;
34
+ readonly CLICK: 1;
35
+ readonly PURCHASE: 2;
36
+ readonly ADD_TO_CART: 3;
37
+ readonly REMOVE_FROM_CART: 4;
38
+ readonly ADD_TO_CART_FROM_DETAILS: 5;
39
+ readonly ADD_TO_WISHLIST: 6;
40
+ readonly EXPAND_PRODUCT: 7;
41
+ readonly BUY_NOW: 8;
42
+ };
32
43
  export type LocalStorageSpotsArrayType = Record<string, // spotId
33
44
  LocalStorageSpotArray>;
34
45
  export declare class LocalStorageService {
@@ -49,8 +60,10 @@ export declare class LocalStorageService {
49
60
  private removeExpiredSpots;
50
61
  private mapToObject;
51
62
  private objectToMap;
52
- private objectToArray;
53
- private arrayToObject;
63
+ private spotEventObjectToArray;
64
+ private spotEventArrayToObject;
65
+ private spotObjectToArray;
66
+ private spotArrayToObject;
54
67
  private encryptData;
55
68
  private decryptData;
56
69
  }
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.11",
5
+ "version": "1.5.0-beta.12",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",