squarecommonblhelper 11.0.0 → 11.1.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/README.md CHANGED
@@ -15,6 +15,11 @@ helper for common bl for my projects.
15
15
 
16
16
  ## changelog
17
17
 
18
+ ### v11.1.0
19
+
20
+ - all:
21
+ - add new optional parameter logErrors to all methods.
22
+
18
23
  ### v11.0.0
19
24
 
20
25
  - AuthenticationCommonBL:
@@ -2,12 +2,12 @@ import { RecoveryMethodEnum } from "./types/AuthenticationResponses.js";
2
2
  declare class AuthenticationCommonBL {
3
3
  private commonBLBaseURL;
4
4
  constructor(commonBLBaseURL?: string);
5
- deleteUserV0(accessToken: string, password: string): Promise<{
5
+ deleteUserV0(accessToken: string, password: string, logErrors?: boolean): Promise<{
6
6
  message: string | null;
7
7
  data: null;
8
8
  log?: any;
9
9
  }>;
10
- updateUsernameV0(accessToken: string, newUsername: string): Promise<{
10
+ updateUsernameV0(accessToken: string, newUsername: string, logErrors?: boolean): Promise<{
11
11
  message: string | null;
12
12
  data: {
13
13
  main: {
@@ -17,7 +17,7 @@ declare class AuthenticationCommonBL {
17
17
  };
18
18
  log?: any;
19
19
  }>;
20
- getUserDetailsV0(accessToken: string): Promise<{
20
+ getUserDetailsV0(accessToken: string, logErrors?: boolean): Promise<{
21
21
  message: string | null;
22
22
  data: {
23
23
  main: {
@@ -52,25 +52,25 @@ declare class AuthenticationCommonBL {
52
52
  };
53
53
  log?: any;
54
54
  }>;
55
- logoutAllV0(accessToken: string): Promise<{
55
+ logoutAllV0(accessToken: string, logErrors?: boolean): Promise<{
56
56
  message: string | null;
57
57
  data: null;
58
58
  log?: any;
59
59
  }>;
60
- logoutAppsV0(accessToken: string, appNames: string[]): Promise<{
60
+ logoutAppsV0(accessToken: string, appNames: string[], logErrors?: boolean): Promise<{
61
61
  message: string | null;
62
62
  data: null;
63
63
  log?: any;
64
64
  }>;
65
- getUserProfilePhotoV0(accessToken: string): Promise<Blob>;
66
- updateUserProfilePhotoV0(accessToken: string, profilePhoto?: File): Promise<{
65
+ getUserProfilePhotoV0(accessToken: string, logErrors?: boolean): Promise<Blob>;
66
+ updateUserProfilePhotoV0(accessToken: string, profilePhoto?: File, logErrors?: boolean): Promise<{
67
67
  message: string | null;
68
68
  data: {
69
69
  main: string | null;
70
70
  };
71
71
  log?: any;
72
72
  }>;
73
- generateAccountBackupCodesV0(accessToken: string): Promise<{
73
+ generateAccountBackupCodesV0(accessToken: string, logErrors?: boolean): Promise<{
74
74
  message: string | null;
75
75
  data: {
76
76
  main: {
@@ -80,7 +80,7 @@ declare class AuthenticationCommonBL {
80
80
  };
81
81
  log?: any;
82
82
  }>;
83
- updateProfileDetailsV0(accessToken: string, firstName?: string, lastName?: string, email?: string, phoneNumberCountryCode?: string, phoneNumber?: string): Promise<{
83
+ updateProfileDetailsV0(accessToken: string, firstName?: string, lastName?: string, email?: string, phoneNumberCountryCode?: string, phoneNumber?: string, logErrors?: boolean): Promise<{
84
84
  message: string | null;
85
85
  data: {
86
86
  main: {
@@ -97,7 +97,7 @@ declare class AuthenticationCommonBL {
97
97
  };
98
98
  log?: any;
99
99
  }>;
100
- sendResetPasswordEmailV0(username: string): Promise<{
100
+ sendResetPasswordEmailV0(username: string, logErrors?: boolean): Promise<{
101
101
  message: string | null;
102
102
  data: {
103
103
  expires_at: string;
@@ -105,14 +105,14 @@ declare class AuthenticationCommonBL {
105
105
  };
106
106
  log?: any;
107
107
  }>;
108
- updateUserRecoveryMethodsV0(accessToken: string, recoveryMethodsToAdd?: RecoveryMethodEnum[], recoveryMethodsToRemove?: RecoveryMethodEnum[]): Promise<{
108
+ updateUserRecoveryMethodsV0(accessToken: string, recoveryMethodsToAdd?: RecoveryMethodEnum[], recoveryMethodsToRemove?: RecoveryMethodEnum[], logErrors?: boolean): Promise<{
109
109
  message: string | null;
110
110
  data: {
111
111
  main: ("EMAIL" | "BACKUP_CODE")[];
112
112
  };
113
113
  log?: any;
114
114
  }>;
115
- sendVerificationEmailV0(accessToken: string): Promise<{
115
+ sendVerificationEmailV0(accessToken: string, logErrors?: boolean): Promise<{
116
116
  message: string | null;
117
117
  data: {
118
118
  expires_at: string;
@@ -120,14 +120,14 @@ declare class AuthenticationCommonBL {
120
120
  } | null;
121
121
  log?: any;
122
122
  }>;
123
- validateEmailVerificationCodeV0(accessToken: string, verificationCode: string): Promise<{
123
+ validateEmailVerificationCodeV0(accessToken: string, verificationCode: string, logErrors?: boolean): Promise<{
124
124
  message: string | null;
125
125
  data: {
126
126
  user_profile_email_verified: string;
127
127
  } | null;
128
128
  log?: any;
129
129
  }>;
130
- getUserRecoveryMethodsV0(username: string): Promise<{
130
+ getUserRecoveryMethodsV0(username: string, logErrors?: boolean): Promise<{
131
131
  message: string | null;
132
132
  data: {
133
133
  main: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
@@ -5,7 +5,7 @@ class AuthenticationCommonBL {
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
6
6
  this.commonBLBaseURL = commonBLBaseURL;
7
7
  }
8
- async deleteUserV0(accessToken, password) {
8
+ async deleteUserV0(accessToken, password, logErrors = true) {
9
9
  try {
10
10
  const data = await fetchJSONData(
11
11
  // base url
@@ -19,14 +19,18 @@ class AuthenticationCommonBL {
19
19
  // body
20
20
  { password: password },
21
21
  // query params
22
- undefined);
22
+ undefined,
23
+ // credentials
24
+ undefined,
25
+ // logErrors
26
+ logErrors);
23
27
  return DeleteUserV0ResponseZ.parse(data);
24
28
  }
25
29
  catch (error) {
26
30
  throw error;
27
31
  }
28
32
  }
29
- async updateUsernameV0(accessToken, newUsername) {
33
+ async updateUsernameV0(accessToken, newUsername, logErrors = true) {
30
34
  try {
31
35
  const data = await fetchJSONData(
32
36
  // base url
@@ -40,14 +44,18 @@ class AuthenticationCommonBL {
40
44
  // body
41
45
  undefined,
42
46
  // query params
43
- { new_username: newUsername });
47
+ { new_username: newUsername },
48
+ // credentials
49
+ undefined,
50
+ // logErrors
51
+ logErrors);
44
52
  return UpdateUsernameV0ResponseZ.parse(data);
45
53
  }
46
54
  catch (error) {
47
55
  throw error;
48
56
  }
49
57
  }
50
- async getUserDetailsV0(accessToken) {
58
+ async getUserDetailsV0(accessToken, logErrors = true) {
51
59
  try {
52
60
  const data = await fetchJSONData(
53
61
  // base url
@@ -61,14 +69,18 @@ class AuthenticationCommonBL {
61
69
  // body
62
70
  undefined,
63
71
  // query params
64
- undefined);
72
+ undefined,
73
+ // credentials
74
+ undefined,
75
+ // logErrors
76
+ logErrors);
65
77
  return GetUserDetailsV0ResponseZ.parse(data);
66
78
  }
67
79
  catch (error) {
68
80
  throw error;
69
81
  }
70
82
  }
71
- async logoutAllV0(accessToken) {
83
+ async logoutAllV0(accessToken, logErrors = true) {
72
84
  try {
73
85
  const data = await fetchJSONData(
74
86
  // base url
@@ -82,14 +94,18 @@ class AuthenticationCommonBL {
82
94
  // body
83
95
  undefined,
84
96
  // query params
85
- undefined);
97
+ undefined,
98
+ // credentials
99
+ undefined,
100
+ // logErrors
101
+ logErrors);
86
102
  return LogoutAllV0ResponseZ.parse(data);
87
103
  }
88
104
  catch (error) {
89
105
  throw error;
90
106
  }
91
107
  }
92
- async logoutAppsV0(accessToken, appNames) {
108
+ async logoutAppsV0(accessToken, appNames, logErrors = true) {
93
109
  try {
94
110
  const data = await fetchJSONData(
95
111
  // base url
@@ -103,14 +119,18 @@ class AuthenticationCommonBL {
103
119
  // body
104
120
  { app_names: appNames },
105
121
  // query params
106
- undefined);
122
+ undefined,
123
+ // credentials
124
+ undefined,
125
+ // logErrors
126
+ logErrors);
107
127
  return LogoutAppsV0ResponseZ.parse(data);
108
128
  }
109
129
  catch (error) {
110
130
  throw error;
111
131
  }
112
132
  }
113
- async getUserProfilePhotoV0(accessToken) {
133
+ async getUserProfilePhotoV0(accessToken, logErrors = true) {
114
134
  try {
115
135
  const data = await fetchFileData(
116
136
  // base url
@@ -124,14 +144,18 @@ class AuthenticationCommonBL {
124
144
  // body
125
145
  undefined,
126
146
  // query params
127
- undefined);
147
+ undefined,
148
+ // credentials
149
+ undefined,
150
+ // logErrors
151
+ logErrors);
128
152
  return data;
129
153
  }
130
154
  catch (error) {
131
155
  throw error;
132
156
  }
133
157
  }
134
- async updateUserProfilePhotoV0(accessToken, profilePhoto) {
158
+ async updateUserProfilePhotoV0(accessToken, profilePhoto, logErrors = true) {
135
159
  try {
136
160
  const MAX_SIZE = 5 * 1024 * 1024; // 5 MiB
137
161
  const ALLOWED_TYPES = ["image/png", "image/jpeg"];
@@ -159,14 +183,18 @@ class AuthenticationCommonBL {
159
183
  // body
160
184
  formData,
161
185
  // query params
162
- undefined);
186
+ undefined,
187
+ // credentials
188
+ undefined,
189
+ // logErrors
190
+ logErrors);
163
191
  return UpdateUserProfilePhotoV0ResponseZ.parse(data);
164
192
  }
165
193
  catch (error) {
166
194
  throw error;
167
195
  }
168
196
  }
169
- async generateAccountBackupCodesV0(accessToken) {
197
+ async generateAccountBackupCodesV0(accessToken, logErrors = true) {
170
198
  try {
171
199
  const data = await fetchJSONData(
172
200
  // base url
@@ -180,14 +208,18 @@ class AuthenticationCommonBL {
180
208
  // body
181
209
  undefined,
182
210
  // query params
183
- undefined);
211
+ undefined,
212
+ // credentials
213
+ undefined,
214
+ // logErrors
215
+ logErrors);
184
216
  return GenerateAccountBackupCodeV0ResponseZ.parse(data);
185
217
  }
186
218
  catch (error) {
187
219
  throw error;
188
220
  }
189
221
  }
190
- async updateProfileDetailsV0(accessToken, firstName, lastName, email, phoneNumberCountryCode, phoneNumber) {
222
+ async updateProfileDetailsV0(accessToken, firstName, lastName, email, phoneNumberCountryCode, phoneNumber, logErrors = true) {
191
223
  try {
192
224
  const queryParams = {};
193
225
  if (firstName)
@@ -213,14 +245,18 @@ class AuthenticationCommonBL {
213
245
  // body
214
246
  undefined,
215
247
  // query params
216
- queryParams);
248
+ queryParams,
249
+ // credentials
250
+ undefined,
251
+ // logErrors
252
+ logErrors);
217
253
  return UpdateProfileDetailsV0ResponseZ.parse(data);
218
254
  }
219
255
  catch (error) {
220
256
  throw error;
221
257
  }
222
258
  }
223
- async sendResetPasswordEmailV0(username) {
259
+ async sendResetPasswordEmailV0(username, logErrors = true) {
224
260
  try {
225
261
  const data = await fetchJSONData(
226
262
  // base url
@@ -234,14 +270,18 @@ class AuthenticationCommonBL {
234
270
  // body
235
271
  { username: username },
236
272
  // query params
237
- undefined);
273
+ undefined,
274
+ // credentials
275
+ undefined,
276
+ // logErrors
277
+ logErrors);
238
278
  return SendResetPasswordEmailV0ResponseZ.parse(data);
239
279
  }
240
280
  catch (error) {
241
281
  throw error;
242
282
  }
243
283
  }
244
- async updateUserRecoveryMethodsV0(accessToken, recoveryMethodsToAdd, recoveryMethodsToRemove) {
284
+ async updateUserRecoveryMethodsV0(accessToken, recoveryMethodsToAdd, recoveryMethodsToRemove, logErrors = true) {
245
285
  try {
246
286
  if (!recoveryMethodsToAdd) {
247
287
  recoveryMethodsToAdd = [];
@@ -264,14 +304,18 @@ class AuthenticationCommonBL {
264
304
  recovery_methods_to_remove: recoveryMethodsToRemove,
265
305
  },
266
306
  // query params
267
- undefined);
307
+ undefined,
308
+ // credentials
309
+ undefined,
310
+ // logErrors
311
+ logErrors);
268
312
  return UpdateUserRecoveryMethodsV0ResponseZ.parse(data);
269
313
  }
270
314
  catch (error) {
271
315
  throw error;
272
316
  }
273
317
  }
274
- async sendVerificationEmailV0(accessToken) {
318
+ async sendVerificationEmailV0(accessToken, logErrors = true) {
275
319
  try {
276
320
  const data = await fetchJSONData(
277
321
  // base url
@@ -285,14 +329,18 @@ class AuthenticationCommonBL {
285
329
  // body
286
330
  undefined,
287
331
  // query params
288
- undefined);
332
+ undefined,
333
+ // credentials
334
+ undefined,
335
+ // logErrors
336
+ logErrors);
289
337
  return SendVerificationEmailV0ResponseZ.parse(data);
290
338
  }
291
339
  catch (error) {
292
340
  throw error;
293
341
  }
294
342
  }
295
- async validateEmailVerificationCodeV0(accessToken, verificationCode) {
343
+ async validateEmailVerificationCodeV0(accessToken, verificationCode, logErrors = true) {
296
344
  try {
297
345
  const data = await fetchJSONData(
298
346
  // base url
@@ -306,14 +354,18 @@ class AuthenticationCommonBL {
306
354
  // body
307
355
  { verification_code: verificationCode },
308
356
  // query params
309
- undefined);
357
+ undefined,
358
+ // credentials
359
+ undefined,
360
+ // logErrors
361
+ logErrors);
310
362
  return ValidateEmailVerificationCodeV0ResponseZ.parse(data);
311
363
  }
312
364
  catch (error) {
313
365
  throw error;
314
366
  }
315
367
  }
316
- async getUserRecoveryMethodsV0(username) {
368
+ async getUserRecoveryMethodsV0(username, logErrors = true) {
317
369
  try {
318
370
  const data = await fetchJSONData(
319
371
  // base url
@@ -327,7 +379,11 @@ class AuthenticationCommonBL {
327
379
  // body
328
380
  undefined,
329
381
  // query params
330
- { username: username });
382
+ { username: username },
383
+ // credentials
384
+ undefined,
385
+ // logErrors
386
+ logErrors);
331
387
  return GetUserRecoveryMethodsV0ResponseZ.parse(data);
332
388
  }
333
389
  catch (error) {
@@ -1,7 +1,7 @@
1
1
  declare class GreetingCommonBL {
2
2
  private commonBLBaseURL;
3
3
  constructor(commonBLBaseURL?: string);
4
- createAnonymousGreetingV0(greetingAnonymousSenderName?: string, greetingText?: string): Promise<{
4
+ createAnonymousGreetingV0(greetingAnonymousSenderName?: string, greetingText?: string, logErrors?: boolean): Promise<{
5
5
  message: string | null;
6
6
  data: {
7
7
  main: {
package/dist/greeting.js CHANGED
@@ -5,12 +5,12 @@ class GreetingCommonBL {
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
6
6
  this.commonBLBaseURL = commonBLBaseURL;
7
7
  }
8
- async createAnonymousGreetingV0(greetingAnonymousSenderName, greetingText) {
8
+ async createAnonymousGreetingV0(greetingAnonymousSenderName, greetingText, logErrors = true) {
9
9
  try {
10
10
  const data = await fetchJSONData(this.commonBLBaseURL, "create_anonymous_greeting/v0", "POST", undefined, {
11
11
  greeting_anonymous_sender_name: greetingAnonymousSenderName,
12
12
  greeting_text: greetingText,
13
- });
13
+ }, undefined, undefined, logErrors);
14
14
  return CreateAnonymousGreetingV0ResponseZ.parse(data);
15
15
  }
16
16
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  "node": ">=18.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "squarecommons": "^2.4.0",
37
+ "squarecommons": "^2.5.0",
38
38
  "zod": "^3.24.1"
39
39
  }
40
40
  }