@techstuff-dev/foundation-api-utils 1.11.0 → 1.13.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.
@@ -22,27 +22,7 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
22
22
  };
23
23
  authenticated: boolean;
24
24
  verifying: boolean;
25
- user: import("immer").WritableDraft<{
26
- accessToken: string;
27
- idToken: string;
28
- refreshToken: string;
29
- accessTokenExpiry?: number | undefined;
30
- details: {
31
- subscriptionDetails?: any;
32
- userSub?: string | undefined;
33
- userEmail?: string | undefined;
34
- lastName?: string | undefined;
35
- firstName?: string | undefined;
36
- avatar?: string | undefined;
37
- dateOfBirth?: string | undefined;
38
- termsAccepted: any;
39
- contactPreference: any;
40
- uuid?: string | undefined;
41
- subscription?: string | undefined;
42
- customerId?: string | undefined;
43
- };
44
- email?: string | undefined;
45
- }>;
25
+ user: import("immer").WritableDraft<import("../../types/index.interfaces").User>;
46
26
  loading: boolean;
47
27
  error: boolean;
48
28
  session?: string | undefined;
@@ -56,21 +36,26 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
56
36
  subscription: any;
57
37
  subscriptionDetails: any;
58
38
  userSub?: string | undefined;
59
- userEmail?: string | undefined;
60
- lastName?: string | undefined;
39
+ uuid?: string | undefined;
61
40
  firstName?: string | undefined;
41
+ lastName?: string | undefined;
42
+ userEmail?: string | undefined;
62
43
  avatar?: string | undefined;
44
+ termsAccepted?: string | undefined;
63
45
  dateOfBirth?: string | undefined;
64
- termsAccepted: any;
65
- contactPreference: any;
66
- uuid?: string | undefined;
67
- customerId?: string | undefined;
46
+ contactPreference?: boolean | undefined;
47
+ password?: string | undefined;
48
+ passwordConfirm?: string | undefined;
49
+ agency?: boolean | undefined;
68
50
  };
69
- accessToken: string;
70
- idToken: string;
71
- refreshToken: string;
72
- accessTokenExpiry?: number | undefined;
51
+ accessToken?: string | undefined;
52
+ idToken?: string | undefined;
53
+ refreshToken?: string | undefined;
54
+ expires?: number | undefined;
55
+ accessTokenExpiry?: number | null | undefined;
73
56
  email?: string | undefined;
57
+ info?: import("immer").WritableDraft<import("../../types/index.interfaces").Info> | undefined;
58
+ sub?: string | undefined;
74
59
  };
75
60
  authenticated: boolean;
76
61
  verifying: boolean;
@@ -85,22 +70,9 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
85
70
  logout: () => AuthState;
