@techstuff-dev/foundation-api-utils 1.33.0 → 1.34.1

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.esm.js CHANGED
@@ -4,7 +4,6 @@ import { createSlice, createSelector, combineSlices, configureStore } from '@red
4
4
  import { jwtDecode } from 'jwt-decode';
5
5
  import { useSelector, useDispatch, useStore } from 'react-redux';
6
6
  import { useMemo } from 'react';
7
- import { persistReducer, FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER } from 'redux-persist';
8
7
  import createWebStorage from 'redux-persist/lib/storage/createWebStorage';
9
8
 
10
9
  /******************************************************************************
@@ -898,14 +897,12 @@ var authDataBaseQueryWithReauth = function (args, api, extraOptions) { return __
898
897
  case 0: return [4 /*yield*/, authDataBaseQuery(args, api, extraOptions)];
899
898
  case 1:
900
899
  result = _b.sent();
901
- console.log('authDataBaseQueryWithReauth: ', result);
902
900
  if (!(((_a = result === null || result === void 0 ? void 0 : result.error) === null || _a === void 0 ? void 0 : _a.status) === 401)) return [3 /*break*/, 6];
903
901
  return [4 /*yield*/, Auth.currentAuthenticatedUser({
904
902
  bypassCache: true, // Ensures that the user is refreshed from the server
905
903
  })];
906
904
  case 2:
907
905
  authSession = _b.sent();
908
- console.log('authDataBaseQueryWithReauth: ', authSession);
909
906
  user = formatAuthSession(authSession);
910
907
  api.dispatch(setCredentials(user));
911
908
  if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
