squarecommonblhelper 2.0.1 → 3.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,11 @@ helper for common bl for my projects.
15
15
 
16
16
  ## changelog
17
17
 
18
+ ### v3.0.0
19
+
20
+ - AuthenticationCommonBL:
21
+ - remove generateAccessTokenV0, logoutV0.
22
+
18
23
  ### v2.0.1
19
24
 
20
25
  - use strictObject in zod.
@@ -1,20 +1,6 @@
1
1
  declare class AuthenticationCommonBL {
2
2
  private commonBLBaseURL;
3
3
  constructor(commonBLBaseURL?: string);
4
- logoutV0(refreshToken: string): Promise<{
5
- message: string | null;
6
- data: null;
7
- log?: any;
8
- }>;
9
- generateAccessTokenV0(refreshToken: string): Promise<{
10
- message: string | null;
11
- data: {
12
- main: {
13
- access_token: string;
14
- };
15
- };
16
- log?: any;
17
- }>;
18
4
  deleteUserV0(accessToken: string, password: string): Promise<{
19
5
  message: string | null;
20
6
  data: null;
@@ -1,52 +1,10 @@
1
1
  import { fetchJSONData } from "squarecommons";
2
- import { DeleteUserV0Z, GenerateAccessTokenV0ResponseZ, GetUserDetailsV0ResponseZ, LogoutV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
2
+ import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
6
6
  this.commonBLBaseURL = commonBLBaseURL;
7
7
  }
8
- async logoutV0(refreshToken) {
9
- try {
10
- const data = await fetchJSONData(
11
- // base url
12
- this.commonBLBaseURL,
13
- // endpoint
14
- "logout/v0",
15
- // method
16
- "DELETE",
17
- // headers
18
- { refresh_token: refreshToken },
19
- // body
20
- undefined,
21
- // query params
22
- undefined);
23
- return LogoutV0Z.parse(data);
24
- }
25
- catch (error) {
26
- throw error;
27
- }
28
- }
29
- async generateAccessTokenV0(refreshToken) {
30
- try {
31
- const data = await fetchJSONData(
32
- // base url
33
- this.commonBLBaseURL,
34
- // endpoint
35
- "generate_access_token/v0",
36
- // method
37
- "GET",
38
- // headers
39
- { refresh_token: refreshToken },
40
- // body
41
- undefined,
42
- // query params
43
- undefined);
44
- return GenerateAccessTokenV0ResponseZ.parse(data);
45
- }
46
- catch (error) {
47
- throw error;
48
- }
49
- }
50
8
  async deleteUserV0(accessToken, password) {
51
9
  try {
52
10
  const data = await fetchJSONData(
@@ -1,44 +1,4 @@
1
1
  import { z } from "zod";
2
- declare const GenerateAccessTokenV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
3
- data: z.ZodAny;
4
- message: z.ZodNullable<z.ZodString>;
5
- log: z.ZodAny;
6
- }, {
7
- data: z.ZodObject<{
8
- main: z.ZodObject<{
9
- access_token: z.ZodString;
10
- }, "strict", z.ZodTypeAny, {
11
- access_token: string;
12
- }, {
13
- access_token: string;
14
- }>;
15
- }, "strict", z.ZodTypeAny, {
16
- main: {
17
- access_token: string;
18
- };
19
- }, {
20
- main: {
21
- access_token: string;
22
- };
23
- }>;
24
- }>, "strip", z.ZodTypeAny, {
25
- message: string | null;
26
- data: {
27
- main: {
28
- access_token: string;
29
- };
30
- };
31
- log?: any;
32
- }, {
33
- message: string | null;
34
- data: {
35
- main: {
36
- access_token: string;
37
- };
38
- };
39
- log?: any;
40
- }>;
41
- type GenerateAccessTokenV0Response = z.infer<typeof GenerateAccessTokenV0ResponseZ>;
42
2
  declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
43
3
  data: z.ZodAny;
44
4
  message: z.ZodNullable<z.ZodString>;
@@ -208,22 +168,6 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
208
168
  log?: any;
209
169
  }>;
210
170
  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
171
  declare const DeleteUserV0Z: z.ZodObject<z.objectUtil.extendShape<{
228
172
  data: z.ZodAny;
229
173
  message: z.ZodNullable<z.ZodString>;
@@ -240,4 +184,4 @@ declare const DeleteUserV0Z: z.ZodObject<z.objectUtil.extendShape<{
240
184
  log?: any;
241
185
  }>;
242
186
  type DeleteUserV0 = z.infer<typeof DeleteUserV0Z>;
243
- export { GenerateAccessTokenV0ResponseZ, GenerateAccessTokenV0Response, UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, LogoutV0, LogoutV0Z, DeleteUserV0, DeleteUserV0Z, };
187
+ export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, };
@@ -1,12 +1,5 @@
1
1
  import { APIOutputZ } from "squarecommons";
2
2
  import { z } from "zod";
3
- const GenerateAccessTokenV0ResponseZ = APIOutputZ.extend({
4
- data: z.strictObject({
5
- main: z.strictObject({
6
- access_token: z.string(),
7
- }),
8
- }),
9
- });
10
3
  const UpdateUsernameV0ResponseZ = APIOutputZ.extend({
11
4
  data: z.strictObject({
12
5
  main: z.strictObject({
@@ -33,10 +26,7 @@ const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
33
26
  }),
34
27
  }),
35
28
  });
36
- const LogoutV0Z = APIOutputZ.extend({
37
- data: z.null(),
38
- });
39
29
  const DeleteUserV0Z = APIOutputZ.extend({
40
30
  data: z.null(),
41
31
  });
42
- export { GenerateAccessTokenV0ResponseZ, UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, LogoutV0Z, DeleteUserV0Z, };
32
+ export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, };
package/example.js CHANGED
@@ -4,9 +4,7 @@ let greetingCommonBL = new GreetingCommonBL();
4
4
  console.log(await greetingCommonBL.createGreetingV0(true));
5
5
 
6
6
  let authenticationCommonBL = new AuthenticationCommonBL();
7
- console.log(
8
- await authenticationCommonBL.generateAccessTokenV0("dummy_refresh_token")
9
- );
7
+
10
8
  console.log(
11
9
  await authenticationCommonBL.updateUsernameV0(
12
10
  "dummy_access_token",
@@ -23,8 +21,6 @@ console.log(
23
21
  console.log(
24
22
  await authenticationCommonBL.getUserDetailsV0("dummy_access_token")
25
23
  );
26
- console.log(await authenticationCommonBL.logoutV0("dummy_refresh_token"));
27
-
28
24
  console.log(
29
25
  await authenticationCommonBL.deleteUserV0("dummy_access_token", "password")
30
26
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "2.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",