@etsoo/appscript 1.5.85 → 1.5.87

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.
@@ -594,11 +594,18 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
594
594
  */
595
595
  abstract freshCountdownUI(callback?: () => PromiseLike<unknown>): void;
596
596
  /**
597
- * Refresh token with result
597
+ * Refresh token
598
598
  * @param props Props
599
599
  * @param callback Callback
600
600
  */
601
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [U, string]) => boolean | void | Promise<boolean>): Promise<void>;
601
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
602
+ /**
603
+ * Refresh token with success
604
+ * @param user User data
605
+ * @param token Refresh token
606
+ * @param callback Callback
607
+ */
608
+ protected refreshTokenSucceed(user: U, token: string, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
602
609
  /**
603
610
  * Setup callback
604
611
  */
@@ -1389,7 +1389,7 @@ class CoreApp {
1389
1389
  this.notifier.hideLoading(true);
1390
1390
  }
1391
1391
  /**
1392
- * Refresh token with result
1392
+ * Refresh token
1393
1393
  * @param props Props
1394
1394
  * @param callback Callback
1395
1395
  */
@@ -1420,16 +1420,8 @@ class CoreApp {
1420
1420
  };
1421
1421
  }
1422
1422
  else {
1423
- // Callback first
1424
- if (callback && (await callback([result.data, token])) === false) {
1425
- return;
1426
- }
1427
- // User login
1428
- this.userLogin(result.data, token);
1429
- // Callback after
1430
- if (callback) {
1431
- await callback(true);
1432
- }
1423
+ // Further processing
1424
+ await this.refreshTokenSucceed(result.data, token, callback);
1433
1425
  // Exit
1434
1426
  return;
1435
1427
  }
@@ -1462,6 +1454,18 @@ class CoreApp {
1462
1454
  });
1463
1455
  }
1464
1456
  }
1457
+ /**
1458
+ * Refresh token with success
1459
+ * @param user User data
1460
+ * @param token Refresh token
1461
+ * @param callback Callback
1462
+ */
1463
+ async refreshTokenSucceed(user, token, callback) {
1464
+ // User login
1465
+ this.userLogin(user, token);
1466
+ // Callback
1467
+ callback?.(true);
1468
+ }
1465
1469
  /**
1466
1470
  * Setup callback
1467
1471
  */
@@ -547,12 +547,11 @@ export interface IApp {
547
547
  */
548
548
  pageExit(): void;
549
549
  /**
550
- * Refresh token with result
550
+ * Refresh token
551
551
  * @param props Props
552
552
  * @param callback Callback
553
- * @param api API
554
553
  */
555
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [IUser, string]) => boolean | void): Promise<void>;
554
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
556
555
  /**
557
556
  * Setup Api error handler
558
557
  * @param api Api
@@ -594,11 +594,18 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
594
594
  */
595
595
  abstract freshCountdownUI(callback?: () => PromiseLike<unknown>): void;
596
596
  /**
597
- * Refresh token with result
597
+ * Refresh token
598
598
  * @param props Props
599
599
  * @param callback Callback
600
600
  */
601
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [U, string]) => boolean | void | Promise<boolean>): Promise<void>;
601
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
602
+ /**
603
+ * Refresh token with success
604
+ * @param user User data
605
+ * @param token Refresh token
606
+ * @param callback Callback
607
+ */
608
+ protected refreshTokenSucceed(user: U, token: string, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
602
609
  /**
603
610
  * Setup callback
604
611
  */
@@ -1386,7 +1386,7 @@ export class CoreApp {
1386
1386
  this.notifier.hideLoading(true);
1387
1387
  }
1388
1388
  /**
1389
- * Refresh token with result
1389
+ * Refresh token
1390
1390
  * @param props Props
1391
1391
  * @param callback Callback
1392
1392
  */
@@ -1417,16 +1417,8 @@ export class CoreApp {
1417
1417
  };
1418
1418
  }
1419
1419
  else {
1420
- // Callback first
1421
- if (callback && (await callback([result.data, token])) === false) {
1422
- return;
1423
- }
1424
- // User login
1425
- this.userLogin(result.data, token);
1426
- // Callback after
1427
- if (callback) {
1428
- await callback(true);
1429
- }
1420
+ // Further processing
1421
+ await this.refreshTokenSucceed(result.data, token, callback);
1430
1422
  // Exit
1431
1423
  return;
1432
1424
  }
