@techstuff-dev/foundation-api-utils 1.12.0 → 1.14.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/@types/lib/hooks/index.d.ts +60 -60
- package/dist/@types/lib/services/auth/index.d.ts +15 -15
- package/dist/@types/lib/services/auth/slice.d.ts +45 -196
- package/dist/@types/lib/services/content/content.interfaces.d.ts +60 -20
- package/dist/@types/lib/services/content/index.d.ts +2 -2
- package/dist/@types/lib/services/index.d.ts +1 -0
- package/dist/@types/lib/store/index.d.ts +150 -150
- package/dist/@types/lib/types/index.interfaces.d.ts +69 -116
- package/dist/@types/lib/utils/dataFormat/index.d.ts +13 -49
- package/dist/index.esm.js +71 -80
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +91 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,83 +15,33 @@ export type UserCreating = {
|
|
|
15
15
|
details: UserDetails;
|
|
16
16
|
};
|
|
17
17
|
export type User = {
|
|
18
|
-
accessToken
|
|
19
|
-
idToken
|
|
20
|
-
refreshToken
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
accessToken?: string;
|
|
19
|
+
idToken?: string;
|
|
20
|
+
refreshToken?: string;
|
|
21
|
+
expires?: number;
|
|
22
|
+
accessTokenExpiry?: number | null;
|
|
23
|
+
details?: UserDetails;
|
|
24
|
+
email?: string;
|
|
24
25
|
info?: Info;
|
|
26
|
+
sub: string;
|
|
25
27
|
};
|
|
26
28
|
export type UserDetails = {
|
|
27
|
-
userSub
|
|
29
|
+
userSub?: string;
|
|
28
30
|
uuid?: string;
|
|
29
|
-
subscription?: string;
|
|
30
31
|
subscriptionDetails?: {
|
|
32
|
+
status: string;
|
|
31
33
|
id: string;
|
|
32
34
|
created: number;
|
|
33
|
-
status: string;
|
|
34
35
|
nextPayment: number;
|
|
35
36
|
amount: number;
|
|
36
37
|
interval: string;
|
|
37
38
|
currency: string;
|
|
38
|
-
cancelAt
|
|
39
|
+
cancelAt?: number;
|
|
39
40
|
planID: string;
|
|
40
41
|
planDescription: string;
|
|
41
42
|
paymentDetails: {
|
|
42
|
-
response:
|
|
43
|
-
|
|
44
|
-
object: string;
|
|
45
|
-
allow_redisplay: string;
|
|
46
|
-
billing_details: {
|
|
47
|
-
address: {
|
|
48
|
-
city: null;
|
|
49
|
-
country: null;
|
|
50
|
-
line1: null;
|
|
51
|
-
line2: null;
|
|
52
|
-
postal_code: null;
|
|
53
|
-
state: null;
|
|
54
|
-
};
|
|
55
|
-
email: null;
|
|
56
|
-
name: string;
|
|
57
|
-
phone: null;
|
|
58
|
-
};
|
|
59
|
-
card: {
|
|
60
|
-
brand: string;
|
|
61
|
-
checks: {
|
|
62
|
-
address_line1_check: null;
|
|
63
|
-
address_postal_code_check: null;
|
|
64
|
-
cvc_check: string;
|
|
65
|
-
};
|
|
66
|
-
country: string;
|
|
67
|
-
display_brand: string;
|
|
68
|
-
exp_month: number;
|
|
69
|
-
exp_year: number;
|
|
70
|
-
fingerprint: string;
|
|
71
|
-
funding: string;
|
|
72
|
-
generated_from: null;
|
|
73
|
-
last4: string;
|
|
74
|
-
networks: {
|
|
75
|
-
available: string[];
|
|
76
|
-
preferred: null;
|
|
77
|
-
};
|
|
78
|
-
three_d_secure_usage: {
|
|
79
|
-
supported: boolean;
|
|
80
|
-
};
|
|
81
|
-
wallet: null;
|
|
82
|
-
};
|
|
83
|
-
created: number;
|
|
84
|
-
customer: string;
|
|
85
|
-
livemode: boolean;
|
|
86
|
-
metadata: {};
|
|
87
|
-
type: string;
|
|
88
|
-
};
|
|
89
|
-
formatted: {
|
|
90
|
-
id: string;
|
|
91
|
-
maskedNumber: string;
|
|
92
|
-
expirationDate: string;
|
|
93
|
-
cardType: string;
|
|
94
|
-
};
|
|
43
|
+
response: PaymentResponse;
|
|
44
|
+
formatted: FormattedPayment;
|
|
95
45
|
};
|
|
96
46
|
};
|
|
97
47
|
firstName?: string;
|
|
@@ -100,10 +50,11 @@ export type UserDetails = {
|
|
|
100
50
|
avatar?: string;
|
|
101
51
|
termsAccepted?: string;
|
|
102
52
|
dateOfBirth?: string;
|
|
103
|
-
contactPreference
|
|
53
|
+
contactPreference?: boolean;
|
|
104
54
|
password?: string;
|
|
105
55
|
passwordConfirm?: string;
|
|
106
56
|
agency?: boolean;
|
|
57
|
+
[key: string]: any;
|
|
107
58
|
};
|
|
108
59
|
export type Info = {
|
|
109
60
|
orders?: string[];
|
|
@@ -209,7 +160,7 @@ export interface LogoutResponse {
|
|
|
209
160
|
export interface UpdateUserInfoRequest {
|
|
210
161
|
sub: string;
|
|
211
162
|
expressions: {
|
|
212
|
-
|
|
163
|
+
[key: string]: {
|
|
213
164
|
KEY: string;
|
|
214
165
|
VALUE: any[];
|
|
215
166
|
};
|
|
@@ -310,58 +261,60 @@ export interface UserSubResponse {
|
|
|
310
261
|
status: string;
|
|
311
262
|
};
|
|
312
263
|
payment: {
|
|
313
|
-
response:
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
type: string;
|
|
264
|
+
response: PaymentResponse;
|
|
265
|
+
formatted: FormattedPayment;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
export interface FormattedPayment {
|
|
269
|
+
id: string;
|
|
270
|
+
maskedNumber: string;
|
|
271
|
+
expirationDate: string;
|
|
272
|
+
cardType: string;
|
|
273
|
+
}
|
|
274
|
+
export interface PaymentResponse {
|
|
275
|
+
id: string;
|
|
276
|
+
object: string;
|
|
277
|
+
allow_redisplay: string;
|
|
278
|
+
billing_details: {
|
|
279
|
+
address: {
|
|
280
|
+
city: null;
|
|
281
|
+
country: null;
|
|
282
|
+
line1: null;
|
|
283
|
+
line2: null;
|
|
284
|
+
postal_code: null;
|
|
285
|
+
state: null;
|
|
286
|
+
};
|
|
287
|
+
email: null;
|
|
288
|
+
name: string;
|
|
289
|
+
phone: null;
|
|
290
|
+
};
|
|
291
|
+
card: {
|
|
292
|
+
brand: string;
|
|
293
|
+
checks: {
|
|
294
|
+
address_line1_check: null;
|
|
295
|
+
address_postal_code_check: null;
|
|
296
|
+
cvc_check: string;
|
|
297
|
+
};
|
|
298
|
+
country: string;
|
|
299
|
+
display_brand: string;
|
|
300
|
+
exp_month: number;
|
|
301
|
+
exp_year: number;
|
|
302
|
+
fingerprint: string;
|
|
303
|
+
funding: string;
|
|
304
|
+
generated_from: null;
|
|
305
|
+
last4: string;
|
|
306
|
+
networks: {
|
|
307
|
+
available: string[];
|
|
308
|
+
preferred: null;
|
|
359
309
|
};
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
maskedNumber: string;
|
|
363
|
-
expirationDate: string;
|
|
364
|
-
cardType: string;
|
|
310
|
+
three_d_secure_usage: {
|
|
311
|
+
supported: boolean;
|
|
365
312
|
};
|
|
313
|
+
wallet: null;
|
|
366
314
|
};
|
|
315
|
+
created: number;
|
|
316
|
+
customer: string;
|
|
317
|
+
livemode: boolean;
|
|
318
|
+
metadata: {};
|
|
319
|
+
type: string;
|
|
367
320
|
}
|
|
@@ -51,7 +51,7 @@ export declare function formatLongform(data: ESLongForm[]): {
|
|
|
51
51
|
image_promo_large: string | undefined;
|
|
52
52
|
image_poster: string | undefined;
|
|
53
53
|
summary: string | undefined;
|
|
54
|
-
created:
|
|
54
|
+
created: number | undefined;
|
|
55
55
|
updated: string | undefined;
|
|
56
56
|
video: string | undefined;
|
|
57
57
|
rating: string | undefined;
|
|
@@ -69,23 +69,14 @@ export declare function formatFaqs(data: ESFaq[]): {
|
|
|
69
69
|
id: string | undefined;
|
|
70
70
|
title: string | undefined;
|
|
71
71
|
answer: string | undefined;
|
|
72
|
-
created:
|
|
73
|
-
updated:
|
|
74
|
-
}[];
|
|
75
|
-
export declare function formatPages(data: ESPage[]): {
|
|
76
|
-
uuid: string | undefined;
|
|
77
|
-
id: string | undefined;
|
|
78
|
-
title: string | undefined;
|
|
79
|
-
body: string | undefined;
|
|
80
|
-
created: string | undefined;
|
|
81
|
-
updated: string | undefined;
|
|
82
|
-
langcode: string | undefined;
|
|
83
|
-
url: string | undefined;
|
|
72
|
+
created: number | undefined;
|
|
73
|
+
updated: number | undefined;
|
|
84
74
|
}[];
|
|
75
|
+
export declare function formatPages(data: ESPage[]): Page[];
|
|
85
76
|
export declare function formatSettings(data: ESSetting[]): {
|
|
86
77
|
uuid: string | undefined;
|
|
87
|
-
created:
|
|
88
|
-
updated:
|
|
78
|
+
created: number | undefined;
|
|
79
|
+
updated: number | undefined;
|
|
89
80
|
status: string | undefined;
|
|
90
81
|
type: string | undefined;
|
|
91
82
|
video: string | undefined;
|
|
@@ -95,8 +86,8 @@ export declare function formatSettings(data: ESSetting[]): {
|
|
|
95
86
|
}[];
|
|
96
87
|
export declare function formatPress(data: ESPress[]): {
|
|
97
88
|
uuid: string | undefined;
|
|
98
|
-
created:
|
|
99
|
-
updated:
|
|
89
|
+
created: number | undefined;
|
|
90
|
+
updated: number | undefined;
|
|
100
91
|
image: string | undefined;
|
|
101
92
|
title: string | undefined;
|
|
102
93
|
}[];
|
|
@@ -104,41 +95,14 @@ export declare function formatGuests(data: ESGuest[]): {
|
|
|
104
95
|
uuid: string | undefined;
|
|
105
96
|
id: string | undefined;
|
|
106
97
|
title: string | undefined;
|
|
107
|
-
updated:
|
|
98
|
+
updated: number | undefined;
|
|
108
99
|
description: string | undefined;
|
|
109
100
|
image: string | undefined;
|
|
110
101
|
display: string | undefined;
|
|
111
102
|
}[];
|
|
112
103
|
export declare function formatVideos(data: ESVideo[]): Video[];
|
|
113
|
-
export declare function formatSections(data: ESSection[]):
|
|
114
|
-
uuid: string | undefined;
|
|
115
|
-
title: string | undefined;
|
|
116
|
-
description: string | undefined;
|
|
117
|
-
image: string | undefined;
|
|
118
|
-
challenge: string | undefined;
|
|
119
|
-
display: string | undefined;
|
|
120
|
-
id: string | undefined;
|
|
121
|
-
}[];
|
|
104
|
+
export declare function formatSections(data: ESSection[]): Section[];
|
|
122
105
|
export declare function formatSchedule(data: ESSchedule[]): Schedule[];
|
|
123
|
-
export declare function formatChallenges(data: ESChallenge[]):
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
body: string | undefined;
|
|
127
|
-
image: string | undefined;
|
|
128
|
-
challengeKey: string | undefined;
|
|
129
|
-
created: string | undefined;
|
|
130
|
-
days: string[] | undefined;
|
|
131
|
-
updated: string | undefined;
|
|
132
|
-
purchaseButtonLabel: string | undefined;
|
|
133
|
-
price: string | undefined;
|
|
134
|
-
}[];
|
|
135
|
-
export declare function formatChallengeDays(data: ESChallengeDay[]): {
|
|
136
|
-
uuid: string | undefined;
|
|
137
|
-
title: string | undefined;
|
|
138
|
-
body: string | undefined;
|
|
139
|
-
image: string | undefined;
|
|
140
|
-
created: string | undefined;
|
|
141
|
-
updated: string | undefined;
|
|
142
|
-
video: string | undefined;
|
|
143
|
-
workout: string | undefined;
|
|
144
|
-
}[];
|
|
106
|
+
export declare function formatChallenges(data: ESChallenge[]): Challenge[];
|
|
107
|
+
export declare function formatChallengeDays(data: ESChallengeDay[]): ChallengeDay[];
|
|
108
|
+
export declare function formatSecondsToISO8601Duration(seconds?: number): string;
|
package/dist/index.esm.js
CHANGED
|
@@ -99,6 +99,7 @@ var initialState = {
|
|
|
99
99
|
accessTokenExpiry: null,
|
|
100
100
|
refreshToken: '',
|
|
101
101
|
email: '',
|
|
102
|
+
sub: '',
|
|
102
103
|
},
|
|
103
104
|
creating: {
|
|
104
105
|
details: '',
|
|
@@ -135,7 +136,7 @@ var authSlice = createSlice({
|
|
|
135
136
|
selectUserCreatingDetails: function (auth) { return auth.creating.details; },
|
|
136
137
|
isVerifying: function (auth) { return auth.verifying; },
|
|
137
138
|
getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
|
|
138
|
-
selectCurrentUserSub: function (auth) { return auth.user.
|
|
139
|
+
selectCurrentUserSub: function (auth) { return auth.user.sub; },
|
|
139
140
|
selectCurrentUserRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
140
141
|
selectUserTokens: function (auth) {
|
|
141
142
|
return {
|
|
@@ -145,15 +146,16 @@ var authSlice = createSlice({
|
|
|
145
146
|
};
|
|
146
147
|
},
|
|
147
148
|
selectUserSubscriptionStatus: function (auth) {
|
|
148
|
-
var _a;
|
|
149
|
-
return (_a = auth.user.details.subscriptionDetails) === null ||
|
|
149
|
+
var _a, _b, _c;
|
|
150
|
+
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;
|
|
150
151
|
},
|
|
151
152
|
selectSubscription: function (auth) {
|
|
152
|
-
|
|
153
|
+
var _a, _b;
|
|
154
|
+
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;
|
|
153
155
|
},
|
|
154
156
|
selectSubscriptionPrice: function (auth) {
|
|
155
|
-
var _a;
|
|
156
|
-
return (_a = auth.user.details.subscriptionDetails) === null ||
|
|
157
|
+
var _a, _b, _c;
|
|
158
|
+
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;
|
|
157
159
|
},
|
|
158
160
|
},
|
|
159
161
|
});
|
|
@@ -165,6 +167,7 @@ authSlice.reducer;
|
|
|
165
167
|
|
|
166
168
|
// TODO: typing.
|
|
167
169
|
var formatUserPayload = function (payload) {
|
|
170
|
+
console.log('formatUserPayload', payload);
|
|
168
171
|
var userEmail = payload.email, firstName = payload.given_name, lastName = payload.family_name, dateOfBirth = payload.birthdate, uuid = payload["cognito:username"], termsAccepted = payload["custom:termsAccepted"], subscriptionId = payload["custom:subscriptionId"], contactPreference = payload["custom:contactPreferences"], customerId = payload["custom:customerId"];
|
|
169
172
|
var parsedTermsAccepted = termsAccepted ? JSON.parse(termsAccepted) : null;
|
|
170
173
|
var parsedContactPreference = contactPreference
|
|
@@ -182,6 +185,7 @@ var formatUserPayload = function (payload) {
|
|
|
182
185
|
subscription: subscriptionId || null,
|
|
183
186
|
customerId: customerId,
|
|
184
187
|
};
|
|
188
|
+
console.log('formatUserPayload', data);
|
|
185
189
|
return data;
|
|
186
190
|
};
|
|
187
191
|
function formatPromos(data) {
|
|
@@ -212,30 +216,29 @@ function formatPromos(data) {
|
|
|
212
216
|
});
|
|
213
217
|
}
|
|
214
218
|
function formatWorkout(data) {
|
|
215
|
-
|
|
216
|
-
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
|
|
219
|
+
return data.map(function (item) {
|
|
220
|
+
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;
|
|
217
221
|
return {
|
|
218
222
|
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],
|
|
219
223
|
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],
|
|
220
224
|
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],
|
|
221
225
|
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],
|
|
222
|
-
duration: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.
|
|
223
|
-
duration_filter:
|
|
224
|
-
level: (
|
|
225
|
-
published: (
|
|
226
|
-
targeted_section: (
|
|
227
|
-
uid: (
|
|
228
|
-
image: (
|
|
229
|
-
title: (
|
|
230
|
-
video: (
|
|
231
|
-
videoDownload: (
|
|
232
|
-
videoPoster: (
|
|
233
|
-
workoutCategory: (
|
|
234
|
-
workoutType: (
|
|
235
|
-
|
|
226
|
+
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],
|
|
227
|
+
// duration_filter: item?._source?.duration_filter?.[0],
|
|
228
|
+
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],
|
|
229
|
+
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],
|
|
230
|
+
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],
|
|
231
|
+
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],
|
|
232
|
+
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],
|
|
233
|
+
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],
|
|
234
|
+
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],
|
|
235
|
+
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],
|
|
236
|
+
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],
|
|
237
|
+
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],
|
|
238
|
+
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],
|
|
239
|
+
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],
|
|
236
240
|
};
|
|
237
241
|
});
|
|
238
|
-
return response;
|
|
239
242
|
}
|
|
240
243
|
function formatSeries(data, channel) {
|
|
241
244
|
var formattedSeriesSelection = data.map(function (series) {
|
|
@@ -376,7 +379,7 @@ function formatGuests(data) {
|
|
|
376
379
|
});
|
|
377
380
|
}
|
|
378
381
|
function formatVideos(data) {
|
|
379
|
-
|
|
382
|
+
return data.map(function (item) {
|
|
380
383
|
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;
|
|
381
384
|
return {
|
|
382
385
|
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],
|
|
@@ -388,12 +391,11 @@ function formatVideos(data) {
|
|
|
388
391
|
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],
|
|
389
392
|
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],
|
|
390
393
|
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],
|
|
391
|
-
|
|
394
|
+
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],
|
|
392
395
|
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],
|
|
393
396
|
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],
|
|
394
397
|
};
|
|
395
398
|
});
|
|
396
|
-
return response;
|
|
397
399
|
}
|
|
398
400
|
function formatSections(data) {
|
|
399
401
|
return data.map(function (item) {
|
|
@@ -508,9 +510,10 @@ function formatSchedule(data) {
|
|
|
508
510
|
}
|
|
509
511
|
function formatChallenges(data) {
|
|
510
512
|
return data.map(function (item) {
|
|
513
|
+
var _a;
|
|
511
514
|
var _source = item._source;
|
|
512
515
|
return {
|
|
513
|
-
uuid: _source
|
|
516
|
+
uuid: (_a = _source === null || _source === void 0 ? void 0 : _source.uuid) === null || _a === void 0 ? void 0 : _a[0],
|
|
514
517
|
title: _source.title && _source.title[0],
|
|
515
518
|
body: _source.body && _source.body[0],
|
|
516
519
|
image: _source.image && _source.image[0],
|
|
@@ -538,6 +541,26 @@ function formatChallengeDays(data) {
|
|
|
538
541
|
};
|
|
539
542
|
});
|
|
540
543
|
}
|
|
544
|
+
function formatSecondsToISO8601Duration(seconds) {
|
|
545
|
+
if (!seconds)
|
|
546
|
+
return '';
|
|
547
|
+
// Calculate hours, minutes, and remaining seconds
|
|
548
|
+
var hours = Math.floor(seconds / 3600);
|
|
549
|
+
var minutes = Math.floor((seconds % 3600) / 60);
|
|
550
|
+
var remainingSeconds = seconds % 60;
|
|
551
|
+
// Build the ISO 8601 duration string
|
|
552
|
+
var duration = 'PT';
|
|
553
|
+
if (hours > 0) {
|
|
554
|
+
duration += "".concat(hours, "H");
|
|
555
|
+
}
|
|
556
|
+
if (minutes > 0) {
|
|
557
|
+
duration += "".concat(minutes, "M");
|
|
558
|
+
}
|
|
559
|
+
if (remainingSeconds > 0 || duration === 'PT') {
|
|
560
|
+
duration += "".concat(remainingSeconds, "S");
|
|
561
|
+
}
|
|
562
|
+
return duration;
|
|
563
|
+
}
|
|
541
564
|
|
|
542
565
|
// console.log('process.env', process.env);
|
|
543
566
|
// console.log('process.env?.WEB_APP', process.env?.WEB_APP);
|
|
@@ -585,17 +608,17 @@ var authApi = createApi({
|
|
|
585
608
|
// add accessToken to headers from slice using selectAccessToken selector
|
|
586
609
|
var tokens = selectUserTokens(state);
|
|
587
610
|
console.log('tokens: ', tokens);
|
|
588
|
-
if (tokens) {
|
|
611
|
+
if (tokens.accessToken && tokens.idToken) {
|
|
589
612
|
headers.set('accesstoken', tokens.accessToken);
|
|
590
613
|
headers.set('idtoken', tokens.idToken);
|
|
591
|
-
headers.set('refreshtoken', tokens.refreshToken);
|
|
614
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
592
615
|
}
|
|
593
616
|
return headers;
|
|
594
617
|
},
|
|
595
618
|
credentials: 'include',
|
|
596
619
|
}),
|
|
597
|
-
tagTypes: ['UserToken'],
|
|
598
|
-
keepUnusedDataFor: 300,
|
|
620
|
+
tagTypes: ['UserToken', 'UserData'],
|
|
621
|
+
// keepUnusedDataFor: 300,
|
|
599
622
|
endpoints: function (builder) { return ({
|
|
600
623
|
/**
|
|
601
624
|
* USER API.
|
|
@@ -845,6 +868,7 @@ var authApi = createApi({
|
|
|
845
868
|
url: "/data/user/".concat(uuid),
|
|
846
869
|
method: 'GET',
|
|
847
870
|
}); },
|
|
871
|
+
providesTags: ['UserData'],
|
|
848
872
|
}),
|
|
849
873
|
updateUserInfo: builder.mutation({
|
|
850
874
|
query: function (expressions) { return ({
|
|
@@ -852,6 +876,7 @@ var authApi = createApi({
|
|
|
852
876
|
method: 'PATCH',
|
|
853
877
|
body: expressions,
|
|
854
878
|
}); },
|
|
879
|
+
invalidatesTags: ['UserData'],
|
|
855
880
|
}),
|
|
856
881
|
updateUser: builder.mutation({
|
|
857
882
|
query: function (data) { return ({
|
|
@@ -859,14 +884,13 @@ var authApi = createApi({
|
|
|
859
884
|
method: 'PATCH',
|
|
860
885
|
body: data,
|
|
861
886
|
}); },
|
|
887
|
+
invalidatesTags: ['UserData'],
|
|
862
888
|
}),
|
|
863
889
|
}); },
|
|
864
890
|
});
|
|
865
891
|
// Export hooks for usage in functional components.
|
|
866
|
-
authApi.useLoginQuery
|
|
892
|
+
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;
|
|
867
893
|
|
|
868
|
-
// console.log('APP_ES_INSTANCE', APP_ES_INSTANCE);
|
|
869
|
-
// console.log('APP_ES_AUTH', APP_ES_AUTH);
|
|
870
894
|
var contentApi = createApi({
|
|
871
895
|
reducerPath: 'contentApi',
|
|
872
896
|
baseQuery: fetchBaseQuery({
|
|
@@ -898,41 +922,7 @@ var contentApi = createApi({
|
|
|
898
922
|
transformResponse: function (response) { var _a; return (_a = response === null || response === void 0 ? void 0 : response.hits) === null || _a === void 0 ? void 0 : _a.hits; },
|
|
899
923
|
providesTags: ['Data'],
|
|
900
924
|
}),
|
|
901
|
-
|
|
902
|
-
// query: (index) => ({
|
|
903
|
-
// url: `${index}/_search`,
|
|
904
|
-
// method: 'POST',
|
|
905
|
-
// body: {
|
|
906
|
-
// from: 0,
|
|
907
|
-
// size: 100,
|
|
908
|
-
// sort: [{ created: { order: 'desc' } }],
|
|
909
|
-
// query: {
|
|
910
|
-
// match_all: {},
|
|
911
|
-
// },
|
|
912
|
-
// },
|
|
913
|
-
// }),
|
|
914
|
-
// transformResponse: (response: ESPromoResponse) =>
|
|
915
|
-
// formatPromos(response?.hits?.hits),
|
|
916
|
-
// providesTags: ['Promos'],
|
|
917
|
-
// }),
|
|
918
|
-
// getWorkouts: builder.query<Workout[], string | undefined>({
|
|
919
|
-
// query: (index) => ({
|
|
920
|
-
// url: `${index}/_search`,
|
|
921
|
-
// method: 'POST',
|
|
922
|
-
// body: {
|
|
923
|
-
// from: 0,
|
|
924
|
-
// size: 100,
|
|
925
|
-
// sort: [{ created: { order: 'desc' } }],
|
|
926
|
-
// query: {
|
|
927
|
-
// match_all: {},
|
|
928
|
-
// },
|
|
929
|
-
// },
|
|
930
|
-
// }),
|
|
931
|
-
// transformResponse: (response: ESWorkoutResponse) =>
|
|
932
|
-
// formatESWorkoutItems(response?.hits?.hits),
|
|
933
|
-
// providesTags: ['Workouts'],
|
|
934
|
-
// }),
|
|
935
|
-
getWorkoutById: builder.query({
|
|
925
|
+
getDataById: builder.query({
|
|
936
926
|
query: function (_a) {
|
|
937
927
|
var index = _a.index, id = _a.id;
|
|
938
928
|
return ({
|
|
@@ -940,25 +930,20 @@ var contentApi = createApi({
|
|
|
940
930
|
method: 'POST',
|
|
941
931
|
body: {
|
|
942
932
|
query: {
|
|
943
|
-
|
|
933
|
+
match: {
|
|
944
934
|
uuid: id,
|
|
945
935
|
},
|
|
946
936
|
},
|
|
947
937
|
},
|
|
948
938
|
});
|
|
949
939
|
},
|
|
940
|
+
transformResponse: function (response) { var _a; return (_a = response === null || response === void 0 ? void 0 : response.hits) === null || _a === void 0 ? void 0 : _a.hits; },
|
|
950
941
|
providesTags: ['Workout'],
|
|
951
942
|
}),
|
|
952
943
|
}); },
|
|
953
944
|
});
|
|
954
|
-
contentApi.useGetDataQuery; contentApi.useLazyGetDataQuery;
|
|
955
|
-
// useGetPromosQuery,
|
|
956
|
-
// useLazyGetPromosQuery,
|
|
957
|
-
// useGetWorkoutsQuery,
|
|
958
|
-
// useLazyGetWorkoutsQuery,
|
|
959
|
-
contentApi.useGetWorkoutByIdQuery; contentApi.useLazyGetWorkoutByIdQuery;
|
|
945
|
+
contentApi.useGetDataQuery; contentApi.useLazyGetDataQuery; contentApi.useGetDataByIdQuery; contentApi.useLazyGetDataByIdQuery;
|
|
960
946
|
|
|
961
|
-
console.log('API_PAYMENTS_PREFIX: ', API_PAYMENTS_PREFIX);
|
|
962
947
|
var paymentApi = createApi({
|
|
963
948
|
reducerPath: 'paymentApi',
|
|
964
949
|
baseQuery: fetchBaseQuery({
|
|
@@ -970,10 +955,10 @@ var paymentApi = createApi({
|
|
|
970
955
|
// add accessToken to headers from slice using selectAccessToken selector
|
|
971
956
|
var tokens = selectUserTokens(state);
|
|
972
957
|
console.log('tokens: ', tokens);
|
|
973
|
-
if (tokens) {
|
|
958
|
+
if (tokens.accessToken && tokens.idToken) {
|
|
974
959
|
headers.set('accesstoken', tokens.accessToken);
|
|
975
960
|
headers.set('idtoken', tokens.idToken);
|
|
976
|
-
headers.set('refreshtoken', tokens.refreshToken);
|
|
961
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
977
962
|
}
|
|
978
963
|
return headers;
|
|
979
964
|
},
|
|
@@ -1052,6 +1037,12 @@ function createPersistStorage() {
|
|
|
1052
1037
|
|
|
1053
1038
|
// Infer the `RootState` type from the root reducer
|
|
1054
1039
|
var rootReducer = combineSlices(authSlice, authApi, contentApi, paymentApi);
|
|
1040
|
+
// export interface RootState {
|
|
1041
|
+
// [authSlice.name]: ReturnType<typeof authSlice.reducer>;
|
|
1042
|
+
// [authApi.reducerPath]: ReturnType<typeof authApi.reducer>;
|
|
1043
|
+
// [contentApi.reducerPath]: ReturnType<typeof contentApi.reducer>;
|
|
1044
|
+
// [paymentApi.reducerPath]: ReturnType<typeof paymentApi.reducer>;
|
|
1045
|
+
// }
|
|
1055
1046
|
// eg. ['auth', 'creating'], or an empty array if you don't want to whitelist any.
|
|
1056
1047
|
// const storageWhiteList: string[] = [];
|
|
1057
1048
|
// `makeStore` encapsulates the store configuration to allow
|
|
@@ -1141,5 +1132,5 @@ var makeWebStore = function () {
|
|
|
1141
1132
|
var nativeStore = !isWeb && makeNativeStore();
|
|
1142
1133
|
var webStore = isWeb && makeWebStore();
|
|
1143
1134
|
|
|
1144
|
-
export { authApi, authSlice, contentApi, formatChallengeDays, formatChallenges, formatFaqs, formatGuests, formatLongform, formatPages, formatPress, formatPromos, formatSchedule, formatSections, formatSeries, formatSettings, formatShortform, formatUserPayload, formatVideos, formatWorkout, getUserSession, isAuthenticated, isVerifying, logout, nativeStore, paymentApi, resetCreating, selectAccessToken, selectCurrentUser, selectCurrentUserRefreshToken, selectCurrentUserSub, selectRefreshToken, selectSubscription, selectSubscriptionPrice, selectUserCreating, selectUserCreatingDetails, selectUserSubscriptionStatus, selectUserTokens, setCredentials, updateSubscription, useAppDispatch, useAppSelector, useAppStore, useLoggedIn, webStore };
|
|
1135
|
+
export { authApi, authSlice, contentApi, formatChallengeDays, formatChallenges, formatFaqs, formatGuests, formatLongform, formatPages, formatPress, formatPromos, formatSchedule, formatSecondsToISO8601Duration, formatSections, formatSeries, formatSettings, formatShortform, formatUserPayload, formatVideos, formatWorkout, getUserSession, isAuthenticated, isVerifying, logout, nativeStore, paymentApi, resetCreating, selectAccessToken, selectCurrentUser, selectCurrentUserRefreshToken, selectCurrentUserSub, selectRefreshToken, selectSubscription, selectSubscriptionPrice, selectUserCreating, selectUserCreatingDetails, selectUserSubscriptionStatus, selectUserTokens, setCredentials, updateSubscription, useAppDispatch, useAppSelector, useAppStore, useForgottenPasswordMutation, useGetUserInfoQuery, useLazyGetUserInfoQuery, useLazyLoginQuery, useLazyLogoutQuery, useLazyRefreshTokenQuery, useLazyVerifyUserAttributesQuery, useLazyVerifyUserQuery, useLazyVerifyUserResendQuery, useLoggedIn, useLoginQuery, useLogoutQuery, useRefreshTokenQuery, useRegisterMutation, useResetPasswordAuthMutation, useResetPasswordMutation, useUpdateUserInfoMutation, useUpdateUserMutation, useVerifyUserAttributesQuery, useVerifyUserQuery, useVerifyUserResendQuery, webStore };
|
|
1145
1136
|
//# sourceMappingURL=index.esm.js.map
|