squarecommonblhelper 4.1.0 → 5.0.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.0.0
19
+
20
+ - AuthenticationCommonBL:
21
+ - change type for GetUserDetailsV0ResponseZ to make it compatible with latest changes.
22
+
23
+ ### v4.2.0
24
+
25
+ - AuthenticationCommonBL:
26
+ - add logoutAppsV0.
27
+
18
28
  ### v4.1.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: {
@@ -43,5 +49,10 @@ declare class AuthenticationCommonBL {
43
49
  data: null;
44
50
  log?: any;
45
51
  }>;
52
+ logoutAppsV0(accessToken: string, appNames: string[]): Promise<{
53
+ message: string | null;
54
+ data: null;
55
+ log?: any;
56
+ }>;
46
57
  }
47
58
  export { AuthenticationCommonBL };
@@ -1,5 +1,5 @@
1
1
  import { fetchJSONData } from "squarecommons";
2
- import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, LogoutAllV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
2
+ import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, LogoutAllV0Z, LogoutAppsV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
@@ -110,5 +110,26 @@ class AuthenticationCommonBL {
110
110
  throw error;
111
111
  }
112
112
  }
113
+ async logoutAppsV0(accessToken, appNames) {
114
+ try {
115
+ const data = await fetchJSONData(
116
+ // base url
117
+ this.commonBLBaseURL,
118
+ // endpoint
119
+ "logout/apps/v0",
120
+ // method
121
+ "DELETE",
122
+ // headers
123
+ { access_token: accessToken },
124
+ // body
125
+ { app_names: appNames },
126
+ // query params
127
+ undefined);
128
+ return LogoutAppsV0Z.parse(data);
129
+ }
130
+ catch (error) {
131
+ throw error;
132
+ }
133
+ }
113
134
  }
114
135
  export { AuthenticationCommonBL };
@@ -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: {
@@ -139,8 +181,14 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
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: {
@@ -200,4 +254,20 @@ declare const LogoutAllV0Z: z.ZodObject<z.objectUtil.extendShape<{
200
254
  log?: any;
201
255
  }>;
202
256
  type LogoutAllV0 = z.infer<typeof LogoutAllV0Z>;
203
- export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, LogoutAllV0, LogoutAllV0Z, };
257
+ declare const LogoutAppsV0Z: z.ZodObject<z.objectUtil.extendShape<{
258
+ data: z.ZodAny;
259
+ message: z.ZodNullable<z.ZodString>;
260
+ log: z.ZodAny;
261
+ }, {
262
+ data: z.ZodNull;
263
+ }>, "strip", z.ZodTypeAny, {
264
+ message: string | null;
265
+ data: null;
266
+ log?: any;
267
+ }, {
268
+ message: string | null;
269
+ data: null;
270
+ log?: any;
271
+ }>;
272
+ type LogoutAppsV0 = z.infer<typeof LogoutAppsV0Z>;
273
+ export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, LogoutAllV0, LogoutAllV0Z, LogoutAppsV0, LogoutAppsV0Z, };
@@ -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({
@@ -32,4 +38,7 @@ const DeleteUserV0Z = APIOutputZ.extend({
32
38
  const LogoutAllV0Z = APIOutputZ.extend({
33
39
  data: z.null(),
34
40
  });
35
- export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, LogoutAllV0Z, };
41
+ const LogoutAppsV0Z = APIOutputZ.extend({
42
+ data: z.null(),
43
+ });
44
+ export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, LogoutAllV0Z, LogoutAppsV0Z, };
package/example.js CHANGED
@@ -25,3 +25,6 @@ console.log(
25
25
  await authenticationCommonBL.deleteUserV0("dummy_access_token", "password")
26
26
  );
27
27
  console.log(await authenticationCommonBL.logoutAllV0("dummy_access_token"));
28
+ console.log(
29
+ await authenticationCommonBL.logoutAppsV0("dummy_access_token", ["test"])
30
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "4.1.0",
3
+ "version": "5.0.0",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",