@liquidcommerce/elements-sdk 2.4.0 → 2.4.2

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.
@@ -1,4 +1,4 @@
1
- import type { IBaseCartEventData, IBaseProductEventData, ICheckoutDetails } from '@/core/pubsub';
1
+ import type { IBaseCartEventData, IBaseProductEventData, ICheckoutDetailsEventData } from '@/core/pubsub';
2
2
  import { type FulfillmentType } from '@/enums';
3
3
  import type { IAddress, ICoords } from '@/interfaces/cloud';
4
4
  import type { IAddressData } from '@/modules/address';
@@ -32,6 +32,7 @@ export interface ICheckoutActions {
32
32
  closeCheckout: () => void;
33
33
  toggleCheckout: () => void;
34
34
  addProduct: (params: IAddProductParams[], openCheckout?: boolean) => Promise<void>;
35
+ addPresaleProduct: (params: IAddProductParams) => Promise<void>;
35
36
  applyPromoCode: (promoCode: string) => Promise<void>;
36
37
  removePromoCode: () => Promise<void>;
37
38
  applyGiftCard: (code: string) => Promise<void>;
@@ -42,7 +43,7 @@ export interface ICheckoutActions {
42
43
  updateCustomerInfo: (params: Record<CustomerFieldName, string>) => void;
43
44
  updateBillingInfo: (params: Record<BillingFieldName, string>) => void;
44
45
  updateGiftInfo: (params: Record<GiftFieldName, string>) => void;
45
- getDetails: () => ICheckoutDetails;
46
+ getDetails: () => ICheckoutDetailsEventData;
46
47
  }
47
48
  export declare class ClientActionService {
48
49
  private readonly pubSub;
@@ -55,6 +55,7 @@ export interface IBaseCartEventData {
55
55
  subtotal: number;
56
56
  total: number;
57
57
  };
58
+ itemCount: number;
58
59
  updatedAt: string;
59
60
  createdAt: string;
60
61
  }
@@ -1,5 +1,4 @@
1
- import type { ICheckoutItemStore } from '@/core/store';
2
- import type { ICheckoutTotalAmounts } from '@/interfaces/cloud';
1
+ import type { ICartItemAttributes, ICheckoutTotalAmounts } from '@/interfaces/cloud';
3
2
  export interface IBaseCheckoutEventData {
4
3
  cartId: string;
5
4
  }
@@ -67,18 +66,59 @@ export interface ICheckoutGiftCardFailedEventData {
67
66
  export interface ICheckoutProductAddEventData {
68
67
  itemsAdded: number;
69
68
  identifiers: string[];
69
+ isPresale?: boolean;
70
70
  }
71
71
  export interface ICheckoutProductAddFailedEventData {
72
72
  identifiers: string[];
73
73
  error: string;
74
+ isPresale?: boolean;
74
75
  }
75
- export interface ICheckoutDetails {
76
+ export interface ICheckoutItemEventData {
77
+ liquidId: string;
78
+ variantId: string;
79
+ cartItemId: string;
80
+ retailerId: string;
81
+ fulfillmentId: string;
82
+ salsifyGrouping: string;
83
+ name: string;
84
+ catPath: string;
85
+ volume: string;
86
+ uom: string;
87
+ proof: string;
88
+ abv: string;
89
+ containerType: string;
90
+ container: string;
91
+ size: string;
92
+ pack: boolean;
93
+ packDesc: string;
94
+ mainImage: string;
95
+ brand: string;
96
+ partNumber: string;
97
+ upc: string;
98
+ sku: string;
99
+ price: number;
100
+ unitPrice: number;
101
+ quantity: number;
102
+ unitTax: number;
103
+ bottleDeposits: number;
104
+ attributes: ICartItemAttributes;
105
+ retailerName: string;
106
+ expectationDetail: string;
107
+ }
108
+ export interface ICheckoutDetailsEventData {
76
109
  cartId: string;
77
- amounts: ICheckoutTotalAmounts;
78
- items: Record<string, Omit<ICheckoutItemStore, 'attributes'>>;
79
- isGift: boolean;
110
+ acceptedAccountCreation: boolean;
80
111
  hasAgeVerify: boolean;
112
+ hasSubstitutionPolicy: boolean;
113
+ isGift: boolean;
114
+ billingSameAsShipping: boolean;
115
+ marketingPreferences: {
116
+ canEmail: boolean;
117
+ canSms: boolean;
118
+ };
81
119
  hasPromoCode: boolean;
82
120
  hasGiftCards: boolean;
121
+ amounts: ICheckoutTotalAmounts;
83
122
  itemCount: number;
123
+ items: Record<string, ICheckoutItemEventData>;
84
124
  }
@@ -9,6 +9,8 @@ export interface IElementsClientIsReadyEventData {
9
9
  export interface IBaseProductFulfillmentEventData {
10
10
  price: number;
11
11
  partNumber: string;
12
+ stock: number;
13
+ isEngravable: boolean;
12
14
  fulfillmentId: string;
13
15
  fulfillmentType: FulfillmentType;
14
16
  modalities: FulfillmentType[];
@@ -17,6 +19,23 @@ export interface IBaseProductFulfillmentEventData {
17
19
  retailerAddress: (IAddress & ICoords) | null;
18
20
  retailerTimezone: string;
19
21
  }
22
+ export interface IBaseProductSizeAttributesEventData {
23
+ engraving?: {
24
+ status: boolean;
25
+ maxLines: number;
26
+ maxCharsPerLine: number;
27
+ fee: number;
28
+ location: string;
29
+ };
30
+ presale?: {
31
+ canPurchaseOn: null | string;
32
+ estimatedShipBy: null | string;
33
+ isActive: boolean;
34
+ language: string;
35
+ presaleLimit: number;
36
+ price: number;
37
+ };
38
+ }
20
39
  export interface IBaseProductSizeEventData {
21
40
  id: string;
22
41
  upc: string;
@@ -29,17 +48,40 @@ export interface IBaseProductSizeEventData {
29
48
  image: string;
30
49
  uom: string;
31
50
  volume: string;
51
+ attributes: IBaseProductSizeAttributesEventData;
32
52
  shippingFulfillments: Record<string, IBaseProductFulfillmentEventData>;
33
53
  onDemandFulfillments: Record<string, IBaseProductFulfillmentEventData>;
34
54
  }
35
55
  export interface IBaseProductEventData {
36
56
  identifier: string;
57
+ selectedSizeId: string | null;
58
+ selectedFulfillmentId: string | null;
59
+ selectedFulfillmentType: FulfillmentType;
37
60
  id: string;
38
61
  name: string;
39
62
  brand: string;
40
- category: string;
41
63
  catPath: string;
64
+ category: string;
42
65
  classification: string;
66
+ type: string;
67
+ salsifyGrouping: string;
68
+ subType: string;
69
+ mainImage: string | null;
70
+ images: string[];
71
+ region: string;
72
+ country: string;
73
+ material: string;
74
+ abv: string;
75
+ proof: string;
76
+ age: string;
77
+ color: string;
78
+ flavor: string;
79
+ variety: string;
80
+ appellation: string;
81
+ vintage: string;
82
+ description: string;
83
+ htmlDescription: string;
84
+ tastingNotes: string;
43
85
  priceInfo: {
44
86
  min: number;
45
87
  max: number;
@@ -1,12 +1,12 @@
1
1
  import type { IClientConfigs } from '@/core/client/client-config.service';
2
- import type { LiquidCommerceElementsClientConstructor } from '@/interfaces/core.interface';
2
+ import type { LiquidCommerceElementsBuilderClientConstructor, LiquidCommerceElementsClientConstructor } from '@/interfaces/core.interface';
3
3
  export declare class SingletonManager {
4
4
  private static instances;
5
5
  private static clientConstructor;
6
6
  private static getInstances;
7
7
  private constructor();
8
- static setClientConstructor(lceConstructor: LiquidCommerceElementsClientConstructor): void;
9
- static getClientConstructor(): LiquidCommerceElementsClientConstructor | null;
8
+ static setClientConstructor(lceConstructor: LiquidCommerceElementsClientConstructor | LiquidCommerceElementsBuilderClientConstructor): void;
9
+ static getClientConstructor(): LiquidCommerceElementsClientConstructor | LiquidCommerceElementsBuilderClientConstructor | null;
10
10
  static getClassInstance<T>(className: string, instanceCreator: () => T): T;
11
11
  static getClient<T>(clientConfigs: IClientConfigs): Promise<T>;
12
12
  }
@@ -36,6 +36,7 @@ export interface ICartTotalsStore {
36
36
  total: number;
37
37
  shippingFee: number;
38
38
  platformFee: number;
39
+ giftCardTotal: number;
39
40
  engravingFee: number;
40
41
  deliveryFee: number;
41
42
  discounts: number;
@@ -49,20 +49,33 @@ export interface IProductStore {
49
49
  id: string;
50
50
  name: string;
51
51
  brand: string;
52
- category: string;
53
52
  catPath: string;
53
+ category: string;
54
54
  classification: string;
55
55
  type: string;
56
- subType: string;
57
56
  salsifyGrouping: string;
57
+ subType: string;
58
+ mainImage: string | null;
59
+ images: string[];
60
+ region: string;
61
+ country: string;
62
+ material: string;
63
+ abv: string;
64
+ proof: string;
65
+ age: string;
66
+ color: string;
67
+ flavor: string;
68
+ variety: string;
69
+ appellation: string;
70
+ vintage: string;
71
+ description: string;
72
+ htmlDescription: string;
73
+ tastingNotes: string;
58
74
  priceInfo?: {
59
75
  min: number;
60
76
  max: number;
61
77
  avg: number;
62
78
  };
63
- description: string;
64
- htmlDescription: string;
65
- images: string[];
66
79
  quantity: number;
67
80
  sizes: Record<string, IProductSizeStore>;
68
81
  productHasAvailability: boolean;
@@ -76,5 +89,4 @@ export interface IProductStore {
76
89
  error: string | null;
77
90
  drawer: IProductDrawerStore;
78
91
  rerender: boolean;
79
- mainImage: string | null;
80
92
  }
@@ -0,0 +1,49 @@
1
+ import { AuthService } from '@/core/auth.service';
2
+ import { ClientActionService } from '@/core/client/client-action.service';
3
+ import { ClientConfigService, type IClientConfigs } from '@/core/client/client-config.service';
4
+ import { CommandService } from '@/core/command/command.service';
5
+ import { DebugPanelService } from '@/core/debug-panel/debug-panel.service';
6
+ import { FingerPrintService } from '@/core/fingerprint.service';
7
+ import { GoogleTagManagerService } from '@/core/google-tag-manager.service';
8
+ import { LoggerFactory } from '@/core/logger/logger-factory';
9
+ import { StoreService } from '@/core/store';
10
+ import { TelemetryService } from '@/core/telemetry/telemetry.service';
11
+ import { type ComponentType } from '@/enums';
12
+ import type { IInjectedComponent, ILiquidCommerceElementsActions, IProcessInjectElementParams } from '@/interfaces/core.interface';
13
+ import { ApiClientService } from '@/modules/api-client';
14
+ import { ThemeProviderService } from '@/modules/theme-provider';
15
+ export declare abstract class ElementsBaseClient {
16
+ protected readonly authService: AuthService;
17
+ protected readonly clientConfig: ClientConfigService;
18
+ protected readonly store: StoreService;
19
+ protected readonly commands: CommandService;
20
+ protected readonly apiClient: ApiClientService;
21
+ protected readonly themeProvider: ThemeProviderService;
22
+ protected readonly fingerPrintService: FingerPrintService;
23
+ protected readonly googleTagManager: GoogleTagManagerService;
24
+ protected readonly clientAction: ClientActionService;
25
+ protected readonly telemetry: TelemetryService;
26
+ protected readonly debugPanel: DebugPanelService;
27
+ protected readonly logger: ReturnType<typeof LoggerFactory.get>;
28
+ protected clientPrepared: boolean;
29
+ protected componentFactoryInitialized: boolean;
30
+ protected cartDrawerCreated: boolean;
31
+ protected gtmInitialized: boolean;
32
+ protected injectedComponents: Map<string, IInjectedComponent>;
33
+ constructor(clientConfigs: IClientConfigs);
34
+ prepare(): Promise<void>;
35
+ private prepareEssentialServices;
36
+ private deferHeavyInitialization;
37
+ private initializeHeavyServices;
38
+ get actions(): ILiquidCommerceElementsActions;
39
+ protected processInjectElement(params: IProcessInjectElementParams): Promise<IInjectedComponent | null>;
40
+ protected ensureCartDrawerExists(): void;
41
+ protected ensureAllComponentsRegistered(): void;
42
+ protected createInjectedComponentWrapper(containerId: string, type: ComponentType, element: HTMLElement): IInjectedComponent;
43
+ protected rerenderInjectedComponentsByType(type: ComponentType): void;
44
+ protected isElementsEnabled(): boolean;
45
+ protected injectDisabledElementsError(containerId: string, componentName: ComponentType): void;
46
+ private registerEssentialComponents;
47
+ protected registerComponents(): void;
48
+ protected registerAllComponents(): void;
49
+ }
@@ -0,0 +1,2 @@
1
+ import type { ILiquidCommerceElementsBuilderClient, ILiquidCommerceElementsBuilderConfig } from '@/interfaces/core.interface';
2
+ export declare function ElementsBuilder(apiKey: string, config: ILiquidCommerceElementsBuilderConfig): Promise<ILiquidCommerceElementsBuilderClient | null>;
@@ -1 +1,4 @@
1
+ import { type ComponentType } from '@/enums';
1
2
  export declare function deepMergeConfigs<T extends Record<string, any>>(target: T, source: Partial<T>): T;
3
+ export declare const layoutFieldToComponentTypes: Map<string, ComponentType[]>;
4
+ export declare function getComponentTypesForLayoutFields(parentPath: string, layoutFields: Record<string, any>): ComponentType[];
@@ -1,3 +1,4 @@
1
+ export * from './elements-builder-client';
1
2
  export * from './elements-client';
2
3
  export * from './enums';
3
4
  export * from './interfaces/configs';
@@ -1,2 +1,2 @@
1
- import { Elements } from './index';
2
- export { Elements };
1
+ import { Elements, ElementsBuilder } from './index';
2
+ export { Elements, ElementsBuilder };
@@ -153,4 +153,6 @@ export interface IProductPresale {
153
153
  estimatedShipBy: null | string;
154
154
  isActive: boolean;
155
155
  language: string;
156
+ presaleLimit: number;
157
+ price: number;
156
158
  }
@@ -18,6 +18,7 @@ export interface ICheckoutLayout {
18
18
  drawerHeaderText: string;
19
19
  placeOrderButtonText: string;
20
20
  placeOrderButtonShowRequiredFields: boolean;
21
+ checkoutCompleted: ICheckoutCompleted;
21
22
  }
22
23
  export interface ICheckoutCompleted {
23
24
  customLogo: string;
@@ -25,7 +26,6 @@ export interface ICheckoutCompleted {
25
26
  }
26
27
  export interface ICheckoutTheme {
27
28
  backgroundColor: string;
28
- checkoutCompleted: ICheckoutCompleted;
29
29
  }
30
30
  export interface ICheckoutComponent {
31
31
  theme: ICheckoutTheme;
@@ -17,12 +17,17 @@ export interface IClientCustomThemeConfig {
17
17
  cart?: UpdateCartComponent;
18
18
  checkout?: UpdateCheckoutComponent;
19
19
  }
20
+ export interface ILiquidCommerceElementsBuilderConfig {
21
+ env?: ElementsEnv;
22
+ promoTicker?: IPromoTicker[];
23
+ customTheme?: IClientCustomThemeConfig;
24
+ debugMode?: DebugMode;
25
+ }
20
26
  export interface ILiquidCommerceElementsConfig {
21
27
  env?: ElementsEnv;
22
28
  promoTicker?: IPromoTicker[];
23
29
  customTheme?: IClientCustomThemeConfig;
24
30
  proxy?: IElementsProxyConfig;
25
- isBuilder?: boolean;
26
31
  debugMode?: DebugMode;
27
32
  }
28
33
  export interface IInjectProductElement {
@@ -34,17 +39,10 @@ export interface IBuilderInjectElementParams {
34
39
  containerId: string;
35
40
  [key: string]: any;
36
41
  }
37
- export interface ILiquidCommerceElementsBuilderMethod {
38
- updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
39
- updateProductComponent(configs: UpdateProductComponent): Promise<void>;
40
- updateAddressComponent(configs: UpdateAddressComponent): void;
41
- updateCartComponent(configs: UpdateCartComponent): void;
42
- updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
43
- injectElement(params: IBuilderInjectElementParams): Promise<void>;
44
- injectProductElement(params: IInjectProductElement[]): Promise<void>;
45
- injectAddressElement(containerId: string, options?: IAddressOptions): Promise<void>;
46
- injectCartElement(containerId: string): Promise<void>;
47
- injectCheckoutElement(containerId: string): Promise<void>;
42
+ export interface IInjectedComponent {
43
+ getType(): ComponentType;
44
+ getElement(): HTMLElement;
45
+ rerender(): void;
48
46
  }
49
47
  export interface IProcessInjectElementParams {
50
48
  type: ComponentType;
@@ -64,13 +62,30 @@ export interface ILiquidCommerceElementsActions {
64
62
  cart: ICartActions;
65
63
  checkout: ICheckoutActions;
66
64
  }
65
+ export interface ILiquidCommerceElementsBuilderClient {
66
+ updateComponentGlobalConfigs(configs: UpdateComponentGlobalConfigs): Promise<void>;
67
+ updateProductComponent(configs: UpdateProductComponent): Promise<void>;
68
+ updateAddressComponent(configs: UpdateAddressComponent): void;
69
+ updateCartComponent(configs: UpdateCartComponent): void;
70
+ updateCheckoutComponent(configs: UpdateCheckoutComponent): void;
71
+ injectElement(params: IBuilderInjectElementParams): Promise<IInjectedComponent | null>;
72
+ injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
73
+ injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
74
+ injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
75
+ injectCheckoutElement(containerId: string, options?: {
76
+ simulatePresale?: boolean;
77
+ presaleExpiresInMinutes?: number;
78
+ }): Promise<IInjectedComponent | null>;
79
+ actions: ILiquidCommerceElementsActions;
80
+ }
67
81
  export interface ILiquidCommerceElementsClient {
68
- builder: ILiquidCommerceElementsBuilderMethod;
69
- injectProductElement(params: IInjectProductElement[]): Promise<void>;
70
- injectAddressElement(containerId: string, options?: IAddressOptions): Promise<void>;
71
- injectCartElement(containerId: string): Promise<void>;
72
- injectCheckoutElement(containerId: string): Promise<void>;
82
+ injectProductElement(params: IInjectProductElement[]): Promise<IInjectedComponent[]>;
83
+ injectAddressElement(containerId: string, options?: IAddressOptions): Promise<IInjectedComponent | null>;
84
+ injectCartElement(containerId: string): Promise<IInjectedComponent | null>;
85
+ injectCheckoutElement(containerId: string): Promise<IInjectedComponent | null>;
73
86
  ui: ILiquidCommerceElementsUIMethod;
74
87
  actions: ILiquidCommerceElementsActions;
88
+ getInjectedComponents(): Map<string, IInjectedComponent>;
75
89
  }
76
90
  export type LiquidCommerceElementsClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsClient;
91
+ export type LiquidCommerceElementsBuilderClientConstructor = new (clientConfigs: IClientConfigs) => ILiquidCommerceElementsBuilderClient;
@@ -1,5 +1,7 @@
1
1
  export * from './cart-body.component';
2
2
  export * from './cart-footer.component';
3
+ export * from './cart-fulfillment.component';
4
+ export * from './cart-fulfillment.component';
3
5
  export * from './cart-header.component';
4
6
  export * from './cart-item.component';
5
7
  export * from './cart-item-quantity-price.component';
@@ -2,6 +2,7 @@ import type { IFontFamily } from '@/interfaces/configs';
2
2
  export declare class FontManagerService {
3
3
  private googleFontsUrl;
4
4
  private defaultFontFamilies;
5
+ private readonly fontsLinkAttribute;
5
6
  loadGoogleFonts(fonts: IFontFamily[], globalDisplay?: string): void;
6
7
  updateGoogleFonts(fonts: IFontFamily[], globalDisplay?: string): void;
7
8
  private injectGoogleFontsResourceHints;
@@ -2,8 +2,10 @@ import type { ComponentType } from '@/enums';
2
2
  export declare class LceElementComponent extends HTMLElement {
3
3
  private _initialized;
4
4
  protected _container: ShadowRoot | null;
5
+ private _wrappedComponentRerender;
5
6
  constructor();
6
7
  initialize(contentType: ComponentType, contentElement: HTMLElement): void;
8
+ rerender(context?: string): void;
7
9
  private applyBasicStyles;
8
10
  private isCSSStyleSheetSupported;
9
11
  private applyThemeStyles;