@techstuff-dev/foundation-api-utils 1.13.0 → 1.15.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/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('@reduxjs/toolkit/query/react');
4
+ var auth = require('@aws-amplify/auth');
4
5
  var jwtDecode = require('jwt-decode');
5
6
  var toolkit = require('@reduxjs/toolkit');
6
7
  var reactRedux = require('react-redux');
@@ -101,6 +102,7 @@ var initialState = {
101
102
  accessTokenExpiry: null,
102
103
  refreshToken: '',
103
104
  email: '',
105
+ sub: '',
104
106
  },
105
107
  creating: {
106
108
  details: '',
@@ -137,7 +139,7 @@ var authSlice = toolkit.createSlice({
137
139
  selectUserCreatingDetails: function (auth) { return auth.creating.details; },
138
140
  isVerifying: function (auth) { return auth.verifying; },
139
141
  getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
140
- selectCurrentUserSub: function (auth) { var _a, _b; 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.uuid; },
142
+ selectCurrentUserSub: function (auth) { return auth.user.sub; },
141
143
  selectCurrentUserRefreshToken: function (auth) { return auth.user.refreshToken; },
142
144
  selectUserTokens: function (auth) {
143
145
  return {
@@ -217,30 +219,29 @@ function formatPromos(data) {
217
219
  });
218
220
  }
219
221
  function formatWorkout(data) {
220
- var response = data.map(function (item) {
221
- 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;
222
+ return data.map(function (item) {
223
+ 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;
222
224
  return {
223
225
  changed: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.changed) === null || _b === void 0 ? void 0 : _b[0],
224
226
  created: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.created) === null || _d === void 0 ? void 0 : _d[0],
225
227
  uuid: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.uuid) === null || _f === void 0 ? void 0 : _f[0],
226
228
  description: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.description) === null || _h === void 0 ? void 0 : _h[0],
227
- duration: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.duration) === null || _k === void 0 ? void 0 : _k[0],
228
- duration_filter: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.duration_filter) === null || _m === void 0 ? void 0 : _m[0],
229
- level: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.level) === null || _p === void 0 ? void 0 : _p[0],
230
- published: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.published) === null || _r === void 0 ? void 0 : _r[0],
231
- targeted_section: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.targeted_section) === null || _t === void 0 ? void 0 : _t[0],
232
- uid: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.uid) === null || _v === void 0 ? void 0 : _v[0],
233
- image: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.image) === null || _x === void 0 ? void 0 : _x[0],
234
- title: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.title) === null || _z === void 0 ? void 0 : _z[0],
235
- video: (_1 = (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.video_url) === null || _1 === void 0 ? void 0 : _1[0],
236
- videoDownload: (_3 = (_2 = item === null || item === void 0 ? void 0 : item._source) === null || _2 === void 0 ? void 0 : _2.video_download) === null || _3 === void 0 ? void 0 : _3[0],
237
- videoPoster: (_5 = (_4 = item === null || item === void 0 ? void 0 : item._source) === null || _4 === void 0 ? void 0 : _4.video_poster) === null || _5 === void 0 ? void 0 : _5[0],
238
- workoutCategory: (_7 = (_6 = item === null || item === void 0 ? void 0 : item._source) === null || _6 === void 0 ? void 0 : _6.workout_category) === null || _7 === void 0 ? void 0 : _7[0],
239
- workoutType: (_9 = (_8 = item === null || item === void 0 ? void 0 : item._source) === null || _8 === void 0 ? void 0 : _8.workout_type) === null || _9 === void 0 ? void 0 : _9[0],
240
- livestream_section: (_11 = (_10 = item === null || item === void 0 ? void 0 : item._source) === null || _10 === void 0 ? void 0 : _10.livestream_section) === null || _11 === void 0 ? void 0 : _11[0],
229
+ duration: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.duration_filter) === null || _k === void 0 ? void 0 : _k[0],
230
+ // duration_filter: item?._source?.duration_filter?.[0],
231
+ level: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.level) === null || _m === void 0 ? void 0 : _m[0],
232
+ published: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.published) === null || _p === void 0 ? void 0 : _p[0],
233
+ targeted_section: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.targeted_section) === null || _r === void 0 ? void 0 : _r[0],
234
+ uid: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.uid) === null || _t === void 0 ? void 0 : _t[0],
235
+ image: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.image) === null || _v === void 0 ? void 0 : _v[0],
236
+ title: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.title) === null || _x === void 0 ? void 0 : _x[0],
237
+ video: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.video_url) === null || _z === void 0 ? void 0 : _z[0],
238
+ videoDownload: (_1 = (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.video_download) === null || _1 === void 0 ? void 0 : _1[0],
239
+ videoPoster: (_3 = (_2 = item === null || item === void 0 ? void 0 : item._source) === null || _2 === void 0 ? void 0 : _2.video_poster) === null || _3 === void 0 ? void 0 : _3[0],
240
+ workoutCategory: (_5 = (_4 = item === null || item === void 0 ? void 0 : item._source) === null || _4 === void 0 ? void 0 : _4.workout_category) === null || _5 === void 0 ? void 0 : _5[0],
241
+ workoutType: (_7 = (_6 = item === null || item === void 0 ? void 0 : item._source) === null || _6 === void 0 ? void 0 : _6.workout_type) === null || _7 === void 0 ? void 0 : _7[0],
242
+ livestreamSection: (_9 = (_8 = item === null || item === void 0 ? void 0 : item._source) === null || _8 === void 0 ? void 0 : _8.livestream_section) === null || _9 === void 0 ? void 0 : _9[0],
241
243
  };
