squarecommonblhelper 4.2.0 → 5.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,16 @@ helper for common bl for my projects.
15
15
 
16
16
  ## changelog
17
17
 
18
+ ### v5.1.0
19
+
20
+ - AuthenticationCommonBL:
21
+ - add getUserProfilePhoto
22
+
23
+ ### v5.0.0
24
+
25
+ - AuthenticationCommonBL:
26
+ - change type for GetUserDetailsV0ResponseZ to make it compatible with latest changes.
27
+
18
28
  ### v4.2.0
19
29
 
20
30
  - AuthenticationCommonBL:
@@ -26,8 +26,14 @@ declare class AuthenticationCommonBL {
26
26
  data: {
27
27
  main: {
28
28
  user_id: string;
29
- credentials: {
30
- username: string;
29
+ profile: {
30
+ user_profile_id: number;
31
+ user_profile_photo_storage_token: string | null;
32
+ user_profile_email: string | null;
33
+ user_profile_phone_number: string | null;
34
+ user_profile_first_name: string | null;
35
+ user_profile_last_name: string | null;
36
+ user_profile_username: string;
31
37
  };
32
38
  apps: string[];
33
39
  sessions: {
@@ -48,5 +54,6 @@ declare class AuthenticationCommonBL {
48
54
  data: null;
49
55
  log?: any;
50
56
  }>;
57
+ getUserProfilePhoto(accessToken: string): Promise<Blob>;
51
58
  }
52
59
  export { AuthenticationCommonBL };
@@ -1,4 +1,4 @@
1
- import { fetchJSONData } from "squarecommons";
1
+ import { fetchFileData, fetchJSONData } from "squarecommons";
2
2
  import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, LogoutAllV0Z, LogoutAppsV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
@@ -131,5 +131,26 @@ class AuthenticationCommonBL {
131
131
  throw error;
132
132
  }
133
133
  }
134
+ async getUserProfilePhoto(accessToken) {
135
+ try {
136
+ const data = await fetchFileData(
137
+ // base url
138
+ this.commonBLBaseURL,
139
+ // endpoint
140
+ "get_user_profile_photo/v0",
141
+ // method
142
+ "GET",
143
+ // headers
144
+ { access_token: accessToken },
145
+ // body
146
+ undefined,
147
+ // query params
148
+ undefined);
149
+ return data;
150
+ }
151
+ catch (error) {
152
+ throw error;
153
+ }
154
+ }
134
155
  }
135
156
  export { AuthenticationCommonBL };
@@ -26,7 +26,7 @@ declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
26
26
  username: string;
27
27
  };
28
28
  }>;
