@etsoo/appscript 1.6.10 → 1.6.11

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.
@@ -6,7 +6,7 @@ import { DataTypes, IActionResult } from "@etsoo/shared";
6
6
  import { RefreshTokenProps, RefreshTokenResult } from "../app/IApp";
7
7
  import { TokenInputRQ } from "./rq/TokenRQ";
8
8
  import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
9
- import { LoginRQ } from "./rq/LoginRQ";
9
+ import { LoginInputAuthResult, LoginInputRQ } from "./rq/LoginRQ";
10
10
  import { ResetPasswordInputRQ } from "./rq/ResetPasswordRQ";
11
11
  import { SignoutRQ } from "./rq/SignoutRQ";
12
12
  import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
@@ -71,7 +71,10 @@ export declare class AuthApi extends BaseApi {
71
71
  * @param tokenKey Refresh token key
72
72
  * @returns Result
73
73
  */
74
- protected loginBase<T extends IUser>(rq: LoginRQ, payload?: IApiPayload<IActionResult<T>>, tokenKey?: string): Promise<[IActionResult<T> | undefined, string | null]>;
74
+ login<T extends IUser, A extends AuthRequest | undefined>(rq: LoginInputRQ, auth: A, payload?: IApiPayload<IActionResult<A extends undefined ? T : LoginInputAuthResult>>, tokenKey?: string): Promise<[
75
+ IActionResult<A extends undefined ? T : LoginInputAuthResult> | undefined,
76
+ string | null
77
+ ]>;
75
78
  /**
76
79
  * Login id check
77
80
  * @param id Check id
@@ -88,12 +88,19 @@ class AuthApi extends BaseApi_1.BaseApi {
88
88
  * @param tokenKey Refresh token key
89
89
  * @returns Result
90
90
  */
91
- async loginBase(rq, payload, tokenKey) {
91
+ async login(rq, auth, payload, tokenKey) {
92
92
  // Default values
93
93
  payload ?? (payload = {});
94
94
  tokenKey ?? (tokenKey = AuthApi.HeaderTokenField);
95
+ const data = {
96
+ ...rq,
97
+ auth,
98
+ deviceId: this.app.deviceId,
99
+ region: this.app.region,
100
+ timeZone: this.app.getTimeZone()
101
+ };
95
102
  // Call the API
96
- const result = await this.api.post("Auth/Login", rq, payload);
103
+ const result = await this.api.post("Auth/Login", data, payload);
97
104
  // Get the refresh token
98
105
  const refreshToken = result?.ok
99
106
  ? this.app.getResponseToken(payload.response, tokenKey)
@@ -1,15 +1,20 @@
1
+ /**
2
+ * Login id input request data
3
+ */
4
+ export type LoginIdInputRQ = {
5
+ /**
6
+ * Username, Email or mobile
7
+ */
8
+ id: string;
9
+ };
1
10
  /**
2
11
  * Login id request data
3
12
  */
4
- export type LoginIdRQ = {
13
+ export type LoginIdRQ = LoginIdInputRQ & {
5
14
  /**
6
15
  * Device id
7
16
  */
8
17
  deviceId: string;
9
- /**
10
- * Username, Email or mobile
11
- */
12
- id: string;
13
18
  /**
14
19
  * Country or region
15
20
  */
@@ -1,9 +1,9 @@
1
1
  import { AuthRequest } from "./AuthRequest";
2
- import { LoginIdRQ } from "./LoginIdRQ";
2
+ import { LoginIdInputRQ, LoginIdRQ } from "./LoginIdRQ";
3
3
  /**
4
- * Login request data
4
+ * Login input request data
5
5
  */
6
- export type LoginRQ = LoginIdRQ & {
6
+ export type LoginInputRQ = LoginIdInputRQ & {
7
7
  /**
8
8
  * Password
9
9
  */
@@ -12,12 +12,22 @@ export type LoginRQ = LoginIdRQ & {
12
12
  * Organization
13
13
  */
14
14
  org?: number;
15
+ };
16
+ /**
17
+ * Login input auth result
18
+ */
19
+ export type LoginInputAuthResult = {
15
20
  /**
16
- * Authorization request data
21
+ * Redirect URI
17
22
  */
18
- auth?: AuthRequest;
23
+ uri: string;
19
24
  };
20
25
  /**
21
- * Login input request data
26
+ * Login request data
22
27
  */
23
- export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
28
+ export type LoginRQ = LoginIdRQ & LoginInputRQ & {
29
+ /**
30
+ * Authorization request data
31
+ */
32
+ auth?: AuthRequest;
33
+ };
@@ -6,7 +6,7 @@ import { DataTypes, IActionResult } from "@etsoo/shared";
6
6
  import { RefreshTokenProps, RefreshTokenResult } from "../app/IApp";
7
7
  import { TokenInputRQ } from "./rq/TokenRQ";
8
8
  import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
9
- import { LoginRQ } from "./rq/LoginRQ";
9
+ import { LoginInputAuthResult, LoginInputRQ } from "./rq/LoginRQ";
10
10
  import { ResetPasswordInputRQ } from "./rq/ResetPasswordRQ";
11
11
  import { SignoutRQ } from "./rq/SignoutRQ";
12
12
  import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
@@ -71,7 +71,10 @@ export declare class AuthApi extends BaseApi {
71
71
  * @param tokenKey Refresh token key
72
72
  * @returns Result
73
73
  */
74
- protected loginBase<T extends IUser>(rq: LoginRQ, payload?: IApiPayload<IActionResult<T>>, tokenKey?: string): Promise<[IActionResult<T> | undefined, string | null]>;
74
+ login<T extends IUser, A extends AuthRequest | undefined>(rq: LoginInputRQ, auth: A, payload?: IApiPayload<IActionResult<A extends undefined ? T : LoginInputAuthResult>>, tokenKey?: string): Promise<[
75
+ IActionResult<A extends undefined ? T : LoginInputAuthResult> | undefined,
76
+ string | null
77
+ ]>;
75
78
  /**
76
79
  * Login id check
77
80
  * @param id Check id
@@ -85,12 +85,19 @@ export class AuthApi extends BaseApi {
85
85
  * @param tokenKey Refresh token key
86
86
  * @returns Result
87
87
  */
88
- async loginBase(rq, payload, tokenKey) {
88
+ async login(rq, auth, payload, tokenKey) {
89
89
  // Default values
90
90
  payload ?? (payload = {});
91
91
  tokenKey ?? (tokenKey = AuthApi.HeaderTokenField);
92
+ const data = {
93
+ ...rq,
94
+ auth,
95
+ deviceId: this.app.deviceId,
96
+ region: this.app.region,
97
+ timeZone: this.app.getTimeZone()
98
+ };
92
99
  // Call the API
93
- const result = await this.api.post("Auth/Login", rq, payload);
100
+ const result = await this.api.post("Auth/Login", data, payload);
94
101
  // Get the refresh token
95
102
  const refreshToken = result?.ok
96
103
  ? this.app.getResponseToken(payload.response, tokenKey)
@@ -1,15 +1,20 @@
1
+ /**
2
+ * Login id input request data
3
+ */
4
+ export type LoginIdInputRQ = {
5
+ /**
6
+ * Username, Email or mobile
7
+ */
8
+ id: string;
9
+ };
1
10
  /**
2
11
  * Login id request data
3
12
  */
4
- export type LoginIdRQ = {
13
+ export type LoginIdRQ = LoginIdInputRQ & {
5
14
  /**
6
15
  * Device id
7
16
  */
8
17
  deviceId: string;
9
- /**
10
- * Username, Email or mobile
11
- */
12
- id: string;
13
18
  /**
14
19
  * Country or region
15
20
  */
@@ -1,9 +1,9 @@
1
1
  import { AuthRequest } from "./AuthRequest";
2
- import { LoginIdRQ } from "./LoginIdRQ";
2
+ import { LoginIdInputRQ, LoginIdRQ } from "./LoginIdRQ";
3
3
  /**
4
- * Login request data
4
+ * Login input request data
5
5
  */
6
- export type LoginRQ = LoginIdRQ & {
6
+ export type LoginInputRQ = LoginIdInputRQ & {
7
7
  /**
8
8
  * Password
9
9
  */
@@ -12,12 +12,22 @@ export type LoginRQ = LoginIdRQ & {
12
12
  * Organization
13
13
  */
14
14
  org?: number;
15
+ };
16
+ /**
17
+ * Login input auth result
18
+ */
19
+ export type LoginInputAuthResult = {
15
20
  /**
16
- * Authorization request data
21
+ * Redirect URI
17
22
  */
18
- auth?: AuthRequest;
23
+ uri: string;
19
24
  };
20
25
  /**
21
- * Login input request data
26
+ * Login request data
22
27
  */
23
- export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
28
+ export type LoginRQ = LoginIdRQ & LoginInputRQ & {
29
+ /**
30
+ * Authorization request data
31
+ */
32
+ auth?: AuthRequest;
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.6.10",
3
+ "version": "1.6.11",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -7,7 +7,7 @@ import { RefreshTokenProps, RefreshTokenResult } from "../app/IApp";
7
7
  import { TokenInputRQ, TokenRQ } from "./rq/TokenRQ";
8
8
  import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
9
9
  import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
10
- import { LoginRQ } from "./rq/LoginRQ";
10
+ import { LoginInputAuthResult, LoginInputRQ, LoginRQ } from "./rq/LoginRQ";
11
11
  import { LoginIdRQ } from "./rq/LoginIdRQ";
12
12
  import { RefreshTokenRQ } from "./rq/RefreshTokenRQ";
13
13
  import { ResetPasswordInputRQ, ResetPasswordRQ } from "./rq/ResetPasswordRQ";
@@ -125,17 +125,33 @@ export class AuthApi extends BaseApi {
125
125
  * @param tokenKey Refresh token key
126
126
  * @returns Result
127
127
  */
128
- protected async loginBase<T extends IUser>(
129
- rq: LoginRQ,
130
- payload?: IApiPayload<IActionResult<T>>,
128
+ async login<T extends IUser, A extends AuthRequest | undefined>(
129
+ rq: LoginInputRQ,
130
+ auth: A,
131
+ payload?: IApiPayload<
132
+ IActionResult<A extends undefined ? T : LoginInputAuthResult>
133
+ >,
131
134
  tokenKey?: string
132
- ): Promise<[IActionResult<T> | undefined, string | null]> {
135
+ ): Promise<
136
+ [
137
+ IActionResult<A extends undefined ? T : LoginInputAuthResult> | undefined,
138
+ string | null
139
+ ]
140
+ > {
133
141
  // Default values
134
142
  payload ??= {};
135
143
  tokenKey ??= AuthApi.HeaderTokenField;
136
144
 
145
+ const data: LoginRQ = {
146
+ ...rq,
147
+ auth,
148
+ deviceId: this.app.deviceId,
149
+ region: this.app.region,
150
+ timeZone: this.app.getTimeZone()
151
+ };
152
+
137
153
  // Call the API
138
- const result = await this.api.post("Auth/Login", rq, payload);
154
+ const result = await this.api.post("Auth/Login", data, payload);
139
155
 
140
156
  // Get the refresh token
141
157
  const refreshToken = result?.ok
@@ -1,16 +1,21 @@
1
1
  /**
2
- * Login id request data
2
+ * Login id input request data
3
3
  */
4
- export type LoginIdRQ = {
4
+ export type LoginIdInputRQ = {
5
5
  /**
6
- * Device id
6
+ * Username, Email or mobile
7
7
  */
8
- deviceId: string;
8
+ id: string;
9
+ };
9
10
 
11
+ /**
12
+ * Login id request data
13
+ */
14
+ export type LoginIdRQ = LoginIdInputRQ & {
10
15
  /**
11
- * Username, Email or mobile
16
+ * Device id
12
17
  */
13
- id: string;
18
+ deviceId: string;
14
19
 
15
20
  /**
16
21
  * Country or region
@@ -1,10 +1,10 @@
1
1
  import { AuthRequest } from "./AuthRequest";
2
- import { LoginIdRQ } from "./LoginIdRQ";
2
+ import { LoginIdInputRQ, LoginIdRQ } from "./LoginIdRQ";
3
3
 
4
4
  /**
5
- * Login request data
5
+ * Login input request data
6
6
  */
7
- export type LoginRQ = LoginIdRQ & {
7
+ export type LoginInputRQ = LoginIdInputRQ & {
8
8
  /**
9
9
  * Password
10
10
  */
@@ -14,14 +14,25 @@ export type LoginRQ = LoginIdRQ & {
14
14
  * Organization
15
15
  */
16
16
  org?: number;
17
+ };
17
18
 
19
+ /**
20
+ * Login input auth result
21
+ */
22
+ export type LoginInputAuthResult = {
18
23
  /**
19
- * Authorization request data
24
+ * Redirect URI
20
25
  */
21
- auth?: AuthRequest;
26
+ uri: string;
22
27
  };
23
28
 
24
29
  /**
25
- * Login input request data
30
+ * Login request data
26
31
  */
27
- export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
32
+ export type LoginRQ = LoginIdRQ &
33
+ LoginInputRQ & {
34
+ /**
35
+ * Authorization request data
36
+ */
37
+ auth?: AuthRequest;
38
+ };