@liquidcommercedev/rmn-sdk 1.4.6 → 1.5.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/dist/index.cjs +2424 -721
  2. package/dist/index.esm.js +2424 -722
  3. package/dist/types/common/helpers/uuid.helper.d.ts +49 -0
  4. package/dist/types/enums.d.ts +59 -1
  5. package/dist/types/index.umd.d.ts +2 -2
  6. package/dist/types/modules/element/component/carousel/carousel.component.d.ts +3 -0
  7. package/dist/types/modules/element/component/carousel/carousel.interface.d.ts +35 -0
  8. package/dist/types/modules/element/component/carousel/carousel.style.d.ts +2 -0
  9. package/dist/types/modules/element/component/carousel/index.d.ts +3 -0
  10. package/dist/types/modules/element/component/spot/index.d.ts +2 -0
  11. package/dist/types/modules/element/component/spot/spot.component.d.ts +3 -0
  12. package/dist/types/modules/element/component/spot/spot.interface.d.ts +10 -0
  13. package/dist/types/modules/element/component/utils.d.ts +1 -0
  14. package/dist/types/modules/{spot/html/constants/html.constant.d.ts → element/element.constant.d.ts} +2 -5
  15. package/dist/types/modules/element/element.interface.d.ts +52 -0
  16. package/dist/types/modules/element/element.service.d.ts +40 -0
  17. package/dist/types/modules/element/index.d.ts +3 -0
  18. package/dist/types/modules/element/template/helper.d.ts +4 -0
  19. package/dist/types/modules/element/template/index.d.ts +1 -0
  20. package/dist/types/modules/element/template/reservebar/collection-banner-without-text-block.template.d.ts +3 -0
  21. package/dist/types/modules/element/template/reservebar/homepage-hero-full-image.template.d.ts +3 -0
  22. package/dist/types/modules/element/template/reservebar/homepage-hero-three-tile.template.d.ts +3 -0
  23. package/dist/types/modules/element/template/reservebar/homepage-hero-two-tile.template.d.ts +3 -0
  24. package/dist/types/modules/element/template/reservebar/large-category-image-tout.template.d.ts +3 -0
  25. package/dist/types/modules/element/template/reservebar/navigation-banner.template.d.ts +3 -0
  26. package/dist/types/modules/element/template/reservebar/small-category-image-tout.template.d.ts +3 -0
  27. package/dist/types/modules/element/template/reservebar/small-discover-tout.template.d.ts +3 -0
  28. package/dist/types/modules/element/template/template.service.d.ts +11 -0
  29. package/dist/types/modules/element/template/template.type.d.ts +11 -0
  30. package/dist/types/modules/event/event.constant.d.ts +1 -0
  31. package/dist/types/modules/event/event.interface.d.ts +72 -0
  32. package/dist/types/modules/event/event.service.d.ts +45 -0
  33. package/dist/types/modules/event/helpers/index.d.ts +3 -0
  34. package/dist/types/modules/event/helpers/intersection.service.d.ts +8 -0
  35. package/dist/types/modules/event/helpers/localstorage.service.d.ts +26 -0
  36. package/dist/types/modules/event/helpers/resize.service.d.ts +30 -0
  37. package/dist/types/modules/event/index.d.ts +4 -0
  38. package/dist/types/modules/event/pubsub.d.ts +69 -0
  39. package/dist/types/modules/selection/index.d.ts +4 -0
  40. package/dist/types/modules/selection/selection.constant.d.ts +1 -0
  41. package/dist/types/modules/{spot/spot.interface.d.ts → selection/selection.interface.d.ts} +10 -13
  42. package/dist/types/modules/selection/selection.service.d.ts +18 -0
  43. package/dist/types/modules/{spot/spot.type.d.ts → selection/selection.type.d.ts} +4 -3
  44. package/dist/types/rmn-client.d.ts +66 -23
  45. package/dist/types/static.constant.d.ts +4 -0
  46. package/dist/types/types.d.ts +17 -6
  47. package/package.json +2 -2
  48. package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
  49. package/dist/types/modules/spot/html/constants/index.d.ts +0 -1
  50. package/dist/types/modules/spot/html/index.d.ts +0 -1
  51. package/dist/types/modules/spot/html/spot.element.service.d.ts +0 -7
  52. package/dist/types/modules/spot/html/templates/index.d.ts +0 -1
  53. package/dist/types/modules/spot/html/templates/reservebar/collection-banner-without-text-block.template.d.ts +0 -2
  54. package/dist/types/modules/spot/html/templates/reservebar/homepage-hero-full-image.template.d.ts +0 -2
  55. package/dist/types/modules/spot/html/templates/reservebar/homepage-hero-three-tile.template.d.ts +0 -2
  56. package/dist/types/modules/spot/html/templates/reservebar/homepage-hero-two-tile.template.d.ts +0 -2
  57. package/dist/types/modules/spot/html/templates/reservebar/large-category-image-tout.template.d.ts +0 -2
  58. package/dist/types/modules/spot/html/templates/reservebar/navigation-banner.template.d.ts +0 -2
  59. package/dist/types/modules/spot/html/templates/reservebar/small-category-image-tout.template.d.ts +0 -2
  60. package/dist/types/modules/spot/html/templates/reservebar/small-discover-tout.template.d.ts +0 -2
  61. package/dist/types/modules/spot/html/templates/spot.template.d.ts +0 -21
  62. package/dist/types/modules/spot/index.d.ts +0 -6
  63. package/dist/types/modules/spot/spot.constant.d.ts +0 -4
  64. package/dist/types/modules/spot/spot.enum.d.ts +0 -57
  65. package/dist/types/modules/spot/spot.html.service.d.ts +0 -22
  66. package/dist/types/modules/spot/spot.selection.service.d.ts +0 -15
  67. /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/billboard-v1.template.d.ts +0 -0
  68. /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/billboard-v2.template.d.ts +0 -0
  69. /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/billboard-v3.template.d.ts +0 -0
  70. /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/index.d.ts +0 -0
  71. /package/dist/types/modules/{spot/html/templates → element/template}/iab/in-text/in-text-v1.template.d.ts +0 -0
  72. /package/dist/types/modules/{spot/html/templates → element/template}/iab/in-text/index.d.ts +0 -0
  73. /package/dist/types/modules/{spot/html/templates → element/template}/iab/index.d.ts +0 -0
  74. /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-leaderboard/index.d.ts +0 -0
  75. /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-leaderboard/large-leaderboard-v1.template.d.ts +0 -0
  76. /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-leaderboard/large-leaderboard-v2.template.d.ts +0 -0
  77. /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-rectangle/index.d.ts +0 -0
  78. /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-rectangle/large-rectangle-v1.template.d.ts +0 -0
  79. /package/dist/types/modules/{spot/html/templates → element/template}/iab/square/index.d.ts +0 -0
  80. /package/dist/types/modules/{spot/html/templates → element/template}/iab/square/square-v1.template.d.ts +0 -0
  81. /package/dist/types/modules/{spot/html/templates → element/template}/iab/square/square-v2.template.d.ts +0 -0
  82. /package/dist/types/modules/{spot/html/templates → element/template}/iab/vertical-rectangle/index.d.ts +0 -0
  83. /package/dist/types/modules/{spot/html/templates → element/template}/iab/vertical-rectangle/vertical-rectangle-v1.template.d.ts +0 -0
  84. /package/dist/types/modules/{spot/html/templates → element/template}/iab/wide-skyscraper/index.d.ts +0 -0
  85. /package/dist/types/modules/{spot/html/templates → element/template}/iab/wide-skyscraper/wide-skyscraper-v1.template.d.ts +0 -0
  86. /package/dist/types/modules/{spot/html/templates → element/template}/reservebar/index.d.ts +0 -0