@@ -1459,6 +1451,18 @@ export class CoreApp {
1459
1451
  });
1460
1452
  }
1461
1453
  }
1454
+ /**
1455
+ * Refresh token with success
1456
+ * @param user User data
1457
+ * @param token Refresh token
1458
+ * @param callback Callback
1459
+ */
1460
+ async refreshTokenSucceed(user, token, callback) {
1461
+ // User login
1462
+ this.userLogin(user, token);
1463
+ // Callback
1464
+ callback?.(true);
1465
+ }
1462
1466
  /**
1463
1467
  * Setup callback
1464
1468
  */
@@ -547,12 +547,11 @@ export interface IApp {
547
547
  */
548
548
  pageExit(): void;
549
549
  /**
550
- * Refresh token with result
550
+ * Refresh token
551
551
  * @param props Props
552
552
  * @param callback Callback
553
- * @param api API
554
553
  */
555
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [IUser, string]) => boolean | void): Promise<void>;
554
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
556
555
  /**
557
556
  * Setup Api error handler
558
557
  * @param api Api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.85",
3
+ "version": "1.5.87",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -71,6 +71,6 @@
71
71
  "jest": "^29.7.0",
72
72
  "jest-environment-jsdom": "^29.7.0",
73
73
  "ts-jest": "^29.2.5",
74
- "typescript": "^5.7.2"
74
+ "typescript": "^5.7.3"
75
75
  }
76
76
  }
@@ -1902,15 +1902,13 @@ export abstract class CoreApp<
1902
1902
  abstract freshCountdownUI(callback?: () => PromiseLike<unknown>): void;
1903
1903
 
1904
1904
  /**
1905
- * Refresh token with result
1905
+ * Refresh token
1906
1906
  * @param props Props
1907
1907
  * @param callback Callback
1908
1908
  */
1909
1909
  async refreshToken(
1910
1910
  props?: RefreshTokenProps,
1911
- callback?: (
1912
- result?: boolean | IActionResult | [U, string]
1913
- ) => boolean | void | Promise<boolean>
1911
+ callback?: (result?: boolean | IActionResult) => boolean | void
1914
1912
  ) {
1915
1913
  // Check props
1916
1914
  props ??= {};
@@ -1938,18 +1936,8 @@ export abstract class CoreApp<
1938
1936
  title: this.get("noData")
1939
1937
  };
1940
1938
  } else {
1941
- // Callback first
1942
- if (callback && (await callback([result.data, token])) === false) {
1943
- return;
1944
- }
1945
-
1946
- // User login
1947
- this.userLogin(result.data, token);
1948
-
1949
- // Callback after
1950
- if (callback) {
1951
- await callback(true);
1952
- }
1939
+ // Further processing
1940
+ await this.refreshTokenSucceed(result.data, token, callback);
1953
1941
 
1954
1942
  // Exit
1955
1943
  return;
@@ -1985,6 +1973,24 @@ export abstract class CoreApp<
1985
1973
  }
1986
1974
  }
1987
1975
 
1976
+ /**
1977
+ * Refresh token with success
1978
+ * @param user User data
1979
+ * @param token Refresh token
1980
+ * @param callback Callback
1981
+ */
1982
+ protected async refreshTokenSucceed(
1983
+ user: U,
1984
+ token: string,
1985
+ callback?: (result?: boolean | IActionResult) => boolean | void
1986
+ ) {
1987
+ // User login
1988
+ this.userLogin(user, token);
1989
+
1990
+ // Callback
1991
+ callback?.(true);
1992
+ }
1993
+
1988
1994
  /**
1989
1995
  * Setup callback
1990
1996
  */
package/src/app/IApp.ts CHANGED
@@ -727,16 +727,13 @@ export interface IApp {
727
727
  pageExit(): void;
728
728
 
729
729
  /**
730
- * Refresh token with result
730
+ * Refresh token
731
731
  * @param props Props
732
732
  * @param callback Callback
733
- * @param api API
734
733
  */
735
734
  refreshToken(
736
735
  props?: RefreshTokenProps,
737
- callback?: (
738
- result?: boolean | IActionResult | [IUser, string]
739
- ) => boolean | void
736
+ callback?: (result?: boolean | IActionResult) => boolean | void
740
737
  ): Promise<void>;
741
738
 
742
739
  /**