@etsoo/appscript 1.5.97 → 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
@@ -1,8 +1,8 @@
1
- import { TokenRQ } from "./TokenRQ";
1
+ import { TokenInputRQ } from "./TokenRQ";
2
2
  /**
3
3
  * API Refresh Token Request data
4
4
  */
5
- export type ApiRefreshTokenRQ = TokenRQ & {
5
+ export type ApiRefreshTokenRQ = TokenInputRQ & {
6
6
  /**
7
7
  * Application ID, 0 for core system
8
8
  */
@@ -1,11 +1,16 @@
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
+ };
10
+ /**
11
+ * Token request data
12
+ */
13
+ export type TokenRQ = TokenInputRQ & {
9
14
  /**
10
15
  * Time zone
11
16
  */
@@ -177,7 +177,7 @@ class CoreApp {
177
177
  const refresh = async (api, rq) => {
178
178
  if (this.lastCalled) {
179
179
  // Call refreshToken to update access token
180
- await this.refreshToken({ token: rq.token, timeZone: rq.timeZone, showLoading: false }, (result) => {
180
+ await this.refreshToken({ token: rq.token, showLoading: false }, (result) => {
181
181
  if (result === true)
182
182
  return;
183
183
  console.log(`CoreApp.${this.name}.RefreshToken`, result);
@@ -1420,7 +1420,7 @@ class CoreApp {
1420
1420
  */
1421
1421
  async refreshToken(props, callback) {
1422
1422
  // Check props
1423
- props ?? (props = { timeZone: this.getTimeZone() });
1423
+ props ?? (props = {});
1424
1424
  props.token ?? (props.token = this.getCacheToken());
1425
1425
  // Call refresh token API
1426
1426
  let data = await this.createAuthApi().refreshToken(props);
@@ -1519,7 +1519,7 @@ class CoreApp {
1519
1519
  throw new Error("System API is not allowed to exchange token");
1520
1520
  }
1521
1521
  // Call the API quietly, no loading bar and no error popup
1522
- const data = await this.createAuthApi().exchangeToken({ token, timeZone: this.getTimeZone() }, {
1522
+ const data = await this.createAuthApi().exchangeToken({ token }, {
1523
1523
  showLoading: false,
1524
1524
  onError: (error) => {
1525
1525
  console.error(`CoreApp.${api.name}.ExchangeToken error`, error);
@@ -1610,8 +1610,6 @@ class CoreApp {
1610
1610
  return;
1611
1611
  // App id
1612
1612
  const appId = this.settings.appId;
1613
- // Timezone
1614
- const timeZone = this.getTimeZone();
1615
1613
  // APIs
1616
1614
  for (const name in this.apis) {
1617
1615
  // Get the API
@@ -1624,7 +1622,7 @@ class CoreApp {
1624
1622
  // Ready to trigger
1625
1623
  if (api[2] === 0) {
1626
1624
  // Refresh token
1627
- api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
1625
+ api[3](api[0], { appId, token: api[4] }).then((data) => {
1628
1626
  if (data == null) {
1629
1627
  // Failed, try it again in 2 seconds
1630
1628
  api[2] = 2;
@@ -85,10 +85,6 @@ export interface RefreshTokenProps {
85
85
  * Refresh token
86
86
  */
87
87
  token?: string;
88
- /**
89
- * Time zone
90
- */
91
- timeZone: string;
92
88
  /**
93
89
  * API URL
94
90
  */
@@ -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
@@ -1,8 +1,8 @@
1
- import { TokenRQ } from "./TokenRQ";
1
+ import { TokenInputRQ } from "./TokenRQ";
2
2
  /**
3
3
  * API Refresh Token Request data
4
4
  */
5
- export type ApiRefreshTokenRQ = TokenRQ & {
5
+ export type ApiRefreshTokenRQ = TokenInputRQ & {
6
6
  /**
7
7
  * Application ID, 0 for core system
8
8
  */
@@ -1,11 +1,16 @@
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
+ };
10
+ /**
11
+ * Token request data
12
+ */
13
+ export type TokenRQ = TokenInputRQ & {
9
14
  /**
10
15
  * Time zone
11
16
  */
@@ -174,7 +174,7 @@ export class CoreApp {
174
174
  const refresh = async (api, rq) => {
175
175
  if (this.lastCalled) {
176
176
  // Call refreshToken to update access token
177
- await this.refreshToken({ token: rq.token, timeZone: rq.timeZone, showLoading: false }, (result) => {
177
+ await this.refreshToken({ token: rq.token, showLoading: false }, (result) => {
178
178
  if (result === true)
179
179
  return;
180
180
  console.log(`CoreApp.${this.name}.RefreshToken`, result);
@@ -1417,7 +1417,7 @@ export class CoreApp {
1417
1417
  */
1418
1418
  async refreshToken(props, callback) {
1419
1419
  // Check props
1420
- props ?? (props = { timeZone: this.getTimeZone() });
1420
+ props ?? (props = {});
1421
1421
  props.token ?? (props.token = this.getCacheToken());
1422
1422
  // Call refresh token API
1423
1423
  let data = await this.createAuthApi().refreshToken(props);
@@ -1516,7 +1516,7 @@ export class CoreApp {
1516
1516
  throw new Error("System API is not allowed to exchange token");
1517
1517
  }
1518
1518
  // Call the API quietly, no loading bar and no error popup
1519
- const data = await this.createAuthApi().exchangeToken({ token, timeZone: this.getTimeZone() }, {
1519
+ const data = await this.createAuthApi().exchangeToken({ token }, {
1520
1520
  showLoading: false,
1521
1521
  onError: (error) => {
1522
1522
  console.error(`CoreApp.${api.name}.ExchangeToken error`, error);
@@ -1607,8 +1607,6 @@ export class CoreApp {
1607
1607
  return;
1608
1608
  // App id
1609
1609
  const appId = this.settings.appId;
1610
- // Timezone
1611
- const timeZone = this.getTimeZone();
1612
1610
  // APIs
1613
1611
  for (const name in this.apis) {
1614
1612
  // Get the API
@@ -1621,7 +1619,7 @@ export class CoreApp {
1621
1619
  // Ready to trigger
1622
1620
  if (api[2] === 0) {
1623
1621
  // Refresh token
1624
- api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
1622
+ api[3](api[0], { appId, token: api[4] }).then((data) => {
1625
1623
  if (data == null) {
1626
1624
  // Failed, try it again in 2 seconds
1627
1625
  api[2] = 2;
@@ -85,10 +85,6 @@ export interface RefreshTokenProps {
85
85
  * Refresh token
86
86
  */
87
87
  token?: string;
88
- /**
89
- * Time zone
90
- */
91
- timeZone: string;
92
88
  /**
93
89
  * API URL
94
90
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.97",
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
  /**
@@ -1,9 +1,9 @@
1
- import { TokenRQ } from "./TokenRQ";
1
+ import { TokenInputRQ } from "./TokenRQ";
2
2
 
3
3
  /**
4
4
  * API Refresh Token Request data
5
5
  */
6
- export type ApiRefreshTokenRQ = TokenRQ & {
6
+ export type ApiRefreshTokenRQ = TokenInputRQ & {
7
7
  /**
8
8
  * Application ID, 0 for core system
9
9
  */
@@ -1,12 +1,17 @@
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 & {
10
15
  /**
11
16
  * Time zone
12
17
  */
@@ -352,7 +352,7 @@ export abstract class CoreApp<
352
352
  if (this.lastCalled) {
353
353
  // Call refreshToken to update access token
354
354
  await this.refreshToken(
355
- { token: rq.token, timeZone: rq.timeZone, showLoading: false },
355
+ { token: rq.token, showLoading: false },
356
356
  (result) => {
357
357
  if (result === true) return;
358
358
  console.log(`CoreApp.${this.name}.RefreshToken`, result);
@@ -1938,7 +1938,7 @@ export abstract class CoreApp<
1938
1938
  callback?: (result?: boolean | IActionResult) => boolean | void
1939
1939
  ) {
1940
1940
  // Check props
1941
- props ??= { timeZone: this.getTimeZone() };
1941
+ props ??= {};
1942
1942
  props.token ??= this.getCacheToken();
1943
1943
 
1944
1944
  // Call refresh token API
@@ -2052,7 +2052,7 @@ export abstract class CoreApp<
2052
2052
 
2053
2053
  // Call the API quietly, no loading bar and no error popup
2054
2054
  const data = await this.createAuthApi().exchangeToken(
2055
- { token, timeZone: this.getTimeZone() },
2055
+ { token },
2056
2056
  {
2057
2057
  showLoading: false,
2058
2058
  onError: (error) => {
@@ -2165,9 +2165,6 @@ export abstract class CoreApp<
2165
2165
  // App id
2166
2166
  const appId = this.settings.appId;
2167
2167
 
2168
- // Timezone
2169
- const timeZone = this.getTimeZone();
2170
-
2171
2168
  // APIs
2172
2169
  for (const name in this.apis) {
2173
2170
  // Get the API
@@ -2182,7 +2179,7 @@ export abstract class CoreApp<
2182
2179
  // Ready to trigger
2183
2180
  if (api[2] === 0) {
2184
2181
  // Refresh token
2185
- api[3](api[0], { appId, token: api[4], timeZone }).then((data) => {
2182
+ api[3](api[0], { appId, token: api[4] }).then((data) => {
2186
2183
  if (data == null) {
2187
2184
  // Failed, try it again in 2 seconds
2188
2185
  api[2] = 2;
package/src/app/IApp.ts CHANGED
@@ -114,11 +114,6 @@ export interface RefreshTokenProps {
114
114
  */
115
115
  token?: string;
116
116
 
117
- /**
118
- * Time zone
119
- */
120
- timeZone: string;
121
-
122
117
  /**
123
118
  * API URL
124
119
  */