29
- }>, "strip", z.ZodTypeAny, {
29
+ }>, "strict", z.ZodTypeAny, {
30
30
  message: string | null;
31
31
  data: {
32
32
  main: {
@@ -52,7 +52,7 @@ declare const UpdatePasswordV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
52
52
  log: z.ZodAny;
53
53
  }, {
54
54
  data: z.ZodNull;
55
- }>, "strip", z.ZodTypeAny, {
55
+ }>, "strict", z.ZodTypeAny, {
56
56
  message: string | null;
57
57
  data: null;
58
58
  log?: any;
@@ -70,12 +70,30 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
70
70
  data: z.ZodObject<{
71
71
  main: z.ZodObject<{
72
72
  user_id: z.ZodString;
73
- credentials: z.ZodObject<{
74
- username: z.ZodString;
73
+ profile: z.ZodObject<{
74
+ user_profile_id: z.ZodNumber;
75
+ user_profile_photo_storage_token: z.ZodNullable<z.ZodString>;
76
+ user_profile_email: z.ZodNullable<z.ZodString>;
77
+ user_profile_phone_number: z.ZodNullable<z.ZodString>;
78
+ user_profile_first_name: z.ZodNullable<z.ZodString>;
79
+ user_profile_last_name: z.ZodNullable<z.ZodString>;
80
+ user_profile_username: z.ZodString;
75
81
  }, "strict", z.ZodTypeAny, {
76
- username: string;
82
+ user_profile_id: number;
83
+ user_profile_photo_storage_token: string | null;
84
+ user_profile_email: string | null;
85
+ user_profile_phone_number: string | null;
86
+ user_profile_first_name: string | null;
87
+ user_profile_last_name: string | null;
88
+ user_profile_username: string;
77
89
  }, {
78
- username: string;
90
+ user_profile_id: number;
91
+ user_profile_photo_storage_token: string | null;
92
+ user_profile_email: string | null;
93
+ user_profile_phone_number: string | null;
94
+ user_profile_first_name: string | null;
95
+ user_profile_last_name: string | null;
96
+ user_profile_username: string;
79
97
  }>;
80
98
  apps: z.ZodArray<z.ZodString, "many">;
81
99
  sessions: z.ZodArray<z.ZodObject<{
@@ -90,8 +108,14 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
90
108
  }>, "many">;
91
109
  }, "strict", z.ZodTypeAny, {
92
110
  user_id: string;
93
- credentials: {
94
- username: string;
111
+ profile: {
112
+ user_profile_id: number;
113
+ user_profile_photo_storage_token: string | null;
114
+ user_profile_email: string | null;
115
+ user_profile_phone_number: string | null;
116
+ user_profile_first_name: string | null;
117
+ user_profile_last_name: string | null;
118
+ user_profile_username: string;
95
119
  };
96
120
  apps: string[];
97
121
  sessions: {
@@ -100,8 +124,14 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
100
124
  }[];
101
125
  }, {
102
126
  user_id: string;
103
- credentials: {
104
- username: string;
127
+ profile: {
128
+ user_profile_id: number;
129
+ user_profile_photo_storage_token: string | null;
130
+ user_profile_email: string | null;
131
+ user_profile_phone_number: string | null;
132
+ user_profile_first_name: string | null;
133
+ user_profile_last_name: string | null;
134
+ user_profile_username: string;
105
135
  };
106
136
  apps: string[];
107
137
  sessions: {
@@ -112,8 +142,14 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
112
142
  }, "strict", z.ZodTypeAny, {
113
143
  main: {
114
144
  user_id: string;
115
- credentials: {
116
- username: string;
145
+ profile: {
146
+ user_profile_id: number;
147
+ user_profile_photo_storage_token: string | null;
148
+ user_profile_email: string | null;
149
+ user_profile_phone_number: string | null;
150
+ user_profile_first_name: string | null;
151
+ user_profile_last_name: string | null;
152
+ user_profile_username: string;
117
153
  };
118
154
  apps: string[];
119
155
  sessions: {
@@ -124,8 +160,14 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
124
160
  }, {
125
161
  main: {
126
162
  user_id: string;
127
- credentials: {
128
- username: string;
163
+ profile: {
164
+ user_profile_id: number;
165
+ user_profile_photo_storage_token: string | null;
166
+ user_profile_email: string | null;
167
+ user_profile_phone_number: string | null;
168
+ user_profile_first_name: string | null;
169
+ user_profile_last_name: string | null;
170
+ user_profile_username: string;
129
171
  };
130
172
  apps: string[];
131
173
  sessions: {
@@ -134,13 +176,19 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
134
176
  }[];
135
177
  };
136
178
  }>;
137
- }>, "strip", z.ZodTypeAny, {
179
+ }>, "strict", z.ZodTypeAny, {
138
180
  message: string | null;
139
181
  data: {
140
182
  main: {
141
183
  user_id: string;
142
- credentials: {
143
- username: string;
184
+ profile: {
185
+ user_profile_id: number;
186
+ user_profile_photo_storage_token: string | null;
187
+ user_profile_email: string | null;
188
+ user_profile_phone_number: string | null;
189
+ user_profile_first_name: string | null;
190
+ user_profile_last_name: string | null;
191
+ user_profile_username: string;
144
192
  };
145
193
  apps: string[];
146
194
  sessions: {
@@ -155,8 +203,14 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
155
203
  data: {
156
204
  main: {
157
205
  user_id: string;
158
- credentials: {
159
- username: string;
206
+ profile: {
207
+ user_profile_id: number;
208
+ user_profile_photo_storage_token: string | null;
209
+ user_profile_email: string | null;
210
+ user_profile_phone_number: string | null;
211
+ user_profile_first_name: string | null;
212
+ user_profile_last_name: string | null;
213
+ user_profile_username: string;
160
214
  };
161
215
  apps: string[];
162
216
  sessions: {
@@ -174,7 +228,7 @@ declare const DeleteUserV0Z: z.ZodObject<z.objectUtil.extendShape<{
174
228
  log: z.ZodAny;
175
229
  }, {
176
230
  data: z.ZodNull;
177
- }>, "strip", z.ZodTypeAny, {
231
+ }>, "strict", z.ZodTypeAny, {
178
232
  message: string | null;
179
233
  data: null;
180
234
  log?: any;
@@ -190,7 +244,7 @@ declare const LogoutAllV0Z: z.ZodObject<z.objectUtil.extendShape<{
190
244
  log: z.ZodAny;
191
245
  }, {
192
246
  data: z.ZodNull;
193
- }>, "strip", z.ZodTypeAny, {
247
+ }>, "strict", z.ZodTypeAny, {
194
248
  message: string | null;
195
249
  data: null;
196
250
  log?: any;
@@ -206,7 +260,7 @@ declare const LogoutAppsV0Z: z.ZodObject<z.objectUtil.extendShape<{
206
260
  log: z.ZodAny;
207
261
  }, {
208
262
  data: z.ZodNull;
209
- }>, "strip", z.ZodTypeAny, {
263
+ }>, "strict", z.ZodTypeAny, {
210
264
  message: string | null;
211
265
  data: null;
212
266
  log?: any;
@@ -15,8 +15,14 @@ const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
15
15
  data: z.strictObject({
16
16
  main: z.strictObject({
17
17
  user_id: z.string(),
18
- credentials: z.strictObject({
19
- username: z.string(),
18
+ profile: z.strictObject({
19
+ user_profile_id: z.number(),
20
+ user_profile_photo_storage_token: z.string().nullable(),
21
+ user_profile_email: z.string().nullable(),
22
+ user_profile_phone_number: z.string().nullable(),
23
+ user_profile_first_name: z.string().nullable(),
24
+ user_profile_last_name: z.string().nullable(),
25
+ user_profile_username: z.string(),
20
26
  }),
21
27
  apps: z.array(z.string()),
22
28
  sessions: z.array(z.strictObject({
@@ -46,7 +46,7 @@ declare const CreateGreetingV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
46
46
  greeting_text: string | null;
47
47
  }[];
48
48
  }>;
49
- }>, "strip", z.ZodTypeAny, {
49
+ }>, "strict", z.ZodTypeAny, {
50
50
  message: string | null;
51
51
  data: {
52
52
  main: {
package/example.js CHANGED
@@ -28,3 +28,4 @@ console.log(await authenticationCommonBL.logoutAllV0("dummy_access_token"));
28
28
  console.log(
29
29
  await authenticationCommonBL.logoutAppsV0("dummy_access_token", ["test"])
30
30
  );
31
+ console.log(await authenticationCommonBL.getProfilePhoto("dummy_access_token"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "4.2.0",
3
+ "version": "5.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.0.0",
37
+ "squarecommons": "^2.2.0",
38
38
  "zod": "^3.24.1"
39
39
  }
40
40
  }