@etsoo/appscript 1.5.84 → 1.5.85

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.
@@ -598,7 +598,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
598
598
  * @param props Props
599
599
  * @param callback Callback
600
600
  */
601
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
601
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [U, string]) => boolean | void | Promise<boolean>): Promise<void>;
602
602
  /**
603
603
  * Setup callback
604
604
  */
@@ -1420,10 +1420,16 @@ class CoreApp {
1420
1420
  };
1421
1421
  }
1422
1422
  else {
1423
+ // Callback first
1424
+ if (callback && (await callback([result.data, token])) === false) {
1425
+ return;
1426
+ }
1423
1427
  // User login
1424
1428
  this.userLogin(result.data, token);
1425
- if (callback)
1426
- callback(true);
1429
+ // Callback after
1430
+ if (callback) {
1431
+ await callback(true);
1432
+ }
1427
1433
  // Exit
1428
1434
  return;
1429
1435
  }
@@ -552,7 +552,7 @@ export interface IApp {
552
552
  * @param callback Callback
553
553
  * @param api API
554
554
  */
555
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
555
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [IUser, string]) => boolean | void): Promise<void>;
556
556
  /**
557
557
  * Setup Api error handler
558
558
  * @param api Api
@@ -598,7 +598,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
598
598
  * @param props Props
599
599
  * @param callback Callback
600
600
  */
601
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
601
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [U, string]) => boolean | void | Promise<boolean>): Promise<void>;
602
602
  /**
603
603
  * Setup callback
604
604
  */
@@ -1417,10 +1417,16 @@ 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
+ }
1420
1424
  // User login
1421
1425
  this.userLogin(result.data, token);
1422
- if (callback)
1423
- callback(true);
1426
+ // Callback after
1427
+ if (callback) {
1428
+ await callback(true);
1429
+ }
1424
1430
  // Exit
1425
1431
  return;
1426
1432
  }
@@ -552,7 +552,7 @@ export interface IApp {
552
552
  * @param callback Callback
553
553
  * @param api API
554
554
  */
555
- refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult) => boolean | void): Promise<void>;
555
+ refreshToken(props?: RefreshTokenProps, callback?: (result?: boolean | IActionResult | [IUser, string]) => boolean | void): Promise<void>;
556
556
  /**
557
557
  * Setup Api error handler
558
558
  * @param api Api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.84",
3
+ "version": "1.5.85",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -1908,7 +1908,9 @@ export abstract class CoreApp<
1908
1908
  */
1909
1909
  async refreshToken(
1910
1910
  props?: RefreshTokenProps,
1911
- callback?: (result?: boolean | IActionResult) => boolean | void
1911
+ callback?: (
1912
+ result?: boolean | IActionResult | [U, string]
1913
+ ) => boolean | void | Promise<boolean>
1912
1914
  ) {
1913
1915
  // Check props
1914
1916
  props ??= {};
@@ -1936,10 +1938,18 @@ export abstract class CoreApp<
1936
1938
  title: this.get("noData")
1937
1939
  };
1938
1940
  } else {
1941
+ // Callback first
1942
+ if (callback && (await callback([result.data, token])) === false) {
1943
+ return;
1944
+ }
1945
+
1939
1946
  // User login
1940
1947
  this.userLogin(result.data, token);
1941
1948
 
1942
- if (callback) callback(true);
1949
+ // Callback after
1950
+ if (callback) {
1951
+ await callback(true);
1952
+ }
1943
1953
 
1944
1954
  // Exit
1945
1955
  return;
package/src/app/IApp.ts CHANGED
@@ -734,7 +734,9 @@ export interface IApp {
734
734
  */
735
735
  refreshToken(
736
736
  props?: RefreshTokenProps,
737
- callback?: (result?: boolean | IActionResult) => boolean | void
737
+ callback?: (
738
+ result?: boolean | IActionResult | [IUser, string]
739
+ ) => boolean | void
738
740
  ): Promise<void>;
739
741
 
740
742
  /**