@liquidcommercedev/rmn-sdk 1.4.6 → 1.5.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +2463 -720
- package/dist/index.esm.js +2463 -721
- package/dist/types/common/helpers/uuid.helper.d.ts +49 -0
- package/dist/types/enums.d.ts +59 -1
- package/dist/types/index.umd.d.ts +2 -2
- package/dist/types/modules/element/component/carousel/carousel.component.d.ts +3 -0
- package/dist/types/modules/element/component/carousel/carousel.interface.d.ts +35 -0
- package/dist/types/modules/element/component/carousel/carousel.style.d.ts +2 -0
- package/dist/types/modules/element/component/carousel/index.d.ts +3 -0
- package/dist/types/modules/element/component/spot/index.d.ts +2 -0
- package/dist/types/modules/element/component/spot/spot.component.d.ts +3 -0
- package/dist/types/modules/element/component/spot/spot.interface.d.ts +10 -0
- package/dist/types/modules/element/component/utils.d.ts +1 -0
- package/dist/types/modules/{spot/html/constants/html.constant.d.ts → element/element.constant.d.ts} +2 -5
- package/dist/types/modules/element/element.interface.d.ts +52 -0
- package/dist/types/modules/element/element.service.d.ts +40 -0
- package/dist/types/modules/element/index.d.ts +3 -0
- package/dist/types/modules/element/template/helper.d.ts +4 -0
- package/dist/types/modules/element/template/index.d.ts +1 -0
- package/dist/types/modules/element/template/reservebar/collection-banner-without-text-block.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/homepage-hero-full-image.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/homepage-hero-three-tile.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/homepage-hero-two-tile.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/large-category-image-tout.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/navigation-banner.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/small-category-image-tout.template.d.ts +3 -0
- package/dist/types/modules/element/template/reservebar/small-discover-tout.template.d.ts +3 -0
- package/dist/types/modules/element/template/template.service.d.ts +11 -0
- package/dist/types/modules/element/template/template.type.d.ts +11 -0
- package/dist/types/modules/event/event.constant.d.ts +1 -0
- package/dist/types/modules/event/event.interface.d.ts +72 -0
- package/dist/types/modules/event/event.service.d.ts +47 -0
- package/dist/types/modules/event/helpers/index.d.ts +3 -0
- package/dist/types/modules/event/helpers/intersection.service.d.ts +8 -0
- package/dist/types/modules/event/helpers/localstorage.service.d.ts +26 -0
- package/dist/types/modules/event/helpers/resize.service.d.ts +30 -0
- package/dist/types/modules/event/index.d.ts +4 -0
- package/dist/types/modules/event/pubsub.d.ts +69 -0
- package/dist/types/modules/selection/index.d.ts +4 -0
- package/dist/types/modules/selection/selection.constant.d.ts +1 -0
- package/dist/types/modules/{spot/spot.interface.d.ts → selection/selection.interface.d.ts} +10 -13
- package/dist/types/modules/selection/selection.service.d.ts +18 -0
- package/dist/types/modules/{spot/spot.type.d.ts → selection/selection.type.d.ts} +4 -3
- package/dist/types/rmn-client.d.ts +66 -23
- package/dist/types/static.constant.d.ts +4 -0
- package/dist/types/types.d.ts +17 -6
- package/package.json +2 -2
- package/umd/liquidcommerce-rmn-sdk.min.js +1 -1
- package/dist/types/modules/spot/html/constants/index.d.ts +0 -1
- package/dist/types/modules/spot/html/index.d.ts +0 -1
- package/dist/types/modules/spot/html/spot.element.service.d.ts +0 -7
- package/dist/types/modules/spot/html/templates/index.d.ts +0 -1
- package/dist/types/modules/spot/html/templates/reservebar/collection-banner-without-text-block.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/reservebar/homepage-hero-full-image.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/reservebar/homepage-hero-three-tile.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/reservebar/homepage-hero-two-tile.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/reservebar/large-category-image-tout.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/reservebar/navigation-banner.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/reservebar/small-category-image-tout.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/reservebar/small-discover-tout.template.d.ts +0 -2
- package/dist/types/modules/spot/html/templates/spot.template.d.ts +0 -21
- package/dist/types/modules/spot/index.d.ts +0 -6
- package/dist/types/modules/spot/spot.constant.d.ts +0 -4
- package/dist/types/modules/spot/spot.enum.d.ts +0 -57
- package/dist/types/modules/spot/spot.html.service.d.ts +0 -22
- package/dist/types/modules/spot/spot.selection.service.d.ts +0 -15
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/billboard-v1.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/billboard-v2.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/billboard-v3.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/billboard/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/in-text/in-text-v1.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/in-text/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-leaderboard/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-leaderboard/large-leaderboard-v1.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-leaderboard/large-leaderboard-v2.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-rectangle/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/large-rectangle/large-rectangle-v1.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/square/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/square/square-v1.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/square/square-v2.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/vertical-rectangle/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/vertical-rectangle/vertical-rectangle-v1.template.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/wide-skyscraper/index.d.ts +0 -0
- /package/dist/types/modules/{spot/html/templates → element/template}/iab/wide-skyscraper/wide-skyscraper-v1.template.d.ts +0 -0
- /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 '
|
2
|
-
import 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
|
33
|
-
|
34
|
-
|
35
|
-
|
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 '
|
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
|
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 '
|
2
|
-
import type {
|
3
|
-
import type {
|
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
|
6
|
-
private readonly
|
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}
|
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(
|
19
|
+
spotSelection(params: ISpotSelectionParams): Promise<ISpots | {
|
20
|
+
error: string;
|
21
|
+
}>;
|
18
22
|
/**
|
19
|
-
*
|
23
|
+
* Injects the spot elements into their provided placement.
|
20
24
|
*
|
21
|
-
*
|
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 {
|
25
|
-
*
|
26
|
-
* @
|
27
|
-
|
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
|
-
* @
|
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
|
-
|
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
|
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 {
|
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?:
|
58
|
-
export { RmnClient, RmnCreateSpotElement };
|
100
|
+
declare function RmnCreateSpotElement(spot: ISpot, config?: IRmnCreateSpotElementConfig): HTMLElement | null;
|
101
|
+
export { RmnClient, RmnCreateSpotElement, RmnEventManager };
|
package/dist/types/types.d.ts
CHANGED
@@ -1,10 +1,21 @@
|
|
1
|
-
|
2
|
-
export {
|
3
|
-
|
4
|
-
|
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(
|
7
|
-
|
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.
|
5
|
+
"version": "1.5.0-beta.2",
|
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\"
|
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"
|