@etsoo/appscript 1.5.41 → 1.5.42
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.
- package/lib/cjs/app/CoreApp.d.ts +10 -6
- package/lib/cjs/app/CoreApp.js +20 -7
- package/lib/cjs/app/IApp.d.ts +25 -5
- package/lib/mjs/app/CoreApp.d.ts +10 -6
- package/lib/mjs/app/CoreApp.js +20 -7
- package/lib/mjs/app/IApp.d.ts +25 -5
- package/package.json +1 -1
- package/src/app/CoreApp.ts +24 -7
- package/src/app/IApp.ts +29 -5
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -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 { FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
10
|
+
import { AppLoginParams, FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
11
11
|
import { UserRole } from './UserRole';
|
|
12
12
|
import { ExternalEndpoint } from './ExternalSettings';
|
|
13
13
|
import { ApiRefreshTokenDto } from '../erp/dto/ApiRefreshTokenDto';
|
|
@@ -135,6 +135,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
135
135
|
*/
|
|
136
136
|
get embedded(): boolean;
|
|
137
137
|
private _isTryingLogin;
|
|
138
|
+
/**
|
|
139
|
+
* Is trying login
|
|
140
|
+
*/
|
|
141
|
+
get isTryingLogin(): boolean;
|
|
142
|
+
protected set isTryingLogin(value: boolean);
|
|
138
143
|
/**
|
|
139
144
|
* Last called with token refresh
|
|
140
145
|
*/
|
|
@@ -630,16 +635,15 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
630
635
|
signout(): Promise<void>;
|
|
631
636
|
/**
|
|
632
637
|
* Go to the login page
|
|
633
|
-
*
|
|
634
|
-
* @param removeUrl Remove current URL for reuse
|
|
638
|
+
* params Login parameters
|
|
635
639
|
*/
|
|
636
|
-
toLoginPage(
|
|
640
|
+
toLoginPage(params?: AppLoginParams): void;
|
|
637
641
|
/**
|
|
638
642
|
* Try login, returning false means is loading
|
|
639
643
|
* UI get involved while refreshToken not intended
|
|
640
|
-
* @param
|
|
644
|
+
* @param params Login parameters
|
|
641
645
|
*/
|
|
642
|
-
tryLogin(
|
|
646
|
+
tryLogin(params?: AppLoginParams): Promise<boolean>;
|
|
643
647
|
/**
|
|
644
648
|
* Update embedded status
|
|
645
649
|
* @param embedded New embedded status
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -102,6 +102,15 @@ class CoreApp {
|
|
|
102
102
|
get embedded() {
|
|
103
103
|
return this._embedded;
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Is trying login
|
|
107
|
+
*/
|
|
108
|
+
get isTryingLogin() {
|
|
109
|
+
return this._isTryingLogin;
|
|
110
|
+
}
|
|
111
|
+
set isTryingLogin(value) {
|
|
112
|
+
this._isTryingLogin = value;
|
|
113
|
+
}
|
|
105
114
|
/**
|
|
106
115
|
* Get persisted fields
|
|
107
116
|
*/
|
|
@@ -1579,28 +1588,32 @@ class CoreApp {
|
|
|
1579
1588
|
// Clear, noTrigger = true, avoid state update
|
|
1580
1589
|
this.userLogout(true, true);
|
|
1581
1590
|
// Go to login page
|
|
1582
|
-
this.toLoginPage(false, true);
|
|
1591
|
+
this.toLoginPage({ tryLogin: false, removeUrl: true });
|
|
1583
1592
|
}
|
|
1584
1593
|
/**
|
|
1585
1594
|
* Go to the login page
|
|
1586
|
-
*
|
|
1587
|
-
* @param removeUrl Remove current URL for reuse
|
|
1595
|
+
* params Login parameters
|
|
1588
1596
|
*/
|
|
1589
|
-
toLoginPage(
|
|
1597
|
+
toLoginPage(params) {
|
|
1598
|
+
// Destruct
|
|
1599
|
+
const { removeUrl, showLoading, ...rest } = params ?? {};
|
|
1590
1600
|
// Save the current URL
|
|
1591
1601
|
this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
|
|
1592
|
-
|
|
1602
|
+
// URL with parameters
|
|
1603
|
+
const url = '/'.addUrlParams(rest);
|
|
1593
1604
|
this.navigate(url);
|
|
1594
1605
|
}
|
|
1595
1606
|
/**
|
|
1596
1607
|
* Try login, returning false means is loading
|
|
1597
1608
|
* UI get involved while refreshToken not intended
|
|
1598
|
-
* @param
|
|
1609
|
+
* @param params Login parameters
|
|
1599
1610
|
*/
|
|
1600
|
-
async tryLogin(
|
|
1611
|
+
async tryLogin(params) {
|
|
1612
|
+
// Check status
|
|
1601
1613
|
if (this._isTryingLogin)
|
|
1602
1614
|
return false;
|
|
1603
1615
|
this._isTryingLogin = true;
|
|
1616
|
+
this.toLoginPage(params);
|
|
1604
1617
|
return true;
|
|
1605
1618
|
}
|
|
1606
1619
|
/**
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -40,6 +40,23 @@ export type FormatResultCustom = {
|
|
|
40
40
|
* Format result custom callback type
|
|
41
41
|
*/
|
|
42
42
|
export type FormatResultCustomCallback = ((data: FormatResultCustom) => string | null | undefined) | boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Login parameters
|
|
45
|
+
*/
|
|
46
|
+
export type AppLoginParams = DataTypes.SimpleObject & {
|
|
47
|
+
/**
|
|
48
|
+
* Try login with cached refresh token
|
|
49
|
+
*/
|
|
50
|
+
tryLogin?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Don't cache current URL instead of the default page
|
|
53
|
+
*/
|
|
54
|
+
removeUrl?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Show loading bar or not
|
|
57
|
+
*/
|
|
58
|
+
showLoading?: boolean;
|
|
59
|
+
};
|
|
43
60
|
/**
|
|
44
61
|
* Refresh token props
|
|
45
62
|
*/
|
|
@@ -123,6 +140,10 @@ export interface IApp {
|
|
|
123
140
|
* Is the app ready
|
|
124
141
|
*/
|
|
125
142
|
readonly isReady: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Is trying to login
|
|
145
|
+
*/
|
|
146
|
+
readonly isTryingLogin: boolean;
|
|
126
147
|
/**
|
|
127
148
|
* Application name
|
|
128
149
|
*/
|
|
@@ -538,16 +559,15 @@ export interface IApp {
|
|
|
538
559
|
persist(): void;
|
|
539
560
|
/**
|
|
540
561
|
* Go to the login page
|
|
541
|
-
* @param
|
|
542
|
-
* @param removeUrl Remove current URL for reuse
|
|
562
|
+
* @param params Login parameters
|
|
543
563
|
*/
|
|
544
|
-
toLoginPage(
|
|
564
|
+
toLoginPage(params?: AppLoginParams): void;
|
|
545
565
|
/**
|
|
546
566
|
* Try login, returning false means is loading
|
|
547
567
|
* UI get involved while refreshToken not intended
|
|
548
|
-
* @param
|
|
568
|
+
* @param params Login parameters
|
|
549
569
|
*/
|
|
550
|
-
tryLogin(
|
|
570
|
+
tryLogin(params?: AppLoginParams): Promise<boolean>;
|
|
551
571
|
/**
|
|
552
572
|
* Update API token and expires
|
|
553
573
|
* @param name Api name
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -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 { FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
10
|
+
import { AppLoginParams, FormatResultCustomCallback, IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
11
11
|
import { UserRole } from './UserRole';
|
|
12
12
|
import { ExternalEndpoint } from './ExternalSettings';
|
|
13
13
|
import { ApiRefreshTokenDto } from '../erp/dto/ApiRefreshTokenDto';
|
|
@@ -135,6 +135,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
135
135
|
*/
|
|
136
136
|
get embedded(): boolean;
|
|
137
137
|
private _isTryingLogin;
|
|
138
|
+
/**
|
|
139
|
+
* Is trying login
|
|
140
|
+
*/
|
|
141
|
+
get isTryingLogin(): boolean;
|
|
142
|
+
protected set isTryingLogin(value: boolean);
|
|
138
143
|
/**
|
|
139
144
|
* Last called with token refresh
|
|
140
145
|
*/
|
|
@@ -630,16 +635,15 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
630
635
|
signout(): Promise<void>;
|
|
631
636
|
/**
|
|
632
637
|
* Go to the login page
|
|
633
|
-
*
|
|
634
|
-
* @param removeUrl Remove current URL for reuse
|
|
638
|
+
* params Login parameters
|
|
635
639
|
*/
|
|
636
|
-
toLoginPage(
|
|
640
|
+
toLoginPage(params?: AppLoginParams): void;
|
|
637
641
|
/**
|
|
638
642
|
* Try login, returning false means is loading
|
|
639
643
|
* UI get involved while refreshToken not intended
|
|
640
|
-
* @param
|
|
644
|
+
* @param params Login parameters
|
|
641
645
|
*/
|
|
642
|
-
tryLogin(
|
|
646
|
+
tryLogin(params?: AppLoginParams): Promise<boolean>;
|
|
643
647
|
/**
|
|
644
648
|
* Update embedded status
|
|
645
649
|
* @param embedded New embedded status
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -99,6 +99,15 @@ export class CoreApp {
|
|
|
99
99
|
get embedded() {
|
|
100
100
|
return this._embedded;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Is trying login
|
|
104
|
+
*/
|
|
105
|
+
get isTryingLogin() {
|
|
106
|
+
return this._isTryingLogin;
|
|
107
|
+
}
|
|
108
|
+
set isTryingLogin(value) {
|
|
109
|
+
this._isTryingLogin = value;
|
|
110
|
+
}
|
|
102
111
|
/**
|
|
103
112
|
* Get persisted fields
|
|
104
113
|
*/
|
|
@@ -1576,28 +1585,32 @@ export class CoreApp {
|
|
|
1576
1585
|
// Clear, noTrigger = true, avoid state update
|
|
1577
1586
|
this.userLogout(true, true);
|
|
1578
1587
|
// Go to login page
|
|
1579
|
-
this.toLoginPage(false, true);
|
|
1588
|
+
this.toLoginPage({ tryLogin: false, removeUrl: true });
|
|
1580
1589
|
}
|
|
1581
1590
|
/**
|
|
1582
1591
|
* Go to the login page
|
|
1583
|
-
*
|
|
1584
|
-
* @param removeUrl Remove current URL for reuse
|
|
1592
|
+
* params Login parameters
|
|
1585
1593
|
*/
|
|
1586
|
-
toLoginPage(
|
|
1594
|
+
toLoginPage(params) {
|
|
1595
|
+
// Destruct
|
|
1596
|
+
const { removeUrl, showLoading, ...rest } = params ?? {};
|
|
1587
1597
|
// Save the current URL
|
|
1588
1598
|
this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
|
|
1589
|
-
|
|
1599
|
+
// URL with parameters
|
|
1600
|
+
const url = '/'.addUrlParams(rest);
|
|
1590
1601
|
this.navigate(url);
|
|
1591
1602
|
}
|
|
1592
1603
|
/**
|
|
1593
1604
|
* Try login, returning false means is loading
|
|
1594
1605
|
* UI get involved while refreshToken not intended
|
|
1595
|
-
* @param
|
|
1606
|
+
* @param params Login parameters
|
|
1596
1607
|
*/
|
|
1597
|
-
async tryLogin(
|
|
1608
|
+
async tryLogin(params) {
|
|
1609
|
+
// Check status
|
|
1598
1610
|
if (this._isTryingLogin)
|
|
1599
1611
|
return false;
|
|
1600
1612
|
this._isTryingLogin = true;
|
|
1613
|
+
this.toLoginPage(params);
|
|
1601
1614
|
return true;
|
|
1602
1615
|
}
|
|
1603
1616
|
/**
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -40,6 +40,23 @@ export type FormatResultCustom = {
|
|
|
40
40
|
* Format result custom callback type
|
|
41
41
|
*/
|
|
42
42
|
export type FormatResultCustomCallback = ((data: FormatResultCustom) => string | null | undefined) | boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Login parameters
|
|
45
|
+
*/
|
|
46
|
+
export type AppLoginParams = DataTypes.SimpleObject & {
|
|
47
|
+
/**
|
|
48
|
+
* Try login with cached refresh token
|
|
49
|
+
*/
|
|
50
|
+
tryLogin?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Don't cache current URL instead of the default page
|
|
53
|
+
*/
|
|
54
|
+
removeUrl?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Show loading bar or not
|
|
57
|
+
*/
|
|
58
|
+
showLoading?: boolean;
|
|
59
|
+
};
|
|
43
60
|
/**
|
|
44
61
|
* Refresh token props
|
|
45
62
|
*/
|
|
@@ -123,6 +140,10 @@ export interface IApp {
|
|
|
123
140
|
* Is the app ready
|
|
124
141
|
*/
|
|
125
142
|
readonly isReady: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Is trying to login
|
|
145
|
+
*/
|
|
146
|
+
readonly isTryingLogin: boolean;
|
|
126
147
|
/**
|
|
127
148
|
* Application name
|
|
128
149
|
*/
|
|
@@ -538,16 +559,15 @@ export interface IApp {
|
|
|
538
559
|
persist(): void;
|
|
539
560
|
/**
|
|
540
561
|
* Go to the login page
|
|
541
|
-
* @param
|
|
542
|
-
* @param removeUrl Remove current URL for reuse
|
|
562
|
+
* @param params Login parameters
|
|
543
563
|
*/
|
|
544
|
-
toLoginPage(
|
|
564
|
+
toLoginPage(params?: AppLoginParams): void;
|
|
545
565
|
/**
|
|
546
566
|
* Try login, returning false means is loading
|
|
547
567
|
* UI get involved while refreshToken not intended
|
|
548
|
-
* @param
|
|
568
|
+
* @param params Login parameters
|
|
549
569
|
*/
|
|
550
|
-
tryLogin(
|
|
570
|
+
tryLogin(params?: AppLoginParams): Promise<boolean>;
|
|
551
571
|
/**
|
|
552
572
|
* Update API token and expires
|
|
553
573
|
* @param name Api name
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { IUser } from '../state/User';
|
|
|
33
33
|
import { IAppSettings } from './AppSettings';
|
|
34
34
|
import {
|
|
35
35
|
appFields,
|
|
36
|
+
AppLoginParams,
|
|
36
37
|
FormatResultCustomCallback,
|
|
37
38
|
IApp,
|
|
38
39
|
IAppFields,
|
|
@@ -257,6 +258,15 @@ export abstract class CoreApp<
|
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
private _isTryingLogin = false;
|
|
261
|
+
/**
|
|
262
|
+
* Is trying login
|
|
263
|
+
*/
|
|
264
|
+
get isTryingLogin() {
|
|
265
|
+
return this._isTryingLogin;
|
|
266
|
+
}
|
|
267
|
+
protected set isTryingLogin(value: boolean) {
|
|
268
|
+
this._isTryingLogin = value;
|
|
269
|
+
}
|
|
260
270
|
|
|
261
271
|
/**
|
|
262
272
|
* Last called with token refresh
|
|
@@ -2166,19 +2176,22 @@ export abstract class CoreApp<
|
|
|
2166
2176
|
this.userLogout(true, true);
|
|
2167
2177
|
|
|
2168
2178
|
// Go to login page
|
|
2169
|
-
this.toLoginPage(false, true);
|
|
2179
|
+
this.toLoginPage({ tryLogin: false, removeUrl: true });
|
|
2170
2180
|
}
|
|
2171
2181
|
|
|
2172
2182
|
/**
|
|
2173
2183
|
* Go to the login page
|
|
2174
|
-
*
|
|
2175
|
-
* @param removeUrl Remove current URL for reuse
|
|
2184
|
+
* params Login parameters
|
|
2176
2185
|
*/
|
|
2177
|
-
toLoginPage(
|
|
2186
|
+
toLoginPage(params?: AppLoginParams) {
|
|
2187
|
+
// Destruct
|
|
2188
|
+
const { removeUrl, showLoading, ...rest } = params ?? {};
|
|
2189
|
+
|
|
2178
2190
|
// Save the current URL
|
|
2179
2191
|
this.cachedUrl = removeUrl ? undefined : globalThis.location.href;
|
|
2180
2192
|
|
|
2181
|
-
|
|
2193
|
+
// URL with parameters
|
|
2194
|
+
const url = '/'.addUrlParams(rest);
|
|
2182
2195
|
|
|
2183
2196
|
this.navigate(url);
|
|
2184
2197
|
}
|
|
@@ -2186,11 +2199,15 @@ export abstract class CoreApp<
|
|
|
2186
2199
|
/**
|
|
2187
2200
|
* Try login, returning false means is loading
|
|
2188
2201
|
* UI get involved while refreshToken not intended
|
|
2189
|
-
* @param
|
|
2202
|
+
* @param params Login parameters
|
|
2190
2203
|
*/
|
|
2191
|
-
async tryLogin(
|
|
2204
|
+
async tryLogin(params?: AppLoginParams) {
|
|
2205
|
+
// Check status
|
|
2192
2206
|
if (this._isTryingLogin) return false;
|
|
2193
2207
|
this._isTryingLogin = true;
|
|
2208
|
+
|
|
2209
|
+
this.toLoginPage(params);
|
|
2210
|
+
|
|
2194
2211
|
return true;
|
|
2195
2212
|
}
|
|
2196
2213
|
|
package/src/app/IApp.ts
CHANGED
|
@@ -63,6 +63,26 @@ export type FormatResultCustomCallback =
|
|
|
63
63
|
| ((data: FormatResultCustom) => string | null | undefined)
|
|
64
64
|
| boolean;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Login parameters
|
|
68
|
+
*/
|
|
69
|
+
export type AppLoginParams = DataTypes.SimpleObject & {
|
|
70
|
+
/**
|
|
71
|
+
* Try login with cached refresh token
|
|
72
|
+
*/
|
|
73
|
+
tryLogin?: boolean;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Don't cache current URL instead of the default page
|
|
77
|
+
*/
|
|
78
|
+
removeUrl?: boolean;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Show loading bar or not
|
|
82
|
+
*/
|
|
83
|
+
showLoading?: boolean;
|
|
84
|
+
};
|
|
85
|
+
|
|
66
86
|
/**
|
|
67
87
|
* Refresh token props
|
|
68
88
|
*/
|
|
@@ -170,6 +190,11 @@ export interface IApp {
|
|
|
170
190
|
*/
|
|
171
191
|
readonly isReady: boolean;
|
|
172
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Is trying to login
|
|
195
|
+
*/
|
|
196
|
+
readonly isTryingLogin: boolean;
|
|
197
|
+
|
|
173
198
|
/**
|
|
174
199
|
* Application name
|
|
175
200
|
*/
|
|
@@ -734,17 +759,16 @@ export interface IApp {
|
|
|
734
759
|
|
|
735
760
|
/**
|
|
736
761
|
* Go to the login page
|
|
737
|
-
* @param
|
|
738
|
-
* @param removeUrl Remove current URL for reuse
|
|
762
|
+
* @param params Login parameters
|
|
739
763
|
*/
|
|
740
|
-
toLoginPage(
|
|
764
|
+
toLoginPage(params?: AppLoginParams): void;
|
|
741
765
|
|
|
742
766
|
/**
|
|
743
767
|
* Try login, returning false means is loading
|
|
744
768
|
* UI get involved while refreshToken not intended
|
|
745
|
-
* @param
|
|
769
|
+
* @param params Login parameters
|
|
746
770
|
*/
|
|
747
|
-
tryLogin(
|
|
771
|
+
tryLogin(params?: AppLoginParams): Promise<boolean>;
|
|
748
772
|
|
|
749
773
|
/**
|
|
750
774
|
* Update API token and expires
|