@wlloyalty/wll-react-sdk 1.4.0 → 1.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.
package/dist/index.d.ts CHANGED
@@ -685,14 +685,22 @@ type NavigationConfig = {
685
685
  */
686
686
  type EventTypes = 'GROUP_DATA_CHANGED' | 'SECTION_DATA_CHANGED' | 'TILE_DATA_CHANGED' | string;
687
687
 
688
- type Fetcher = <T>(endpoint: string, options?: RequestInit) => Promise<APIResponse<T>>;
688
+ declare enum CoreApiUrl {
689
+ PRODUCTION_EU = "https://api.core.wlloyalty.net/v1",
690
+ PRODUCTION_US = "https://api.core.us.wlloyalty.net/v1",
691
+ STAGING_EU = "https://api.staging.core.wlloyalty.net/v1",
692
+ STAGING_US = "https://api.staging.core.us.wlloyalty.net/v1",
693
+ DEVELOPMENT = "https://localhost:8080/v1"
694
+ }
695
+ type AllowedCoreApiUrl = `${CoreApiUrl}`;
689
696
  type SDKConfig = {
690
697
  apiKey: string;
691
698
  userToken?: string;
692
699
  fetcher?: Fetcher;
693
700
  locale?: string;
694
- environment?: 'PRODUCTION' | 'STAGING' | 'DEVELOPMENT';
701
+ coreApiUrl: AllowedCoreApiUrl;
695
702
  };
703
+ type Fetcher = <T>(endpoint: string, options?: RequestInit) => Promise<APIResponse<T>>;
696
704
  type APIResponse<T> = {
697
705
  status: 'success' | 'error';
698
706
  data: T | null;
@@ -717,4 +725,4 @@ type WllSdkProviderProps = WithChildren & {
717
725
  declare const WllSdkProvider: ({ children, theme: providedTheme, config, navigationConfig, }: WllSdkProviderProps) => JSX.Element;
718
726
  declare const useWllSdk: () => WllSdkContextType;
719
727
 
720
- export { type APIResponse, type Align, type Availability, type Badge, type BadgeDetail, _default$6 as BadgeTile, BadgeTileConfig, BadgeTileType, _default$5 as BannerTile, BannerTileConfig, BaseBanner, type BaseThemeObject, BaseTile, Button, CTALinkTarget, Carousel, CarouselNavButton, Column, _default$4 as ContentTile, ContentTileConfig, type DerivedColors, type DerivedProperties, type DesaturationType, type FlexDirection, FullFlex, Grid, Group, Icon, type ImagePropsNoSource, Indicator, type Justify, Layout, type LayoutProps$1 as LayoutProps, LoadingIndicator, type NavigationConfig, type NavigationType, type PercentageKey, _default$3 as PointsTile, PointsTileConfig, type ProgessType, ProgressBar, ProgressIndicator, ProgressType, ProgressiveImage, Reward, type RewardCategory, _default$2 as RewardCategoryTile, RewardCategoryTileConfig, _default$1 as RewardTile, RewardTileConfig, _default as RoundupTile, RoundupTileConfig, Row, type SDKConfig, Section, SectionHeader, SectionType, type Size, Skeleton, Spacer, type TGroup, type TSection, Text, type ThemeContextType, type ThemeObject, type ThemeProviderProps, TierTileConfig, TierTileType, TierTile as TierTileUpdated, type TierType, type Tile, type TileConfig, TileContainer, TileHeight, type TileSizeInfo, TileType, type Variant, WllSdkProvider, alignMap, justifyMap, useWllSdk };
728
+ export { type APIResponse, type Align, type AllowedCoreApiUrl, type Availability, type Badge, type BadgeDetail, _default$6 as BadgeTile, BadgeTileConfig, BadgeTileType, _default$5 as BannerTile, BannerTileConfig, BaseBanner, type BaseThemeObject, BaseTile, Button, CTALinkTarget, Carousel, CarouselNavButton, Column, _default$4 as ContentTile, ContentTileConfig, CoreApiUrl, type DerivedColors, type DerivedProperties, type DesaturationType, type FlexDirection, FullFlex, Grid, Group, Icon, type ImagePropsNoSource, Indicator, type Justify, Layout, type LayoutProps$1 as LayoutProps, LoadingIndicator, type NavigationConfig, type NavigationType, type PercentageKey, _default$3 as PointsTile, PointsTileConfig, type ProgessType, ProgressBar, ProgressIndicator, ProgressType, ProgressiveImage, Reward, type RewardCategory, _default$2 as RewardCategoryTile, RewardCategoryTileConfig, _default$1 as RewardTile, RewardTileConfig, _default as RoundupTile, RoundupTileConfig, Row, type SDKConfig, Section, SectionHeader, SectionType, type Size, Skeleton, Spacer, type TGroup, type TSection, Text, type ThemeContextType, type ThemeObject, type ThemeProviderProps, TierTileConfig, TierTileType, TierTile as TierTileUpdated, type TierType, type Tile, type TileConfig, TileContainer, TileHeight, type TileSizeInfo, TileType, type Variant, WllSdkProvider, alignMap, justifyMap, useWllSdk };
package/dist/native.js CHANGED
@@ -1523,22 +1523,6 @@ var useNavigation = function (config) {
1523
1523
  return handleNavigation;
1524
1524
  };
1525
1525
 
1526
- var getBaseUrl = function (environment) {
1527
- if (environment === void 0) { environment = 'STAGING'; }
1528
- switch (environment) {
1529
- case 'PRODUCTION':
1530
- return 'https://api.core.wlloyalty.net/v1';
1531
- case 'PRODUCTION-US':
1532
- return 'https://api.core.us.wlloyalty.net/v1';
1533
- case 'STAGING-US':
1534
- return 'https://api.core.wlloyalty.net/v1';
1535
- case 'DEVELOPMENT':
1536
- return 'https://localhost:8080/v1';
1537
- case 'STAGING':
1538
- default:
1539
- return 'https://api.staging.core.wlloyalty.net/v1';
1540
- }
1541
- };
1542
1526
  var useCreateRequestOptions = function (config) {
1543
1527
  return React.useCallback(function (options) {
1544
1528
  if (options === void 0) { options = {}; }
@@ -1601,11 +1585,10 @@ var createResourceGetter = function (resource, includeHydrate) {
1601
1585
  }
1602
1586
  // Always append locale=en
1603
1587
  params.append('locale', config.locale || 'en');
1604
- var env = config.environment || 'STAGING';
1605
- var baseUrl = getBaseUrl(env);
1588
+ var baseUrl = config.coreApiUrl;
1606
1589
  var queryString = params.toString();
1607
1590
  return makeRequest("".concat(baseUrl, "/tiles-management/").concat(resource, "/").concat(id).concat(queryString ? "?".concat(queryString) : ''));
1608
- }, [makeRequest, config.environment]);
1591
+ }, [makeRequest, resource, includeHydrate, config.coreApiUrl, config.locale]);
1609
1592
  };
1610
1593
  };
