@techstuff-dev/foundation-api-utils 1.12.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.
@@ -35,7 +35,7 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
35
35
  details: {
36
36
  subscription: any;
37
37
  subscriptionDetails: any;
38
- userSub: string;
38
+ userSub?: string | undefined;
39
39
  uuid?: string | undefined;
40
40
  firstName?: string | undefined;
41
41
  lastName?: string | undefined;
@@ -43,17 +43,19 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
43
43
  avatar?: string | undefined;
44
44
  termsAccepted?: string | undefined;
45
45
  dateOfBirth?: string | undefined;
46
- contactPreference: boolean;
46
+ contactPreference?: boolean | undefined;
47
47
  password?: string | undefined;
48
48
  passwordConfirm?: string | undefined;
49
49
  agency?: boolean | undefined;
50
50
  };
51
- accessToken: string;
52
- idToken: string;
53
- refreshToken: string;
54
- accessTokenExpiry: number | null;
55
- email: string;
51
+ accessToken?: string | undefined;
52
+ idToken?: string | undefined;
53
+ refreshToken?: string | undefined;
54
+ expires?: number | undefined;
55
+ accessTokenExpiry?: number | null | undefined;
56
+ email?: string | undefined;
56
57
  info?: import("immer").WritableDraft<import("../../types/index.interfaces").Info> | undefined;
58
+ sub?: string | undefined;
57
59
  };
58
60
  authenticated: boolean;
59
61
  verifying: boolean;
@@ -68,9 +70,9 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
68
70
  logout: () => AuthState;
