squarecommonblhelper 3.0.0 → 4.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
+ ### v4.1.0
19
+
20
+ - AuthenticationCommonBL:
21
+ - add logoutAllV0.
22
+
23
+ ### v4.0.0
24
+
25
+ - AuthenticationCommonBL:
26
+ - change type for GetUserDetailsV0ResponseZ to make it compatible with latest changes.
27
+
18
28
  ### v3.0.0
19
29
 
20
30
  - AuthenticationCommonBL:
@@ -29,14 +29,19 @@ declare class AuthenticationCommonBL {
29
29
  credentials: {
30
30
  username: string;
31
31
  };
32
- apps: number[];
32
+ apps: string[];
33
33
  sessions: {
34
- app_id: number;
34
+ app_name: string;
35
35
  active_sessions: number;
36
36
  }[];
37
37
  };
38
38
  };
39
39
  log?: any;
40
40
  }>;
41
+ logoutAllV0(accessToken: string): Promise<{
42
+ message: string | null;
43
+ data: null;
44
+ log?: any;
45
+ }>;
41
46
  }
42
47
  export { AuthenticationCommonBL };
@@ -1,5 +1,5 @@
1
1
  import { fetchJSONData } from "squarecommons";
2
- import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
2
+ import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, LogoutAllV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
@@ -89,5 +89,26 @@ class AuthenticationCommonBL {
89
89
  throw error;
90
90
  }
91
91
  }
92
+ async logoutAllV0(accessToken) {
93
+ try {
94
+ const data = await fetchJSONData(
95
+ // base url
96
+ this.commonBLBaseURL,
97
+ // endpoint
98
+ "logout/all/v0",
99
+ // method
100
+ "DELETE",
101
+ // headers
102
+ { access_token: accessToken },
103
+ // body
104
+ undefined,
105
+ // query params
106
+ undefined);
107
+ return LogoutAllV0Z.parse(data);
108
+ }
109
+ catch (error) {
110
+ throw error;
111
+ }
112
+ }
92
113
  }
93
114
  export { AuthenticationCommonBL };
@@ -77,15 +77,15 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
77
77
  }, {
78
78
  username: string;
79
79
  }>;
80
- apps: z.ZodArray<z.ZodNumber, "many">;
80
+ apps: z.ZodArray<z.ZodString, "many">;
81
81
  sessions: z.ZodArray<z.ZodObject<{
82
- app_id: z.ZodNumber;
82
+ app_name: z.ZodString;
83
83
  active_sessions: z.ZodNumber;
84
84
  }, "strict", z.ZodTypeAny, {
85
- app_id: number;
85
+ app_name: string;
86
86
  active_sessions: number;
87
87
  }, {
88
- app_id: number;
88
+ app_name: string;
89
89
  active_sessions: number;
90
90
  }>, "many">;
91
91
  }, "strict", z.ZodTypeAny, {
@@ -93,9 +93,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
93
93
  credentials: {
94
94
  username: string;
95
95
  };
96
- apps: number[];
96
+ apps: string[];
97
97
  sessions: {
98
- app_id: number;
98
+ app_name: string;
99
99
  active_sessions: number;
100
100
  }[];
101
101
  }, {
@@ -103,9 +103,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
103
103
  credentials: {
104
104
  username: string;
105
105
  };
106
- apps: number[];
106
+ apps: string[];
107
107
  sessions: {
108
- app_id: number;
108
+ app_name: string;
109
109
  active_sessions: number;
110
110
  }[];
111
111
  }>;
@@ -115,9 +115,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
115
115
  credentials: {
116
116
  username: string;
117
117
  };
118
- apps: number[];
118
+ apps: string[];
119
119
  sessions: {
120
- app_id: number;
120
+ app_name: string;
121
121
  active_sessions: number;
122
122
  }[];
123
123
  };
@@ -127,9 +127,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
127
127
  credentials: {
128
128
  username: string;
129
129
  };
130
- apps: number[];
130
+ apps: string[];
131
131
  sessions: {
132
- app_id: number;
132
+ app_name: string;
133
133
  active_sessions: number;
134
134
  }[];
135
135
  };
@@ -142,9 +142,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
142
142
  credentials: {
143
143
  username: string;
144
144
  };
145
- apps: number[];
145
+ apps: string[];
146
146
  sessions: {
147
- app_id: number;
147
+ app_name: string;
148
148
  active_sessions: number;
149
149
  }[];
150
150
  };
@@ -158,9 +158,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
158
158
  credentials: {
159
159
  username: string;
160
160
  };
161
- apps: number[];
161
+ apps: string[];
162
162
  sessions: {
163
- app_id: number;
163
+ app_name: string;
164
164
  active_sessions: number;
165
165
  }[];
166
166
  };
@@ -184,4 +184,20 @@ declare const DeleteUserV0Z: z.ZodObject<z.objectUtil.extendShape<{
184
184
  log?: any;
185
185
  }>;
186
186
  type DeleteUserV0 = z.infer<typeof DeleteUserV0Z>;
187
- export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, };
187
+ declare const LogoutAllV0Z: z.ZodObject<z.objectUtil.extendShape<{
188
+ data: z.ZodAny;
189
+ message: z.ZodNullable<z.ZodString>;
190
+ log: z.ZodAny;
191
+ }, {
192
+ data: z.ZodNull;
193
+ }>, "strip", z.ZodTypeAny, {
194
+ message: string | null;
195
+ data: null;
196
+ log?: any;
197
+ }, {
198
+ message: string | null;
199
+ data: null;
200
+ log?: any;
201
+ }>;
202
+ type LogoutAllV0 = z.infer<typeof LogoutAllV0Z>;
203
+ export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, LogoutAllV0, LogoutAllV0Z, };
@@ -18,9 +18,9 @@ const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
18
18
  credentials: z.strictObject({
19
19
  username: z.string(),
20
20
  }),
21
- apps: z.array(z.number()),
21
+ apps: z.array(z.string()),
22
22
  sessions: z.array(z.strictObject({
23
- app_id: z.number(),
23
+ app_name: z.string(),
24
24
  active_sessions: z.number(),
25
25
  })),
26
26
  }),
@@ -29,4 +29,7 @@ const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
29
29
  const DeleteUserV0Z = APIOutputZ.extend({
30
30
  data: z.null(),
31
31
  });
32
- export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, };
32
+ const LogoutAllV0Z = APIOutputZ.extend({
33
+ data: z.null(),
34
+ });
35
+ export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, LogoutAllV0Z, };
package/example.js CHANGED
@@ -24,3 +24,4 @@ console.log(
24
24
  console.log(
25
25
  await authenticationCommonBL.deleteUserV0("dummy_access_token", "password")
26
26
  );
27
+ console.log(await authenticationCommonBL.logoutAllV0("dummy_access_token"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "3.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",