1611
1594
  var useGetGroupByID = createResourceGetter('groups', true);
@@ -2018,6 +2001,14 @@ function useResponsive() {
2018
2001
  return context;
2019
2002
  }
2020
2003
 
2004
+ exports.CoreApiUrl = void 0;
2005
+ (function (CoreApiUrl) {
2006
+ CoreApiUrl["PRODUCTION_EU"] = "https://api.core.wlloyalty.net/v1";
2007
+ CoreApiUrl["PRODUCTION_US"] = "https://api.core.us.wlloyalty.net/v1";
2008
+ CoreApiUrl["STAGING_EU"] = "https://api.staging.core.wlloyalty.net/v1";
2009
+ CoreApiUrl["STAGING_US"] = "https://api.staging.core.us.wlloyalty.net/v1";
2010
+ CoreApiUrl["DEVELOPMENT"] = "https://localhost:8080/v1";
2011
+ })(exports.CoreApiUrl || (exports.CoreApiUrl = {}));
2021
2012
  var createTheme = function (baseTheme) {
2022
2013
  if (baseTheme === void 0) { baseTheme = {}; }
2023
2014
  var mergedTheme = __assign(__assign({}, defaultTheme), baseTheme);
@@ -2107,9 +2098,6 @@ var validateConfig = function (config) {
2107
2098
  if (config.locale && !/^[a-z]{2}$/.test(config.locale)) {
2108
2099
  throw new Error('Invalid locale format. Expected ISO 639-1 language code (e.g. "en")');
2109
2100
  }
2110
- if (!config.environment) {
2111
- config.environment = 'STAGING';
2112
- }
2113
2101
  };
2114
2102
 
2115
2103
  function createVariantSystem(baseStyle, variantStyles) {