86
71
  }, "auth", "auth", {
87
72
  isAuthenticated: (auth: AuthState) => boolean;
88
- selectAccessToken: (auth: AuthState) => string;
89
- selectRefreshToken: (auth: AuthState) => string;
90
- selectCurrentUser: (auth: AuthState) => {
91
- subscriptionDetails?: any;
92
- userSub?: string | undefined;
93
- userEmail?: string | undefined;
94
- lastName?: string | undefined;
95
- firstName?: string | undefined;
96
- avatar?: string | undefined;
97
- dateOfBirth?: string | undefined;
98
- termsAccepted: any;
99
- contactPreference: any;
100
- uuid?: string | undefined;
101
- subscription?: string | undefined;
102
- customerId?: string | undefined;
103
- };
73
+ selectAccessToken: (auth: AuthState) => string | undefined;
74
+ selectRefreshToken: (auth: AuthState) => string | undefined;
75
+ selectCurrentUser: (auth: AuthState) => import("../../types/index.interfaces").UserDetails | undefined;
104
76
  selectUserCreating: (auth: AuthState) => {
105
77
  details: string;
106
78
  payment: string;
@@ -109,15 +81,30 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
109
81
  isVerifying: (auth: AuthState) => boolean;
110
82
  getUserSession: (auth: AuthState) => string | false | undefined;
111
83
  selectCurrentUserSub: (auth: AuthState) => string | undefined;
112
- selectCurrentUserRefreshToken: (auth: AuthState) => string;
84
+ selectCurrentUserRefreshToken: (auth: AuthState) => string | undefined;
113
85
  selectUserTokens: (auth: AuthState) => {
114
- accessToken: string;
115
- refreshToken: string;
116
- idToken: string;
86
+ accessToken: string | undefined;
87
+ refreshToken: string | undefined;
88
+ idToken: string | undefined;
117
89
  };
118
- selectUserSubscriptionStatus: (auth: AuthState) => any;
119
- selectSubscription: (auth: AuthState) => string | undefined;
120
- selectSubscriptionPrice: (auth: AuthState) => any;
90
+ selectUserSubscriptionStatus: (auth: AuthState) => string | undefined;
91
+ selectSubscription: (auth: AuthState) => {
92
+ status: string;
93
+ id: string;
94
+ created: number;
95
+ nextPayment: number;
96
+ amount: number;
97
+ interval: string;
98
+ currency: string;
99
+ cancelAt?: number | undefined;
100
+ planID: string;
101
+ planDescription: string;
102
+ paymentDetails: {
103
+ response: import("../../types/index.interfaces").PaymentResponse;
104
+ formatted: import("../../types/index.interfaces").FormattedPayment;
105
+ };
106
+ } | undefined;
107
+ selectSubscriptionPrice: (auth: AuthState) => number | undefined;
121
108
  }>;
122
109
  export declare const setCredentials: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "auth/setCredentials">, resetCreating: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"auth/resetCreating">, logout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"auth/logout">, updateSubscription: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "auth/updateSubscription">;
123
110
  export declare const isAuthenticated: import("reselect").Selector<{
@@ -126,42 +113,16 @@ export declare const isAuthenticated: import("reselect").Selector<{
126
113
  unwrapped: (auth: AuthState) => boolean;
127
114
  }, selectAccessToken: import("reselect").Selector<{
128
115
  auth: AuthState;
129
- }, string, []> & {
130
- unwrapped: (auth: AuthState) => string;
116
+ }, string | undefined, []> & {
117
+ unwrapped: (auth: AuthState) => string | undefined;
131
118
  }, selectRefreshToken: import("reselect").Selector<{
132
119
  auth: AuthState;
133
- }, string, []> & {
134
- unwrapped: (auth: AuthState) => string;
120
+ }, string | undefined, []> & {
121
+ unwrapped: (auth: AuthState) => string | undefined;
135
122
  }, selectCurrentUser: import("reselect").Selector<{
136
123
  auth: AuthState;
137
- }, {
138
- subscriptionDetails?: any;
139
- userSub?: string | undefined;
140
- userEmail?: string | undefined;
141
- lastName?: string | undefined;
142
- firstName?: string | undefined;
143
- avatar?: string | undefined;
144
- dateOfBirth?: string | undefined;
145
- termsAccepted: any;
146
- contactPreference: any;
147
- uuid?: string | undefined;
148
- subscription?: string | undefined;
149
- customerId?: string | undefined;
150
- }, []> & {
151
- unwrapped: (auth: AuthState) => {
152
- subscriptionDetails?: any;
153
- userSub?: string | undefined;
154
- userEmail?: string | undefined;
155
- lastName?: string | undefined;
156
- firstName?: string | undefined;
157
- avatar?: string | undefined;
158
- dateOfBirth?: string | undefined;
159
- termsAccepted: any;
160
- contactPreference: any;
161
- uuid?: string | undefined;
162
- subscription?: string | undefined;
163
- customerId?: string | undefined;
164
- };
124
+ }, import("../../types/index.interfaces").UserDetails | undefined, []> & {
125
+ unwrapped: (auth: AuthState) => import("../../types/index.interfaces").UserDetails | undefined;
165
126
  }, selectUserCreating: import("reselect").Selector<{
166
127
  auth: AuthState;
167
128
  }, {
@@ -190,32 +151,62 @@ export declare const isAuthenticated: import("reselect").Selector<{
190
151
  unwrapped: (auth: AuthState) => string | undefined;
191
152
  }, selectCurrentUserRefreshToken: import("reselect").Selector<{
192
153
  auth: AuthState;
193
- }, string, []> & {
194
- unwrapped: (auth: AuthState) => string;
154
+ }, string | undefined, []> & {
155
+ unwrapped: (auth: AuthState) => string | undefined;
195
156
  }, selectUserTokens: import("reselect").Selector<{
196
157
  auth: AuthState;
197
158
  }, {
198
- accessToken: string;
199
- refreshToken: string;
200
- idToken: string;
159
+ accessToken: string | undefined;
160
+ refreshToken: string | undefined;
161
+ idToken: string | undefined;
201
162
  }, []> & {
202
163
  unwrapped: (auth: AuthState) => {
203
- accessToken: string;
204
- refreshToken: string;
205
- idToken: string;
164
+ accessToken: string | undefined;
165
+ refreshToken: string | undefined;
166
+ idToken: string | undefined;
206
167
  };
207
168
  }, selectUserSubscriptionStatus: import("reselect").Selector<{
208
169
  auth: AuthState;
209
- }, any, []> & {
210
- unwrapped: (auth: AuthState) => any;
211
- }, selectSubscription: import("reselect").Selector<{
212
- auth: AuthState;
213
170
  }, string | undefined, []> & {
214
171
  unwrapped: (auth: AuthState) => string | undefined;
172
+ }, selectSubscription: import("reselect").Selector<{
173
+ auth: AuthState;
174
+ }, {
175
+ status: string;
176
+ id: string;
177
+ created: number;
178
+ nextPayment: number;
179
+ amount: number;
180
+ interval: string;
181
+ currency: string;
182
+ cancelAt?: number | undefined;
183
+ planID: string;
184
+ planDescription: string;
185
+ paymentDetails: {
186
+ response: import("../../types/index.interfaces").PaymentResponse;
187
+ formatted: import("../../types/index.interfaces").FormattedPayment;
188
+ };
189
+ } | undefined, []> & {
190
+ unwrapped: (auth: AuthState) => {
191
+ status: string;
192
+ id: string;
193
+ created: number;
194
+ nextPayment: number;
195
+ amount: number;
196
+ interval: string;
197
+ currency: string;
198
+ cancelAt?: number | undefined;
199
+ planID: string;
200
+ planDescription: string;
201
+ paymentDetails: {
202
+ response: import("../../types/index.interfaces").PaymentResponse;
203
+ formatted: import("../../types/index.interfaces").FormattedPayment;
204
+ };
205
+ } | undefined;
215
206
  }, selectSubscriptionPrice: import("reselect").Selector<{
216
207
  auth: AuthState;
217
- }, any, []> & {
218
- unwrapped: (auth: AuthState) => any;
208
+ }, number | undefined, []> & {
209
+ unwrapped: (auth: AuthState) => number | undefined;
219
210
  };
220
211
  declare const _default: import("redux").Reducer<AuthState>;
221
212
  export default _default;
@@ -15,19 +15,34 @@ export type UserCreating = {
15
15
  details: UserDetails;
16
16
  };
17
17
  export type User = {
18
- accessToken: string;
19
- idToken: string;
20
- refreshToken: string;
21
- accessTokenExpiry: number | null;
22
- details: UserDetails;
23
- email: string;
24
- info: Info;
18
+ accessToken?: string;
19
+ idToken?: string;
20
+ refreshToken?: string;
21
+ expires?: number;
22
+ accessTokenExpiry?: number | null;
23
+ details?: UserDetails;
24
+ email?: string;
25
+ info?: Info;
26
+ sub?: string;
25
27
  };
26
28
  export type UserDetails = {
27
- userSub: string;
29
+ userSub?: string;
28
30
  uuid?: string;
29
31
  subscriptionDetails?: {
30
32
  status: string;
33
+ id: string;
34
+ created: number;
35
+ nextPayment: number;
36
+ amount: number;
37
+ interval: string;
38
+ currency: string;
39
+ cancelAt?: number;
40
+ planID: string;
41
+ planDescription: string;
42
+ paymentDetails: {
43
+ response: PaymentResponse;
44
+ formatted: FormattedPayment;
45
+ };
31
46
  };
32
47
  firstName?: string;
33
48
  lastName?: string;
@@ -35,10 +50,11 @@ export type UserDetails = {
35
50
  avatar?: string;
36
51
  termsAccepted?: string;
37
52
  dateOfBirth?: string;
38
- contactPreference: boolean;
53
+ contactPreference?: boolean;
39
54
  password?: string;
40
55
  passwordConfirm?: string;
41
- agency: boolean;
56
+ agency?: boolean;
57
+ [key: string]: any;
42
58
  };
43
59
  export type Info = {
44
60
  orders?: string[];
@@ -92,27 +108,7 @@ export interface VerifyUserResponse {
92
108
  export interface AuthState {
93
109
  authenticated: boolean;
94
110
  verifying: boolean;
95
- user: {
96
- accessToken: string;
97
- idToken: string;
98
- refreshToken: string;
99
- accessTokenExpiry?: number;
100
- details: {
101
- subscriptionDetails?: any;
102
- userSub?: string;
103
- userEmail?: string;
104
- lastName?: string;
105
- firstName?: string;
106
- avatar?: string;
107
- dateOfBirth?: string;
108
- termsAccepted: any;
109
- contactPreference: any;
110
- uuid?: string;
111
- subscription?: string;
112
- customerId?: string;
113
- };
114
- email?: string;
115
- };
111
+ user: User;
116
112
  creating: {
117
113
  details: string;
118
114
  payment: string;
@@ -265,58 +261,60 @@ export interface UserSubResponse {
265
261
  status: string;
266
262
  };
267
263
  payment: {
268
- response: {
269
- id: string;
270
- object: string;
271
- allow_redisplay: string;
272
- billing_details: {
273
- address: {
274
- city: null;
275
- country: null;
276
- line1: null;
277
- line2: null;
278
- postal_code: null;
279
- state: null;
280
- };
281
- email: null;
282
- name: string;
283
- phone: null;
284
- };
285
- card: {
286
- brand: string;
287
- checks: {
288
- address_line1_check: null;
289
- address_postal_code_check: null;
290
- cvc_check: string;
291
- };
292
- country: string;
293
- display_brand: string;
294
- exp_month: number;
295
- exp_year: number;
296
- fingerprint: string;
297
- funding: string;
298
- generated_from: null;
299
- last4: string;
300
- networks: {
301
- available: string[];
302
- preferred: null;
303
- };
304
- three_d_secure_usage: {
305
- supported: boolean;
306
- };
307
- wallet: null;
308
- };
309
- created: number;
310
- customer: string;
311
- livemode: boolean;
312
- metadata: {};
313
- 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;
314
309
  };
315
- formatted: {
316
- id: string;
317
- maskedNumber: string;
318
- expirationDate: string;
319
- cardType: string;
310
+ three_d_secure_usage: {
311
+ supported: boolean;
320
312
  };
313
+ wallet: null;
321
314
  };
315
+ created: number;
316
+ customer: string;
317
+ livemode: boolean;
318
+ metadata: {};
319
+ type: string;
322
320
  }
package/dist/index.esm.js CHANGED
@@ -86,9 +86,7 @@ var initialState = {
86
86
  userSub: '',
87
87
  uuid: '',
88
88
  subscription: '',
89
- subscriptionDetails: {
90
- status: '',
91
- },
89
+ subscriptionDetails: undefined,
92
90
  firstName: '',
93
91
  lastName: '',
94
92
  userEmail: '',
@@ -98,7 +96,7 @@ var initialState = {
98
96
  },
99
97
  accessToken: '',
100
98
  idToken: '',
101
- accessTokenExpiry: undefined,
99
+ accessTokenExpiry: null,
102
100
  refreshToken: '',
103
101
  email: '',
104
102
  },
@@ -137,7 +135,7 @@ var authSlice = createSlice({
137
135
  selectUserCreatingDetails: function (auth) { return auth.creating.details; },
138
136
  isVerifying: function (auth) { return auth.verifying; },
139
137
  getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
140
- selectCurrentUserSub: function (auth) { return auth.user.details.uuid; },
138
+ 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; },
141
139
  selectCurrentUserRefreshToken: function (auth) { return auth.user.refreshToken; },
142
140
  selectUserTokens: function (auth) {
143
141
  return {
@@ -147,13 +145,16 @@ var authSlice = createSlice({
147
145
  };
148
146
  },
149
147
  selectUserSubscriptionStatus: function (auth) {
150
- return auth.user.details.subscriptionDetails.status;
148
+ var _a, _b, _c;
149
+ 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;
151
150
  },
152
151
  selectSubscription: function (auth) {
153
- return auth.user.details.subscription;
152
+ var _a, _b;
153
+ 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;
154
154
  },
155
155
  selectSubscriptionPrice: function (auth) {
156
- return auth.user.details.subscriptionDetails.price;
156
+ var _a, _b, _c;
157
+ 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
158
  },
158
159
  },
159
160
  });
@@ -165,6 +166,7 @@ authSlice.reducer;
165
166
 
166
167
  // TODO: typing.
167
168
  var formatUserPayload = function (payload) {
169
+ console.log('formatUserPayload', payload);
168
170
  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
171
  var parsedTermsAccepted = termsAccepted ? JSON.parse(termsAccepted) : null;
170
172
  var parsedContactPreference = contactPreference
@@ -182,6 +184,7 @@ var formatUserPayload = function (payload) {
182
184
  subscription: subscriptionId || null,
183
185
  customerId: customerId,
184
186
  };
187
+ console.log('formatUserPayload', data);
185
188
  return data;
186
189
  };
187
190
  function formatPromos(data) {