squarecommonblhelper 1.5.0 → 1.7.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
+ ### v1.7.0
19
+
20
+ - AuthenticationCommonBL:
21
+ - add types for logoutV0
22
+
23
+ ### v1.6.0
24
+
25
+ - AuthenticationCommonBL:
26
+ - add types for getUserDetailsV0
27
+
18
28
  ### v1.5.0
19
29
 
20
30
  - AuthenticationCommonBL:
@@ -3,7 +3,7 @@ declare class AuthenticationCommonBL {
3
3
  constructor(commonBLBaseURL?: string);
4
4
  logoutV0(refreshToken: string): Promise<{
5
5
  message: string | null;
6
- data?: any;
6
+ data: null;
7
7
  log?: any;
8
8
  }>;
9
9
  generateAccessTokenV0(refreshToken: string): Promise<{
@@ -37,7 +37,19 @@ declare class AuthenticationCommonBL {
37
37
  }>;
38
38
  getUserDetailsV0(accessToken: string): Promise<{
39
39
  message: string | null;
40
- data?: any;
40
+ data: {
41
+ main: {
42
+ user_id: string;
43
+ credentials: {
44
+ username: string;
45
+ };
46
+ apps: number[];
47
+ sessions: {
48
+ app_id: number;
49
+ active_sessions: number;
50
+ }[];
51
+ };
52
+ };
41
53
  log?: any;
42
54
  }>;
43
55
  }
@@ -1,5 +1,5 @@
1
1
  import { fetchJSONData } from "squarecommons";
2
- import { GenerateAccessTokenV0ResponseZ, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
2
+ import { GenerateAccessTokenV0ResponseZ, GetUserDetailsV0ResponseZ, LogoutV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
@@ -20,7 +20,7 @@ class AuthenticationCommonBL {
20
20
  undefined,
21
21
  // query params
22
22
  undefined);
23
- return data;
23
+ return LogoutV0Z.parse(data);
24
24
  }
25
25
  catch (error) {
26
26
  throw error;
@@ -125,7 +125,7 @@ class AuthenticationCommonBL {
125
125
  undefined,
126
126
  // query params
127
127
  undefined);
128
- return data;
128
+ return GetUserDetailsV0ResponseZ.parse(data);
129
129
  }
130
130
  catch (error) {
131
131
  throw error;
@@ -102,4 +102,126 @@ declare const UpdatePasswordV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
102
102
  log?: any;
103
103
  }>;
104
104
  type UpdatePasswordV0Response = z.infer<typeof UpdatePasswordV0ResponseZ>;
105
- export { GenerateAccessTokenV0ResponseZ, GenerateAccessTokenV0Response, UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, };
105
+ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
106
+ data: z.ZodAny;
107
+ message: z.ZodNullable<z.ZodString>;
108
+ log: z.ZodAny;
109
+ }, {
110
+ data: z.ZodObject<{
111
+ main: z.ZodObject<{
112
+ user_id: z.ZodString;
113
+ credentials: z.ZodObject<{
114
+ username: z.ZodString;
115
+ }, "strip", z.ZodTypeAny, {
116
+ username: string;
117
+ }, {
118
+ username: string;
119
+ }>;
120
+ apps: z.ZodArray<z.ZodNumber, "many">;
121
+ sessions: z.ZodArray<z.ZodObject<{
122
+ app_id: z.ZodNumber;
123
+ active_sessions: z.ZodNumber;
124
+ }, "strip", z.ZodTypeAny, {
125
+ app_id: number;
126
+ active_sessions: number;
127
+ }, {
128
+ app_id: number;
129
+ active_sessions: number;
130
+ }>, "many">;
131
+ }, "strip", z.ZodTypeAny, {
132
+ user_id: string;
133
+ credentials: {
134
+ username: string;
135
+ };
136
+ apps: number[];
137
+ sessions: {
138
+ app_id: number;
139
+ active_sessions: number;
140
+ }[];
141
+ }, {
142
+ user_id: string;
143
+ credentials: {
144
+ username: string;
145
+ };
146
+ apps: number[];
147
+ sessions: {
148
+ app_id: number;
149
+ active_sessions: number;
150
+ }[];
151
+ }>;
152
+ }, "strip", z.ZodTypeAny, {
153
+ main: {
154
+ user_id: string;
155
+ credentials: {
156
+ username: string;
157
+ };
158
+ apps: number[];
159
+ sessions: {
160
+ app_id: number;
161
+ active_sessions: number;
162
+ }[];
163
+ };
164
+ }, {
165
+ main: {
166
+ user_id: string;
167
+ credentials: {
168
+ username: string;
169
+ };
170
+ apps: number[];
171
+ sessions: {
172
+ app_id: number;
173
+ active_sessions: number;
174
+ }[];
175
+ };
176
+ }>;
177
+ }>, "strip", z.ZodTypeAny, {
178
+ message: string | null;
179
+ data: {
180
+ main: {
181
+ user_id: string;
182
+ credentials: {
183
+ username: string;
184
+ };
185
+ apps: number[];
186
+ sessions: {
187
+ app_id: number;
188
+ active_sessions: number;
189
+ }[];
190
+ };
191
+ };
192
+ log?: any;
193
+ }, {
194
+ message: string | null;
195
+ data: {
196
+ main: {
197
+ user_id: string;
198
+ credentials: {
199
+ username: string;
200
+ };
201
+ apps: number[];
202
+ sessions: {
203
+ app_id: number;
204
+ active_sessions: number;
205
+ }[];
206
+ };
207
+ };
208
+ log?: any;
209
+ }>;
210
+ type GetUserDetailsV0Response = z.infer<typeof GetUserDetailsV0ResponseZ>;
211
+ declare const LogoutV0Z: z.ZodObject<z.objectUtil.extendShape<{
212
+ data: z.ZodAny;
213
+ message: z.ZodNullable<z.ZodString>;
214
+ log: z.ZodAny;
215
+ }, {
216
+ data: z.ZodNull;
217
+ }>, "strip", z.ZodTypeAny, {
218
+ message: string | null;
219
+ data: null;
220
+ log?: any;
221
+ }, {
222
+ message: string | null;
223
+ data: null;
224
+ log?: any;
225
+ }>;
226
+ type LogoutV0 = z.infer<typeof LogoutV0Z>;
227
+ export { GenerateAccessTokenV0ResponseZ, GenerateAccessTokenV0Response, UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, LogoutV0, LogoutV0Z, };
@@ -18,4 +18,22 @@ const UpdateUsernameV0ResponseZ = APIOutputZ.extend({
18
18
  const UpdatePasswordV0ResponseZ = APIOutputZ.extend({
19
19
  data: z.null(),
20
20
  });
21
- export { GenerateAccessTokenV0ResponseZ, UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, };
21
+ const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
22
+ data: z.object({
23
+ main: z.object({
24
+ user_id: z.string(),
25
+ credentials: z.object({
26
+ username: z.string(),
27
+ }),
28
+ apps: z.array(z.number()),
29
+ sessions: z.array(z.object({
30
+ app_id: z.number(),
31
+ active_sessions: z.number(),
32
+ })),
33
+ }),
34
+ }),
35
+ });
36
+ const LogoutV0Z = APIOutputZ.extend({
37
+ data: z.null(),
38
+ });
39
+ export { GenerateAccessTokenV0ResponseZ, UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, LogoutV0Z, };
package/example.js CHANGED
@@ -27,3 +27,7 @@ console.log(
27
27
  "newPassword"
28
28
  )
29
29
  );
30
+ console.log(
31
+ await authenticationCommonBL.getUserDetailsV0("dummy_access_token")
32
+ );
33
+ console.log(await authenticationCommonBL.logoutV0("dumm_refresh_token"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",