@etsoo/appscript 1.5.96 → 1.5.98

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.
@@ -4,7 +4,7 @@ import { BaseApi } from "./BaseApi";
4
4
  import { ResultPayload } from "./dto/ResultPayload";
5
5
  import { DataTypes, IActionResult } from "@etsoo/shared";
6
6
  import { RefreshTokenProps, RefreshTokenResult } from "../app/IApp";
7
- import { TokenRQ } from "./rq/TokenRQ";
7
+ import { TokenInputRQ } from "./rq/TokenRQ";
8
8
  import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
9
9
  import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
10
10
  import { LoginRQ } from "./rq/LoginRQ";
@@ -27,7 +27,7 @@ export declare class AuthApi extends BaseApi {
27
27
  * @param payload Payload
28
28
  * @returns Result
29
29
  */
30
- apiRefreshToken(rq: TokenRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
30
+ apiRefreshToken(rq: TokenInputRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
31
31
  /**
32
32
  * Authorization request
33
33
  * @param auth Authorization request data
@@ -56,7 +56,7 @@ export declare class AuthApi extends BaseApi {
56
56
  * @param payload Payload
57
57
  * @returns Result
58
58
  */
59
- exchangeToken(rq: TokenRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
59
+ exchangeToken(rq: TokenInputRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
60
60
  /**
61
61
  * Get log in url
62
62
  * @param rq Request data
@@ -14,7 +14,8 @@ class AuthApi extends BaseApi_1.BaseApi {
14
14
  * @returns Result
15
15
  */
16
16
  apiRefreshToken(rq, payload) {
17
- return this.api.put("Auth/ApiRefreshToken", rq, payload);
17
+ const data = { ...rq, timeZone: this.app.getTimeZone() };
18
+ return this.api.put("Auth/ApiRefreshToken", data, payload);
18
19
  }
19
20
  /**
20
21
  * Authorization request
@@ -63,7 +64,8 @@ class AuthApi extends BaseApi_1.BaseApi {
63
64
  * @returns Result
64
65
  */
65
66
  exchangeToken(rq, payload) {
66
- return this.api.put("Auth/ExchangeToken", rq, payload);
67
+ const data = { ...rq, timeZone: this.app.getTimeZone() };
68
+ return this.api.put("Auth/ExchangeToken", data, payload);
67
69
  }
68
70
  /**
69
71
  * Get log in url
@@ -106,7 +108,8 @@ class AuthApi extends BaseApi_1.BaseApi {
106
108
  const rq = {
107
109
  id,
108
110
  deviceId,
109
- region
111
+ region,
112
+ timeZone: this.app.getTimeZone()
110
113
  };
111
114
  return this.api.post("Auth/LoginId", rq, payload);
112
115
  }
@@ -129,7 +132,8 @@ class AuthApi extends BaseApi_1.BaseApi {
129
132
  }
130
133
  // Reqest data
131
134
  const rq = {
132
- deviceId: this.app.deviceId
135
+ deviceId: this.app.deviceId,
136
+ timeZone: this.app.getTimeZone()
133
137
  };
134
138
  // Payload
135
139
  const payload = {
@@ -1,13 +1,10 @@
1
+ import { TokenInputRQ } from "./TokenRQ";
1
2
  /**
2
3
  * API Refresh Token Request data
3
4
  */
4
- export type ApiRefreshTokenRQ = {
5
- /**
6
- * Refresh token
7
- */
8
- token: string;
5
+ export type ApiRefreshTokenRQ = TokenInputRQ & {
9
6
  /**
10
7
  * Application ID, 0 for core system
11
8
  */
12
- appId?: number;
9
+ appId: number;
13
10
  };
@@ -14,4 +14,8 @@ export type LoginIdRQ = {
14
14
  * Country or region
15
15
  */
16
16
  region: string;
17
+ /**
18
+ * Time zone
19
+ */
20
+ timeZone: string;
17
21
  };
@@ -8,10 +8,6 @@ export type LoginRQ = LoginIdRQ & {
8
8
  * Password
9
9
  */
10
10
  pwd: string;
11
- /**
12
- * Time zone
13
- */
14
- timezone: string;
15
11
  /**
16
12
  * Organization
17
13
  */
@@ -6,4 +6,8 @@ export type RefreshTokenRQ = {
6
6
  * Device id
7
7
  */
8
8
  deviceId: string;
9
+ /***
10
+ * Time zone
11
+ */
12
+ timeZone: string;
9
13
  };
@@ -1,9 +1,18 @@
1
1
  /**
2
2
  * Token request data
3
3
  */
4
- export type TokenRQ = {
4
+ export type TokenInputRQ = {
5
5
  /**
6
6
  * Refresh token
7
7
  */
8
8
  token: string;
9
9
  };
10
+ /**
11
+ * Token request data
12
+ */
13
+ export type TokenRQ = TokenInputRQ & {
14
+ /**
15
+ * Time zone
16
+ */
17
+ timeZone: string;
18
+ };
@@ -1608,6 +1608,8 @@ class CoreApp {
1608
1608
  // Exit when not authorized
1609
1609
  if (!this.authorized)
1610
1610
  return;
1611
+ // App id
1612
+ const appId = this.settings.appId;
1611
1613
  // APIs
1612
1614
  for (const name in this.apis) {
1613
1615
  // Get the API
@@ -1620,7 +1622,7 @@ class CoreApp {
1620
1622
  // Ready to trigger
1621
1623
  if (api[2] === 0) {
1622
1624
  // Refresh token
1623
- api[3](api[0], { token: api[4] }).then((data) => {
1625
+ api[3](api[0], { appId, token: api[4] }).then((data) => {
1624
1626
  if (data == null) {
1625
1627
  // Failed, try it again in 2 seconds
1626
1628
  api[2] = 2;
@@ -4,7 +4,7 @@ import { BaseApi } from "./BaseApi";
4
4
  import { ResultPayload } from "./dto/ResultPayload";
5
5
  import { DataTypes, IActionResult } from "@etsoo/shared";
6
6
  import { RefreshTokenProps, RefreshTokenResult } from "../app/IApp";
7
- import { TokenRQ } from "./rq/TokenRQ";
7
+ import { TokenInputRQ } from "./rq/TokenRQ";
8
8
  import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
9
9
  import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
10
10
  import { LoginRQ } from "./rq/LoginRQ";
@@ -27,7 +27,7 @@ export declare class AuthApi extends BaseApi {
27
27
  * @param payload Payload
28
28
  * @returns Result
29
29
  */
30
- apiRefreshToken(rq: TokenRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
30
+ apiRefreshToken(rq: TokenInputRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
31
31
  /**
32
32
  * Authorization request
33
33
  * @param auth Authorization request data
@@ -56,7 +56,7 @@ export declare class AuthApi extends BaseApi {
56
56
  * @param payload Payload
57
57
  * @returns Result
58
58
  */
59
- exchangeToken(rq: TokenRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
59
+ exchangeToken(rq: TokenInputRQ, payload?: IApiPayload<ApiRefreshTokenDto>): Promise<ApiRefreshTokenDto | undefined>;
60
60
  /**
61
61
  * Get log in url
62
62
  * @param rq Request data
@@ -11,7 +11,8 @@ export class AuthApi extends BaseApi {
11
11
  * @returns Result
12
12
  */
13
13
  apiRefreshToken(rq, payload) {
14
- return this.api.put("Auth/ApiRefreshToken", rq, payload);
14
+ const data = { ...rq, timeZone: this.app.getTimeZone() };
15
+ return this.api.put("Auth/ApiRefreshToken", data, payload);
15
16
  }
16
17
  /**
17
18
  * Authorization request
@@ -60,7 +61,8 @@ export class AuthApi extends BaseApi {
60
61
  * @returns Result
61
62
  */
62
63
  exchangeToken(rq, payload) {
63
- return this.api.put("Auth/ExchangeToken", rq, payload);
64
+ const data = { ...rq, timeZone: this.app.getTimeZone() };
65
+ return this.api.put("Auth/ExchangeToken", data, payload);
64
66
  }
65
67
  /**
66
68
  * Get log in url
@@ -103,7 +105,8 @@ export class AuthApi extends BaseApi {
103
105
  const rq = {
104
106
  id,
105
107
  deviceId,
106
- region
108
+ region,
109
+ timeZone: this.app.getTimeZone()
107
110
  };
108
111
  return this.api.post("Auth/LoginId", rq, payload);
109
112
  }
@@ -126,7 +129,8 @@ export class AuthApi extends BaseApi {
126
129
  }
127
130
  // Reqest data
128
131
  const rq = {
129
- deviceId: this.app.deviceId
132
+ deviceId: this.app.deviceId,
133
+ timeZone: this.app.getTimeZone()
130
134
  };
131
135
  // Payload
132
136
  const payload = {
@@ -1,13 +1,10 @@
1
+ import { TokenInputRQ } from "./TokenRQ";
1
2
  /**
2
3
  * API Refresh Token Request data
3
4
  */
4
- export type ApiRefreshTokenRQ = {
5
- /**
6
- * Refresh token
7
- */
8
- token: string;
5
+ export type ApiRefreshTokenRQ = TokenInputRQ & {
9
6
  /**
10
7
  * Application ID, 0 for core system
11
8
  */
12
- appId?: number;
9
+ appId: number;
13
10
  };
@@ -14,4 +14,8 @@ export type LoginIdRQ = {
14
14
  * Country or region
15
15
  */
16
16
  region: string;
17
+ /**
18
+ * Time zone
19
+ */
20
+ timeZone: string;
17
21
  };
@@ -8,10 +8,6 @@ export type LoginRQ = LoginIdRQ & {
8
8
  * Password
9
9
  */
10
10
  pwd: string;
11
- /**
12
- * Time zone
13
- */
14
- timezone: string;
15
11
  /**
16
12
  * Organization
17
13
  */
@@ -6,4 +6,8 @@ export type RefreshTokenRQ = {
6
6
  * Device id
7
7
  */
8
8
  deviceId: string;
9
+ /***
10
+ * Time zone
11
+ */
12
+ timeZone: string;
9
13
  };
@@ -1,9 +1,18 @@
1
1
  /**
2
2
  * Token request data
3
3
  */
4
- export type TokenRQ = {
4
+ export type TokenInputRQ = {
5
5
  /**
6
6
  * Refresh token
7
7
  */
8
8
  token: string;
9
9
  };
10
+ /**
11
+ * Token request data
12
+ */
13
+ export type TokenRQ = TokenInputRQ & {
14
+ /**
15
+ * Time zone
16
+ */
17
+ timeZone: string;
18
+ };
@@ -1605,6 +1605,8 @@ export class CoreApp {
1605
1605
  // Exit when not authorized
1606
1606
  if (!this.authorized)
1607
1607
  return;
1608
+ // App id
1609
+ const appId = this.settings.appId;
1608
1610
  // APIs
1609
1611
  for (const name in this.apis) {
1610
1612
  // Get the API
@@ -1617,7 +1619,7 @@ export class CoreApp {
1617
1619
  // Ready to trigger
1618
1620
  if (api[2] === 0) {
1619
1621
  // Refresh token
1620
- api[3](api[0], { token: api[4] }).then((data) => {
1622
+ api[3](api[0], { appId, token: api[4] }).then((data) => {
1621
1623
  if (data == null) {
1622
1624
  // Failed, try it again in 2 seconds
1623
1625
  api[2] = 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.96",
3
+ "version": "1.5.98",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -42,14 +42,14 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@babel/cli": "^7.26.4",
45
- "@babel/core": "^7.26.7",
46
- "@babel/plugin-transform-runtime": "^7.25.9",
47
- "@babel/preset-env": "^7.26.7",
45
+ "@babel/core": "^7.26.8",
46
+ "@babel/plugin-transform-runtime": "^7.26.8",
47
+ "@babel/preset-env": "^7.26.8",
48
48
  "@babel/runtime-corejs3": "^7.26.7",
49
49
  "@types/crypto-js": "^4.2.2",
50
50
  "@vitejs/plugin-react": "^4.3.4",
51
51
  "jsdom": "^26.0.0",
52
52
  "typescript": "^5.7.3",
53
- "vitest": "^3.0.4"
53
+ "vitest": "^3.0.5"
54
54
  }
55
55
  }
@@ -4,7 +4,7 @@ import { BaseApi } from "./BaseApi";
4
4
  import { ResultPayload } from "./dto/ResultPayload";
5
5
  import { ActionResult, DataTypes, IActionResult } from "@etsoo/shared";
6
6
  import { RefreshTokenProps, RefreshTokenResult } from "../app/IApp";
7
- import { TokenRQ } from "./rq/TokenRQ";
7
+ import { TokenInputRQ, TokenRQ } from "./rq/TokenRQ";
8
8
  import { ApiRefreshTokenDto } from "./dto/ApiRefreshTokenDto";
9
9
  import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
10
10
  import { LoginRQ } from "./rq/LoginRQ";
@@ -32,8 +32,9 @@ export class AuthApi extends BaseApi {
32
32
  * @param payload Payload
33
33
  * @returns Result
34
34
  */
35
- apiRefreshToken(rq: TokenRQ, payload?: IApiPayload<ApiRefreshTokenDto>) {
36
- return this.api.put("Auth/ApiRefreshToken", rq, payload);
35
+ apiRefreshToken(rq: TokenInputRQ, payload?: IApiPayload<ApiRefreshTokenDto>) {
36
+ const data: TokenRQ = { ...rq, timeZone: this.app.getTimeZone() };
37
+ return this.api.put("Auth/ApiRefreshToken", data, payload);
37
38
  }
38
39
 
39
40
  /**
@@ -93,8 +94,9 @@ export class AuthApi extends BaseApi {
93
94
  * @param payload Payload
94
95
  * @returns Result
95
96
  */
96
- exchangeToken(rq: TokenRQ, payload?: IApiPayload<ApiRefreshTokenDto>) {
97
- return this.api.put("Auth/ExchangeToken", rq, payload);
97
+ exchangeToken(rq: TokenInputRQ, payload?: IApiPayload<ApiRefreshTokenDto>) {
98
+ const data: TokenRQ = { ...rq, timeZone: this.app.getTimeZone() };
99
+ return this.api.put("Auth/ExchangeToken", data, payload);
98
100
  }
99
101
 
100
102
  /**
@@ -147,7 +149,8 @@ export class AuthApi extends BaseApi {
147
149
  const rq: LoginIdRQ = {
148
150
  id,
149
151
  deviceId,
150
- region
152
+ region,
153
+ timeZone: this.app.getTimeZone()
151
154
  };
152
155
  return this.api.post("Auth/LoginId", rq, payload);
153
156
  }
@@ -180,7 +183,8 @@ export class AuthApi extends BaseApi {
180
183
 
181
184
  // Reqest data
182
185
  const rq: RefreshTokenRQ = {
183
- deviceId: this.app.deviceId
186
+ deviceId: this.app.deviceId,
187
+ timeZone: this.app.getTimeZone()
184
188
  };
185
189
 
186
190
  // Payload
@@ -1,14 +1,11 @@
1
+ import { TokenInputRQ } from "./TokenRQ";
2
+
1
3
  /**
2
4
  * API Refresh Token Request data
3
5
  */
4
- export type ApiRefreshTokenRQ = {
5
- /**
6
- * Refresh token
7
- */
8
- token: string;
9
-
6
+ export type ApiRefreshTokenRQ = TokenInputRQ & {
10
7
  /**
11
8
  * Application ID, 0 for core system
12
9
  */
13
- appId?: number;
10
+ appId: number;
14
11
  };
@@ -16,4 +16,9 @@ export type LoginIdRQ = {
16
16
  * Country or region
17
17
  */
18
18
  region: string;
19
+
20
+ /**
21
+ * Time zone
22
+ */
23
+ timeZone: string;
19
24
  };
@@ -10,11 +10,6 @@ export type LoginRQ = LoginIdRQ & {
10
10
  */
11
11
  pwd: string;
12
12
 
13
- /**
14
- * Time zone
15
- */
16
- timezone: string;
17
-
18
13
  /**
19
14
  * Organization
20
15
  */
@@ -6,4 +6,9 @@ export type RefreshTokenRQ = {
6
6
  * Device id
7
7
  */
8
8
  deviceId: string;
9
+
10
+ /***
11
+ * Time zone
12
+ */
13
+ timeZone: string;
9
14
  };
@@ -1,9 +1,19 @@
1
1
  /**
2
2
  * Token request data
3
3
  */
4
- export type TokenRQ = {
4
+ export type TokenInputRQ = {
5
5
  /**
6
6
  * Refresh token
7
7
  */
8
8
  token: string;
9
9
  };
10
+
11
+ /**
12
+ * Token request data
13
+ */
14
+ export type TokenRQ = TokenInputRQ & {
15
+ /**
16
+ * Time zone
17
+ */
18
+ timeZone: string;
19
+ };
@@ -61,7 +61,7 @@ type ApiRefreshTokenFunction = (
61
61
  rq: ApiRefreshTokenRQ
62
62
  ) => Promise<[string, number] | undefined>;
63
63
 
64
- // API task data
64
+ // API task data, [api, token expires in seconds, token expires countdown seconds, app id, refresh token function, token]
65
65
  type ApiTaskData = [IApi, number, number, ApiRefreshTokenFunction, string?];
66
66
 
67
67
  // System API name
@@ -2162,6 +2162,9 @@ export abstract class CoreApp<
2162
2162
  // Exit when not authorized
2163
2163
  if (!this.authorized) return;
2164
2164
 
2165
+ // App id
2166
+ const appId = this.settings.appId;
2167
+
2165
2168
  // APIs
2166
2169
  for (const name in this.apis) {
2167
2170
  // Get the API
@@ -2176,7 +2179,7 @@ export abstract class CoreApp<
2176
2179
  // Ready to trigger
2177
2180
  if (api[2] === 0) {
2178
2181
  // Refresh token
2179
- api[3](api[0], { token: api[4] }).then((data) => {
2182
+ api[3](api[0], { appId, token: api[4] }).then((data) => {
2180
2183
  if (data == null) {
2181
2184
  // Failed, try it again in 2 seconds
2182
2185
  api[2] = 2;