@techstuff-dev/foundation-api-utils 1.47.0 → 1.49.0
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/cjs/chunks/index-CfrYa4U_.js +9 -0
- package/dist/cjs/chunks/index-CfrYa4U_.js.map +1 -0
- package/dist/cjs/chunks/shared-2Qy1c7Qz.js +19 -0
- package/dist/cjs/chunks/shared-2Qy1c7Qz.js.map +1 -0
- package/dist/cjs/chunks/slice-CkWobkWw.js +125 -0
- package/dist/cjs/chunks/slice-CkWobkWw.js.map +1 -0
- package/dist/{index.js → cjs/chunks/slice-DsZzY7T7.js} +618 -875
- package/dist/cjs/chunks/slice-DsZzY7T7.js.map +1 -0
- package/dist/cjs/chunks/useAuth-DKhvUX_r.js +13 -0
- package/dist/cjs/chunks/useAuth-DKhvUX_r.js.map +1 -0
- package/dist/cjs/hooks/index.native.js +19 -0
- package/dist/cjs/hooks/index.native.js.map +1 -0
- package/dist/cjs/hooks/index.web.js +19 -0
- package/dist/cjs/hooks/index.web.js.map +1 -0
- package/dist/cjs/index.js +96 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/store/index.native.js +415 -0
- package/dist/cjs/store/index.native.js.map +1 -0
- package/dist/cjs/store/index.web.js +188 -0
- package/dist/cjs/store/index.web.js.map +1 -0
- package/dist/esm/chunks/index-KjhWa1AL.js +6 -0
- package/dist/esm/chunks/index-KjhWa1AL.js.map +1 -0
- package/dist/esm/chunks/shared--CrxBBZ8.js +16 -0
- package/dist/esm/chunks/shared--CrxBBZ8.js.map +1 -0
- package/dist/{index.esm.js → esm/chunks/slice-3o-PH5Gz.js} +619 -855
- package/dist/esm/chunks/slice-3o-PH5Gz.js.map +1 -0
- package/dist/esm/chunks/slice-ChJ8ZvmP.js +107 -0
- package/dist/esm/chunks/slice-ChJ8ZvmP.js.map +1 -0
- package/dist/esm/chunks/useAuth-8d6DlERn.js +11 -0
- package/dist/esm/chunks/useAuth-8d6DlERn.js.map +1 -0
- package/dist/esm/hooks/index.native.js +14 -0
- package/dist/esm/hooks/index.native.js.map +1 -0
- package/dist/esm/hooks/index.web.js +14 -0
- package/dist/esm/hooks/index.web.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/store/index.native.js +412 -0
- package/dist/esm/store/index.native.js.map +1 -0
- package/dist/esm/store/index.web.js +185 -0
- package/dist/esm/store/index.web.js.map +1 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/index-BDQnFTra.d.ts +1299 -0
- package/dist/{index.d.ts → types/index.d.ts} +64 -1301
- package/dist/types/store/index.d.ts +3 -0
- package/package.json +37 -9
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/api/index.d.ts +0 -21
- package/dist/lib/hooks/index.d.ts +0 -4
- package/dist/lib/hooks/useAuth.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -6
- package/dist/lib/services/auth/index.d.ts +0 -2027
- package/dist/lib/services/auth/slice.d.ts +0 -91
- package/dist/lib/services/cart/slice.d.ts +0 -155
- package/dist/lib/services/content/content.interfaces.d.ts +0 -801
- package/dist/lib/services/content/index.d.ts +0 -532
- package/dist/lib/services/index.d.ts +0 -7
- package/dist/lib/services/orders/index.d.ts +0 -271
- package/dist/lib/services/payment/index.d.ts +0 -1063
- package/dist/lib/store/index.d.ts +0 -2
- package/dist/lib/store/index.native.d.ts +0 -68
- package/dist/lib/store/index.web.d.ts +0 -68
- package/dist/lib/store/storage.d.ts +0 -2
- package/dist/lib/types/index.interfaces.d.ts +0 -428
- package/dist/lib/utils/dataFormat/index.d.ts +0 -86
- package/dist/lib/utils/helpers/index.d.ts +0 -14
- package/dist/node_modules/@reduxjs/toolkit/dist/uncheckedindexed.d.ts +0 -5
|
@@ -1,92 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var awsAmplify = require('aws-amplify');
|
|
4
|
+
var slice = require('./slice-CkWobkWw.js');
|
|
3
5
|
var toolkit = require('@reduxjs/toolkit');
|
|
4
6
|
var reactRedux = require('react-redux');
|
|
5
7
|
var React = require('react');
|
|
6
|
-
var awsAmplify = require('aws-amplify');
|
|
7
8
|
var jwtDecode = require('jwt-decode');
|
|
8
|
-
var reactNative = require('react-native');
|
|
9
|
-
|
|
10
|
-
/******************************************************************************
|
|
11
|
-
Copyright (c) Microsoft Corporation.
|
|
12
|
-
|
|
13
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
-
purpose with or without fee is hereby granted.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
-
***************************************************************************** */
|
|
24
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var __assign = function() {
|
|
28
|
-
__assign = Object.assign || function __assign(t) {
|
|
29
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
30
|
-
s = arguments[i];
|
|
31
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
34
|
-
};
|
|
35
|
-
return __assign.apply(this, arguments);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
39
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function __generator(thisArg, body) {
|
|
49
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
50
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
51
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
52
|
-
function step(op) {
|
|
53
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
54
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
55
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
56
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
57
|
-
switch (op[0]) {
|
|
58
|
-
case 0: case 1: t = op; break;
|
|
59
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
60
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
61
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
62
|
-
default:
|
|
63
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
64
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
65
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
66
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
67
|
-
if (t[2]) _.ops.pop();
|
|
68
|
-
_.trys.pop(); continue;
|
|
69
|
-
}
|
|
70
|
-
op = body.call(thisArg, _);
|
|
71
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
72
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function __spreadArray(to, from, pack) {
|
|
77
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
78
|
-
if (ar || !(i in from)) {
|
|
79
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
80
|
-
ar[i] = from[i];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
87
|
-
var e = new Error(message);
|
|
88
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
89
|
-
};
|
|
90
9
|
|
|
91
10
|
// src/utils/env.ts
|
|
92
11
|
var NOTHING = Symbol.for("immer-nothing");
|
|
@@ -2431,7 +2350,7 @@ function updateMutationSubstateIfExists(state, id, update) {
|
|
|
2431
2350
|
update(substate);
|
|
2432
2351
|
}
|
|
2433
2352
|
}
|
|
2434
|
-
var initialState$
|
|
2353
|
+
var initialState$1 = {};
|
|
2435
2354
|
function buildSlice({
|
|
2436
2355
|
reducerPath,
|
|
2437
2356
|
queryThunk,
|
|
@@ -2507,7 +2426,7 @@ function buildSlice({
|
|
|
2507
2426
|
}
|
|
2508
2427
|
const querySlice = toolkit.createSlice({
|
|
2509
2428
|
name: `${reducerPath}/queries`,
|
|
2510
|
-
initialState: initialState$
|
|
2429
|
+
initialState: initialState$1,
|
|
2511
2430
|
reducers: {
|
|
2512
2431
|
removeQueryResult: {
|
|
2513
2432
|
reducer(draft, {
|
|
@@ -2641,7 +2560,7 @@ function buildSlice({
|
|
|
2641
2560
|
});
|
|
2642
2561
|
const mutationSlice = toolkit.createSlice({
|
|
2643
2562
|
name: `${reducerPath}/mutations`,
|
|
2644
|
-
initialState: initialState$
|
|
2563
|
+
initialState: initialState$1,
|
|
2645
2564
|
reducers: {
|
|
2646
2565
|
removeMutationResult: {
|
|
2647
2566
|
reducer(draft, {
|
|
@@ -2810,7 +2729,7 @@ function buildSlice({
|
|
|
2810
2729
|
}
|
|
2811
2730
|
const subscriptionSlice = toolkit.createSlice({
|
|
2812
2731
|
name: `${reducerPath}/subscriptions`,
|
|
2813
|
-
initialState: initialState$
|
|
2732
|
+
initialState: initialState$1,
|
|
2814
2733
|
reducers: {
|
|
2815
2734
|
updateSubscriptionOptions(d, a) {
|
|
2816
2735
|
},
|
|
@@ -2822,7 +2741,7 @@ function buildSlice({
|
|
|
2822
2741
|
});
|
|
2823
2742
|
const internalSubscriptionsSlice = toolkit.createSlice({
|
|
2824
2743
|
name: `${reducerPath}/internalSubscriptions`,
|
|
2825
|
-
initialState: initialState$
|
|
2744
|
+
initialState: initialState$1,
|
|
2826
2745
|
reducers: {
|
|
2827
2746
|
subscriptionsUpdated: {
|
|
2828
2747
|
reducer(state, action) {
|
|
@@ -4765,110 +4684,30 @@ Hook ${hookName} was either not provided or not a function.`);
|
|
|
4765
4684
|
// src/query/react/index.ts
|
|
4766
4685
|
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
|
4767
4686
|
|
|
4768
|
-
var _a$2, _b$2;
|
|
4769
|
-
var initialState$1 = {
|
|
4770
|
-
authenticated: false,
|
|
4771
|
-
verifying: false,
|
|
4772
|
-
user: {
|
|
4773
|
-
details: {
|
|
4774
|
-
userSub: '',
|
|
4775
|
-
uuid: '',
|
|
4776
|
-
subscription: '',
|
|
4777
|
-
subscriptionDetails: undefined,
|
|
4778
|
-
firstName: '',
|
|
4779
|
-
lastName: '',
|
|
4780
|
-
userEmail: '',
|
|
4781
|
-
termsAccepted: '',
|
|
4782
|
-
contactPreference: false,
|
|
4783
|
-
dateOfBirth: '',
|
|
4784
|
-
picture: '',
|
|
4785
|
-
},
|
|
4786
|
-
accessToken: '',
|
|
4787
|
-
idToken: '',
|
|
4788
|
-
accessTokenExpiry: null,
|
|
4789
|
-
refreshToken: '',
|
|
4790
|
-
email: '',
|
|
4791
|
-
sub: '',
|
|
4792
|
-
},
|
|
4793
|
-
loading: false,
|
|
4794
|
-
error: false,
|
|
4795
|
-
session: undefined,
|
|
4796
|
-
};
|
|
4797
|
-
var authSlice = toolkit.createSlice({
|
|
4798
|
-
name: 'auth',
|
|
4799
|
-
initialState: initialState$1,
|
|
4800
|
-
reducers: {
|
|
4801
|
-
setCredentials: function (state, data) {
|
|
4802
|
-
return __assign(__assign({}, state), { session: data.payload.accessToken, authenticated: true, verifying: true, user: __assign(__assign({}, state.user), data.payload) });
|
|
4803
|
-
},
|
|
4804
|
-
resetCreating: function (state) {
|
|
4805
|
-
return __assign(__assign({}, state), { creating: {
|
|
4806
|
-
details: '',
|
|
4807
|
-
payment: '',
|
|
4808
|
-
} });
|
|
4809
|
-
},
|
|
4810
|
-
updateSubscription: function (state, data) {
|
|
4811
|
-
return __assign(__assign({}, state), { user: __assign(__assign({}, state.user), { details: __assign(__assign({}, state.user.details), { customerId: data.payload.customerId, subscription: data.payload.subscription, subscriptionDetails: data.payload.subscriptionDetails }) }) });
|
|
4812
|
-
},
|
|
4813
|
-
logout: function () { return initialState$1; },
|
|
4814
|
-
},
|
|
4815
|
-
selectors: {
|
|
4816
|
-
isAuthenticated: function (auth) { return auth.authenticated; },
|
|
4817
|
-
selectAccessToken: function (auth) { return auth.user.accessToken; },
|
|
4818
|
-
selectRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
4819
|
-
selectCurrentUser: function (auth) { return auth.user.details; },
|
|
4820
|
-
isVerifying: function (auth) { return auth.verifying; },
|
|
4821
|
-
getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
|
|
4822
|
-
// TODO: override this selector directly in the CNBCMEDIA app.
|
|
4823
|
-
selectCurrentUserSub: function (auth) { var _a, _b, _c; return ((_c = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c["custom:legacySub"]) || auth.user.sub; },
|
|
4824
|
-
selectCurrentUserRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
4825
|
-
selectUserTokens: function (auth) {
|
|
4826
|
-
return {
|
|
4827
|
-
accessToken: auth.user.accessToken,
|
|
4828
|
-
refreshToken: auth.user.refreshToken,
|
|
4829
|
-
idToken: auth.user.idToken,
|
|
4830
|
-
};
|
|
4831
|
-
},
|
|
4832
|
-
selectUserSubscriptionStatus: function (auth) {
|
|
4833
|
-
var _a, _b, _c;
|
|
4834
|
-
return (_c = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.subscriptionDetails) === null || _c === void 0 ? void 0 : _c.status;
|
|
4835
|
-
},
|
|
4836
|
-
selectSubscription: function (auth) {
|
|
4837
|
-
var _a, _b;
|
|
4838
|
-
return (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.subscriptionDetails;
|
|
4839
|
-
},
|
|
4840
|
-
selectSubscriptionPrice: function (auth) {
|
|
4841
|
-
var _a, _b, _c;
|
|
4842
|
-
return (_c = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.subscriptionDetails) === null || _c === void 0 ? void 0 : _c.amount;
|
|
4843
|
-
},
|
|
4844
|
-
},
|
|
4845
|
-
});
|
|
4846
|
-
// Action creators are generated for each case reducer function.
|
|
4847
|
-
var setCredentials = (_a$2 = authSlice.actions, _a$2.setCredentials), resetCreating = _a$2.resetCreating, logout = _a$2.logout, updateSubscription = _a$2.updateSubscription;
|
|
4848
|
-
// Selectors returned by `slice.selectors` take the root state as their first argument.
|
|
4849
|
-
var isAuthenticated = (_b$2 = authSlice.selectors, _b$2.isAuthenticated), selectAccessToken = _b$2.selectAccessToken, selectRefreshToken = _b$2.selectRefreshToken, selectCurrentUser = _b$2.selectCurrentUser, isVerifying = _b$2.isVerifying, getUserSession = _b$2.getUserSession, selectCurrentUserSub = _b$2.selectCurrentUserSub, selectCurrentUserRefreshToken = _b$2.selectCurrentUserRefreshToken, selectUserTokens = _b$2.selectUserTokens, selectUserSubscriptionStatus = _b$2.selectUserSubscriptionStatus, selectSubscription = _b$2.selectSubscription, selectSubscriptionPrice = _b$2.selectSubscriptionPrice;
|
|
4850
|
-
authSlice.reducer;
|
|
4851
|
-
|
|
4852
4687
|
function applyCoupon(coupon, netTotal) {
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4688
|
+
const discountedAmount = netTotal * (Number(coupon.discount) / 100);
|
|
4689
|
+
const discountedTotal = netTotal - discountedAmount;
|
|
4690
|
+
const data = {
|
|
4691
|
+
...coupon,
|
|
4692
|
+
discountedTotal,
|
|
4693
|
+
discountedAmount,
|
|
4694
|
+
};
|
|
4856
4695
|
return data;
|
|
4857
4696
|
}
|
|
4858
4697
|
function applyTax(taxRate, netTotal) {
|
|
4859
|
-
|
|
4698
|
+
const taxAmount = netTotal * (taxRate.percentage / 100);
|
|
4860
4699
|
return taxAmount;
|
|
4861
4700
|
}
|
|
4862
4701
|
function toCamelCaseObject(obj) {
|
|
4863
|
-
|
|
4864
|
-
return str.replace(/([-_][a-z])/gi,
|
|
4702
|
+
const toCamelCase = (str) => {
|
|
4703
|
+
return str.replace(/([-_][a-z])/gi, (match) => {
|
|
4865
4704
|
return match.toUpperCase().replace(/[-_]/, '');
|
|
4866
4705
|
});
|
|
4867
4706
|
};
|
|
4868
|
-
|
|
4869
|
-
for (
|
|
4707
|
+
const camelCaseObject = {};
|
|
4708
|
+
for (const key in obj) {
|
|
4870
4709
|
if (obj.hasOwnProperty(key)) {
|
|
4871
|
-
|
|
4710
|
+
const camelKey = toCamelCase(key);
|
|
4872
4711
|
camelCaseObject[camelKey] = obj[key];
|
|
4873
4712
|
}
|
|
4874
4713
|
}
|
|
@@ -4876,44 +4715,43 @@ function toCamelCaseObject(obj) {
|
|
|
4876
4715
|
}
|
|
4877
4716
|
|
|
4878
4717
|
// TODO: typing.
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4718
|
+
const formatUserPayload = (payload) => {
|
|
4719
|
+
const { email: userEmail, given_name: firstName, family_name: lastName, birthdate: dateOfBirth, picture: picture, 'cognito:username': uuid, 'custom:termsAccepted': termsAccepted, 'custom:subscriptionId': subscriptionId, 'custom:contactPreferences': contactPreference, 'custom:customerId': customerId, } = payload;
|
|
4720
|
+
const parsedTermsAccepted = termsAccepted ? JSON.parse(termsAccepted) : null;
|
|
4721
|
+
const parsedContactPreference = contactPreference
|
|
4883
4722
|
? JSON.parse(contactPreference)
|
|
4884
4723
|
: null;
|
|
4885
|
-
|
|
4886
|
-
userEmail
|
|
4887
|
-
lastName
|
|
4888
|
-
firstName
|
|
4889
|
-
dateOfBirth
|
|
4724
|
+
const data = {
|
|
4725
|
+
userEmail,
|
|
4726
|
+
lastName,
|
|
4727
|
+
firstName,
|
|
4728
|
+
dateOfBirth,
|
|
4890
4729
|
/** Handles the auth micro service/Cognito serving boolean options as a string. */
|
|
4891
4730
|
termsAccepted: parsedTermsAccepted,
|
|
4892
4731
|
contactPreference: parsedContactPreference,
|
|
4893
|
-
uuid
|
|
4732
|
+
uuid,
|
|
4894
4733
|
subscription: subscriptionId || null,
|
|
4895
|
-
customerId
|
|
4896
|
-
picture
|
|
4734
|
+
customerId,
|
|
4735
|
+
picture,
|
|
4897
4736
|
};
|
|
4898
4737
|
return data;
|
|
4899
4738
|
};
|
|
4900
4739
|
function formatPromos(data) {
|
|
4901
|
-
return data.map(
|
|
4902
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
4740
|
+
return data.map((item) => {
|
|
4903
4741
|
return {
|
|
4904
|
-
uuid:
|
|
4905
|
-
id:
|
|
4906
|
-
title:
|
|
4907
|
-
image:
|
|
4908
|
-
imageFormatted:
|
|
4909
|
-
description:
|
|
4910
|
-
created:
|
|
4911
|
-
updated:
|
|
4912
|
-
weight:
|
|
4913
|
-
buttonText:
|
|
4914
|
-
link:
|
|
4915
|
-
linkMobile:
|
|
4916
|
-
term:
|
|
4742
|
+
uuid: item?._source?.uuid?.[0],
|
|
4743
|
+
id: item?._source?.uuid?.[0],
|
|
4744
|
+
title: item?._source?.title?.[0],
|
|
4745
|
+
image: item?._source?.image?.[0],
|
|
4746
|
+
imageFormatted: item?._source?.image_formatted?.[0],
|
|
4747
|
+
description: item?._source?.description?.[0],
|
|
4748
|
+
created: item?._source?.created?.[0],
|
|
4749
|
+
updated: item?._source?.updated?.[0],
|
|
4750
|
+
weight: item?._source?.weight?.[0],
|
|
4751
|
+
buttonText: item?._source?.button_text?.[0],
|
|
4752
|
+
link: item?._source?.link?.[0],
|
|
4753
|
+
linkMobile: item?._source?.link_mobile?.[0],
|
|
4754
|
+
term: item?._source?.term?.[0],
|
|
4917
4755
|
// video: item?._source?.video?.[0],
|
|
4918
4756
|
// align: item?._source?.align?.[0],
|
|
4919
4757
|
// section: item?._source?.section?.[0],
|
|
@@ -4926,28 +4764,27 @@ function formatPromos(data) {
|
|
|
4926
4764
|
});
|
|
4927
4765
|
}
|
|
4928
4766
|
function formatWorkout(data) {
|
|
4929
|
-
return data.map(
|
|
4930
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
|
4767
|
+
return data.map((item) => {
|
|
4931
4768
|
return {
|
|
4932
|
-
changed:
|
|
4933
|
-
created:
|
|
4934
|
-
uuid:
|
|
4935
|
-
description:
|
|
4936
|
-
duration:
|
|
4769
|
+
changed: item?._source?.changed?.[0],
|
|
4770
|
+
created: item?._source?.created?.[0],
|
|
4771
|
+
uuid: item?._source?.uuid?.[0],
|
|
4772
|
+
description: item?._source?.description?.[0],
|
|
4773
|
+
duration: item?._source?.duration_filter?.[0],
|
|
4937
4774
|
// duration_filter: item?._source?.duration_filter?.[0],
|
|
4938
|
-
level:
|
|
4939
|
-
published:
|
|
4940
|
-
targeted_section:
|
|
4941
|
-
uid:
|
|
4942
|
-
imageStyled:
|
|
4943
|
-
image:
|
|
4944
|
-
title:
|
|
4945
|
-
video:
|
|
4946
|
-
videoDownload:
|
|
4947
|
-
videoPoster:
|
|
4948
|
-
workoutCategory:
|
|
4949
|
-
workoutType:
|
|
4950
|
-
livestreamSection:
|
|
4775
|
+
level: item?._source?.level?.[0],
|
|
4776
|
+
published: item?._source?.published?.[0],
|
|
4777
|
+
targeted_section: item?._source?.targeted_section?.[0],
|
|
4778
|
+
uid: item?._source?.uid?.[0],
|
|
4779
|
+
imageStyled: item?._source?.image_16_9?.[0],
|
|
4780
|
+
image: item?._source?.image?.[0],
|
|
4781
|
+
title: item?._source?.title?.[0],
|
|
4782
|
+
video: item?._source?.video_url?.[0],
|
|
4783
|
+
videoDownload: item?._source?.video_download?.[0],
|
|
4784
|
+
videoPoster: item?._source?.video_poster?.[0],
|
|
4785
|
+
workoutCategory: item?._source?.workout_category?.[0],
|
|
4786
|
+
workoutType: item?._source?.workout_type?.[0],
|
|
4787
|
+
livestreamSection: item?._source?.livestream_section?.[0],
|
|
4951
4788
|
};
|
|
4952
4789
|
});
|
|
4953
4790
|
}
|
|
@@ -4970,8 +4807,8 @@ function formatWorkout(data) {
|
|
|
4970
4807
|
// return formattedSeriesSelection;
|
|
4971
4808
|
// }
|
|
4972
4809
|
function formatShortform(data) {
|
|
4973
|
-
return data.map(
|
|
4974
|
-
|
|
4810
|
+
return data.map((item) => {
|
|
4811
|
+
const { _source } = item;
|
|
4975
4812
|
return {
|
|
4976
4813
|
uuid: _source.uuid && _source.uuid[0],
|
|
4977
4814
|
id: _source.uuid && _source.uuid[0],
|
|
@@ -5020,8 +4857,8 @@ function formatShortform(data) {
|
|
|
5020
4857
|
// });
|
|
5021
4858
|
// }
|
|
5022
4859
|
function formatFaqs(data) {
|
|
5023
|
-
return data.map(
|
|
5024
|
-
|
|
4860
|
+
return data.map((item) => {
|
|
4861
|
+
const { _source } = item;
|
|
5025
4862
|
return {
|
|
5026
4863
|
uuid: _source.uuid && _source.uuid[0],
|
|
5027
4864
|
id: _source.uuid && _source.uuid[0],
|
|
@@ -5033,24 +4870,23 @@ function formatFaqs(data) {
|
|
|
5033
4870
|
});
|
|
5034
4871
|
}
|
|
5035
4872
|
function formatPages(data) {
|
|
5036
|
-
return data.map(
|
|
5037
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
4873
|
+
return data.map((item) => {
|
|
5038
4874
|
return {
|
|
5039
|
-
uuid:
|
|
5040
|
-
id:
|
|
5041
|
-
title:
|
|
5042
|
-
body:
|
|
5043
|
-
created:
|
|
5044
|
-
updated:
|
|
5045
|
-
langcode:
|
|
5046
|
-
url:
|
|
4875
|
+
uuid: item?._source?.uuid?.[0],
|
|
4876
|
+
id: item?._source?.uuid?.[0],
|
|
4877
|
+
title: item?._source?.title?.[0],
|
|
4878
|
+
body: item?._source?.body?.[0],
|
|
4879
|
+
created: item?._source?.created?.[0],
|
|
4880
|
+
updated: item?._source?.updated?.[0],
|
|
4881
|
+
langcode: item?._source?.langcode?.[0],
|
|
4882
|
+
url: item?._source?.url?.[0],
|
|
5047
4883
|
};
|
|
5048
4884
|
});
|
|
5049
4885
|
}
|
|
5050
4886
|
function formatSettings(data) {
|
|
5051
|
-
return data.map(
|
|
5052
|
-
|
|
5053
|
-
|
|
4887
|
+
return data.map((item) => {
|
|
4888
|
+
const { _source } = item;
|
|
4889
|
+
const fieldset = _source.fieldset && _source.fieldset[0].toLowerCase();
|
|
5054
4890
|
return {
|
|
5055
4891
|
uuid: _source.uuid && _source.uuid[0],
|
|
5056
4892
|
created: _source.created && _source.created[0],
|
|
@@ -5060,13 +4896,13 @@ function formatSettings(data) {
|
|
|
5060
4896
|
video: _source.video && _source.video[0],
|
|
5061
4897
|
number: _source.number && _source.number[0],
|
|
5062
4898
|
pass: _source.pass && _source.pass[0],
|
|
5063
|
-
fieldset
|
|
4899
|
+
fieldset,
|
|
5064
4900
|
};
|
|
5065
4901
|
});
|
|
5066
4902
|
}
|
|
5067
4903
|
function formatPress(data) {
|
|
5068
|
-
return data.map(
|
|
5069
|
-
|
|
4904
|
+
return data.map((item) => {
|
|
4905
|
+
const { _source } = item;
|
|
5070
4906
|
return {
|
|
5071
4907
|
uuid: _source.uuid && _source.uuid[0],
|
|
5072
4908
|
created: _source.created && _source.created[0],
|
|
@@ -5077,8 +4913,8 @@ function formatPress(data) {
|
|
|
5077
4913
|
});
|
|
5078
4914
|
}
|
|
5079
4915
|
function formatGuests(data) {
|
|
5080
|
-
return data.map(
|
|
5081
|
-
|
|
4916
|
+
return data.map((item) => {
|
|
4917
|
+
const { _source } = item;
|
|
5082
4918
|
return {
|
|
5083
4919
|
uuid: _source.uuid && _source.uuid[0],
|
|
5084
4920
|
id: _source.id && _source.id[0],
|
|
@@ -5091,27 +4927,26 @@ function formatGuests(data) {
|
|
|
5091
4927
|
});
|
|
5092
4928
|
}
|
|
5093
4929
|
function formatVideos(data) {
|
|
5094
|
-
return data.map(
|
|
5095
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
4930
|
+
return data.map((item) => {
|
|
5096
4931
|
return {
|
|
5097
|
-
uuid:
|
|
5098
|
-
title:
|
|
5099
|
-
created:
|
|
5100
|
-
updated:
|
|
5101
|
-
description:
|
|
5102
|
-
image:
|
|
5103
|
-
duration:
|
|
5104
|
-
section:
|
|
5105
|
-
videoPoster:
|
|
5106
|
-
video:
|
|
5107
|
-
videoDownload:
|
|
5108
|
-
sectionId:
|
|
4932
|
+
uuid: item?._source?.uuid?.[0],
|
|
4933
|
+
title: item?._source?.title?.[0],
|
|
4934
|
+
created: item?._source?.created?.[0],
|
|
4935
|
+
updated: item?._source?.updated?.[0],
|
|
4936
|
+
description: item?._source?.description?.[0],
|
|
4937
|
+
image: item?._source?.image?.[0],
|
|
4938
|
+
duration: item?._source?.duration?.[0],
|
|
4939
|
+
section: item?._source?.section?.[0],
|
|
4940
|
+
videoPoster: item?._source?.video_poster?.[0],
|
|
4941
|
+
video: item?._source?.video_url?.[0],
|
|
4942
|
+
videoDownload: item?._source?.video_download?.[0],
|
|
4943
|
+
sectionId: item?._source?.section_id?.[0],
|
|
5109
4944
|
};
|
|
5110
4945
|
});
|
|
5111
4946
|
}
|
|
5112
4947
|
function formatSections(data) {
|
|
5113
|
-
return data.map(
|
|
5114
|
-
|
|
4948
|
+
return data.map((item) => {
|
|
4949
|
+
const { _source } = item;
|
|
5115
4950
|
return {
|
|
5116
4951
|
uuid: _source.uuid && _source.uuid[0],
|
|
5117
4952
|
title: _source.title && _source.title[0],
|
|
@@ -5124,95 +4959,87 @@ function formatSections(data) {
|
|
|
5124
4959
|
});
|
|
5125
4960
|
}
|
|
5126
4961
|
function formatSchedule(data) {
|
|
5127
|
-
return data.map(
|
|
5128
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
4962
|
+
return data.map((item) => {
|
|
5129
4963
|
return {
|
|
5130
|
-
uuid:
|
|
5131
|
-
created:
|
|
5132
|
-
langcode:
|
|
5133
|
-
updated:
|
|
4964
|
+
uuid: item?._source?.uuid?.[0],
|
|
4965
|
+
created: item?._source?.created?.[0],
|
|
4966
|
+
langcode: item?._source?.langcode?.[0],
|
|
4967
|
+
updated: item?._source?.updated?.[0],
|
|
5134
4968
|
days: [
|
|
5135
4969
|
{
|
|
5136
|
-
monday:
|
|
5137
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4970
|
+
monday: item?._source?.monday_title?.map((title, index) => {
|
|
5138
4971
|
return {
|
|
5139
|
-
end:
|
|
5140
|
-
start:
|
|
4972
|
+
end: item?._source?.monday_end?.[index],
|
|
4973
|
+
start: item?._source?.monday_start?.[index],
|
|
5141
4974
|
title: title,
|
|
5142
|
-
video:
|
|
5143
|
-
live:
|
|
4975
|
+
video: item?._source?.monday_video?.[index],
|
|
4976
|
+
live: item?._source?.monday_live?.[index],
|
|
5144
4977
|
};
|
|
5145
4978
|
}),
|
|
5146
4979
|
},
|
|
5147
4980
|
{
|
|
5148
|
-
tuesday:
|
|
5149
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4981
|
+
tuesday: item?._source?.tuesday_title?.map((title, index) => {
|
|
5150
4982
|
return {
|
|
5151
|
-
end:
|
|
5152
|
-
start:
|
|
4983
|
+
end: item?._source?.tuesday_end?.[index],
|
|
4984
|
+
start: item?._source?.tuesday_start?.[index],
|
|
5153
4985
|
title: title,
|
|
5154
|
-
video:
|
|
5155
|
-
live:
|
|
4986
|
+
video: item?._source?.tuesday_video?.[index],
|
|
4987
|
+
live: item?._source?.tuesday_live?.[index],
|
|
5156
4988
|
};
|
|
5157
4989
|
}),
|
|
5158
4990
|
},
|
|
5159
4991
|
{
|
|
5160
|
-
wednesday:
|
|
5161
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4992
|
+
wednesday: item?._source?.wednesday_title?.map((title, index) => {
|
|
5162
4993
|
return {
|
|
5163
|
-
end:
|
|
5164
|
-
start:
|
|
4994
|
+
end: item?._source?.wednesday_end?.[index],
|
|
4995
|
+
start: item?._source?.wednesday_start?.[index],
|
|
5165
4996
|
title: title,
|
|
5166
|
-
video:
|
|
5167
|
-
live:
|
|
4997
|
+
video: item?._source?.wednesday_video?.[index],
|
|
4998
|
+
live: item?._source?.wednesday_live?.[index],
|
|
5168
4999
|
};
|
|
5169
5000
|
}),
|
|
5170
5001
|
},
|
|
5171
5002
|
{
|
|
5172
|
-
thursday:
|
|
5173
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5003
|
+
thursday: item?._source?.thursday_title?.map((title, index) => {
|
|
5174
5004
|
return {
|
|
5175
|
-
end:
|
|
5176
|
-
start:
|
|
5005
|
+
end: item?._source?.thursday_end?.[index],
|
|
5006
|
+
start: item?._source?.thursday_start?.[index],
|
|
5177
5007
|
title: title,
|
|
5178
|
-
video:
|
|
5179
|
-
live:
|
|
5008
|
+
video: item?._source?.thursday_video?.[index],
|
|
5009
|
+
live: item?._source?.thursday_live?.[index],
|
|
5180
5010
|
};
|
|
5181
5011
|
}),
|
|
5182
5012
|
},
|
|
5183
5013
|
{
|
|
5184
|
-
friday:
|
|
5185
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5014
|
+
friday: item?._source?.friday_title?.map((title, index) => {
|
|
5186
5015
|
return {
|
|
5187
|
-
end:
|
|
5188
|
-
start:
|
|
5016
|
+
end: item?._source?.friday_end?.[index],
|
|
5017
|
+
start: item?._source?.friday_start?.[index],
|
|
5189
5018
|
title: title,
|
|
5190
|
-
video:
|
|
5191
|
-
live:
|
|
5019
|
+
video: item?._source?.friday_video?.[index],
|
|
5020
|
+
live: item?._source?.friday_live?.[index],
|
|
5192
5021
|
};
|
|
5193
5022
|
}),
|
|
5194
5023
|
},
|
|
5195
5024
|
{
|
|
5196
|
-
saturday:
|
|
5197
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5025
|
+
saturday: item?._source?.saturday_title?.map((title, index) => {
|
|
5198
5026
|
return {
|
|
5199
|
-
end:
|
|
5200
|
-
start:
|
|
5027
|
+
end: item?._source?.saturday_end?.[index],
|
|
5028
|
+
start: item?._source?.saturday_start?.[index],
|
|
5201
5029
|
title: title,
|
|
5202
|
-
video:
|
|
5203
|
-
live:
|
|
5030
|
+
video: item?._source?.saturday_video?.[index],
|
|
5031
|
+
live: item?._source?.saturday_live?.[index],
|
|
5204
5032
|
};
|
|
5205
5033
|
}),
|
|
5206
5034
|
},
|
|
5207
5035
|
{
|
|
5208
|
-
sunday:
|
|
5209
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5036
|
+
sunday: item?._source?.sunday_title?.map((title, index) => {
|
|
5210
5037
|
return {
|
|
5211
|
-
end:
|
|
5212
|
-
start:
|
|
5038
|
+
end: item?._source?.sunday_end?.[index],
|
|
5039
|
+
start: item?._source?.sunday_start?.[index],
|
|
5213
5040
|
title: title,
|
|
5214
|
-
video:
|
|
5215
|
-
live:
|
|
5041
|
+
video: item?._source?.sunday_video?.[index],
|
|
5042
|
+
live: item?._source?.sunday_live?.[index],
|
|
5216
5043
|
};
|
|
5217
5044
|
}),
|
|
5218
5045
|
},
|
|
@@ -5221,11 +5048,10 @@ function formatSchedule(data) {
|
|
|
5221
5048
|
});
|
|
5222
5049
|
}
|
|
5223
5050
|
function formatChallenges(data) {
|
|
5224
|
-
return data.map(
|
|
5225
|
-
|
|
5226
|
-
var _source = item._source;
|
|
5051
|
+
return data.map((item) => {
|
|
5052
|
+
const { _source } = item;
|
|
5227
5053
|
return {
|
|
5228
|
-
uuid:
|
|
5054
|
+
uuid: _source?.uuid?.[0],
|
|
5229
5055
|
title: _source.title && _source.title[0],
|
|
5230
5056
|
body: _source.body && _source.body[0],
|
|
5231
5057
|
image: _source.image && _source.image[0],
|
|
@@ -5239,17 +5065,16 @@ function formatChallenges(data) {
|
|
|
5239
5065
|
});
|
|
5240
5066
|
}
|
|
5241
5067
|
function formatChallengeDays(data) {
|
|
5242
|
-
return data.map(
|
|
5243
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
5068
|
+
return data.map((item) => {
|
|
5244
5069
|
return {
|
|
5245
|
-
uuid:
|
|
5246
|
-
title:
|
|
5247
|
-
body:
|
|
5248
|
-
image:
|
|
5249
|
-
created:
|
|
5250
|
-
updated:
|
|
5251
|
-
video:
|
|
5252
|
-
workout:
|
|
5070
|
+
uuid: item?._source?.uuid?.[0],
|
|
5071
|
+
title: item?._source?.title?.[0],
|
|
5072
|
+
body: item?._source?.body?.[0],
|
|
5073
|
+
image: item?._source?.image?.[0],
|
|
5074
|
+
created: item?._source?.created?.[0],
|
|
5075
|
+
updated: item?._source?.updated?.[0],
|
|
5076
|
+
video: item?._source?.video?.[0],
|
|
5077
|
+
workout: item?._source?.workout?.[0],
|
|
5253
5078
|
};
|
|
5254
5079
|
});
|
|
5255
5080
|
}
|
|
@@ -5257,360 +5082,328 @@ function formatSecondsToISO8601Duration(seconds) {
|
|
|
5257
5082
|
if (!seconds)
|
|
5258
5083
|
return '';
|
|
5259
5084
|
// Calculate hours, minutes, and remaining seconds
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5085
|
+
const hours = Math.floor(seconds / 3600);
|
|
5086
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
5087
|
+
const remainingSeconds = seconds % 60;
|
|
5263
5088
|
// Build the ISO 8601 duration string
|
|
5264
|
-
|
|
5089
|
+
let duration = 'PT';
|
|
5265
5090
|
if (hours > 0) {
|
|
5266
|
-
duration +=
|
|
5091
|
+
duration += `${hours}H`;
|
|
5267
5092
|
}
|
|
5268
5093
|
if (minutes > 0) {
|
|
5269
|
-
duration +=
|
|
5094
|
+
duration += `${minutes}M`;
|
|
5270
5095
|
}
|
|
5271
5096
|
if (remainingSeconds > 0 || duration === 'PT') {
|
|
5272
|
-
duration +=
|
|
5097
|
+
duration += `${remainingSeconds}S`;
|
|
5273
5098
|
}
|
|
5274
5099
|
return duration;
|
|
5275
5100
|
}
|
|
5276
5101
|
function formatAuthSession(session) {
|
|
5277
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
|
|
5278
5102
|
return {
|
|
5279
|
-
accessToken:
|
|
5280
|
-
idToken:
|
|
5103
|
+
accessToken: session?.tokens?.accessToken.toString(),
|
|
5104
|
+
idToken: session?.tokens?.idToken?.toString(),
|
|
5281
5105
|
refreshToken: undefined,
|
|
5282
|
-
accessTokenExpiry:
|
|
5283
|
-
expires:
|
|
5284
|
-
sub:
|
|
5106
|
+
accessTokenExpiry: session?.tokens?.idToken?.payload?.exp,
|
|
5107
|
+
expires: session?.tokens?.idToken?.payload?.exp,
|
|
5108
|
+
sub: session?.tokens?.idToken?.payload?.['cognito:username']?.toString(),
|
|
5285
5109
|
details: {
|
|
5286
|
-
userEmail:
|
|
5287
|
-
firstName:
|
|
5288
|
-
lastName:
|
|
5289
|
-
dateOfBirth:
|
|
5290
|
-
'cognito:username':
|
|
5291
|
-
'custom:termsAccepted':
|
|
5292
|
-
'custom:subscriptionId':
|
|
5293
|
-
'custom:contactPreferences':
|
|
5294
|
-
'custom:customerId':
|
|
5295
|
-
picture:
|
|
5110
|
+
userEmail: session?.tokens?.idToken?.payload?.email?.toString(),
|
|
5111
|
+
firstName: session?.tokens?.idToken?.payload?.given_name?.toString(),
|
|
5112
|
+
lastName: session?.tokens?.idToken?.payload?.family_name?.toString(),
|
|
5113
|
+
dateOfBirth: session?.tokens?.idToken?.payload?.birthdate?.toString(),
|
|
5114
|
+
'cognito:username': session?.tokens?.idToken?.payload?.['cognito:username']?.toString(),
|
|
5115
|
+
'custom:termsAccepted': session?.tokens?.idToken?.payload?.['custom:termsAccepted']?.toString(),
|
|
5116
|
+
'custom:subscriptionId': session?.tokens?.idToken?.payload?.['custom:subscriptionId']?.toString(),
|
|
5117
|
+
'custom:contactPreferences': session?.tokens?.idToken?.payload?.['custom:contactPreferences']?.toString(),
|
|
5118
|
+
'custom:customerId': session?.tokens?.idToken?.payload?.['custom:customerId']?.toString(),
|
|
5119
|
+
picture: session?.tokens?.idToken?.payload?.picture?.toString(),
|
|
5296
5120
|
},
|
|
5297
5121
|
};
|
|
5298
5122
|
}
|
|
5299
5123
|
function formatFedaratedSession(session) {
|
|
5300
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
5301
5124
|
return {
|
|
5302
|
-
accessToken:
|
|
5303
|
-
idToken:
|
|
5304
|
-
refreshToken:
|
|
5305
|
-
accessTokenExpiry:
|
|
5306
|
-
expires:
|
|
5307
|
-
sub:
|
|
5125
|
+
accessToken: session?.accessToken?.jwtToken,
|
|
5126
|
+
idToken: session?.idToken?.jwtToken,
|
|
5127
|
+
refreshToken: session?.refreshToken?.token,
|
|
5128
|
+
accessTokenExpiry: session?.accessToken?.payload?.exp,
|
|
5129
|
+
expires: session?.accessToken?.payload?.exp,
|
|
5130
|
+
sub: session?.idToken?.payload?.sub,
|
|
5308
5131
|
details: {
|
|
5309
|
-
userEmail:
|
|
5310
|
-
firstName:
|
|
5311
|
-
lastName:
|
|
5312
|
-
dateOfBirth:
|
|
5313
|
-
'cognito:username':
|
|
5314
|
-
'custom:termsAccepted':
|
|
5315
|
-
'custom:subscriptionId':
|
|
5316
|
-
'custom:contactPreferences':
|
|
5317
|
-
'custom:customerId':
|
|
5318
|
-
picture:
|
|
5319
|
-
id: toCamelCaseObject(
|
|
5132
|
+
userEmail: session?.idToken?.payload?.email,
|
|
5133
|
+
firstName: session?.idToken?.payload?.given_name,
|
|
5134
|
+
lastName: session?.idToken?.payload?.family_name,
|
|
5135
|
+
dateOfBirth: session?.idToken?.payload?.birthdate,
|
|
5136
|
+
'cognito:username': session?.idToken?.payload?.sub,
|
|
5137
|
+
'custom:termsAccepted': session?.idToken?.payload?.['custom:termsAccepted'],
|
|
5138
|
+
'custom:subscriptionId': session?.idToken?.payload?.['custom:subscriptionId'],
|
|
5139
|
+
'custom:contactPreferences': session?.idToken?.payload?.['custom:contactPreferences'],
|
|
5140
|
+
'custom:customerId': session?.idToken?.payload?.['custom:customerId'],
|
|
5141
|
+
picture: session?.idToken?.payload?.picture,
|
|
5142
|
+
id: toCamelCaseObject(session?.idToken?.payload),
|
|
5320
5143
|
},
|
|
5321
5144
|
};
|
|
5322
5145
|
}
|
|
5323
5146
|
function formatSocialAuthSession(tokens) {
|
|
5324
|
-
|
|
5147
|
+
const idToken = jwtDecode.jwtDecode(tokens.idToken);
|
|
5325
5148
|
return {
|
|
5326
5149
|
socialSignin: true,
|
|
5327
5150
|
accessToken: tokens.accessToken,
|
|
5328
5151
|
idToken: tokens.idToken,
|
|
5329
5152
|
refreshToken: tokens.refreshToken,
|
|
5330
|
-
accessTokenExpiry: idToken
|
|
5331
|
-
expires: idToken
|
|
5153
|
+
accessTokenExpiry: idToken?.exp,
|
|
5154
|
+
expires: idToken?.exp,
|
|
5332
5155
|
sub: idToken.sub,
|
|
5333
5156
|
details: {
|
|
5334
5157
|
userEmail: idToken.email,
|
|
5335
5158
|
firstName: idToken.given_name,
|
|
5336
5159
|
lastName: idToken.family_name,
|
|
5337
|
-
dateOfBirth: idToken
|
|
5338
|
-
'cognito:username': idToken
|
|
5339
|
-
'custom:termsAccepted': idToken
|
|
5340
|
-
'custom:subscriptionId': idToken
|
|
5341
|
-
'custom:contactPreferences': idToken
|
|
5342
|
-
'custom:customerId': idToken
|
|
5343
|
-
picture: idToken
|
|
5160
|
+
dateOfBirth: idToken?.birthdate,
|
|
5161
|
+
'cognito:username': idToken?.['cognito:username'],
|
|
5162
|
+
'custom:termsAccepted': idToken?.['custom:termsAccepted'],
|
|
5163
|
+
'custom:subscriptionId': idToken?.['custom:subscriptionId'],
|
|
5164
|
+
'custom:contactPreferences': idToken?.['custom:contactPreferences'],
|
|
5165
|
+
'custom:customerId': idToken?.['custom:customerId'],
|
|
5166
|
+
picture: idToken?.picture,
|
|
5344
5167
|
},
|
|
5345
5168
|
};
|
|
5346
5169
|
}
|
|
5347
5170
|
function formatConfig(data) {
|
|
5348
|
-
return data.map(
|
|
5349
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
5171
|
+
return data.map((item) => {
|
|
5350
5172
|
return {
|
|
5351
|
-
uuid:
|
|
5352
|
-
id:
|
|
5353
|
-
created:
|
|
5354
|
-
updated:
|
|
5355
|
-
type:
|
|
5356
|
-
cla:
|
|
5357
|
-
enabled:
|
|
5358
|
-
name:
|
|
5359
|
-
price:
|
|
5360
|
-
video:
|
|
5361
|
-
imageHomepage:
|
|
5362
|
-
imageSectionBanner:
|
|
5173
|
+
uuid: item?._source?.uuid?.[0],
|
|
5174
|
+
id: item?._source?.uuid?.[0],
|
|
5175
|
+
created: item?._source?.created?.[0],
|
|
5176
|
+
updated: item?._source?.updated?.[0],
|
|
5177
|
+
type: item?._source?.type?.[0],
|
|
5178
|
+
cla: item?._source?.cla?.[0],
|
|
5179
|
+
enabled: item?._source?.enabled?.[0],
|
|
5180
|
+
name: item?._source?.name?.[0],
|
|
5181
|
+
price: item?._source?.price?.[0],
|
|
5182
|
+
video: item?._source?.video?.[0],
|
|
5183
|
+
imageHomepage: item?._source?.image_homepage?.[0],
|
|
5184
|
+
imageSectionBanner: item?._source?.image_section_banner?.[0],
|
|
5363
5185
|
};
|
|
5364
5186
|
});
|
|
5365
5187
|
}
|
|
5366
5188
|
function formatSectionPanels(data) {
|
|
5367
|
-
return data.map(
|
|
5368
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
5189
|
+
return data.map((item) => {
|
|
5369
5190
|
return {
|
|
5370
|
-
uuid:
|
|
5371
|
-
id:
|
|
5372
|
-
title:
|
|
5373
|
-
created:
|
|
5374
|
-
updated:
|
|
5375
|
-
weight:
|
|
5376
|
-
items:
|
|
5377
|
-
type:
|
|
5191
|
+
uuid: item?._source?.uuid?.[0],
|
|
5192
|
+
id: item?._source?.uuid?.[0],
|
|
5193
|
+
title: item?._source?.title?.[0],
|
|
5194
|
+
created: item?._source?.created?.[0],
|
|
5195
|
+
updated: item?._source?.updated?.[0],
|
|
5196
|
+
weight: item?._source?.weight?.[0],
|
|
5197
|
+
items: item?._source?.item_uuid,
|
|
5198
|
+
type: item?._source?.type?.[0],
|
|
5378
5199
|
};
|
|
5379
5200
|
});
|
|
5380
5201
|
}
|
|
5381
5202
|
function formatSectionItems(data) {
|
|
5382
|
-
return data.map(
|
|
5383
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
5203
|
+
return data.map((item) => {
|
|
5384
5204
|
return {
|
|
5385
|
-
uuid:
|
|
5386
|
-
id:
|
|
5387
|
-
title:
|
|
5388
|
-
created:
|
|
5389
|
-
updated:
|
|
5390
|
-
type:
|
|
5391
|
-
term:
|
|
5392
|
-
image:
|
|
5393
|
-
bannerImage:
|
|
5205
|
+
uuid: item?._source?.uuid?.[0],
|
|
5206
|
+
id: item?._source?.uuid?.[0],
|
|
5207
|
+
title: item?._source?.title?.[0],
|
|
5208
|
+
created: item?._source?.created?.[0],
|
|
5209
|
+
updated: item?._source?.updated?.[0],
|
|
5210
|
+
type: item?._source?.type?.[0],
|
|
5211
|
+
term: item?._source?.term?.[0],
|
|
5212
|
+
image: item?._source?.custom_image_formatted?.[0],
|
|
5213
|
+
bannerImage: item?._source?.banner_image_formatted?.[0],
|
|
5394
5214
|
};
|
|
5395
5215
|
});
|
|
5396
5216
|
}
|
|
5397
|
-
|
|
5398
|
-
return data.map(
|
|
5399
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
5217
|
+
const formatTaxonomies = (data) => {
|
|
5218
|
+
return data.map((item) => {
|
|
5400
5219
|
return {
|
|
5401
|
-
uuid:
|
|
5402
|
-
id:
|
|
5403
|
-
updated:
|
|
5404
|
-
vocabulary:
|
|
5405
|
-
name:
|
|
5406
|
-
description:
|
|
5407
|
-
image:
|
|
5408
|
-
imageBanner:
|
|
5409
|
-
imageBannerTaxonomy:
|
|
5410
|
-
imageLarge:
|
|
5411
|
-
weight:
|
|
5412
|
-
parentName:
|
|
5413
|
-
color:
|
|
5220
|
+
uuid: item?._source?.uuid?.[0],
|
|
5221
|
+
id: item?._source?.uuid?.[0],
|
|
5222
|
+
updated: item?._source?.updated?.[0],
|
|
5223
|
+
vocabulary: item?._source?.vocabulary?.[0],
|
|
5224
|
+
name: item?._source?.name?.[0],
|
|
5225
|
+
description: item?._source?.description?.[0],
|
|
5226
|
+
image: item?._source?.image?.[0],
|
|
5227
|
+
imageBanner: item?._source?.image_banner?.[0],
|
|
5228
|
+
imageBannerTaxonomy: item?._source?.image_banner_taxonomy?.[0],
|
|
5229
|
+
imageLarge: item?._source?.image_large_16_9?.[0],
|
|
5230
|
+
weight: item?._source?.weight?.[0],
|
|
5231
|
+
parentName: item?._source?.parent_name?.[0],
|
|
5232
|
+
color: item?._source?.color?.[0],
|
|
5414
5233
|
};
|
|
5415
5234
|
});
|
|
5416
5235
|
};
|
|
5417
|
-
|
|
5418
|
-
return data.map(
|
|
5419
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5236
|
+
const formatSeries = (data) => {
|
|
5237
|
+
return data.map((item) => {
|
|
5420
5238
|
return {
|
|
5421
|
-
uuid:
|
|
5422
|
-
id:
|
|
5423
|
-
created:
|
|
5424
|
-
updated:
|
|
5425
|
-
title:
|
|
5426
|
-
synopsis:
|
|
5427
|
-
imagePoster:
|
|
5428
|
-
imageThumb:
|
|
5429
|
-
category:
|
|
5430
|
-
categoryId:
|
|
5431
|
-
seasons:
|
|
5239
|
+
uuid: item?._source?.uuid?.[0],
|
|
5240
|
+
id: item?._source?.uuid?.[0],
|
|
5241
|
+
created: item?._source?.created?.[0],
|
|
5242
|
+
updated: item?._source?.updated?.[0],
|
|
5243
|
+
title: item?._source?.display_title?.[0],
|
|
5244
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5245
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5246
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5247
|
+
category: item?._source?.category?.[0],
|
|
5248
|
+
categoryId: item?._source?.category_id?.[0],
|
|
5249
|
+
seasons: item?._source?.seasons || [],
|
|
5432
5250
|
};
|
|
5433
5251
|
});
|
|
5434
5252
|
};
|
|
5435
|
-
|
|
5436
|
-
return data.map(
|
|
5437
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5253
|
+
const formatSeasons = (data) => {
|
|
5254
|
+
return data.map((item) => {
|
|
5438
5255
|
return {
|
|
5439
|
-
uuid:
|
|
5440
|
-
id:
|
|
5441
|
-
created:
|
|
5442
|
-
updated:
|
|
5443
|
-
title:
|
|
5444
|
-
synopsis:
|
|
5445
|
-
imagePoster:
|
|
5446
|
-
imageThumb:
|
|
5447
|
-
episodes:
|
|
5448
|
-
seasonNumber:
|
|
5449
|
-
showId:
|
|
5256
|
+
uuid: item?._source?.uuid?.[0],
|
|
5257
|
+
id: item?._source?.uuid?.[0],
|
|
5258
|
+
created: item?._source?.created?.[0],
|
|
5259
|
+
updated: item?._source?.updated?.[0],
|
|
5260
|
+
title: item?._source?.display_title?.[0],
|
|
5261
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5262
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5263
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5264
|
+
episodes: item?._source?.episodes || [],
|
|
5265
|
+
seasonNumber: item?._source?.season_number?.[0],
|
|
5266
|
+
showId: item?._source?.show?.[0],
|
|
5450
5267
|
};
|
|
5451
5268
|
});
|
|
5452
5269
|
};
|
|
5453
|
-
|
|
5454
|
-
return data.map(
|
|
5455
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
5270
|
+
const formatLongform = (data) => {
|
|
5271
|
+
return data.map((item) => {
|
|
5456
5272
|
return {
|
|
5457
|
-
uuid:
|
|
5458
|
-
id:
|
|
5459
|
-
created:
|
|
5460
|
-
updated:
|
|
5461
|
-
title:
|
|
5462
|
-
synopsis:
|
|
5463
|
-
imagePoster:
|
|
5464
|
-
imageThumb:
|
|
5465
|
-
duration:
|
|
5466
|
-
releaseDate:
|
|
5467
|
-
video:
|
|
5468
|
-
imageUrl:
|
|
5469
|
-
episodeNumber:
|
|
5273
|
+
uuid: item?._source?.uuid?.[0],
|
|
5274
|
+
id: item?._source?.uuid?.[0],
|
|
5275
|
+
created: item?._source?.created?.[0],
|
|
5276
|
+
updated: item?._source?.updated?.[0],
|
|
5277
|
+
title: item?._source?.display_title?.[0],
|
|
5278
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5279
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5280
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5281
|
+
duration: item?._source?.duration?.[0],
|
|
5282
|
+
releaseDate: item?._source?.release_date?.[0],
|
|
5283
|
+
video: item?._source?.video?.[0],
|
|
5284
|
+
imageUrl: item?._source?.image_url?.[0],
|
|
5285
|
+
episodeNumber: item?._source?.episode_number?.[0],
|
|
5470
5286
|
};
|
|
5471
5287
|
});
|
|
5472
5288
|
};
|
|
5473
|
-
|
|
5474
|
-
return data.map(
|
|
5475
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
5289
|
+
const formatMediaItem = (data) => {
|
|
5290
|
+
return data.map((item) => {
|
|
5476
5291
|
return {
|
|
5477
|
-
changed:
|
|
5478
|
-
created:
|
|
5479
|
-
image:
|
|
5480
|
-
customThumbnail:
|
|
5481
|
-
price:
|
|
5482
|
-
priceTwoYear:
|
|
5483
|
-
revisionTimestamp:
|
|
5484
|
-
sku:
|
|
5485
|
-
status:
|
|
5486
|
-
uuid:
|
|
5487
|
-
description:
|
|
5488
|
-
transcript:
|
|
5489
|
-
entities:
|
|
5490
|
-
phrases:
|
|
5491
|
-
video:
|
|
5492
|
-
title:
|
|
5493
|
-
generatedTitle:
|
|
5494
|
-
projectPricing:
|
|
5495
|
-
related_items:
|
|
5496
|
-
franchises:
|
|
5497
|
-
franchisesIds:
|
|
5498
|
-
original:
|
|
5499
|
-
script:
|
|
5500
|
-
hideThumbnailTitle:
|
|
5292
|
+
changed: item?._source?.changed?.[0],
|
|
5293
|
+
created: item?._source?.created?.[0],
|
|
5294
|
+
image: item?._source?.image?.[0],
|
|
5295
|
+
customThumbnail: item?._source?.custom_thumbnail?.[0],
|
|
5296
|
+
price: item?._source?.price?.[0],
|
|
5297
|
+
priceTwoYear: item?._source?.price_2_year?.[0],
|
|
5298
|
+
revisionTimestamp: item?._source?.revision_timestamp?.[0],
|
|
5299
|
+
sku: item?._source?.sku?.[0],
|
|
5300
|
+
status: item?._source?.status?.[0],
|
|
5301
|
+
uuid: item?._source?.uuid?.[0],
|
|
5302
|
+
description: item?._source?.description?.[0],
|
|
5303
|
+
transcript: item?._source?.transcript?.[0],
|
|
5304
|
+
entities: item?._source?.entities,
|
|
5305
|
+
phrases: item?._source?.phrases,
|
|
5306
|
+
video: item?._source?.video?.[0],
|
|
5307
|
+
title: item?._source?.title?.[0],
|
|
5308
|
+
generatedTitle: item?._source?.generated_title?.[0],
|
|
5309
|
+
projectPricing: item?._source?.project_pricing?.[0],
|
|
5310
|
+
related_items: item?._source?.related_uuids,
|
|
5311
|
+
franchises: item?._source?.franchise_name,
|
|
5312
|
+
franchisesIds: item?._source?.franchise_tid,
|
|
5313
|
+
original: item?._source?.original?.[0],
|
|
5314
|
+
script: item?._source?.script?.[0],
|
|
5315
|
+
hideThumbnailTitle: item?._source?.hide_thumbnail_title?.[0],
|
|
5501
5316
|
};
|
|
5502
5317
|
});
|
|
5503
5318
|
};
|
|
5504
5319
|
|
|
5505
|
-
var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
5506
5320
|
// Render the store based on the environment.
|
|
5507
|
-
|
|
5508
|
-
|
|
5321
|
+
const isWeb = process.env.NEXT_PUBLIC_WEB_APP;
|
|
5322
|
+
const ENV = isWeb ? process.env : Promise.resolve().then(function () { return require('./index-CfrYa4U_.js'); }).then((mod) => mod.default).catch(() => ({}));
|
|
5509
5323
|
// export const ENV = process.env;
|
|
5510
|
-
|
|
5324
|
+
process.env?.NEXT_PUBLIC_API_PREFIX || ENV.API_PREFIX;
|
|
5511
5325
|
// Auth specific API
|
|
5512
|
-
|
|
5326
|
+
const API_AUTH_PREFIX = process.env?.NEXT_PUBLIC_API_AUTH_PREFIX || ENV.API_AUTH_PREFIX;
|
|
5513
5327
|
// Payments specific API
|
|
5514
|
-
|
|
5328
|
+
const API_PAYMENTS_PREFIX = process.env?.NEXT_PUBLIC_API_PAYMENTS_PREFIX || ENV.API_PAYMENTS_PREFIX;
|
|
5515
5329
|
// Orders specific API
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5330
|
+
const API_ORDERS_PREFIX = process.env?.NEXT_PUBLIC_API_ORDERS_PREFIX || ENV.API_ORDERS_PREFIX;
|
|
5331
|
+
process.env?.NEXT_PUBLIC_APP_BASE_URL || ENV.APP_BASE_URL;
|
|
5332
|
+
const APP_ES_INSTANCE = process.env?.NEXT_PUBLIC_APP_ES_INSTANCE || ENV.APP_ES_INSTANCE;
|
|
5333
|
+
const APP_ES_AUTH = process.env?.NEXT_PUBLIC_APP_ES_AUTH || ENV.APP_ES_AUTH;
|
|
5334
|
+
process.env?.NEXT_PUBLIC_APP_ES_PROMO_PANEL_INDEX ||
|
|
5521
5335
|
ENV.APP_ES_PROMO_PANEL_INDEX;
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5336
|
+
process.env?.NEXT_PUBLIC_APP_ES_FAQ_INDEX || ENV.APP_ES_FAQ_INDEX;
|
|
5337
|
+
process.env?.NEXT_PUBLIC_APP_ES_PAGES_INDEX || ENV.APP_ES_PAGES_INDEX;
|
|
5338
|
+
process.env?.NEXT_PUBLIC_APP_ES_SETTINGS_INDEX || ENV.APP_ES_SETTINGS_INDEX;
|
|
5339
|
+
process.env?.NEXT_PUBLIC_APP_ES_PRESS_INDEX || ENV.APP_ES_PRESS_INDEX;
|
|
5340
|
+
process.env?.NEXT_PUBLIC_APP_ES_GUESTS_INDEX || ENV.APP_ES_GUESTS_INDEX;
|
|
5341
|
+
process.env?.NEXT_PUBLIC_APP_ES_VIDEOS_INDEX || ENV.APP_ES_VIDEOS_INDEX;
|
|
5342
|
+
process.env?.NEXT_PUBLIC_APP_ES_SECTIONS_INDEX || ENV.APP_ES_SECTIONS_INDEX;
|
|
5343
|
+
process.env?.NEXT_PUBLIC_APP_ES_WORKOUTS_INDEX || ENV.APP_ES_WORKOUTS_INDEX;
|
|
5344
|
+
process.env?.NEXT_PUBLIC_APP_ES_SCHEDULE_INDEX || ENV.APP_ES_SCHEDULE_INDEX;
|
|
5345
|
+
process.env?.NEXT_PUBLIC_APP_ES_CHALLENGES_INDEX ||
|
|
5532
5346
|
ENV.APP_ES_CHALLENGES_INDEX;
|
|
5533
|
-
|
|
5347
|
+
process.env?.NEXT_PUBLIC_APP_ES_CHALLENGE_DAYS_INDEX ||
|
|
5534
5348
|
ENV.APP_ES_CHALLENGE_DAYS_INDEX;
|
|
5535
5349
|
|
|
5536
|
-
|
|
5350
|
+
const authDataBaseQuery = fetchBaseQuery({
|
|
5537
5351
|
baseUrl: API_AUTH_PREFIX,
|
|
5538
|
-
prepareHeaders:
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
session = _c.sent();
|
|
5550
|
-
idToken = session.getIdToken().getJwtToken();
|
|
5551
|
-
accessToken = session.getAccessToken().getJwtToken();
|
|
5552
|
-
if (accessToken && idToken) {
|
|
5553
|
-
headers.set('accesstoken', accessToken);
|
|
5554
|
-
headers.set('idtoken', idToken);
|
|
5555
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5556
|
-
}
|
|
5557
|
-
return [2 /*return*/, headers];
|
|
5558
|
-
case 3:
|
|
5559
|
-
error_1 = _c.sent();
|
|
5560
|
-
console.error('authDataBaseQuery: ', error_1);
|
|
5561
|
-
return [2 /*return*/, headers];
|
|
5562
|
-
case 4: return [2 /*return*/];
|
|
5352
|
+
prepareHeaders: async (headers, {}) => {
|
|
5353
|
+
headers.set('Content-Type', 'application/json');
|
|
5354
|
+
try {
|
|
5355
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5356
|
+
const session = await awsAmplify.Auth.currentSession();
|
|
5357
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5358
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5359
|
+
if (accessToken && idToken) {
|
|
5360
|
+
headers.set('accesstoken', accessToken);
|
|
5361
|
+
headers.set('idtoken', idToken);
|
|
5362
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5563
5363
|
}
|
|
5564
|
-
|
|
5565
|
-
|
|
5364
|
+
return headers;
|
|
5365
|
+
}
|
|
5366
|
+
catch (error) {
|
|
5367
|
+
console.error('authDataBaseQuery: ', error);
|
|
5368
|
+
return headers;
|
|
5369
|
+
}
|
|
5370
|
+
},
|
|
5566
5371
|
credentials: 'include',
|
|
5567
5372
|
});
|
|
5568
5373
|
/**
|
|
5569
5374
|
* This function is used to retry a request if we get a 401 error.
|
|
5570
5375
|
*/
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
user = formatAuthSession(authSession);
|
|
5586
|
-
api.dispatch(setCredentials(user));
|
|
5587
|
-
if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
|
|
5588
|
-
return [4 /*yield*/, authDataBaseQuery(args, api, extraOptions)];
|
|
5589
|
-
case 3:
|
|
5590
|
-
// If we get a new access token, retry the original request.
|
|
5591
|
-
result = _b.sent();
|
|
5592
|
-
return [3 /*break*/, 6];
|
|
5593
|
-
case 4:
|
|
5376
|
+
const authDataBaseQueryWithReauth = async (args, api, extraOptions) => {
|
|
5377
|
+
let result = await authDataBaseQuery(args, api, extraOptions);
|
|
5378
|
+
// If we get a 401 error
|
|
5379
|
+
if (result?.error?.status === 401) {
|
|
5380
|
+
const authSession = await awsAmplify.Auth.currentAuthenticatedUser({
|
|
5381
|
+
bypassCache: true, // Ensures that the user is refreshed from the server
|
|
5382
|
+
});
|
|
5383
|
+
const user = formatAuthSession(authSession);
|
|
5384
|
+
api.dispatch(slice.setCredentials(user));
|
|
5385
|
+
if (authSession?.tokens) {
|
|
5386
|
+
// If we get a new access token, retry the original request.
|
|
5387
|
+
result = await authDataBaseQuery(args, api, extraOptions);
|
|
5388
|
+
}
|
|
5389
|
+
else {
|
|
5594
5390
|
// TODO; require full data reset?
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
api.dispatch(logout());
|
|
5600
|
-
// If no access token throw error.
|
|
5601
|
-
throw new Error('No access token found');
|
|
5602
|
-
case 6: return [2 /*return*/, result];
|
|
5391
|
+
await awsAmplify.Auth.signOut();
|
|
5392
|
+
api.dispatch(slice.logout());
|
|
5393
|
+
// If no access token throw error.
|
|
5394
|
+
throw new Error('No access token found');
|
|
5603
5395
|
}
|
|
5604
|
-
}
|
|
5605
|
-
|
|
5606
|
-
|
|
5396
|
+
}
|
|
5397
|
+
return result;
|
|
5398
|
+
};
|
|
5399
|
+
const authApi = createApi({
|
|
5607
5400
|
reducerPath: 'authApi',
|
|
5608
5401
|
baseQuery: authDataBaseQueryWithReauth,
|
|
5609
5402
|
tagTypes: ['UserToken', 'UserData'],
|
|
5610
5403
|
// keepUnusedDataFor: 300,
|
|
5611
|
-
endpoints:
|
|
5404
|
+
endpoints: (builder) => ({
|
|
5612
5405
|
resetPassword: builder.mutation({
|
|
5613
|
-
query:
|
|
5406
|
+
query: (data) => ({
|
|
5614
5407
|
url: '/user/password/reset',
|
|
5615
5408
|
method: 'POST',
|
|
5616
5409
|
body: {
|
|
@@ -5619,10 +5412,10 @@ var authApi = createApi({
|
|
|
5619
5412
|
currentPassword: data.currentPassword,
|
|
5620
5413
|
newPassword: data.newPassword,
|
|
5621
5414
|
},
|
|
5622
|
-
})
|
|
5415
|
+
}),
|
|
5623
5416
|
}),
|
|
5624
5417
|
resetPasswordAuth: builder.mutation({
|
|
5625
|
-
query:
|
|
5418
|
+
query: (data) => ({
|
|
5626
5419
|
url: '/user/password/reset-auth',
|
|
5627
5420
|
method: 'POST',
|
|
5628
5421
|
body: {
|
|
@@ -5630,54 +5423,41 @@ var authApi = createApi({
|
|
|
5630
5423
|
currentPassword: data.currentPassword,
|
|
5631
5424
|
newPassword: data.newPassword,
|
|
5632
5425
|
},
|
|
5633
|
-
})
|
|
5426
|
+
}),
|
|
5634
5427
|
}),
|
|
5635
5428
|
forgottenPassword: builder.mutation({
|
|
5636
|
-
query:
|
|
5429
|
+
query: (data) => ({
|
|
5637
5430
|
url: '/user/password/forgot',
|
|
5638
5431
|
method: 'POST',
|
|
5639
5432
|
body: {
|
|
5640
5433
|
email: data.email,
|
|
5641
5434
|
},
|
|
5642
|
-
})
|
|
5435
|
+
}),
|
|
5643
5436
|
}),
|
|
5644
5437
|
register: builder.mutation({
|
|
5645
|
-
query:
|
|
5438
|
+
query: (data) => ({
|
|
5646
5439
|
url: '/user/register',
|
|
5647
5440
|
method: 'POST',
|
|
5648
5441
|
body: data,
|
|
5649
|
-
})
|
|
5650
|
-
onQueryStarted
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
return [4 /*yield*/, queryFulfilled];
|
|
5659
|
-
case 1:
|
|
5660
|
-
_c.sent();
|
|
5661
|
-
dispatch(resetCreating());
|
|
5662
|
-
return [3 /*break*/, 3];
|
|
5663
|
-
case 2:
|
|
5664
|
-
err_1 = _c.sent();
|
|
5665
|
-
console.error('REGISTER: ', err_1);
|
|
5666
|
-
return [3 /*break*/, 3];
|
|
5667
|
-
case 3: return [2 /*return*/];
|
|
5668
|
-
}
|
|
5669
|
-
});
|
|
5670
|
-
});
|
|
5442
|
+
}),
|
|
5443
|
+
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
5444
|
+
try {
|
|
5445
|
+
await queryFulfilled;
|
|
5446
|
+
dispatch(slice.resetCreating());
|
|
5447
|
+
}
|
|
5448
|
+
catch (err) {
|
|
5449
|
+
console.error('REGISTER: ', err);
|
|
5450
|
+
}
|
|
5671
5451
|
},
|
|
5672
5452
|
}),
|
|
5673
5453
|
verifyUser: builder.query({
|
|
5674
|
-
query:
|
|
5454
|
+
query: (data) => ({
|
|
5675
5455
|
url: '/user/verify',
|
|
5676
5456
|
method: 'POST',
|
|
5677
5457
|
body: data,
|
|
5678
|
-
})
|
|
5679
|
-
transformErrorResponse:
|
|
5680
|
-
|
|
5458
|
+
}),
|
|
5459
|
+
transformErrorResponse: (rawResult) => {
|
|
5460
|
+
const { status, data, message } = rawResult;
|
|
5681
5461
|
switch (status) {
|
|
5682
5462
|
case 429:
|
|
5683
5463
|
// Toast.info(TOO_MANY_REQUESTS_MESSAGE);
|
|
@@ -5689,7 +5469,7 @@ var authApi = createApi({
|
|
|
5689
5469
|
*/
|
|
5690
5470
|
return {
|
|
5691
5471
|
route: 'resend',
|
|
5692
|
-
message:
|
|
5472
|
+
message: data?.message || message,
|
|
5693
5473
|
};
|
|
5694
5474
|
case 404:
|
|
5695
5475
|
/**
|
|
@@ -5697,7 +5477,7 @@ var authApi = createApi({
|
|
|
5697
5477
|
*/
|
|
5698
5478
|
return {
|
|
5699
5479
|
route: 'failed',
|
|
5700
|
-
message:
|
|
5480
|
+
message: data?.message || message,
|
|
5701
5481
|
};
|
|
5702
5482
|
case 401:
|
|
5703
5483
|
/**
|
|
@@ -5705,159 +5485,146 @@ var authApi = createApi({
|
|
|
5705
5485
|
*/
|
|
5706
5486
|
return {
|
|
5707
5487
|
route: 'error',
|
|
5708
|
-
message:
|
|
5488
|
+
message: data?.message || message,
|
|
5709
5489
|
};
|
|
5710
5490
|
default:
|
|
5711
5491
|
return {
|
|
5712
5492
|
route: 'error',
|
|
5713
|
-
message:
|
|
5493
|
+
message: data?.message || message,
|
|
5714
5494
|
};
|
|
5715
5495
|
}
|
|
5716
5496
|
},
|
|
5717
|
-
transformResponse:
|
|
5718
|
-
|
|
5719
|
-
return { route: 'success', message: data
|
|
5497
|
+
transformResponse: (rawResult) => {
|
|
5498
|
+
const { data } = rawResult;
|
|
5499
|
+
return { route: 'success', message: data?.message };
|
|
5720
5500
|
},
|
|
5721
5501
|
}),
|
|
5722
5502
|
verifyUserAttributes: builder.query({
|
|
5723
|
-
query:
|
|
5503
|
+
query: (data) => ({
|
|
5724
5504
|
url: '/user/verify/email',
|
|
5725
5505
|
method: 'POST',
|
|
5726
5506
|
body: data,
|
|
5727
|
-
})
|
|
5507
|
+
}),
|
|
5728
5508
|
}),
|
|
5729
5509
|
verifyUserResend: builder.query({
|
|
5730
|
-
query:
|
|
5510
|
+
query: (data) => ({
|
|
5731
5511
|
url: '/user/verify/resend',
|
|
5732
5512
|
method: 'POST',
|
|
5733
5513
|
body: data,
|
|
5734
|
-
})
|
|
5514
|
+
}),
|
|
5735
5515
|
}),
|
|
5736
5516
|
getUserInfo: builder.query({
|
|
5737
|
-
query:
|
|
5738
|
-
url:
|
|
5517
|
+
query: (uuid) => ({
|
|
5518
|
+
url: `/data/user/${uuid}`,
|
|
5739
5519
|
method: 'GET',
|
|
5740
|
-
})
|
|
5520
|
+
}),
|
|
5741
5521
|
providesTags: ['UserData'],
|
|
5742
5522
|
}),
|
|
5743
5523
|
updateUserInfo: builder.mutation({
|
|
5744
|
-
query:
|
|
5524
|
+
query: (expressions) => ({
|
|
5745
5525
|
url: '/data/user',
|
|
5746
5526
|
method: 'PATCH',
|
|
5747
5527
|
body: expressions,
|
|
5748
|
-
})
|
|
5528
|
+
}),
|
|
5749
5529
|
invalidatesTags: ['UserData'],
|
|
5750
5530
|
}),
|
|
5751
5531
|
updateUser: builder.mutation({
|
|
5752
|
-
query:
|
|
5532
|
+
query: (data) => ({
|
|
5753
5533
|
url: '/user',
|
|
5754
5534
|
method: 'PATCH',
|
|
5755
5535
|
body: data,
|
|
5756
|
-
})
|
|
5536
|
+
}),
|
|
5757
5537
|
invalidatesTags: ['UserData'],
|
|
5758
5538
|
}),
|
|
5759
|
-
})
|
|
5539
|
+
}),
|
|
5760
5540
|
});
|
|
5761
5541
|
// Export hooks for usage in functional components.
|
|
5762
|
-
|
|
5542
|
+
const {
|
|
5543
|
+
// useLoginQuery,
|
|
5763
5544
|
// useLazyLoginQuery,
|
|
5764
5545
|
// useRefreshTokenQuery,
|
|
5765
5546
|
// useLazyRefreshTokenQuery,
|
|
5766
5547
|
// useLogoutQuery,
|
|
5767
5548
|
// useLazyLogoutQuery,
|
|
5768
|
-
useResetPasswordMutation
|
|
5769
|
-
useResetPasswordAuthMutation
|
|
5549
|
+
useResetPasswordMutation, // Use this for mobile app.
|
|
5550
|
+
useResetPasswordAuthMutation, useRegisterMutation, useVerifyUserQuery, useLazyVerifyUserQuery, useGetUserInfoQuery, useLazyGetUserInfoQuery, useUpdateUserInfoMutation, useForgottenPasswordMutation, useVerifyUserAttributesQuery, useLazyVerifyUserAttributesQuery, useVerifyUserResendQuery, useLazyVerifyUserResendQuery, useUpdateUserMutation, } = authApi;
|
|
5770
5551
|
|
|
5771
|
-
|
|
5552
|
+
const contentApi = createApi({
|
|
5772
5553
|
reducerPath: 'contentApi',
|
|
5773
5554
|
baseQuery: fetchBaseQuery({
|
|
5774
5555
|
baseUrl: APP_ES_INSTANCE,
|
|
5775
|
-
prepareHeaders:
|
|
5556
|
+
prepareHeaders: (headers) => {
|
|
5776
5557
|
headers.set('Authorization', APP_ES_AUTH);
|
|
5777
5558
|
return headers;
|
|
5778
5559
|
},
|
|
5779
5560
|
}),
|
|
5780
5561
|
tagTypes: ['Data', 'Workout'],
|
|
5781
5562
|
// keepUnusedDataFor: 300,
|
|
5782
|
-
endpoints:
|
|
5563
|
+
endpoints: (builder) => ({
|
|
5783
5564
|
getData: builder.query({
|
|
5784
|
-
query:
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
query: options.query || {
|
|
5794
|
-
match_all: {},
|
|
5795
|
-
},
|
|
5565
|
+
query: ({ index, options = {} }) => ({
|
|
5566
|
+
url: `${index}/_search`,
|
|
5567
|
+
method: 'POST',
|
|
5568
|
+
body: {
|
|
5569
|
+
from: 0,
|
|
5570
|
+
size: options.size || 1000,
|
|
5571
|
+
sort: options.sort || [{ created: { order: 'desc' } }],
|
|
5572
|
+
query: options.query || {
|
|
5573
|
+
match_all: {},
|
|
5796
5574
|
},
|
|
5797
|
-
}
|
|
5798
|
-
},
|
|
5799
|
-
transformResponse:
|
|
5575
|
+
},
|
|
5576
|
+
}),
|
|
5577
|
+
transformResponse: (response) => response?.hits?.hits,
|
|
5800
5578
|
providesTags: ['Data'],
|
|
5801
5579
|
}),
|
|
5802
5580
|
getDataById: builder.query({
|
|
5803
|
-
query:
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
query: {
|
|
5813
|
-
terms: (_b = {},
|
|
5814
|
-
_b['uuid.keyword'] = ids,
|
|
5815
|
-
_b),
|
|
5581
|
+
query: ({ index, ids }) => ({
|
|
5582
|
+
url: `${index}/_search`,
|
|
5583
|
+
method: 'POST',
|
|
5584
|
+
body: {
|
|
5585
|
+
from: 0,
|
|
5586
|
+
size: ids.length,
|
|
5587
|
+
query: {
|
|
5588
|
+
terms: {
|
|
5589
|
+
['uuid.keyword']: ids,
|
|
5816
5590
|
},
|
|
5817
5591
|
},
|
|
5818
|
-
}
|
|
5819
|
-
},
|
|
5820
|
-
transformResponse:
|
|
5592
|
+
},
|
|
5593
|
+
}),
|
|
5594
|
+
transformResponse: (response) => response?.hits?.hits,
|
|
5821
5595
|
providesTags: ['Workout'],
|
|
5822
5596
|
}),
|
|
5823
|
-
})
|
|
5597
|
+
}),
|
|
5824
5598
|
});
|
|
5825
|
-
|
|
5599
|
+
const { useGetDataQuery, useLazyGetDataQuery, useGetDataByIdQuery, useLazyGetDataByIdQuery, } = contentApi;
|
|
5826
5600
|
|
|
5827
|
-
|
|
5601
|
+
const paymentApi = createApi({
|
|
5828
5602
|
reducerPath: 'paymentApi',
|
|
5829
5603
|
baseQuery: fetchBaseQuery({
|
|
5830
5604
|
baseUrl: API_PAYMENTS_PREFIX,
|
|
5831
|
-
prepareHeaders:
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
headers.set('idtoken', idToken);
|
|
5845
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5846
|
-
}
|
|
5847
|
-
return [2 /*return*/, headers];
|
|
5848
|
-
}
|
|
5849
|
-
});
|
|
5850
|
-
}); },
|
|
5605
|
+
prepareHeaders: async (headers, {}) => {
|
|
5606
|
+
headers.set('Content-Type', 'application/json');
|
|
5607
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5608
|
+
const session = await awsAmplify.Auth.currentSession();
|
|
5609
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5610
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5611
|
+
if (accessToken && idToken) {
|
|
5612
|
+
headers.set('accesstoken', accessToken);
|
|
5613
|
+
headers.set('idtoken', idToken);
|
|
5614
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5615
|
+
}
|
|
5616
|
+
return headers;
|
|
5617
|
+
},
|
|
5851
5618
|
credentials: 'include',
|
|
5852
5619
|
}),
|
|
5853
5620
|
tagTypes: ['UserSubscription', 'Plans', 'TaxRates', 'PromoCodes'],
|
|
5854
5621
|
// keepUnusedDataFor: 300,
|
|
5855
|
-
endpoints:
|
|
5622
|
+
endpoints: (builder) => ({
|
|
5856
5623
|
/**
|
|
5857
5624
|
* USER API.
|
|
5858
5625
|
*/
|
|
5859
5626
|
checkUserSubscription: builder.query({
|
|
5860
|
-
query:
|
|
5627
|
+
query: (data) => ({
|
|
5861
5628
|
url: '/payment/subscriber',
|
|
5862
5629
|
method: 'POST',
|
|
5863
5630
|
body: {
|
|
@@ -5865,119 +5632,99 @@ var paymentApi = createApi({
|
|
|
5865
5632
|
email: data.email,
|
|
5866
5633
|
sub: data.sub,
|
|
5867
5634
|
},
|
|
5868
|
-
})
|
|
5635
|
+
}),
|
|
5869
5636
|
providesTags: ['UserSubscription'],
|
|
5870
5637
|
}),
|
|
5871
5638
|
getPaymentPlans: builder.query({
|
|
5872
|
-
query:
|
|
5639
|
+
query: () => '/payment/plans',
|
|
5873
5640
|
providesTags: ['Plans'],
|
|
5874
5641
|
}),
|
|
5875
5642
|
getTaxRates: builder.query({
|
|
5876
|
-
query:
|
|
5643
|
+
query: () => ({
|
|
5877
5644
|
url: '/payment/tax-rates',
|
|
5878
5645
|
method: 'GET',
|
|
5879
|
-
})
|
|
5646
|
+
}),
|
|
5880
5647
|
providesTags: ['TaxRates'],
|
|
5881
5648
|
}),
|
|
5882
5649
|
checkPromoCode: builder.query({
|
|
5883
|
-
query:
|
|
5884
|
-
url:
|
|
5650
|
+
query: (promoCode) => ({
|
|
5651
|
+
url: `/payment/coupon/${promoCode}`,
|
|
5885
5652
|
method: 'GET',
|
|
5886
|
-
})
|
|
5653
|
+
}),
|
|
5887
5654
|
providesTags: ['PromoCodes'],
|
|
5888
5655
|
}),
|
|
5889
|
-
})
|
|
5656
|
+
}),
|
|
5890
5657
|
});
|
|
5891
5658
|
// Export hooks for usage in functional components.
|
|
5892
|
-
|
|
5659
|
+
const { useCheckUserSubscriptionQuery, useLazyCheckUserSubscriptionQuery, useGetPaymentPlansQuery, useLazyGetPaymentPlansQuery, useGetTaxRatesQuery, useLazyGetTaxRatesQuery, useCheckPromoCodeQuery, useLazyCheckPromoCodeQuery, } = paymentApi;
|
|
5893
5660
|
|
|
5894
|
-
|
|
5661
|
+
const dataBaseQuery = fetchBaseQuery({
|
|
5895
5662
|
baseUrl: API_ORDERS_PREFIX,
|
|
5896
|
-
prepareHeaders:
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
headers.set('idtoken', idToken);
|
|
5910
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5911
|
-
}
|
|
5912
|
-
return [2 /*return*/, headers];
|
|
5913
|
-
}
|
|
5914
|
-
});
|
|
5915
|
-
}); },
|
|
5663
|
+
prepareHeaders: async (headers, {}) => {
|
|
5664
|
+
headers.set('Content-Type', 'application/json');
|
|
5665
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5666
|
+
const session = await awsAmplify.Auth.currentSession();
|
|
5667
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5668
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5669
|
+
if (accessToken && idToken) {
|
|
5670
|
+
headers.set('accesstoken', accessToken);
|
|
5671
|
+
headers.set('idtoken', idToken);
|
|
5672
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5673
|
+
}
|
|
5674
|
+
return headers;
|
|
5675
|
+
},
|
|
5916
5676
|
credentials: 'include',
|
|
5917
5677
|
});
|
|
5918
5678
|
/**
|
|
5919
5679
|
* This function is used to retry a request if we get a 401 error.
|
|
5920
5680
|
*/
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
user = formatAuthSession(authSession);
|
|
5936
|
-
api.dispatch(setCredentials(user));
|
|
5937
|
-
if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
|
|
5938
|
-
return [4 /*yield*/, dataBaseQuery(args, api, extraOptions)];
|
|
5939
|
-
case 3:
|
|
5940
|
-
// If we get a new access token, retry the original request.
|
|
5941
|
-
result = _b.sent();
|
|
5942
|
-
return [3 /*break*/, 6];
|
|
5943
|
-
case 4:
|
|
5681
|
+
const dataBaseQueryWithReauth = async (args, api, extraOptions) => {
|
|
5682
|
+
let result = await dataBaseQuery(args, api, extraOptions);
|
|
5683
|
+
// If we get a 401 error
|
|
5684
|
+
if (result?.error?.status === 401) {
|
|
5685
|
+
const authSession = await awsAmplify.Auth.currentAuthenticatedUser({
|
|
5686
|
+
bypassCache: true, // Ensures that the user is refreshed from the server
|
|
5687
|
+
});
|
|
5688
|
+
const user = formatAuthSession(authSession);
|
|
5689
|
+
api.dispatch(slice.setCredentials(user));
|
|
5690
|
+
if (authSession?.tokens) {
|
|
5691
|
+
// If we get a new access token, retry the original request.
|
|
5692
|
+
result = await dataBaseQuery(args, api, extraOptions);
|
|
5693
|
+
}
|
|
5694
|
+
else {
|
|
5944
5695
|
// TODO; require full data reset?
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
api.dispatch(logout());
|
|
5950
|
-
// If no access token throw error.
|
|
5951
|
-
throw new Error('No access token found');
|
|
5952
|
-
case 6: return [2 /*return*/, result];
|
|
5696
|
+
await awsAmplify.Auth.signOut();
|
|
5697
|
+
api.dispatch(slice.logout());
|
|
5698
|
+
// If no access token throw error.
|
|
5699
|
+
throw new Error('No access token found');
|
|
5953
5700
|
}
|
|
5954
|
-
}
|
|
5955
|
-
|
|
5956
|
-
|
|
5701
|
+
}
|
|
5702
|
+
return result;
|
|
5703
|
+
};
|
|
5704
|
+
const ordersApi = createApi({
|
|
5957
5705
|
reducerPath: 'ordersApi',
|
|
5958
5706
|
baseQuery: dataBaseQueryWithReauth,
|
|
5959
5707
|
tagTypes: ['Orders'],
|
|
5960
5708
|
// keepUnusedDataFor: 300,
|
|
5961
|
-
endpoints:
|
|
5709
|
+
endpoints: (builder) => ({
|
|
5962
5710
|
/**
|
|
5963
5711
|
* USER API.
|
|
5964
5712
|
*/
|
|
5965
5713
|
fetchOrders: builder.query({
|
|
5966
|
-
query:
|
|
5714
|
+
query: (ids) => ({
|
|
5967
5715
|
url: '/order/search',
|
|
5968
5716
|
method: 'POST',
|
|
5969
5717
|
body: {
|
|
5970
|
-
ids
|
|
5718
|
+
ids,
|
|
5971
5719
|
},
|
|
5972
|
-
})
|
|
5720
|
+
}),
|
|
5973
5721
|
}),
|
|
5974
|
-
})
|
|
5722
|
+
}),
|
|
5975
5723
|
});
|
|
5976
5724
|
// Export hooks for usage in functional components.
|
|
5977
|
-
|
|
5725
|
+
const { useFetchOrdersQuery, useLazyFetchOrdersQuery } = ordersApi;
|
|
5978
5726
|
|
|
5979
|
-
|
|
5980
|
-
var initialState = {
|
|
5727
|
+
const initialState = {
|
|
5981
5728
|
addedItems: [],
|
|
5982
5729
|
netTotal: 0,
|
|
5983
5730
|
taxRate: {
|
|
@@ -5996,125 +5743,141 @@ var initialState = {
|
|
|
5996
5743
|
error: false,
|
|
5997
5744
|
open: false,
|
|
5998
5745
|
};
|
|
5999
|
-
|
|
5746
|
+
const cartSlice = toolkit.createSlice({
|
|
6000
5747
|
name: 'cart',
|
|
6001
|
-
initialState
|
|
5748
|
+
initialState,
|
|
6002
5749
|
reducers: {
|
|
6003
|
-
setTaxRate:
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
if (promoCode
|
|
6007
|
-
|
|
5750
|
+
setTaxRate: (state, action) => {
|
|
5751
|
+
const { netTotal, promoCode } = state;
|
|
5752
|
+
let currentTotal = netTotal;
|
|
5753
|
+
if (promoCode?.code) {
|
|
5754
|
+
const data = applyCoupon(promoCode, currentTotal);
|
|
6008
5755
|
currentTotal = data.discountedTotal;
|
|
6009
5756
|
}
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
return
|
|
5757
|
+
const taxAmount = applyTax(action.payload, currentTotal);
|
|
5758
|
+
const grossTotal = currentTotal + taxAmount;
|
|
5759
|
+
return {
|
|
5760
|
+
...state,
|
|
5761
|
+
taxRate: action.payload,
|
|
5762
|
+
taxAmount,
|
|
5763
|
+
grossTotal,
|
|
5764
|
+
};
|
|
6013
5765
|
},
|
|
6014
|
-
resetTaxRate:
|
|
6015
|
-
return
|
|
5766
|
+
resetTaxRate: (state, action) => {
|
|
5767
|
+
return {
|
|
5768
|
+
...state,
|
|
5769
|
+
taxRate: {
|
|
6016
5770
|
country: 'none',
|
|
6017
5771
|
percentage: 0,
|
|
6018
|
-
},
|
|
5772
|
+
},
|
|
5773
|
+
taxAmount: 0,
|
|
5774
|
+
};
|
|
6019
5775
|
},
|
|
6020
|
-
setPromoCode:
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
return
|
|
5776
|
+
setPromoCode: (state, action) => {
|
|
5777
|
+
const { netTotal, taxRate } = state;
|
|
5778
|
+
const data = applyCoupon(action.payload, netTotal);
|
|
5779
|
+
const taxAmount = applyTax(taxRate, data.discountedTotal);
|
|
5780
|
+
const grossTotal = data.discountedTotal + taxAmount;
|
|
5781
|
+
return {
|
|
5782
|
+
...state,
|
|
5783
|
+
promoCode: {
|
|
6026
5784
|
code: data.code,
|
|
6027
5785
|
name: data.code,
|
|
6028
5786
|
discount: data.discount,
|
|
6029
5787
|
discountedAmount: data.discountedAmount,
|
|
6030
|
-
},
|
|
5788
|
+
},
|
|
5789
|
+
taxAmount,
|
|
5790
|
+
grossTotal,
|
|
5791
|
+
};
|
|
6031
5792
|
},
|
|
6032
|
-
removePromoCode:
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
return
|
|
5793
|
+
removePromoCode: (state, action) => {
|
|
5794
|
+
const { netTotal, taxRate } = state;
|
|
5795
|
+
const taxAmount = applyTax(taxRate, netTotal);
|
|
5796
|
+
const grossTotal = netTotal + taxAmount;
|
|
5797
|
+
return {
|
|
5798
|
+
...state,
|
|
5799
|
+
promoCode: initialState.promoCode,
|
|
5800
|
+
taxAmount,
|
|
5801
|
+
grossTotal,
|
|
5802
|
+
};
|
|
6037
5803
|
},
|
|
6038
|
-
addToCart:
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
5804
|
+
addToCart: (state, action) => {
|
|
5805
|
+
const { options, item } = action.payload;
|
|
5806
|
+
const newTotal = state.netTotal + options.selectedPrice;
|
|
5807
|
+
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
5808
|
+
const grossTotal = newTotal + taxAmount;
|
|
5809
|
+
const addItem = item ? { ...item, options } : null;
|
|
6044
5810
|
if (!addItem) {
|
|
6045
5811
|
return state;
|
|
6046
5812
|
}
|
|
6047
|
-
|
|
6048
|
-
return
|
|
5813
|
+
const addedItems = [...state.addedItems, addItem];
|
|
5814
|
+
return {
|
|
5815
|
+
...state,
|
|
5816
|
+
addedItems: addedItems,
|
|
5817
|
+
netTotal: newTotal,
|
|
5818
|
+
grossTotal: grossTotal,
|
|
5819
|
+
};
|
|
6049
5820
|
},
|
|
6050
|
-
updateCart:
|
|
6051
|
-
|
|
6052
|
-
return
|
|
6053
|
-
|
|
6054
|
-
|
|
5821
|
+
updateCart: (state, action) => {
|
|
5822
|
+
const { options } = action.payload;
|
|
5823
|
+
return {
|
|
5824
|
+
...state,
|
|
5825
|
+
addedItems: state.addedItems.map((item) => item && {
|
|
5826
|
+
...item,
|
|
5827
|
+
options: options,
|
|
5828
|
+
}),
|
|
5829
|
+
};
|
|
6055
5830
|
},
|
|
6056
|
-
removeFromCart:
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
return
|
|
5831
|
+
removeFromCart: (state, action) => {
|
|
5832
|
+
const { id, price } = action.payload;
|
|
5833
|
+
const newTotal = state.netTotal - price;
|
|
5834
|
+
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
5835
|
+
const grossTotal = newTotal + taxAmount;
|
|
5836
|
+
return {
|
|
5837
|
+
...state,
|
|
5838
|
+
addedItems: state.addedItems.filter((item) => item && item.uuid !== id),
|
|
5839
|
+
netTotal: newTotal,
|
|
5840
|
+
grossTotal: grossTotal,
|
|
5841
|
+
};
|
|
6062
5842
|
},
|
|
6063
|
-
toggleCart:
|
|
6064
|
-
return
|
|
5843
|
+
toggleCart: (state, action) => {
|
|
5844
|
+
return {
|
|
5845
|
+
...state,
|
|
5846
|
+
open: action.payload,
|
|
5847
|
+
};
|
|
6065
5848
|
},
|
|
6066
|
-
emptyCart:
|
|
5849
|
+
emptyCart: () => initialState,
|
|
6067
5850
|
},
|
|
6068
5851
|
selectors: {
|
|
6069
|
-
selectMediaInCart:
|
|
6070
|
-
selectCartTotal:
|
|
6071
|
-
selectCartNetTotal:
|
|
6072
|
-
selectCartTaxRate:
|
|
6073
|
-
selectCartTaxAmount:
|
|
6074
|
-
selectCartCount:
|
|
6075
|
-
selectCartStatus:
|
|
6076
|
-
selectPromoCode:
|
|
5852
|
+
selectMediaInCart: (cart) => cart.addedItems,
|
|
5853
|
+
selectCartTotal: (cart) => cart.grossTotal,
|
|
5854
|
+
selectCartNetTotal: (cart) => cart.netTotal,
|
|
5855
|
+
selectCartTaxRate: (cart) => cart.taxRate,
|
|
5856
|
+
selectCartTaxAmount: (cart) => cart.taxAmount,
|
|
5857
|
+
selectCartCount: (cart) => cart.addedItems.length,
|
|
5858
|
+
selectCartStatus: (cart) => cart.open,
|
|
5859
|
+
selectPromoCode: (cart) => cart.promoCode,
|
|
6077
5860
|
},
|
|
6078
5861
|
});
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
return items.map(
|
|
5862
|
+
const { setTaxRate, resetTaxRate, setPromoCode, removePromoCode, addToCart, updateCart, removeFromCart, emptyCart, toggleCart, } = cartSlice.actions;
|
|
5863
|
+
const { selectMediaInCart, selectCartTotal, selectCartNetTotal, selectCartTaxRate, selectCartTaxAmount, selectCartCount, selectCartStatus, selectPromoCode, } = cartSlice.selectors;
|
|
5864
|
+
const selectCartItems = toolkit.createSelector([selectMediaInCart], (items) => {
|
|
5865
|
+
return items.map((item) => {
|
|
6083
5866
|
return {
|
|
6084
5867
|
title: item.title || item.generatedTitle,
|
|
6085
|
-
file:
|
|
5868
|
+
file: `${item.sku}.mp4`,
|
|
6086
5869
|
options: item.options,
|
|
6087
5870
|
script: item.script,
|
|
6088
5871
|
};
|
|
6089
5872
|
});
|
|
6090
5873
|
});
|
|
6091
|
-
|
|
6092
|
-
return items.map(
|
|
5874
|
+
const selectCartItemsIds = toolkit.createSelector([selectMediaInCart], (items) => {
|
|
5875
|
+
return items.map((item) => item.uuid);
|
|
6093
5876
|
});
|
|
6094
5877
|
cartSlice.reducer;
|
|
6095
5878
|
|
|
6096
|
-
var useLoggedIn = function () {
|
|
6097
|
-
var isLoggedIn = reactRedux.useSelector(isAuthenticated);
|
|
6098
|
-
return React.useMemo(function () { return isLoggedIn; }, [isLoggedIn]);
|
|
6099
|
-
};
|
|
6100
|
-
|
|
6101
|
-
// This file serves as a central hub for re-exporting pre-typed Redux hooks.
|
|
6102
|
-
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
|
6103
|
-
var useAppDispatch = isWeb ? reactRedux.useDispatch.withTypes() : reactRedux.useDispatch.withTypes();
|
|
6104
|
-
var useAppSelector = isWeb ? reactRedux.useSelector.withTypes() : reactRedux.useSelector.withTypes();
|
|
6105
|
-
var useAppStore = isWeb ? reactRedux.useStore.withTypes() : reactRedux.useStore.withTypes();
|
|
6106
|
-
|
|
6107
|
-
const Config = reactNative.NativeModules.RNCConfigModule || {};
|
|
6108
|
-
|
|
6109
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
6110
|
-
__proto__: null,
|
|
6111
|
-
Config: Config,
|
|
6112
|
-
default: Config
|
|
6113
|
-
});
|
|
6114
|
-
|
|
6115
5879
|
exports.addToCart = addToCart;
|
|
6116
5880
|
exports.authApi = authApi;
|
|
6117
|
-
exports.authSlice = authSlice;
|
|
6118
5881
|
exports.cartSlice = cartSlice;
|
|
6119
5882
|
exports.contentApi = contentApi;
|
|
6120
5883
|
exports.emptyCart = emptyCart;
|
|
@@ -6144,17 +5907,11 @@ exports.formatTaxonomies = formatTaxonomies;
|
|
|
6144
5907
|
exports.formatUserPayload = formatUserPayload;
|
|
6145
5908
|
exports.formatVideos = formatVideos;
|
|
6146
5909
|
exports.formatWorkout = formatWorkout;
|
|
6147
|
-
exports.getUserSession = getUserSession;
|
|
6148
|
-
exports.isAuthenticated = isAuthenticated;
|
|
6149
|
-
exports.isVerifying = isVerifying;
|
|
6150
|
-
exports.logout = logout;
|
|
6151
5910
|
exports.ordersApi = ordersApi;
|
|
6152
5911
|
exports.paymentApi = paymentApi;
|
|
6153
5912
|
exports.removeFromCart = removeFromCart;
|
|
6154
5913
|
exports.removePromoCode = removePromoCode;
|
|
6155
|
-
exports.resetCreating = resetCreating;
|
|
6156
5914
|
exports.resetTaxRate = resetTaxRate;
|
|
6157
|
-
exports.selectAccessToken = selectAccessToken;
|
|
6158
5915
|
exports.selectCartCount = selectCartCount;
|
|
6159
5916
|
exports.selectCartItems = selectCartItems;
|
|
6160
5917
|
exports.selectCartItemsIds = selectCartItemsIds;
|
|
@@ -6163,32 +5920,18 @@ exports.selectCartStatus = selectCartStatus;
|
|
|
6163
5920
|
exports.selectCartTaxAmount = selectCartTaxAmount;
|
|
6164
5921
|
exports.selectCartTaxRate = selectCartTaxRate;
|
|
6165
5922
|
exports.selectCartTotal = selectCartTotal;
|
|
6166
|
-
exports.selectCurrentUser = selectCurrentUser;
|
|
6167
|
-
exports.selectCurrentUserRefreshToken = selectCurrentUserRefreshToken;
|
|
6168
|
-
exports.selectCurrentUserSub = selectCurrentUserSub;
|
|
6169
5923
|
exports.selectMediaInCart = selectMediaInCart;
|
|
6170
5924
|
exports.selectPromoCode = selectPromoCode;
|
|
6171
|
-
exports.selectRefreshToken = selectRefreshToken;
|
|
6172
|
-
exports.selectSubscription = selectSubscription;
|
|
6173
|
-
exports.selectSubscriptionPrice = selectSubscriptionPrice;
|
|
6174
|
-
exports.selectUserSubscriptionStatus = selectUserSubscriptionStatus;
|
|
6175
|
-
exports.selectUserTokens = selectUserTokens;
|
|
6176
|
-
exports.setCredentials = setCredentials;
|
|
6177
5925
|
exports.setPromoCode = setPromoCode;
|
|
6178
5926
|
exports.setTaxRate = setTaxRate;
|
|
6179
5927
|
exports.toggleCart = toggleCart;
|
|
6180
5928
|
exports.updateCart = updateCart;
|
|
6181
|
-
exports.updateSubscription = updateSubscription;
|
|
6182
|
-
exports.useAppDispatch = useAppDispatch;
|
|
6183
|
-
exports.useAppSelector = useAppSelector;
|
|
6184
|
-
exports.useAppStore = useAppStore;
|
|
6185
5929
|
exports.useForgottenPasswordMutation = useForgottenPasswordMutation;
|
|
6186
5930
|
exports.useGetUserInfoQuery = useGetUserInfoQuery;
|
|
6187
5931
|
exports.useLazyGetUserInfoQuery = useLazyGetUserInfoQuery;
|
|
6188
5932
|
exports.useLazyVerifyUserAttributesQuery = useLazyVerifyUserAttributesQuery;
|
|
6189
5933
|
exports.useLazyVerifyUserQuery = useLazyVerifyUserQuery;
|
|
6190
5934
|
exports.useLazyVerifyUserResendQuery = useLazyVerifyUserResendQuery;
|
|
6191
|
-
exports.useLoggedIn = useLoggedIn;
|
|
6192
5935
|
exports.useRegisterMutation = useRegisterMutation;
|
|
6193
5936
|
exports.useResetPasswordAuthMutation = useResetPasswordAuthMutation;
|
|
6194
5937
|
exports.useResetPasswordMutation = useResetPasswordMutation;
|
|
@@ -6197,4 +5940,4 @@ exports.useUpdateUserMutation = useUpdateUserMutation;
|
|
|
6197
5940
|
exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
|
|
6198
5941
|
exports.useVerifyUserQuery = useVerifyUserQuery;
|
|
6199
5942
|
exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
|
|
6200
|
-
//# sourceMappingURL=
|
|
5943
|
+
//# sourceMappingURL=slice-DsZzY7T7.js.map
|