@@ -0,0 +1 @@
1
+ export declare const SELECTION_API_PATH = "/spots/selection";
@@ -1,5 +1,6 @@
1
- import type { RMN_SPOT_EVENT, RMN_SPOT_TYPE } from './spot.enum';
2
- import type { RmnFilterType, RmnSpotType, SpotIdentifierType, SpotVariantType } from './spot.type';
1
+ import type { RMN_SPOT_EVENT, RMN_SPOT_TYPE } from 'enums';
2
+ import type { PlacementIdType, SpotVariantType } from 'modules/selection';
3
+ import type { RmnFilterType, RmnSpotType } from 'types';
3
4
  export interface ISpotSelectionParams {
4
5
  url?: string;
5
6
  spots: RmnSpotType[];
@@ -10,6 +11,7 @@ export interface ISpotEvent {
10
11
  url: string;
11
12
  }
12
13
  export interface ISpot {
14
+ id: string;
13
15
  events: ISpotEvent[];
14
16
  spot: RMN_SPOT_TYPE;
15
17
  variant: SpotVariantType;
@@ -27,17 +29,12 @@ export interface ISpot {
27
29
  secondaryImage?: string;
28
30
  mobilePrimaryImage?: string;
29
31
  mobileSecondaryImage?: string;
32
+ productIds?: Array<string | number>;
30
33
  productUpcs?: string[];
31
34
  }
32
- export interface ICreateSpotElementConfig {
33
- fluid?: boolean;
34
- customContent?: HTMLElement | string;
35
- redirectOnClick?: boolean;
36
- }
37
- export type ISpots = Record<SpotIdentifierType, ISpot[]>;
38
- export interface ISpotSelectionService {
39
- spotSelection(data: ISpotSelectionParams): Promise<ISpots>;
40
- }
41
- export interface ISpotHtmlService {
42
- createSpotHtmlElement(spot: ISpot, config?: ICreateSpotElementConfig): HTMLElement | null;
35
+ export type ISpots = Record<PlacementIdType, ISpot[]>;
36
+ export interface ISelectionService {
37
+ spotSelection(data: ISpotSelectionParams): Promise<ISpots | {
38
+ error: string;
39
+ }>;
43
40
  }
@@ -0,0 +1,18 @@
1
+ import { BaseApi } from 'common/http';
2
+ import type { IAuthCredentials } from 'modules/auth';
3
+ import type { ISpots } from 'modules/selection';
4
+ import type { ISelectionService, ISpotSelectionParams } from './selection.interface';
5
+ export declare class SelectionService extends BaseApi implements ISelectionService {
6
+ private constructor();
7
+ static getInstance(auth: IAuthCredentials): SelectionService;
8
+ /**
9
+ * Makes a selection request on our server based on the provided data.
10
+ *
11
+ * @param {ISpotSelectionParams} data - Spots selection parameters.
12
+ *
13
+ * @return {Promise<ISpots | { error: string }>} - The spots response object.
14
+ */
15
+ spotSelection(data: ISpotSelectionParams): Promise<ISpots | {
16
+ error: string;
17
+ }>;
18
+ }
@@ -1,13 +1,14 @@
1
- import type { RMN_FILTER_PROPERTIES, RMN_SPOT_TYPE } from './spot.enum';
1
+ import type { RMN_FILTER_PROPERTIES, RMN_SPOT_TYPE } from 'enums';
2
2
  export type RmnFilterType = {
3
3
  [key in RMN_FILTER_PROPERTIES]?: string[];
4
4
  };
5
+ export type PlacementIdType = RMN_SPOT_TYPE | `${RMN_SPOT_TYPE}${number}` | string;
5
6
  export type SpotFilterType = {
7
+ placementId?: PlacementIdType;
6
8
  spot: RMN_SPOT_TYPE | string;
7
- count: number;
9
+ count?: number;
8
10
  exactMatch?: string;
9
11
  } & Omit<RmnFilterType, RMN_FILTER_PROPERTIES.KEYWORDS>;
10
- export type SpotIdentifierType = RMN_SPOT_TYPE | `${RMN_SPOT_TYPE}${number}`;
11
12
  export type RmnSpotType = RMN_SPOT_TYPE | string | SpotFilterType;
12
13
  type RBSpotTypeKeys = keyof {
13
14
  [K in keyof typeof RMN_SPOT_TYPE as K extends `RB_${string}` ? K : never]: (typeof RMN_SPOT_TYPE)[K];
@@ -1,34 +1,74 @@
1
- import type { IAuthCredentials } from './modules/auth';
2
- import type { ICreateSpotElementConfig, ISpot, ISpots, ISpotSelectionParams } from './modules/spot';
3
- import type { IRmnClient, IRmnConfig } from './types';
1
+ import type { IAuthCredentials } from 'modules/auth';
2
+ import type { IInjectSpotElementParams, IRmnCreateSpotElementConfig } from 'modules/element';
3
+ import type { ISpot, ISpots, ISpotSelectionParams } from 'modules/selection';
4
+ import type { IRmnClient, IRmnConfig, IRmnEventManager } from 'types';
4
5
  export declare class LiquidCommerceRmnClient implements IRmnClient {
5
- private readonly spotSelectionService;
6
- private readonly spotHtmlService;
6
+ private readonly selectionService;
7
+ private readonly elementService;
8
+ private readonly eventService;
7
9
  constructor(auth: IAuthCredentials);
8
10
  /**
9
11
  * Makes a selection request on our server based on the provided data.
10
12
  *
11
13
  * To create a spot html element, use the RmnCreateSpotElement function.
12
14
  *
13
- * @param {ISpotSelectionParams} data - Spots selection parameters.
15
+ * @param {ISpotSelectionParams} params - Spots selection parameters.
14
16
  *
15
- * @return {Promise<ISpots>} - The spots response object.
17
+ * @return {Promise<ISpots | {error : string}>} - The spots response object.
16
18
  */
17
- spotSelection(data: ISpotSelectionParams): Promise<ISpots>;
19
+ spotSelection(params: ISpotSelectionParams): Promise<ISpots | {
20
+ error: string;
21
+ }>;
18
22
  /**
19
- * Creates the spot html element based on the provided data using shadow dom.
23
+ * Injects the spot elements into their provided placement.
20
24
  *
21
- * This method is useful when you are initializing the client in a browser environment, so you can create the spot html element directly from the RmnClient instance.
25
+ * @param {IInjectSpotElementParams} params - Parameters for injecting spot elements.
22
26
  *
27
+ * @return {Promise<void>} - A promise that resolves when the spot elements are injected.
28
+ */
29
+ injectSpotElement(params: IInjectSpotElementParams): Promise<void>;
30
+ /**
31
+ * Makes a selection request on our server based on the provided data.
32
+ *
33
+ * @param {IInjectSpotElementParams} params - Parameters for injecting spot elements.
34
+ *
35
+ * @return {Promise<ISpots | {error: string}>} - The spots response object.
36
+ */
37
+ private spotSelectionRequest;
38
+ /**
39
+ * Injects a carousel element with the provided spots into the placement.
40
+ *
41
+ * @param {HTMLElement} placement - The placement element.
42
+ * @param {ISpot[]} spots - The spot data.
43
+ * @param {IInjectSpotElementConfig} config - The configuration object.
44
+ *
45
+ * @return {void}
46
+ */
47
+ private injectCarouselSpotElement;
48
+ /**
49
+ * Injects a single spot element into the provided placement.
50
+ *
51
+ * @param {IInjectSpotElement} injectItem - The inject item data.
52
+ * @param {HTMLElement} placement - The placement element.
23
53
  * @param {ISpot} spot - The spot data.
24
- * @param {ICreateSpotElementConfig} config - The configuration object.
25
- * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
26
- * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
27
- * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
54
+ * @param {IInjectSpotElementConfig} config - The configuration object.
55
+ *
56
+ * @return {void}
57
+ */
58
+ private injectOneSpotElement;
59
+ /**
60
+ * Prevents duplicate placement ids in the inject data.
28
61
  *
29
- * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
62
+ * @param {IInjectSpotElement[]} inject - The inject data.
63
+ *
64
+ * @throws {Error} - If a duplicate placement id is found.
65
+ *
66
+ * @return {void}
30
67
  */
31
- createSpotElement(spot: ISpot, config?: ICreateSpotElementConfig): HTMLElement | null;
68
+ private preventDuplicateSpotPlacementIds;
69
+ private preventNonExistentSpotTypes;
70
+ private updateSpotsState;
71
+ private useSpotSelectionExample;
32
72
  }
33
73
  /**
34
74
  * Creates a new instance of the RmnClient.
@@ -39,20 +79,23 @@ export declare class LiquidCommerceRmnClient implements IRmnClient {
39
79
  * @return {Promise<IRmnClient>} - The RmnClient instance.
40
80
  */
41
81
  declare function RmnClient(apiKey: string, config: IRmnConfig): Promise<IRmnClient>;
82
+ /**
83
+ * Creates a new instance of the RmnEventManager.
84
+ *
85
+ * @return {IRmnEventManager} - The RmnEventManager instance.
86
+ */
87
+ declare function RmnEventManager(): IRmnEventManager;
42
88
  /**
43
89
  * Creates the spot html element based on the provided data using shadow dom.
44
90
  *
45
91
  * This method is useful when you are initializing the client in a non-browser environment.
46
- * When you request a spot selection, you will receive the spot data in server-side and return them back to the client.
92
+ * When you request a spot selection, you will receive the spot data in server-side and return them to the client.
47
93
  * Then you can use this function to create the spot html element based on the provided data without the need of the RmnClient instance.
48
94
  *
49
95
  * @param {ISpot} spot - The spot data.
50
- * @param {ICreateSpotElementConfig} config - The configuration object.
51
- * @param {ICreateSpotElementConfig.fluid} config.fluid - If the spot should be fluid or not.
52
- * @param {ICreateSpotElementConfig.customContent} config.customContent - Use a custom html element/string.
53
- * @param {ICreateSpotElementConfig.redirectOnClick} config.redirectOnClick - If the spot should redirect on click.
96
+ * @param {IRmnCreateSpotElementConfig} config - The configuration object.
54
97
  *
55
98
  * @return {HTMLElement | null} - The spot html element or null if the browser environment is not available.
56
99
  */
57
- declare function RmnCreateSpotElement(spot: ISpot, config?: ICreateSpotElementConfig): HTMLElement | null;
58
- export { RmnClient, RmnCreateSpotElement };
100
+ declare function RmnCreateSpotElement(spot: ISpot, config?: IRmnCreateSpotElementConfig): HTMLElement | null;
101
+ export { RmnClient, RmnCreateSpotElement, RmnEventManager };
@@ -0,0 +1,4 @@
1
+ import type { ISpotEvent, ISpots } from 'types';
2
+ export declare const SPOT_EVENTS_EXAMPLE: ISpotEvent[];
3
+ export declare const RB_SPOTS_SELECTION_EXAMPLE: Partial<ISpots>;
4
+ export declare const IAB_SPOTS_SELECTION_EXAMPLE: Partial<ISpots>;
@@ -1,10 +1,21 @@
1
- export type { ICreateSpotElementConfig, ISpotEvent, ISpots, RmnFilterType, RmnSpotType, } from './modules/spot';
2
- export { ISpot, ISpotSelectionParams } from './modules/spot';
3
- import type { RMN_ENV } from './enums';
4
- import type { ICreateSpotElementConfig, ISpot, ISpots, ISpotSelectionParams } from './modules/spot';
1
+ import type { IEventMap } from './modules/event';
2
+ export type { IInjectSpotElement, IInjectSpotElementConfig, IInjectSpotElementParams, IRmnCreateSpotElementConfig, ISpotColors, ISpotOverlay, } from 'modules/element';
3
+ export type { CarouselNavPositionType, ICarouselButtonOptions, ICarouselDotOptions, ICarouselOptions, } from 'modules/element/component/carousel';
4
+ export type { ISpots, RmnFilterType, RmnSpotType } from 'modules/selection';
5
+ export { ISpot, ISpotEvent, ISpotSelectionParams } from 'modules/selection';
6
+ import type { RMN_ENV, RMN_SPOT_EVENT } from 'enums';
7
+ import type { IInjectSpotElementParams } from 'modules/element';
8
+ import type { ISpots, ISpotSelectionParams } from 'modules/selection';
5
9
  export interface IRmnClient {
6
- spotSelection(data: ISpotSelectionParams): Promise<ISpots>;
7
- createSpotElement(spot: ISpot, config?: ICreateSpotElementConfig): HTMLElement | null;
10
+ spotSelection(params: ISpotSelectionParams): Promise<ISpots | {
11
+ error: string;
12
+ }>;
13
+ injectSpotElement(params: IInjectSpotElementParams): Promise<void>;
14
+ }
15
+ export interface IRmnEventManager {
16
+ subscribe: (eventType: RMN_SPOT_EVENT, callback: (data: IEventMap[RMN_SPOT_EVENT]) => void) => () => void;
17
+ publish: (eventType: RMN_SPOT_EVENT, data: IEventMap[RMN_SPOT_EVENT]) => void;
18
+ destroySpot: (placementId: string) => void;
8
19
  }
9
20
  export interface IRmnConfig {
10
21
  env: RMN_ENV;
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.4.6",
5
+ "version": "1.5.0-beta.1",
6
6
  "homepage": "https://docs.liquidcommerce.co/rmn-sdk",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.esm.js",
@@ -42,7 +42,7 @@
42
42
  "test": "vitest run",
43
43
  "test:watch": "vitest",
44
44
  "test:coverage": "vitest run --coverage",
45
- "lint": "eslint \"src/**/*.ts\" --fix",
45
+ "lint": "eslint \"src/**/*.ts\"",
46
46
  "format": "prettier --write \"src/**/*.ts\"",
47
47
  "docs": "typedoc --out docs src",
48
48
  "prepublishOnly": "pnpm run build"