@etsoo/appscript 1.5.47 → 1.5.48

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.
@@ -7,7 +7,7 @@ import { InitCallDto } from '../erp/dto/InitCallDto';
7
7
  import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
8
8
  import { IUser } from '../state/User';
9
9
  import { IAppSettings } from './AppSettings';
10
- import { AppLoginParams, FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps } from './IApp';
10
+ import { AppLoginParams, AppTryLoginParams, FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps } from './IApp';
11
11
  import { UserRole } from './UserRole';
12
12
  import { ExternalEndpoint } from './ExternalSettings';
13
13
  import { ApiRefreshTokenDto } from '../erp/dto/ApiRefreshTokenDto';
@@ -626,7 +626,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
626
626
  * UI get involved while refreshToken not intended
627
627
  * @param params Login parameters
628
628
  */
629
- tryLogin(params?: AppLoginParams): Promise<void>;
629
+ tryLogin(params?: AppTryLoginParams): Promise<boolean>;
630
630
  /**
631
631
  * Update embedded status
632
632
  * @param embedded New embedded status
@@ -1614,9 +1614,9 @@ class CoreApp {
1614
1614
  async tryLogin(params) {
1615
1615
  // Check status
1616
1616
  if (this._isTryingLogin)
1617
- return;
1617
+ return false;
1618
1618
  this._isTryingLogin = true;
1619
- this.toLoginPage(params);
1619
+ return true;
1620
1620
  }
1621
1621
  /**
1622
1622
  * Update embedded status
@@ -57,6 +57,19 @@ export type AppLoginParams = DataTypes.SimpleObject & {
57
57
  */
58
58
  showLoading?: boolean;
59
59
  };
60
+ /**
61
+ * App try login parameters
62
+ */
63
+ export type AppTryLoginParams = AppLoginParams & {
64
+ /**
65
+ * Callback on failure
66
+ */
67
+ onFailure?: () => void;
68
+ /**
69
+ * Callback on success
70
+ */
71
+ onSuccess?: () => void;
72
+ };
60
73
  /**
61
74
  * Refresh token props
62
75
  */
@@ -560,7 +573,7 @@ export interface IApp {
560
573
  * UI get involved while refreshToken not intended
561
574
  * @param params Login parameters
562
575
  */
563
- tryLogin(params?: AppLoginParams): Promise<void>;
576
+ tryLogin(params?: AppLoginParams): Promise<boolean>;
564
577
  /**
565
578
  * Update API token and expires
566
579
  * @param name Api name
@@ -7,7 +7,7 @@ import { InitCallDto } from '../erp/dto/InitCallDto';
7
7
  import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
8
8
  import { IUser } from '../state/User';
9
9
  import { IAppSettings } from './AppSettings';
10
- import { AppLoginParams, FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps } from './IApp';
10
+ import { AppLoginParams, AppTryLoginParams, FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps } from './IApp';
11
11
  import { UserRole } from './UserRole';
12
12
  import { ExternalEndpoint } from './ExternalSettings';
13
13
  import { ApiRefreshTokenDto } from '../erp/dto/ApiRefreshTokenDto';
@@ -626,7 +626,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
626
626
  * UI get involved while refreshToken not intended
627
627
  * @param params Login parameters
628
628
  */
629
- tryLogin(params?: AppLoginParams): Promise<void>;
629
+ tryLogin(params?: AppTryLoginParams): Promise<boolean>;
630
630
  /**
631
631
  * Update embedded status
632
632
  * @param embedded New embedded status
@@ -1611,9 +1611,9 @@ export class CoreApp {
1611
1611
  async tryLogin(params) {
1612
1612
  // Check status
1613
1613
  if (this._isTryingLogin)
1614
- return;
1614
+ return false;
1615
1615
  this._isTryingLogin = true;
1616
- this.toLoginPage(params);
1616
+ return true;
1617
1617
  }
1618
1618
  /**
1619
1619
  * Update embedded status
@@ -57,6 +57,19 @@ export type AppLoginParams = DataTypes.SimpleObject & {
57
57
  */
58
58
  showLoading?: boolean;
59
59
  };
60
+ /**
61
+ * App try login parameters
62
+ */
63
+ export type AppTryLoginParams = AppLoginParams & {
64
+ /**
65
+ * Callback on failure
66
+ */
67
+ onFailure?: () => void;
68
+ /**
69
+ * Callback on success
70
+ */
71
+ onSuccess?: () => void;
72
+ };
60
73
  /**
61
74
  * Refresh token props
62
75
  */
@@ -560,7 +573,7 @@ export interface IApp {
560
573
  * UI get involved while refreshToken not intended
561
574
  * @param params Login parameters
562
575
  */
563
- tryLogin(params?: AppLoginParams): Promise<void>;
576
+ tryLogin(params?: AppLoginParams): Promise<boolean>;
564
577
  /**
565
578
  * Update API token and expires
566
579
  * @param name Api name
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.47",
3
+ "version": "1.5.48",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -34,6 +34,7 @@ import { IAppSettings } from './AppSettings';
34
34
  import {
35
35
  appFields,
36
36
  AppLoginParams,
37
+ AppTryLoginParams,
37
38
  FormatResultCustomCallback,
38
39
  IApp,
39
40
  IAppFields,
@@ -2199,12 +2200,12 @@ export abstract class CoreApp<
2199
2200
  * UI get involved while refreshToken not intended
2200
2201
  * @param params Login parameters
2201
2202
  */
2202
- async tryLogin(params?: AppLoginParams) {
2203
+ async tryLogin(params?: AppTryLoginParams) {
2203
2204
  // Check status
2204
- if (this._isTryingLogin) return;
2205
+ if (this._isTryingLogin) return false;
2205
2206
  this._isTryingLogin = true;
2206
2207
 
2207
- this.toLoginPage(params);
2208
+ return true;
2208
2209
  }
2209
2210
 
2210
2211
  /**
package/src/app/IApp.ts CHANGED
@@ -83,6 +83,21 @@ export type AppLoginParams = DataTypes.SimpleObject & {
83
83
  showLoading?: boolean;
84
84
  };
85
85
 
86
+ /**
87
+ * App try login parameters
88
+ */
89
+ export type AppTryLoginParams = AppLoginParams & {
90
+ /**
91
+ * Callback on failure
92
+ */
93
+ onFailure?: () => void;
94
+
95
+ /**
96
+ * Callback on success
97
+ */
98
+ onSuccess?: () => void;
99
+ };
100
+
86
101
  /**
87
102
  * Refresh token props
88
103
  */
@@ -757,7 +772,7 @@ export interface IApp {
757
772
  * UI get involved while refreshToken not intended
758
773
  * @param params Login parameters
759
774
  */
760
- tryLogin(params?: AppLoginParams): Promise<void>;
775
+ tryLogin(params?: AppLoginParams): Promise<boolean>;
761
776
 
762
777
  /**
763
778
  * Update API token and expires