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