squarecommonblhelper 1.4.0 → 1.6.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.6.0
19
+
20
+ - AuthenticationCommonBL:
21
+ - add types for getUserDetailsV0
22
+
23
+ ### v1.5.0
24
+
25
+ - AuthenticationCommonBL:
26
+ - add types for updatePasswordV0
27
+
18
28
  ### v1.4.0
19
29
 
20
30
  - AuthenticationCommonBL:
@@ -32,12 +32,24 @@ declare class AuthenticationCommonBL {
32
32
  }>;
33
33
  updatePasswordV0(accessToken: string, oldPassword: string, newPassword: string): Promise<{
34
34
  message: string | null;
35
- data?: any;
35
+ data: null;
36
36
  log?: any;
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, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
2
+ import { GenerateAccessTokenV0ResponseZ, GetUserDetailsV0ResponseZ, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
@@ -104,7 +104,7 @@ class AuthenticationCommonBL {
104
104
  { old_password: oldPassword, new_password: newPassword },
105
105
  // query params
106
106
  undefined);
107
- return data;
107
+ return UpdatePasswordV0ResponseZ.parse(data);
108
108
  }
109
109
  catch (error) {
110
110
  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;
@@ -86,4 +86,126 @@ declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
86
86
  log?: any;
87
87
  }>;
88
88
  type UpdateUsernameV0Response = z.infer<typeof UpdateUsernameV0ResponseZ>;
89
- export { GenerateAccessTokenV0ResponseZ, GenerateAccessTokenV0Response, UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, };
89
+ declare const UpdatePasswordV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
90
+ data: z.ZodAny;
91
+ message: z.ZodNullable<z.ZodString>;
92
+ log: z.ZodAny;
93
+ }, {
94
+ data: z.ZodNull;
95
+ }>, "strip", z.ZodTypeAny, {
96
+ message: string | null;
97
+ data: null;
98
+ log?: any;
99
+ }, {
100
+ message: string | null;
101
+ data: null;
102
+ log?: any;
103
+ }>;
104
+ type UpdatePasswordV0Response = z.infer<typeof UpdatePasswordV0ResponseZ>;
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
+ export { GenerateAccessTokenV0ResponseZ, GenerateAccessTokenV0Response, UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, };
@@ -15,4 +15,22 @@ const UpdateUsernameV0ResponseZ = APIOutputZ.extend({
15
15
  }),
16
16
  }),
17
17
  });
18
- export { GenerateAccessTokenV0ResponseZ, UpdateUsernameV0ResponseZ, };
18
+ const UpdatePasswordV0ResponseZ = APIOutputZ.extend({
19
+ data: z.null(),
20
+ });
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
+ export { GenerateAccessTokenV0ResponseZ, UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, };
package/example.js CHANGED
@@ -20,3 +20,13 @@ console.log(
20
20
  "new_username"
21
21
  )
22
22
  );
23
+ console.log(
24
+ await authenticationCommonBL.updatePasswordV0(
25
+ "dummy_access_token",
26
+ "oldPassword",
27
+ "newPassword"
28
+ )
29
+ );
30
+ console.log(
31
+ await authenticationCommonBL.getUserDetailsV0("dummy_access_token")
32
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",