@liquidcommerce/elements-sdk 2.5.6-beta.20 → 2.5.6-beta.21

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 { AuthService } from '@/core/auth.service';
1
+ import type { AuthClientService } from '@/core/api/auth-client.service';
2
2
  import type { IPersistedStore } from '@/core/store/interfaces/core.interface';
3
3
  import type { IAddressAutocompleteResult, IAddressDetailsResult, ICart, ICartUpdateParams, ICatalog, ICatalogParams, ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutPrepareParams, ICheckoutPrepareResponse, ILiquidPaymentToken, ILoc, IProductData } from '@/interfaces/cloud';
4
4
  import type { IUserPaymentSession, IUserSession } from '@/interfaces/cloud/user.interface';
@@ -8,7 +8,7 @@ export declare class ApiClientService {
8
8
  private readonly logger;
9
9
  constructor();
10
10
  static getInstance(): ApiClientService;
11
- setClient(client: AuthService): Promise<void>;
11
+ setClient(client: AuthClientService): Promise<void>;
12
12
  getAllConfigs(): Promise<IAllConfigs>;
13
13
  setPersistedStore(userDeviceId: string, data: IPersistedStore): Promise<void>;
14
14
  getPersistedStore(userDeviceId: string): Promise<IPersistedStore | null>;
@@ -29,7 +29,7 @@ export interface IApiResponseBase {
29
29
  export type IApiResponseWithData<T> = IApiResponseBase & {
30
30
  data: T;
31
31
  };
32
- export declare class AuthService {
32
+ export declare class AuthClientService {
33
33
  private readonly apiKey;
34
34
  private readonly baseUrl;
35
35
  private readonly env;
@@ -40,7 +40,7 @@ export declare class AuthService {
40
40
  private readonly logger;
41
41
  private readonly clientConfig;
42
42
  private constructor();
43
- static getInstance(config: IAuthConfig): AuthService;
43
+ static getInstance(config: IAuthConfig): AuthClientService;
44
44
  authenticate(): Promise<boolean>;
45
45
  isTokenExpired(): boolean;
46
46
  private request;
@@ -0,0 +1,45 @@
1
+ export type FetchFunction = typeof fetch;
2
+ export interface IHttpClientOptions {
3
+ method: string;
4
+ headers: Record<string, string>;
5
+ body?: string;
6
+ }
7
+ export interface ICustomResponse {
8
+ ok: boolean;
9
+ status: number;
10
+ statusText: string;
11
+ headers: Record<string, string>;
12
+ json: () => Promise<any>;
13
+ text: () => Promise<string>;
14
+ _bodyText?: string;
15
+ }
16
+ export interface IRequestOptions {
17
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
18
+ headers?: Record<string, string>;
19
+ body?: any;
20
+ }
21
+ export interface IHttpRequestConfig {
22
+ url: string;
23
+ options: IHttpClientOptions;
24
+ retryConfig?: {
25
+ maxRetries: number;
26
+ retryDelay: number;
27
+ shouldRetry?: (error: any, response?: ICustomResponse) => boolean;
28
+ };
29
+ }
30
+ export declare class HttpClientService {
31
+ private readonly fetchImpl;
32
+ private readonly logger;
33
+ constructor();
34
+ request(config: IHttpRequestConfig): Promise<ICustomResponse>;
35
+ private defaultShouldRetry;
36
+ private logFailedResponse;
37
+ private logNetworkError;
38
+ private diagnosePossibleCauses;
39
+ private enhanceError;
40
+ private sanitizeHeaders;
41
+ private delay;
42
+ private getFetchImplementation;
43
+ private fetchAdapter;
44
+ private xhrFetch;
45
+ }
@@ -1,4 +1,4 @@
1
- import { ApiClientService } from '@/core/api-client.service';
1
+ import { ApiClientService } from '@/core/api/api-client.service';
2
2
  import { ClientConfigService } from '@/core/client/client-config.service';
3
3
  import { GoogleTagManagerService } from '@/core/google-tag-manager.service';
4
4
  import { LoggerFactory } from '@/core/logger/logger-factory';
@@ -1,5 +1,5 @@
1
- import { ApiClientService } from '@/core/api-client.service';
2
- import { AuthService } from '@/core/auth.service';
1
+ import { ApiClientService } from '@/core/api/api-client.service';
2
+ import { AuthClientService } from '@/core/api/auth-client.service';
3
3
  import { ClientActionService } from '@/core/client/client-action.service';
4
4
  import { ClientConfigService, type IClientConfigs } from '@/core/client/client-config.service';
5
5
  import { CommandService } from '@/core/command/command.service';
@@ -13,7 +13,7 @@ import { type ComponentType } from '@/enums';
13
13
  import type { IInjectedComponent, IInjectProductElement, IInjectProductListParams, ILiquidCommerceElementsActions, IProcessInjectElementParams } from '@/interfaces/core.interface';
14
14
  import { ThemeProviderService } from '@/modules/theme-provider/theme-provider.service';
15
15
  export declare abstract class ElementsBaseClient {
16
- protected readonly authService: AuthService;
16
+ protected readonly authClient: AuthClientService;
17
17
  protected readonly clientConfig: ClientConfigService;
18
18
  protected readonly store: StoreService;
19
19
  protected readonly commands: CommandService;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "LiquidCommerce Elements SDK",
4
4
  "license": "UNLICENSED",
5
5
  "author": "LiquidCommerce Team",
6
- "version": "2.5.6-beta.20",
6
+ "version": "2.5.6-beta.21",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",