squarecommonblhelper 2.0.0 → 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 +10 -0
- package/dist/authentication.d.ts +0 -14
- package/dist/authentication.js +1 -43
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types/AuthenticationResponses.d.ts +7 -63
- package/dist/types/AuthenticationResponses.js +7 -17
- package/dist/types/GreetingResponses.d.ts +2 -2
- package/dist/types/GreetingResponses.js +2 -2
- package/example.js +1 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,16 @@ 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
|
+
|
|
23
|
+
### v2.0.1
|
|
24
|
+
|
|
25
|
+
- use strictObject in zod.
|
|
26
|
+
- export types in index file.
|
|
27
|
+
|
|
18
28
|
### v2.0.0
|
|
19
29
|
|
|
20
30
|
- remove UtilsCommonBL
|
package/dist/authentication.d.ts
CHANGED
|
@@ -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;
|
package/dist/authentication.js
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
1
|
import { fetchJSONData } from "squarecommons";
|
|
2
|
-
import { DeleteUserV0Z,
|
|
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(
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
access_token: string;
|
|
12
|
-
}, {
|
|
13
|
-
access_token: string;
|
|
14
|
-
}>;
|
|
15
|
-
}, "strip", 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>;
|
|
@@ -48,14 +8,14 @@ declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
48
8
|
main: z.ZodObject<{
|
|
49
9
|
user_id: z.ZodString;
|
|
50
10
|
username: z.ZodString;
|
|
51
|
-
}, "
|
|
11
|
+
}, "strict", z.ZodTypeAny, {
|
|
52
12
|
user_id: string;
|
|
53
13
|
username: string;
|
|
54
14
|
}, {
|
|
55
15
|
user_id: string;
|
|
56
16
|
username: string;
|
|
57
17
|
}>;
|
|
58
|
-
}, "
|
|
18
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
19
|
main: {
|
|
60
20
|
user_id: string;
|
|
61
21
|
username: string;
|
|
@@ -112,7 +72,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
112
72
|
user_id: z.ZodString;
|
|
113
73
|
credentials: z.ZodObject<{
|
|
114
74
|
username: z.ZodString;
|
|
115
|
-
}, "
|
|
75
|
+
}, "strict", z.ZodTypeAny, {
|
|
116
76
|
username: string;
|
|
117
77
|
}, {
|
|
118
78
|
username: string;
|
|
@@ -121,14 +81,14 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
121
81
|
sessions: z.ZodArray<z.ZodObject<{
|
|
122
82
|
app_id: z.ZodNumber;
|
|
123
83
|
active_sessions: z.ZodNumber;
|
|
124
|
-
}, "
|
|
84
|
+
}, "strict", z.ZodTypeAny, {
|
|
125
85
|
app_id: number;
|
|
126
86
|
active_sessions: number;
|
|
127
87
|
}, {
|
|
128
88
|
app_id: number;
|
|
129
89
|
active_sessions: number;
|
|
130
90
|
}>, "many">;
|
|
131
|
-
}, "
|
|
91
|
+
}, "strict", z.ZodTypeAny, {
|
|
132
92
|
user_id: string;
|
|
133
93
|
credentials: {
|
|
134
94
|
username: string;
|
|
@@ -149,7 +109,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
149
109
|
active_sessions: number;
|
|
150
110
|
}[];
|
|
151
111
|
}>;
|
|
152
|
-
}, "
|
|
112
|
+
}, "strict", z.ZodTypeAny, {
|
|
153
113
|
main: {
|
|
154
114
|
user_id: string;
|
|
155
115
|
credentials: {
|
|
@@ -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 {
|
|
187
|
+
export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, };
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { APIOutputZ } from "squarecommons";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
const GenerateAccessTokenV0ResponseZ = APIOutputZ.extend({
|
|
4
|
-
data: z.object({
|
|
5
|
-
main: z.object({
|
|
6
|
-
access_token: z.string(),
|
|
7
|
-
}),
|
|
8
|
-
}),
|
|
9
|
-
});
|
|
10
3
|
const UpdateUsernameV0ResponseZ = APIOutputZ.extend({
|
|
11
|
-
data: z.
|
|
12
|
-
main: z.
|
|
4
|
+
data: z.strictObject({
|
|
5
|
+
main: z.strictObject({
|
|
13
6
|
user_id: z.string(),
|
|
14
7
|
username: z.string(),
|
|
15
8
|
}),
|
|
@@ -19,24 +12,21 @@ const UpdatePasswordV0ResponseZ = APIOutputZ.extend({
|
|
|
19
12
|
data: z.null(),
|
|
20
13
|
});
|
|
21
14
|
const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
|
|
22
|
-
data: z.
|
|
23
|
-
main: z.
|
|
15
|
+
data: z.strictObject({
|
|
16
|
+
main: z.strictObject({
|
|
24
17
|
user_id: z.string(),
|
|
25
|
-
credentials: z.
|
|
18
|
+
credentials: z.strictObject({
|
|
26
19
|
username: z.string(),
|
|
27
20
|
}),
|
|
28
21
|
apps: z.array(z.number()),
|
|
29
|
-
sessions: z.array(z.
|
|
22
|
+
sessions: z.array(z.strictObject({
|
|
30
23
|
app_id: z.number(),
|
|
31
24
|
active_sessions: z.number(),
|
|
32
25
|
})),
|
|
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 {
|
|
32
|
+
export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, };
|
|
@@ -12,7 +12,7 @@ declare const CreateGreetingV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
12
12
|
greeting_datetime: z.ZodString;
|
|
13
13
|
greeting_is_anonymous: z.ZodBoolean;
|
|
14
14
|
greeting_text: z.ZodNullable<z.ZodString>;
|
|
15
|
-
}, "
|
|
15
|
+
}, "strict", z.ZodTypeAny, {
|
|
16
16
|
user_id: string | null;
|
|
17
17
|
greeting_anonymous_sender_name: string | null;
|
|
18
18
|
greeting_id: number;
|
|
@@ -27,7 +27,7 @@ declare const CreateGreetingV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
27
27
|
greeting_is_anonymous: boolean;
|
|
28
28
|
greeting_text: string | null;
|
|
29
29
|
}>, "many">;
|
|
30
|
-
}, "
|
|
30
|
+
}, "strict", z.ZodTypeAny, {
|
|
31
31
|
main: {
|
|
32
32
|
user_id: string | null;
|
|
33
33
|
greeting_anonymous_sender_name: string | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { APIOutputZ } from "squarecommons";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
const CreateGreetingV0ResponseZ = APIOutputZ.extend({
|
|
4
|
-
data: z.
|
|
5
|
-
main: z.array(z.
|
|
4
|
+
data: z.strictObject({
|
|
5
|
+
main: z.array(z.strictObject({
|
|
6
6
|
greeting_anonymous_sender_name: z.string().nullable(),
|
|
7
7
|
user_id: z.string().nullable(),
|
|
8
8
|
greeting_id: z.number(),
|
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
|
-
|
|
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
|
);
|