@etsoo/appscript 1.5.94 → 1.5.96

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.
@@ -13,7 +13,8 @@ function EnhanceApp<TBase extends DataTypes.MConstructor<TestApp>>(
13
13
 
14
14
  const appClass = EnhanceApp(TestApp);
15
15
  const app = new appClass();
16
- app.changeCulture(app.settings.cultures[0]);
16
+
17
+ await app.changeCulture(app.settings.cultures[0]);
17
18
 
18
19
  test("Test for domain replacement", () => {
19
20
  expect(app.settings.endpoint).toBe("http://localhost:9000/api/");
@@ -104,9 +104,6 @@ export class TestApp extends CoreApp<
104
104
  // Supported regions
105
105
  regions: supportedRegions,
106
106
 
107
- // Browser's time zone
108
- timeZone: Utils.getTimeZone(),
109
-
110
107
  // Current country or region
111
108
  currentRegion: AddressUtils.getRegion(
112
109
  supportedRegions,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ES2020",
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
5
  "moduleResolution": "bundler",
6
6
  "allowJs": false,
7
7
  "skipLibCheck": false,
@@ -8,7 +8,7 @@ import { 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";
11
- import { ResetPasswordRQ } from "./rq/ResetPasswordRQ";
11
+ import { ResetPasswordInputRQ } from "./rq/ResetPasswordRQ";
12
12
  import { SignoutRQ } from "./rq/SignoutRQ";
13
13
  import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
14
14
  import { AuthRequest } from "./rq/AuthRequest";
@@ -91,7 +91,7 @@ export declare class AuthApi extends BaseApi {
91
91
  * @param payload Payload
92
92
  * @returns Result
93
93
  */
94
- resetPassword(rq: ResetPasswordRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
94
+ resetPassword(rq: ResetPasswordInputRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
95
95
  /**
96
96
  * Signout
97
97
  * @param rq Request data
@@ -51,7 +51,8 @@ class AuthApi extends BaseApi_1.BaseApi {
51
51
  const rq = {
52
52
  type,
53
53
  openid: this.app.encrypt(openid),
54
- deviceId: this.app.deviceId
54
+ deviceId: this.app.deviceId,
55
+ region: this.app.region
55
56
  };
56
57
  return this.api.post("Auth/CheckUserIdentifier", rq, payload);
57
58
  }
@@ -164,7 +165,13 @@ class AuthApi extends BaseApi_1.BaseApi {
164
165
  * @returns Result
165
166
  */
166
167
  resetPassword(rq, payload) {
167
- return this.api.put("Auth/ResetPassword", rq, payload);
168
+ const data = {
169
+ ...rq,
170
+ deviceId: this.app.deviceId,
171
+ region: this.app.region,
172
+ timezone: this.app.getTimeZone()
173
+ };
174
+ return this.api.put("Auth/ResetPassword", data, payload);
168
175
  }
169
176
  /**
170
177
  * Signout
@@ -19,4 +19,9 @@ export type CheckUserIdentifierRQ = {
19
19
  * 设备编号
20
20
  */
21
21
  deviceId: string;
22
+ /**
23
+ * Region
24
+ * 区域
25
+ */
26
+ region: string;
22
27
  };
@@ -9,15 +9,19 @@ export type LoginRQ = LoginIdRQ & {
9
9
  */
10
10
  pwd: string;
11
11
  /**
12
- * Organization
12
+ * Time zone
13
13
  */
14
- org?: number;
14
+ timezone: string;
15
15
  /**
16
- * Time zone
16
+ * Organization
17
17
  */
18
- timezone?: string;
18
+ org?: number;
19
19
  /**
20
20
  * Authorization request data
21
21
  */
22
22
  auth?: AuthRequest;
23
23
  };
24
+ /**
25
+ * Login input request data
26
+ */
27
+ export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
@@ -15,4 +15,12 @@ export type ResetPasswordRQ = {
15
15
  * Country or region
16
16
  */
17
17
  region: string;
18
+ /**
19
+ * Time zone
20
+ */
21
+ timezone: string;
18
22
  };
23
+ /**
24
+ * Reset password input request data
25
+ */
26
+ export type ResetPasswordInputRQ = Pick<ResetPasswordRQ, "id" | "password">;
@@ -18,7 +18,7 @@ export interface IAppSettings extends IExternalSettings {
18
18
  */
19
19
  readonly detectedCulture: string;
20
20
  /**
21
- * Time zone
21
+ * Time zone, set a static value for all clients
22
22
  */
23
23
  timeZone?: string;
24
24
  /**
@@ -543,7 +543,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
543
543
  * Get time zone
544
544
  * @returns Time zone
545
545
  */
546
- getTimeZone(): string | undefined;
546
+ getTimeZone(): string;
547
547
  /**
548
548
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
549
549
  * https://cryptojs.gitbook.io/docs/
@@ -1021,8 +1021,8 @@ class CoreApp {
1021
1021
  * @returns string
1022
1022
  */
1023
1023
  formatDate(input, options, timeZone) {
1024
- const { currentCulture, timeZone: defaultTimeZone } = this.settings;
1025
- timeZone ?? (timeZone = defaultTimeZone);
1024
+ const { currentCulture } = this.settings;
1025
+ timeZone ?? (timeZone = this.getTimeZone());
1026
1026
  return shared_1.DateUtils.format(input, currentCulture.name, options, timeZone);
1027
1027
  }
1028
1028
  /**
@@ -1295,8 +1295,7 @@ class CoreApp {
1295
1295
  * @returns Time zone
1296
1296
  */
1297
1297
  getTimeZone() {
1298
- // settings.timeZone = Utils.getTimeZone()
1299
- return this.settings.timeZone ?? this.ipData?.timezone;
1298
+ return this.settings.timeZone ?? shared_1.Utils.getTimeZone(this.ipData?.timezone);
1300
1299
  }
1301
1300
  /**
1302
1301
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
@@ -489,7 +489,7 @@ export interface IApp {
489
489
  * Get time zone
490
490
  * @returns Time zone
491
491
  */
492
- getTimeZone(): string | undefined;
492
+ getTimeZone(): string;
493
493
  /**
494
494
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
495
495
  * https://cryptojs.gitbook.io/docs/
@@ -8,7 +8,7 @@ import { 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";
11
- import { ResetPasswordRQ } from "./rq/ResetPasswordRQ";
11
+ import { ResetPasswordInputRQ } from "./rq/ResetPasswordRQ";
12
12
  import { SignoutRQ } from "./rq/SignoutRQ";
13
13
  import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
14
14
  import { AuthRequest } from "./rq/AuthRequest";
@@ -91,7 +91,7 @@ export declare class AuthApi extends BaseApi {
91
91
  * @param payload Payload
92
92
  * @returns Result
93
93
  */
94
- resetPassword(rq: ResetPasswordRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
94
+ resetPassword(rq: ResetPasswordInputRQ, payload?: ResultPayload): Promise<IActionResult<{}> | undefined>;
95
95
  /**
96
96
  * Signout
97
97
  * @param rq Request data
@@ -48,7 +48,8 @@ export class AuthApi extends BaseApi {
48
48
  const rq = {
49
49
  type,
50
50
  openid: this.app.encrypt(openid),
51
- deviceId: this.app.deviceId
51
+ deviceId: this.app.deviceId,
52
+ region: this.app.region
52
53
  };
53
54
  return this.api.post("Auth/CheckUserIdentifier", rq, payload);
54
55
  }
@@ -161,7 +162,13 @@ export class AuthApi extends BaseApi {
161
162
  * @returns Result
162
163
  */
163
164
  resetPassword(rq, payload) {
164
- return this.api.put("Auth/ResetPassword", rq, payload);
165
+ const data = {
166
+ ...rq,
167
+ deviceId: this.app.deviceId,
168
+ region: this.app.region,
169
+ timezone: this.app.getTimeZone()
170
+ };
171
+ return this.api.put("Auth/ResetPassword", data, payload);
165
172
  }
166
173
  /**
167
174
  * Signout
@@ -19,4 +19,9 @@ export type CheckUserIdentifierRQ = {
19
19
  * 设备编号
20
20
  */
21
21
  deviceId: string;
22
+ /**
23
+ * Region
24
+ * 区域
25
+ */
26
+ region: string;
22
27
  };
@@ -9,15 +9,19 @@ export type LoginRQ = LoginIdRQ & {
9
9
  */
10
10
  pwd: string;
11
11
  /**
12
- * Organization
12
+ * Time zone
13
13
  */
14
- org?: number;
14
+ timezone: string;
15
15
  /**
16
- * Time zone
16
+ * Organization
17
17
  */
18
- timezone?: string;
18
+ org?: number;
19
19
  /**
20
20
  * Authorization request data
21
21
  */
22
22
  auth?: AuthRequest;
23
23
  };
24
+ /**
25
+ * Login input request data
26
+ */
27
+ export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
@@ -15,4 +15,12 @@ export type ResetPasswordRQ = {
15
15
  * Country or region
16
16
  */
17
17
  region: string;
18
+ /**
19
+ * Time zone
20
+ */
21
+ timezone: string;
18
22
  };
23
+ /**
24
+ * Reset password input request data
25
+ */
26
+ export type ResetPasswordInputRQ = Pick<ResetPasswordRQ, "id" | "password">;
@@ -18,7 +18,7 @@ export interface IAppSettings extends IExternalSettings {
18
18
  */
19
19
  readonly detectedCulture: string;
20
20
  /**
21
- * Time zone
21
+ * Time zone, set a static value for all clients
22
22
  */
23
23
  timeZone?: string;
24
24
  /**
@@ -543,7 +543,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
543
543
  * Get time zone
544
544
  * @returns Time zone
545
545
  */
546
- getTimeZone(): string | undefined;
546
+ getTimeZone(): string;
547
547
  /**
548
548
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
549
549
  * https://cryptojs.gitbook.io/docs/
@@ -1018,8 +1018,8 @@ export class CoreApp {
1018
1018
  * @returns string
1019
1019
  */
1020
1020
  formatDate(input, options, timeZone) {
1021
- const { currentCulture, timeZone: defaultTimeZone } = this.settings;
1022
- timeZone ?? (timeZone = defaultTimeZone);
1021
+ const { currentCulture } = this.settings;
1022
+ timeZone ?? (timeZone = this.getTimeZone());
1023
1023
  return DateUtils.format(input, currentCulture.name, options, timeZone);
1024
1024
  }
1025
1025
  /**
@@ -1292,8 +1292,7 @@ export class CoreApp {
1292
1292
  * @returns Time zone
1293
1293
  */
1294
1294
  getTimeZone() {
1295
- // settings.timeZone = Utils.getTimeZone()
1296
- return this.settings.timeZone ?? this.ipData?.timezone;
1295
+ return this.settings.timeZone ?? Utils.getTimeZone(this.ipData?.timezone);
1297
1296
  }
1298
1297
  /**
1299
1298
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
@@ -489,7 +489,7 @@ export interface IApp {
489
489
  * Get time zone
490
490
  * @returns Time zone
491
491
  */
492
- getTimeZone(): string | undefined;
492
+ getTimeZone(): string;
493
493
  /**
494
494
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
495
495
  * https://cryptojs.gitbook.io/docs/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.94",
3
+ "version": "1.5.96",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -35,17 +35,17 @@
35
35
  },
36
36
  "homepage": "https://github.com/ETSOO/AppScript#readme",
37
37
  "dependencies": {
38
- "@etsoo/notificationbase": "^1.1.57",
39
- "@etsoo/restclient": "^1.1.21",
40
- "@etsoo/shared": "^1.2.59",
38
+ "@etsoo/notificationbase": "^1.1.58",
39
+ "@etsoo/restclient": "^1.1.23",
40
+ "@etsoo/shared": "^1.2.60",
41
41
  "crypto-js": "^4.2.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@babel/cli": "^7.26.4",
45
- "@babel/core": "^7.26.0",
45
+ "@babel/core": "^7.26.7",
46
46
  "@babel/plugin-transform-runtime": "^7.25.9",
47
- "@babel/preset-env": "^7.26.0",
48
- "@babel/runtime-corejs3": "^7.26.0",
47
+ "@babel/preset-env": "^7.26.7",
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",
@@ -10,7 +10,7 @@ import { GetLogInUrlRQ } from "./rq/GetLogInUrlRQ";
10
10
  import { LoginRQ } from "./rq/LoginRQ";
11
11
  import { LoginIdRQ } from "./rq/LoginIdRQ";
12
12
  import { RefreshTokenRQ } from "./rq/RefreshTokenRQ";
13
- import { ResetPasswordRQ } from "./rq/ResetPasswordRQ";
13
+ import { ResetPasswordInputRQ, ResetPasswordRQ } from "./rq/ResetPasswordRQ";
14
14
  import { SignoutRQ } from "./rq/SignoutRQ";
15
15
  import { SwitchOrgRQ } from "./rq/SwitchOrgRQ";
16
16
  import { AuthRequest } from "./rq/AuthRequest";
@@ -81,7 +81,8 @@ export class AuthApi extends BaseApi {
81
81
  const rq: CheckUserIdentifierRQ = {
82
82
  type,
83
83
  openid: this.app.encrypt(openid),
84
- deviceId: this.app.deviceId
84
+ deviceId: this.app.deviceId,
85
+ region: this.app.region
85
86
  };
86
87
  return this.api.post("Auth/CheckUserIdentifier", rq, payload);
87
88
  }
@@ -222,8 +223,14 @@ export class AuthApi extends BaseApi {
222
223
  * @param payload Payload
223
224
  * @returns Result
224
225
  */
225
- resetPassword(rq: ResetPasswordRQ, payload?: ResultPayload) {
226
- return this.api.put("Auth/ResetPassword", rq, payload);
226
+ resetPassword(rq: ResetPasswordInputRQ, payload?: ResultPayload) {
227
+ const data: ResetPasswordRQ = {
228
+ ...rq,
229
+ deviceId: this.app.deviceId,
230
+ region: this.app.region,
231
+ timezone: this.app.getTimeZone()
232
+ };
233
+ return this.api.put("Auth/ResetPassword", data, payload);
227
234
  }
228
235
 
229
236
  /**
@@ -22,4 +22,10 @@ export type CheckUserIdentifierRQ = {
22
22
  * 设备编号
23
23
  */
24
24
  deviceId: string;
25
+
26
+ /**
27
+ * Region
28
+ * 区域
29
+ */
30
+ region: string;
25
31
  };
@@ -11,17 +11,22 @@ export type LoginRQ = LoginIdRQ & {
11
11
  pwd: string;
12
12
 
13
13
  /**
14
- * Organization
14
+ * Time zone
15
15
  */
16
- org?: number;
16
+ timezone: string;
17
17
 
18
18
  /**
19
- * Time zone
19
+ * Organization
20
20
  */
21
- timezone?: string;
21
+ org?: number;
22
22
 
23
23
  /**
24
24
  * Authorization request data
25
25
  */
26
26
  auth?: AuthRequest;
27
27
  };
28
+
29
+ /**
30
+ * Login input request data
31
+ */
32
+ export type LoginInputRQ = Pick<LoginRQ, "id" | "pwd" | "org" | "auth">;
@@ -18,4 +18,14 @@ export type ResetPasswordRQ = {
18
18
  * Country or region
19
19
  */
20
20
  region: string;
21
+
22
+ /**
23
+ * Time zone
24
+ */
25
+ timezone: string;
21
26
  };
27
+
28
+ /**
29
+ * Reset password input request data
30
+ */
31
+ export type ResetPasswordInputRQ = Pick<ResetPasswordRQ, "id" | "password">;
@@ -22,7 +22,7 @@ export interface IAppSettings extends IExternalSettings {
22
22
  readonly detectedCulture: string;
23
23
 
24
24
  /**
25
- * Time zone
25
+ * Time zone, set a static value for all clients
26
26
  */
27
27
  timeZone?: string;
28
28
 
@@ -1473,8 +1473,8 @@ export abstract class CoreApp<
1473
1473
  options?: DateUtils.FormatOptions,
1474
1474
  timeZone?: string
1475
1475
  ) {
1476
- const { currentCulture, timeZone: defaultTimeZone } = this.settings;
1477
- timeZone ??= defaultTimeZone;
1476
+ const { currentCulture } = this.settings;
1477
+ timeZone ??= this.getTimeZone();
1478
1478
  return DateUtils.format(input, currentCulture.name, options, timeZone);
1479
1479
  }
1480
1480
 
@@ -1796,9 +1796,8 @@ export abstract class CoreApp<
1796
1796
  * Get time zone
1797
1797
  * @returns Time zone
1798
1798
  */
1799
- getTimeZone(): string | undefined {
1800
- // settings.timeZone = Utils.getTimeZone()
1801
- return this.settings.timeZone ?? this.ipData?.timezone;
1799
+ getTimeZone() {
1800
+ return this.settings.timeZone ?? Utils.getTimeZone(this.ipData?.timezone);
1802
1801
  }
1803
1802
 
1804
1803
  /**
package/src/app/IApp.ts CHANGED
@@ -649,7 +649,7 @@ export interface IApp {
649
649
  * Get time zone
650
650
  * @returns Time zone
651
651
  */
652
- getTimeZone(): string | undefined;
652
+ getTimeZone(): string;
653
653
 
654
654
  /**
655
655
  * Hash message, SHA3 or HmacSHA512, 512 as Base64