69
71
  }, "auth", "auth", {
70
72
  isAuthenticated: (auth: AuthState) => boolean;
71
- selectAccessToken: (auth: AuthState) => string;
72
- selectRefreshToken: (auth: AuthState) => string;
73
- selectCurrentUser: (auth: AuthState) => import("../../types/index.interfaces").UserDetails;
73
+ selectAccessToken: (auth: AuthState) => string | undefined;
74
+ selectRefreshToken: (auth: AuthState) => string | undefined;
75
+ selectCurrentUser: (auth: AuthState) => import("../../types/index.interfaces").UserDetails | undefined;
74
76
  selectUserCreating: (auth: AuthState) => {
75
77
  details: string;
76
78
  payment: string;
@@ -79,78 +81,27 @@ export declare const authSlice: import("@reduxjs/toolkit").Slice<AuthState, {
79
81
  isVerifying: (auth: AuthState) => boolean;
80
82
  getUserSession: (auth: AuthState) => string | false | undefined;
81
83
  selectCurrentUserSub: (auth: AuthState) => string | undefined;
82
- selectCurrentUserRefreshToken: (auth: AuthState) => string;
84
+ selectCurrentUserRefreshToken: (auth: AuthState) => string | undefined;
83
85
  selectUserTokens: (auth: AuthState) => {
84
- accessToken: string;
85
- refreshToken: string;
86
- idToken: string;
86
+ accessToken: string | undefined;
87
+ refreshToken: string | undefined;
88
+ idToken: string | undefined;
87
89
  };
88
90
  selectUserSubscriptionStatus: (auth: AuthState) => string | undefined;
89
91
  selectSubscription: (auth: AuthState) => {
92
+ status: string;
90
93
  id: string;
91
94
  created: number;
92
- status: string;
93
95
  nextPayment: number;
94
96
  amount: number;
95
97
  interval: string;
96
98
  currency: string;
97
- cancelAt: string;
99
+ cancelAt?: number | undefined;
98
100
  planID: string;
99
101
  planDescription: string;
100
102
  paymentDetails: {
101
- response: {
102
- id: string;
103
- object: string;
104
- allow_redisplay: string;
105
- billing_details: {
106
- address: {
107
- city: null;
108
- country: null;
109
- line1: null;
110
- line2: null;
111
- postal_code: null;
112
- state: null;
113
- };
114
- email: null;
115
- name: string;
116
- phone: null;
117
- };
118
- card: {
119
- brand: string;
120
- checks: {
121
- address_line1_check: null;
122
- address_postal_code_check: null;
123
- cvc_check: string;
124
- };
125
- country: string;
126
- display_brand: string;
127
- exp_month: number;
128
- exp_year: number;
129
- fingerprint: string;
130
- funding: string;
131
- generated_from: null;
132
- last4: string;
133
- networks: {
134
- available: string[];
135
- preferred: null;
136
- };
137
- three_d_secure_usage: {
138
- supported: boolean;
139
- };
140
- wallet: null;
141
- };
142
- created: number;
143
- customer: string;
144
- livemode: boolean;
145
- metadata: {};
146
- type: string;
147
- };
148
- formatted: {
149
- id: string;
150
- maskedNumber: string;
151
- expirationDate: string;
152
- cardType: string;
153
- };
103
+ response: import("../../types/index.interfaces").PaymentResponse;
104
+ formatted: import("../../types/index.interfaces").FormattedPayment;
154
105
  };
155
106
  } | undefined;
156
107
  selectSubscriptionPrice: (auth: AuthState) => number | undefined;
@@ -162,16 +113,16 @@ export declare const isAuthenticated: import("reselect").Selector<{
162
113
  unwrapped: (auth: AuthState) => boolean;
163
114
  }, selectAccessToken: import("reselect").Selector<{
164
115
  auth: AuthState;
165
- }, string, []> & {
166
- unwrapped: (auth: AuthState) => string;
116
+ }, string | undefined, []> & {
117
+ unwrapped: (auth: AuthState) => string | undefined;
167
118
  }, selectRefreshToken: import("reselect").Selector<{
168
119
  auth: AuthState;
169
- }, string, []> & {
170
- unwrapped: (auth: AuthState) => string;
120
+ }, string | undefined, []> & {
121
+ unwrapped: (auth: AuthState) => string | undefined;
171
122
  }, selectCurrentUser: import("reselect").Selector<{
172
123
  auth: AuthState;
173
- }, import("../../types/index.interfaces").UserDetails, []> & {
174
- unwrapped: (auth: AuthState) => import("../../types/index.interfaces").UserDetails;
124
+ }, import("../../types/index.interfaces").UserDetails | undefined, []> & {
125
+ unwrapped: (auth: AuthState) => import("../../types/index.interfaces").UserDetails | undefined;
175
126
  }, selectUserCreating: import("reselect").Selector<{
176
127
  auth: AuthState;
177
128
  }, {
@@ -200,19 +151,19 @@ export declare const isAuthenticated: import("reselect").Selector<{
200
151
  unwrapped: (auth: AuthState) => string | undefined;
201
152
  }, selectCurrentUserRefreshToken: import("reselect").Selector<{
202
153
  auth: AuthState;
203
- }, string, []> & {
204
- unwrapped: (auth: AuthState) => string;
154
+ }, string | undefined, []> & {
155
+ unwrapped: (auth: AuthState) => string | undefined;
205
156
  }, selectUserTokens: import("reselect").Selector<{
206
157
  auth: AuthState;
207
158
  }, {
208
- accessToken: string;
209
- refreshToken: string;
210
- idToken: string;
159
+ accessToken: string | undefined;
160
+ refreshToken: string | undefined;
161
+ idToken: string | undefined;
211
162
  }, []> & {
212
163
  unwrapped: (auth: AuthState) => {
213
- accessToken: string;
214
- refreshToken: string;
215
- idToken: string;
164
+ accessToken: string | undefined;
165
+ refreshToken: string | undefined;
166
+ idToken: string | undefined;
216
167
  };
217
168
  }, selectUserSubscriptionStatus: import("reselect").Selector<{
218
169
  auth: AuthState;
@@ -221,137 +172,35 @@ export declare const isAuthenticated: import("reselect").Selector<{
221
172
  }, selectSubscription: import("reselect").Selector<{
222
173
  auth: AuthState;
223
174
  }, {
175
+ status: string;
224
176
  id: string;
225
177
  created: number;
226
- status: string;
227
178
  nextPayment: number;
228
179
  amount: number;
229
180
  interval: string;
230
181
  currency: string;
231
- cancelAt: string;
182
+ cancelAt?: number | undefined;
232
183
  planID: string;
233
184
  planDescription: string;
234
185
  paymentDetails: {
235
- response: {
236
- id: string;
237
- object: string;
238
- allow_redisplay: string;
239
- billing_details: {
240
- address: {
241
- city: null;
242
- country: null;
243
- line1: null;
244
- line2: null;
245
- postal_code: null;
246
- state: null;
247
- };
248
- email: null;
249
- name: string;
250
- phone: null;
251
- };
252
- card: {
253
- brand: string;
254
- checks: {
255
- address_line1_check: null;
256
- address_postal_code_check: null;
257
- cvc_check: string;
258
- };
259
- country: string;
260
- display_brand: string;
261
- exp_month: number;
262
- exp_year: number;
263
- fingerprint: string;
264
- funding: string;
265
- generated_from: null;
266
- last4: string;
267
- networks: {
268
- available: string[];
269
- preferred: null;
270
- };
271
- three_d_secure_usage: {
272
- supported: boolean;
273
- };
274
- wallet: null;
275
- };
276
- created: number;
277
- customer: string;
278
- livemode: boolean;
279
- metadata: {};
280
- type: string;
281
- };
282
- formatted: {
283
- id: string;
284
- maskedNumber: string;
285
- expirationDate: string;
286
- cardType: string;
287
- };
186
+ response: import("../../types/index.interfaces").PaymentResponse;
187
+ formatted: import("../../types/index.interfaces").FormattedPayment;
288
188
  };
289
189
  } | undefined, []> & {
290
190
  unwrapped: (auth: AuthState) => {
191
+ status: string;
291
192
  id: string;
292
193
  created: number;
293
- status: string;
294
194
  nextPayment: number;
295
195
  amount: number;
296
196
  interval: string;
297
197
  currency: string;
298
- cancelAt: string;
198
+ cancelAt?: number | undefined;
299
199
  planID: string;
300
200
  planDescription: string;
301
201
  paymentDetails: {
302
- response: {
303
- id: string;
304
- object: string;
305
- allow_redisplay: string;
306
- billing_details: {
307
- address: {
308
- city: null;
309
- country: null;
310
- line1: null;
311
- line2: null;
312
- postal_code: null;
313
- state: null;
314
- };
315
- email: null;
316
- name: string;
317
- phone: null;
318
- };
319
- card: {
320
- brand: string;
321
- checks: {
322
- address_line1_check: null;
323
- address_postal_code_check: null;
324
- cvc_check: string;
325
- };
326
- country: string;
327
- display_brand: string;
328
- exp_month: number;
329
- exp_year: number;
330
- fingerprint: string;
331
- funding: string;
332
- generated_from: null;
333
- last4: string;
334
- networks: {
335
- available: string[];
336
- preferred: null;
337
- };
338
- three_d_secure_usage: {
339
- supported: boolean;
340
- };
341
- wallet: null;
342
- };
343
- created: number;
344
- customer: string;
345
- livemode: boolean;
346
- metadata: {};
347
- type: string;
348
- };
349
- formatted: {
350
- id: string;
351
- maskedNumber: string;
352
- expirationDate: string;
353
- cardType: string;
354
- };
202
+ response: import("../../types/index.interfaces").PaymentResponse;
203
+ formatted: import("../../types/index.interfaces").FormattedPayment;
355
204
  };
356
205
  } | undefined;
357
206
  }, selectSubscriptionPrice: import("reselect").Selector<{
@@ -15,83 +15,33 @@ 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;
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: string;
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: string;
39
+ cancelAt?: number;
39
40
  planID: string;
40
41
  planDescription: string;
41
42
  paymentDetails: {
42
- response: {
43
- id: string;
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: boolean;
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[];
@@ -310,58 +261,60 @@ export interface UserSubResponse {
310
261
  status: string;
311
262
  };
312
263
  payment: {
313
- response: {
314
- id: string;
315
- object: string;
316
- allow_redisplay: string;
317
- billing_details: {
318
- address: {
319
- city: null;
320
- country: null;
321
- line1: null;
322
- line2: null;
323
- postal_code: null;
324
- state: null;
325
- };
326
- email: null;
327
- name: string;
328
- phone: null;
329
- };
330
- card: {
331
- brand: string;
332
- checks: {
333
- address_line1_check: null;
334
- address_postal_code_check: null;
335
- cvc_check: string;
336
- };
337
- country: string;
338
- display_brand: string;
339
- exp_month: number;
340
- exp_year: number;
341
- fingerprint: string;
342
- funding: string;
343
- generated_from: null;
344
- last4: string;
345
- networks: {
346
- available: string[];
347
- preferred: null;
348
- };
349
- three_d_secure_usage: {
350
- supported: boolean;
351
- };
352
- wallet: null;
353
- };
354
- created: number;
355
- customer: string;
356
- livemode: boolean;
357
- metadata: {};
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
- formatted: {
361
- id: string;
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
  }
package/dist/index.esm.js CHANGED
@@ -135,7 +135,7 @@ var authSlice = createSlice({
135
135
  selectUserCreatingDetails: function (auth) { return auth.creating.details; },
136
136
  isVerifying: function (auth) { return auth.verifying; },
137
137
  getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
138
- 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; },
139
139
  selectCurrentUserRefreshToken: function (auth) { return auth.user.refreshToken; },
140
140
  selectUserTokens: function (auth) {
141
141
  return {
@@ -145,15 +145,16 @@ var authSlice = createSlice({
145
145
  };
146
146
  },
147
147
  selectUserSubscriptionStatus: function (auth) {
148
- var _a;
149
- return (_a = auth.user.details.subscriptionDetails) === null || _a === void 0 ? void 0 : _a.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;
150
150
  },
151
151
  selectSubscription: function (auth) {
152
- return auth.user.details.subscriptionDetails;
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;
153
154
  },
154
155
  selectSubscriptionPrice: function (auth) {
155
- var _a;
156
- return (_a = auth.user.details.subscriptionDetails) === null || _a === void 0 ? void 0 : _a.amount;
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) {