@etsoo/appscript 1.5.85 → 1.5.86

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,17 @@ 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
+ */
607
+ protected refreshTokenSucceed(user: U, token: string): Promise<void>;
602
608
  /**
603
609
  * Setup callback
604
610
  */
@@ -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,10 @@ 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);
1425
+ // Callback
1426
+ callback?.(true);
1433
1427
  // Exit
1434
1428
  return;
1435
1429
  }
@@ -1462,6 +1456,15 @@ class CoreApp {
1462
1456
  });
1463
1457
  }
1464
1458
  }
1459
+ /**
1460
+ * Refresh token with success
1461
+ * @param user User data
1462
+ * @param token Refresh token
1463
+ */
1464
+ async refreshTokenSucceed(user, token) {
1465
+ // User login
1466
+ this.userLogin(user, token);
1467
+ }
1465
1468
  /**
1466
1469
  * Setup callback
1467
1470
  */
@@ -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,17 @@ 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
+ */
607
+ protected refreshTokenSucceed(user: U, token: string): Promise<void>;
602
608
  /**
603
609
  * Setup callback
604
610
  */
@@ -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,10 @@ 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);
1422
+ // Callback
1423
+ callback?.(true);
1430
1424
  // Exit
1431
1425
  return;
1432
1426
  }
@@ -1459,6 +1453,15 @@ export class CoreApp {
1459
1453
  });
1460
1454
  }
1461
1455
  }
1456
+ /**
1457
+ * Refresh token with success
1458
+ * @param user User data
1459
+ * @param token Refresh token
1460
+ */
1461
+ async refreshTokenSucceed(user, token) {
1462
+ // User login
1463
+ this.userLogin(user, token);
1464
+ }
1462
1465
  /**
1463
1466
  * Setup callback
1464
1467
  */
@@ -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.86",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -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,11 @@ 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);
1939
+ // Further processing
1940
+ await this.refreshTokenSucceed(result.data, token);
1948
1941
 
1949
- // Callback after
1950
- if (callback) {
1951
- await callback(true);
1952
- }
1942
+ // Callback
1943
+ callback?.(true);
1953
1944
 
1954
1945
  // Exit
1955
1946
  return;
@@ -1985,6 +1976,16 @@ export abstract class CoreApp<
1985
1976
  }
1986
1977
  }
1987
1978
 
1979
+ /**
1980
+ * Refresh token with success
1981
+ * @param user User data
1982
+ * @param token Refresh token
1983
+ */
1984
+ protected async refreshTokenSucceed(user: U, token: string) {
1985
+ // User login
1986
+ this.userLogin(user, token);
1987
+ }
1988
+
1988
1989
  /**
1989
1990
  * Setup callback
1990
1991
  */
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
  /**