@@ -1226,7 +1223,6 @@ var dataBaseQuery = fetchBaseQuery({
1226
1223
  return [4 /*yield*/, Auth.currentSession()];
1227
1224
  case 1:
1228
1225
  session = _c.sent();
1229
- console.log('session', session);
1230
1226
  idToken = session.getIdToken().getJwtToken();
1231
1227
  accessToken = session.getAccessToken().getJwtToken();
1232
1228
  if (accessToken && idToken) {
@@ -1251,7 +1247,6 @@ var dataBaseQueryWithReauth = function (args, api, extraOptions) { return __awai
1251
1247
  case 0: return [4 /*yield*/, dataBaseQuery(args, api, extraOptions)];
1252
1248
  case 1:
1253
1249
  result = _b.sent();
1254
- console.log('result', result);
1255
1250
  if (!(((_a = result === null || result === void 0 ? void 0 : result.error) === null || _a === void 0 ? void 0 : _a.status) === 401)) return [3 /*break*/, 6];
1256
1251
  return [4 /*yield*/, Auth.currentAuthenticatedUser({
1257
1252
  bypassCache: true, // Ensures that the user is refreshed from the server
@@ -1338,7 +1333,6 @@ var cartSlice = createSlice({
1338
1333
  return __assign(__assign({}, state), { taxRate: action.payload, taxAmount: taxAmount, grossTotal: grossTotal });
1339
1334
  },
1340
1335
  resetTaxRate: function (state, action) {
1341
- console.log('resetTaxRate', action);
1342
1336
  return __assign(__assign({}, state), { taxRate: {
1343
1337
  country: 'none',
1344
1338
  percentage: 0,
@@ -1357,7 +1351,6 @@ var cartSlice = createSlice({
1357
1351
  }, taxAmount: taxAmount, grossTotal: grossTotal });
1358
1352
  },
1359
1353
  removePromoCode: function (state, action) {
1360
- console.log('removePromoCode', action);
1361
1354
  var netTotal = state.netTotal, taxRate = state.taxRate;
1362
1355
  var taxAmount = applyTax(taxRate, netTotal);
1363
1356
  var grossTotal = netTotal + taxAmount;
@@ -1432,6 +1425,7 @@ var useAppDispatch = isWeb ? useDispatch.withTypes() : useDispatch.withTypes();
1432
1425
  var useAppSelector = isWeb ? useSelector.withTypes() : useSelector.withTypes();
1433
1426
  var useAppStore = isWeb ? useStore.withTypes() : useStore.withTypes();
1434
1427
 
1428
+ // @ts-expect-error - required for module alias
1435
1429
  function createPersistStorage() {
1436
1430
  var isServer = typeof window === 'undefined';
1437
1431
  // Returns noop (dummy) storage.
@@ -1461,27 +1455,9 @@ var storageBlackList = [];
1461
1455
  // server-side rendering (SSR) scenarios. In SSR, separate store instances
1462
1456
  // are needed for each request to prevent cross-request state pollution.
1463
1457
  var makeNativeStore = function () {
1464
- var storage = require('@react-native-async-storage/async-storage').default;
1465
- storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath, ordersApi.reducerPath);
1466
- var persistConfig = {
1467
- key: 'root',
1468
- storage: storage,
1469
- // whitelist: storageWhiteList,
1470
- blacklist: storageBlackList,
1471
- };
1472
- var middlewares = [
1473
- authApi.middleware,
1474
- contentApi.middleware,
1475
- paymentApi.middleware,
1476
- ordersApi.middleware,
1477
- ];
1478
- // `combineSlices` automatically combines the reducers using
1479
- // their `reducerPath`s, therefore we no longer need to call `combineReducers`.
1480
- var persistedReducer = persistReducer(persistConfig, rootReducer);
1481
1458
  var customEnhancers = [];
1482
1459
  // Make sure compilation stops in next.js web app.
1483
- if (!process.env.NEXT_PUBLIC_WEB_APP &&
1484
- process.env.NODE_ENV === 'development') {
1460
+ if (!isWeb && process.env.NODE_ENV === 'development') {
1485
1461
  var Reactotron = require('reactotron-react-native').default;
1486
1462
  var reactotronRedux = require('reactotron-redux').reactotronRedux;
1487
1463
  var reactotron = Reactotron.configure({ name: 'nrgAtHome' })
@@ -1491,8 +1467,45 @@ var makeNativeStore = function () {
1491
1467
  // Add reactotron to the native DEV store.
1492
1468
  customEnhancers.push(reactotron.createEnhancer());
1493
1469
  }
1470
+ var Platform = require('react-native').Platform;
1471
+ var reducer;
1472
+ var FLUSH;
1473
+ var REHYDRATE;
1474
+ var PAUSE;
1475
+ var PERSIST;
1476
+ var PURGE;
1477
+ var REGISTER;
1478
+ if (Platform.OS !== 'web' && !Platform.isTV) {
1479
+ var reduxPersist = require('redux-persist');
1480
+ var persistReducer = require('redux-persist').persistReducer;
1481
+ FLUSH = reduxPersist.FLUSH;
1482
+ REHYDRATE = reduxPersist.REHYDRATE;
1483
+ PAUSE = reduxPersist.PAUSE;
1484
+ PERSIST = reduxPersist.PERSIST;
1485
+ PURGE = reduxPersist.PURGE;
1486
+ REGISTER = reduxPersist.REGISTER;
1487
+ storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath, ordersApi.reducerPath);
1488
+ var storage = require('@react-native-async-storage/async-storage').default;
1489
+ var persistConfig = {
1490
+ key: 'root',
1491
+ storage: storage,
1492
+ // whitelist: storageWhiteList,
1493
+ blacklist: storageBlackList,
1494
+ };
1495
+ var persistedReducer = persistReducer(persistConfig, rootReducer);
1496
+ reducer = persistedReducer;
1497
+ }
1498
+ else {
1499
+ reducer = rootReducer;
1500
+ }
1501
+ var middlewares = [
1502
+ authApi.middleware,
1503
+ contentApi.middleware,
1504
+ paymentApi.middleware,
1505
+ ordersApi.middleware,
1506
+ ];
1494
1507
  return configureStore({
1495
- reducer: persistedReducer,
1508
+ reducer: reducer,
1496
1509
  // Adding the api middleware enables caching, invalidation, polling,
1497
1510
  // and other useful features of `rtk-query`.
1498
1511
  middleware: function (getDefaultMiddleware) {
@@ -1510,6 +1523,14 @@ var makeNativeStore = function () {
1510
1523
  });
1511
1524
  };
1512
1525
  var makeWebStore = function () {
1526
+ var reduxPersist = require('redux-persist');
1527
+ var persistReducer = require('redux-persist').persistReducer;
1528
+ var FLUSH = reduxPersist.FLUSH;
1529
+ var REHYDRATE = reduxPersist.REHYDRATE;
1530
+ var PAUSE = reduxPersist.PAUSE;
1531
+ var PERSIST = reduxPersist.PERSIST;
1532
+ var PURGE = reduxPersist.PURGE;
1533
+ var REGISTER = reduxPersist.REGISTER;
1513
1534
  var storage = createPersistStorage();
1514
1535
  storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath, ordersApi.reducerPath);
1515
1536
  var persistConfig = {