242
244
  });
243
- return response;
244
245
  }
245
246
  function formatSeries(data, channel) {
246
247
  var formattedSeriesSelection = data.map(function (series) {
@@ -381,7 +382,7 @@ function formatGuests(data) {
381
382
  });
382
383
  }
383
384
  function formatVideos(data) {
384
- var response = data.map(function (item) {
385
+ return data.map(function (item) {
385
386
  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;
386
387
  return {
387
388
  uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
@@ -393,12 +394,11 @@ function formatVideos(data) {
393
394
  duration: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.duration) === null || _p === void 0 ? void 0 : _p[0],
394
395
  section: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.section) === null || _r === void 0 ? void 0 : _r[0],
395
396
  videoPoster: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.video_poster) === null || _t === void 0 ? void 0 : _t[0],
396
- videoUrl: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.video_url) === null || _v === void 0 ? void 0 : _v[0],
397
+ video: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.video_url) === null || _v === void 0 ? void 0 : _v[0],
397
398
  videoDownload: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.video_download) === null || _x === void 0 ? void 0 : _x[0],
398
399
  sectionId: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.section_id) === null || _z === void 0 ? void 0 : _z[0],
399
400
  };
400
401
  });
401
- return response;
402
402
  }
403
403
  function formatSections(data) {
404
404
  return data.map(function (item) {
@@ -513,9 +513,10 @@ function formatSchedule(data) {
513
513
  }
514
514
  function formatChallenges(data) {
515
515
  return data.map(function (item) {
516
+ var _a;
516
517
  var _source = item._source;
517
518
  return {
518
- uuid: _source.uuid && _source.uuid[0],
519
+ uuid: (_a = _source === null || _source === void 0 ? void 0 : _source.uuid) === null || _a === void 0 ? void 0 : _a[0],
519
520
  title: _source.title && _source.title[0],
520
521
  body: _source.body && _source.body[0],
521
522
  image: _source.image && _source.image[0],
@@ -543,6 +544,48 @@ function formatChallengeDays(data) {
543
544
  };
544
545
  });
545
546
  }
547
+ function formatSecondsToISO8601Duration(seconds) {
548
+ if (!seconds)
549
+ return '';
550
+ // Calculate hours, minutes, and remaining seconds
551
+ var hours = Math.floor(seconds / 3600);
552
+ var minutes = Math.floor((seconds % 3600) / 60);
553
+ var remainingSeconds = seconds % 60;
554
+ // Build the ISO 8601 duration string
555
+ var duration = 'PT';
556
+ if (hours > 0) {
557
+ duration += "".concat(hours, "H");
558
+ }
559
+ if (minutes > 0) {
560
+ duration += "".concat(minutes, "M");
561
+ }
562
+ if (remainingSeconds > 0 || duration === 'PT') {
563
+ duration += "".concat(remainingSeconds, "S");
564
+ }
565
+ return duration;
566
+ }
567
+ function formatAuthSession(session) {
568
+ 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;
569
+ return {
570
+ accessToken: (_a = session === null || session === void 0 ? void 0 : session.tokens) === null || _a === void 0 ? void 0 : _a.accessToken.toString(),
571
+ idToken: (_c = (_b = session === null || session === void 0 ? void 0 : session.tokens) === null || _b === void 0 ? void 0 : _b.idToken) === null || _c === void 0 ? void 0 : _c.toString(),
572
+ refreshToken: undefined,
573
+ accessTokenExpiry: (_f = (_e = (_d = session === null || session === void 0 ? void 0 : session.tokens) === null || _d === void 0 ? void 0 : _d.idToken) === null || _e === void 0 ? void 0 : _e.payload) === null || _f === void 0 ? void 0 : _f.exp,
574
+ expires: (_j = (_h = (_g = session === null || session === void 0 ? void 0 : session.tokens) === null || _g === void 0 ? void 0 : _g.idToken) === null || _h === void 0 ? void 0 : _h.payload) === null || _j === void 0 ? void 0 : _j.exp,
575
+ sub: (_o = (_m = (_l = (_k = session === null || session === void 0 ? void 0 : session.tokens) === null || _k === void 0 ? void 0 : _k.idToken) === null || _l === void 0 ? void 0 : _l.payload) === null || _m === void 0 ? void 0 : _m['cognito:username']) === null || _o === void 0 ? void 0 : _o.toString(),
576
+ details: {
577
+ userEmail: (_s = (_r = (_q = (_p = session === null || session === void 0 ? void 0 : session.tokens) === null || _p === void 0 ? void 0 : _p.idToken) === null || _q === void 0 ? void 0 : _q.payload) === null || _r === void 0 ? void 0 : _r.email) === null || _s === void 0 ? void 0 : _s.toString(),
578
+ firstName: (_w = (_v = (_u = (_t = session === null || session === void 0 ? void 0 : session.tokens) === null || _t === void 0 ? void 0 : _t.idToken) === null || _u === void 0 ? void 0 : _u.payload) === null || _v === void 0 ? void 0 : _v.given_name) === null || _w === void 0 ? void 0 : _w.toString(),
579
+ lastName: (_0 = (_z = (_y = (_x = session === null || session === void 0 ? void 0 : session.tokens) === null || _x === void 0 ? void 0 : _x.idToken) === null || _y === void 0 ? void 0 : _y.payload) === null || _z === void 0 ? void 0 : _z.family_name) === null || _0 === void 0 ? void 0 : _0.toString(),
580
+ dateOfBirth: (_4 = (_3 = (_2 = (_1 = session === null || session === void 0 ? void 0 : session.tokens) === null || _1 === void 0 ? void 0 : _1.idToken) === null || _2 === void 0 ? void 0 : _2.payload) === null || _3 === void 0 ? void 0 : _3.birthdate) === null || _4 === void 0 ? void 0 : _4.toString(),
581
+ 'cognito:username': (_8 = (_7 = (_6 = (_5 = session === null || session === void 0 ? void 0 : session.tokens) === null || _5 === void 0 ? void 0 : _5.idToken) === null || _6 === void 0 ? void 0 : _6.payload) === null || _7 === void 0 ? void 0 : _7['cognito:username']) === null || _8 === void 0 ? void 0 : _8.toString(),
582
+ 'custom:termsAccepted': (_12 = (_11 = (_10 = (_9 = session === null || session === void 0 ? void 0 : session.tokens) === null || _9 === void 0 ? void 0 : _9.idToken) === null || _10 === void 0 ? void 0 : _10.payload) === null || _11 === void 0 ? void 0 : _11['custom:termsAccepted']) === null || _12 === void 0 ? void 0 : _12.toString(),
583
+ 'custom:subscriptionId': (_16 = (_15 = (_14 = (_13 = session === null || session === void 0 ? void 0 : session.tokens) === null || _13 === void 0 ? void 0 : _13.idToken) === null || _14 === void 0 ? void 0 : _14.payload) === null || _15 === void 0 ? void 0 : _15['custom:subscriptionId']) === null || _16 === void 0 ? void 0 : _16.toString(),
584
+ 'custom:contactPreferences': (_20 = (_19 = (_18 = (_17 = session === null || session === void 0 ? void 0 : session.tokens) === null || _17 === void 0 ? void 0 : _17.idToken) === null || _18 === void 0 ? void 0 : _18.payload) === null || _19 === void 0 ? void 0 : _19['custom:contactPreferences']) === null || _20 === void 0 ? void 0 : _20.toString(),
585
+ 'custom:customerId': (_24 = (_23 = (_22 = (_21 = session === null || session === void 0 ? void 0 : session.tokens) === null || _21 === void 0 ? void 0 : _21.idToken) === null || _22 === void 0 ? void 0 : _22.payload) === null || _23 === void 0 ? void 0 : _23['custom:customerId']) === null || _24 === void 0 ? void 0 : _24.toString(),
586
+ },
587
+ };
588
+ }
546
589
 
547
590
  // console.log('process.env', process.env);
548
591
  // console.log('process.env?.WEB_APP', process.env?.WEB_APP);
@@ -579,28 +622,69 @@ var APP_ES_AUTH = ((_f = process.env) === null || _f === void 0 ? void 0 : _f.NE
579
622
  ((_t = process.env) === null || _t === void 0 ? void 0 : _t.NEXT_PUBLIC_APP_ES_CHALLENGE_DAYS_INDEX) ||
580
623
  ENV.APP_ES_CHALLENGE_DAYS_INDEX;
581
624
 
625
+ var authDataBaseQuery = react.fetchBaseQuery({
626
+ baseUrl: API_AUTH_PREFIX,
627
+ prepareHeaders: function (headers_1, _a) { return __awaiter(void 0, [headers_1, _a], void 0, function (headers, _b) {
628
+ var tokens;
629
+ return __generator(this, function (_c) {
630
+ switch (_c.label) {
631
+ case 0:
632
+ headers.set('Content-Type', 'application/json');
633
+ return [4 /*yield*/, auth.fetchAuthSession()];
634
+ case 1:
635
+ tokens = (_c.sent()).tokens;
636
+ if ((tokens === null || tokens === void 0 ? void 0 : tokens.accessToken) && tokens.idToken) {
637
+ headers.set('accesstoken', tokens.accessToken.toString());
638
+ headers.set('idtoken', tokens.idToken.toString());
639
+ // headers.set('refreshtoken', tokens.refreshToken);
640
+ }
641
+ return [2 /*return*/, headers];
642
+ }
643
+ });
644
+ }); },
645
+ credentials: 'include',
646
+ });
647
+ /**
648
+ * This function is used to retry a request if we get a 401 error.
649
+ */
650
+ var authDataBaseQueryWithReauth = function (args, api, extraOptions) { return __awaiter(void 0, void 0, void 0, function () {
651
+ var result, authSession, user;
652
+ var _a;
653
+ return __generator(this, function (_b) {
654
+ switch (_b.label) {
655
+ case 0: return [4 /*yield*/, authDataBaseQuery(args, api, extraOptions)];
656
+ case 1:
657
+ result = _b.sent();
658
+ if (!(((_a = result === null || result === void 0 ? void 0 : result.error) === null || _a === void 0 ? void 0 : _a.status) === 401)) return [3 /*break*/, 6];
659
+ return [4 /*yield*/, auth.fetchAuthSession()];
660
+ case 2:
661
+ authSession = _b.sent();
662
+ user = formatAuthSession(authSession);
663
+ api.dispatch(setCredentials(user));
664
+ if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
665
+ return [4 /*yield*/, authDataBaseQuery(args, api, extraOptions)];
666
+ case 3:
667
+ // If we get a new access token, retry the original request.
668
+ result = _b.sent();
669
+ return [3 /*break*/, 6];
670
+ case 4:
671
+ // TODO; require full data reset?
672
+ return [4 /*yield*/, auth.signOut()];
673
+ case 5:
674
+ // TODO; require full data reset?
675
+ _b.sent();
676
+ api.dispatch(logout());
677
+ // If no access token throw error.
678
+ throw new Error('No access token found');
679
+ case 6: return [2 /*return*/, result];
680
+ }
681
+ });
682
+ }); };
582
683
  var authApi = react.createApi({
583
684
  reducerPath: 'authApi',
584
- baseQuery: react.fetchBaseQuery({
585
- baseUrl: API_AUTH_PREFIX,
586
- prepareHeaders: function (headers, _a) {
587
- var getState = _a.getState;
588
- var state = getState();
589
- headers.set('Content-Type', 'application/json');
590
- // add accessToken to headers from slice using selectAccessToken selector
591
- var tokens = selectUserTokens(state);
592
- console.log('tokens: ', tokens);
593
- if (tokens) {
594
- headers.set('accesstoken', tokens.accessToken);
595
- headers.set('idtoken', tokens.idToken);
596
- headers.set('refreshtoken', tokens.refreshToken);
597
- }
598
- return headers;
599
- },
600
- credentials: 'include',
601
- }),
602
- tagTypes: ['UserToken'],
603
- keepUnusedDataFor: 300,
685
+ baseQuery: authDataBaseQueryWithReauth,
686
+ tagTypes: ['UserToken', 'UserData'],
687
+ // keepUnusedDataFor: 300,
604
688
  endpoints: function (builder) { return ({
605
689
  /**
606
690
  * USER API.
@@ -850,6 +934,7 @@ var authApi = react.createApi({
850
934
  url: "/data/user/".concat(uuid),
851
935
  method: 'GET',
852
936
  }); },
937
+ providesTags: ['UserData'],
853
938
  }),
854
939
  updateUserInfo: builder.mutation({
855
940
  query: function (expressions) { return ({
@@ -857,6 +942,7 @@ var authApi = react.createApi({
857
942
  method: 'PATCH',
858
943
  body: expressions,
859
944
  }); },
945
+ invalidatesTags: ['UserData'],
860
946
  }),
861
947
  updateUser: builder.mutation({
862
948
  query: function (data) { return ({
@@ -864,14 +950,13 @@ var authApi = react.createApi({
864
950
  method: 'PATCH',
865
951
  body: data,
866
952
  }); },
953
+ invalidatesTags: ['UserData'],
867
954
  }),
868
955
  }); },
869
956
  });
870
957
  // Export hooks for usage in functional components.
871
- authApi.useLoginQuery; authApi.useLazyLoginQuery; authApi.useResetPasswordMutation; authApi.useResetPasswordAuthMutation; authApi.useRefreshTokenQuery; authApi.useLazyRefreshTokenQuery; authApi.useLogoutQuery; authApi.useLazyLogoutQuery; authApi.useRegisterMutation; authApi.useVerifyUserQuery; authApi.useLazyVerifyUserQuery; authApi.useGetUserInfoQuery; authApi.useLazyGetUserInfoQuery; authApi.useUpdateUserInfoMutation; authApi.useForgottenPasswordMutation; authApi.useVerifyUserAttributesQuery; authApi.useLazyVerifyUserAttributesQuery; authApi.useVerifyUserResendQuery; authApi.useLazyVerifyUserResendQuery; authApi.useUpdateUserMutation;
958
+ var useLoginQuery = authApi.useLoginQuery, useLazyLoginQuery = authApi.useLazyLoginQuery, useResetPasswordMutation = authApi.useResetPasswordMutation, useResetPasswordAuthMutation = authApi.useResetPasswordAuthMutation, useRefreshTokenQuery = authApi.useRefreshTokenQuery, useLazyRefreshTokenQuery = authApi.useLazyRefreshTokenQuery, useLogoutQuery = authApi.useLogoutQuery, useLazyLogoutQuery = authApi.useLazyLogoutQuery, useRegisterMutation = authApi.useRegisterMutation, useVerifyUserQuery = authApi.useVerifyUserQuery, useLazyVerifyUserQuery = authApi.useLazyVerifyUserQuery, useGetUserInfoQuery = authApi.useGetUserInfoQuery, useLazyGetUserInfoQuery = authApi.useLazyGetUserInfoQuery, useUpdateUserInfoMutation = authApi.useUpdateUserInfoMutation, useForgottenPasswordMutation = authApi.useForgottenPasswordMutation, useVerifyUserAttributesQuery = authApi.useVerifyUserAttributesQuery, useLazyVerifyUserAttributesQuery = authApi.useLazyVerifyUserAttributesQuery, useVerifyUserResendQuery = authApi.useVerifyUserResendQuery, useLazyVerifyUserResendQuery = authApi.useLazyVerifyUserResendQuery, useUpdateUserMutation = authApi.useUpdateUserMutation;
872
959
 
873
- // console.log('APP_ES_INSTANCE', APP_ES_INSTANCE);
874
- // console.log('APP_ES_AUTH', APP_ES_AUTH);
875
960
  var contentApi = react.createApi({
876
961
  reducerPath: 'contentApi',
877
962
  baseQuery: react.fetchBaseQuery({
@@ -903,41 +988,7 @@ var contentApi = react.createApi({
903
988
  transformResponse: function (response) { var _a; return (_a = response === null || response === void 0 ? void 0 : response.hits) === null || _a === void 0 ? void 0 : _a.hits; },
904
989
  providesTags: ['Data'],
905
990
  }),
906
- // getPromos: builder.query<Promo[], string | undefined>({
907
- // query: (index) => ({
908
- // url: `${index}/_search`,
909
- // method: 'POST',
910
- // body: {
911
- // from: 0,
912
- // size: 100,
913
- // sort: [{ created: { order: 'desc' } }],
914
- // query: {
915
- // match_all: {},
916
- // },
917
- // },
918
- // }),
919
- // transformResponse: (response: ESPromoResponse) =>
920
- // formatPromos(response?.hits?.hits),
921
- // providesTags: ['Promos'],
922
- // }),
923
- // getWorkouts: builder.query<Workout[], string | undefined>({
924
- // query: (index) => ({
925
- // url: `${index}/_search`,
926
- // method: 'POST',
927
- // body: {
928
- // from: 0,
929
- // size: 100,
930
- // sort: [{ created: { order: 'desc' } }],
931
- // query: {
932
- // match_all: {},
933
- // },
934
- // },
935
- // }),
936
- // transformResponse: (response: ESWorkoutResponse) =>
937
- // formatESWorkoutItems(response?.hits?.hits),
938
- // providesTags: ['Workouts'],
939
- // }),
940
- getWorkoutById: builder.query({
991
+ getDataById: builder.query({
941
992
  query: function (_a) {
942
993
  var index = _a.index, id = _a.id;
943
994
  return ({
@@ -945,25 +996,20 @@ var contentApi = react.createApi({
945
996
  method: 'POST',
946
997
  body: {
947
998
  query: {
948
- term: {
999
+ match: {
949
1000
  uuid: id,
950
1001
  },
951
1002
  },
952
1003
  },
953
1004
  });
954
1005
  },
1006
+ transformResponse: function (response) { var _a; return (_a = response === null || response === void 0 ? void 0 : response.hits) === null || _a === void 0 ? void 0 : _a.hits; },
955
1007
  providesTags: ['Workout'],
956
1008
  }),
957
1009
  }); },
958
1010
  });
959
- contentApi.useGetDataQuery; contentApi.useLazyGetDataQuery;
960
- // useGetPromosQuery,
961
- // useLazyGetPromosQuery,
962
- // useGetWorkoutsQuery,
963
- // useLazyGetWorkoutsQuery,
964
- contentApi.useGetWorkoutByIdQuery; contentApi.useLazyGetWorkoutByIdQuery;
1011
+ contentApi.useGetDataQuery; contentApi.useLazyGetDataQuery; contentApi.useGetDataByIdQuery; contentApi.useLazyGetDataByIdQuery;
965
1012
 
966
- console.log('API_PAYMENTS_PREFIX: ', API_PAYMENTS_PREFIX);
967
1013
  var paymentApi = react.createApi({
968
1014
  reducerPath: 'paymentApi',
969
1015
  baseQuery: react.fetchBaseQuery({
@@ -975,10 +1021,10 @@ var paymentApi = react.createApi({
975
1021
  // add accessToken to headers from slice using selectAccessToken selector
976
1022
  var tokens = selectUserTokens(state);
977
1023
  console.log('tokens: ', tokens);
978
- if (tokens) {
1024
+ if (tokens.accessToken && tokens.idToken) {
979
1025
  headers.set('accesstoken', tokens.accessToken);
980
1026
  headers.set('idtoken', tokens.idToken);
981
- headers.set('refreshtoken', tokens.refreshToken);
1027
+ // headers.set('refreshtoken', tokens.refreshToken);
982
1028
  }
983
1029
  return headers;
984
1030
  },
@@ -1057,6 +1103,12 @@ function createPersistStorage() {
1057
1103
 
1058
1104
  // Infer the `RootState` type from the root reducer
1059
1105
  var rootReducer = toolkit.combineSlices(authSlice, authApi, contentApi, paymentApi);
1106
+ // export interface RootState {
1107
+ // [authSlice.name]: ReturnType<typeof authSlice.reducer>;
1108
+ // [authApi.reducerPath]: ReturnType<typeof authApi.reducer>;
1109
+ // [contentApi.reducerPath]: ReturnType<typeof contentApi.reducer>;
1110
+ // [paymentApi.reducerPath]: ReturnType<typeof paymentApi.reducer>;
1111
+ // }
1060
1112
  // eg. ['auth', 'creating'], or an empty array if you don't want to whitelist any.
1061
1113
  // const storageWhiteList: string[] = [];
1062
1114
  // `makeStore` encapsulates the store configuration to allow
@@ -1149,6 +1201,7 @@ var webStore = isWeb && makeWebStore();
1149
1201
  exports.authApi = authApi;
1150
1202
  exports.authSlice = authSlice;
1151
1203
  exports.contentApi = contentApi;
1204
+ exports.formatAuthSession = formatAuthSession;
1152
1205
  exports.formatChallengeDays = formatChallengeDays;
1153
1206
  exports.formatChallenges = formatChallenges;
1154
1207
  exports.formatFaqs = formatFaqs;
@@ -1158,6 +1211,7 @@ exports.formatPages = formatPages;
1158
1211
  exports.formatPress = formatPress;
1159
1212
  exports.formatPromos = formatPromos;
1160
1213
  exports.formatSchedule = formatSchedule;
1214
+ exports.formatSecondsToISO8601Duration = formatSecondsToISO8601Duration;
1161
1215
  exports.formatSections = formatSections;
1162
1216
  exports.formatSeries = formatSeries;
1163
1217
  exports.formatSettings = formatSettings;
@@ -1188,6 +1242,26 @@ exports.updateSubscription = updateSubscription;
1188
1242
  exports.useAppDispatch = useAppDispatch;
1189
1243
  exports.useAppSelector = useAppSelector;
1190
1244
  exports.useAppStore = useAppStore;
1245
+ exports.useForgottenPasswordMutation = useForgottenPasswordMutation;
1246
+ exports.useGetUserInfoQuery = useGetUserInfoQuery;
1247
+ exports.useLazyGetUserInfoQuery = useLazyGetUserInfoQuery;
1248
+ exports.useLazyLoginQuery = useLazyLoginQuery;
1249
+ exports.useLazyLogoutQuery = useLazyLogoutQuery;
1250
+ exports.useLazyRefreshTokenQuery = useLazyRefreshTokenQuery;
1251
+ exports.useLazyVerifyUserAttributesQuery = useLazyVerifyUserAttributesQuery;
1252
+ exports.useLazyVerifyUserQuery = useLazyVerifyUserQuery;
1253
+ exports.useLazyVerifyUserResendQuery = useLazyVerifyUserResendQuery;
1191
1254
  exports.useLoggedIn = useLoggedIn;
1255
+ exports.useLoginQuery = useLoginQuery;
1256
+ exports.useLogoutQuery = useLogoutQuery;
1257
+ exports.useRefreshTokenQuery = useRefreshTokenQuery;
1258
+ exports.useRegisterMutation = useRegisterMutation;
1259
+ exports.useResetPasswordAuthMutation = useResetPasswordAuthMutation;
1260
+ exports.useResetPasswordMutation = useResetPasswordMutation;
1261
+ exports.useUpdateUserInfoMutation = useUpdateUserInfoMutation;
1262
+ exports.useUpdateUserMutation = useUpdateUserMutation;
1263
+ exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
1264
+ exports.useVerifyUserQuery = useVerifyUserQuery;
1265
+ exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
1192
1266
  exports.webStore = webStore;
1193
1267
  //# sourceMappingURL=index.js.map