@etsoo/appscript 1.2.69 → 1.2.72
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/__tests__/app/CoreApp.ts +7 -2
- package/lib/cjs/app/CoreApp.d.ts +15 -9
- package/lib/mjs/app/CoreApp.d.ts +15 -9
- package/package.json +4 -4
- package/src/app/CoreApp.ts +17 -8
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@etsoo/notificationbase';
|
|
9
9
|
import { ApiAuthorizationScheme, createClient } from '@etsoo/restclient';
|
|
10
10
|
import { DataTypes, DomUtils, Utils, WindowStorage } from '@etsoo/shared';
|
|
11
|
-
import { BusinessUtils } from '../../src';
|
|
11
|
+
import { BusinessUtils, IUser } from '../../src';
|
|
12
12
|
import { AddressUtils } from '../../src/address/AddressUtils';
|
|
13
13
|
import { IAppSettings } from '../../src/app/AppSettings';
|
|
14
14
|
import { CoreApp } from '../../src/app/CoreApp';
|
|
@@ -49,7 +49,12 @@ class NotificationContainerTest extends NotificationContainer<
|
|
|
49
49
|
var container = new NotificationContainerTest((update) => {});
|
|
50
50
|
|
|
51
51
|
// Arrange
|
|
52
|
-
class CoreAppTest extends CoreApp<
|
|
52
|
+
class CoreAppTest extends CoreApp<
|
|
53
|
+
IUser,
|
|
54
|
+
IAppSettings,
|
|
55
|
+
{},
|
|
56
|
+
NotificationCallProps
|
|
57
|
+
> {
|
|
53
58
|
/**
|
|
54
59
|
* Constructor
|
|
55
60
|
* @param settings Settings
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IdLabelDto } from '../dto/IdLabelDto';
|
|
|
7
7
|
import { InitCallDto } from '../dto/InitCallDto';
|
|
8
8
|
import { IActionResult } from '../result/IActionResult';
|
|
9
9
|
import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
|
|
10
|
-
import {
|
|
10
|
+
import { IUser } from '../state/User';
|
|
11
11
|
import { IAppSettings } from './AppSettings';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
13
|
/**
|
|
@@ -56,7 +56,7 @@ export declare type IAppFields = {
|
|
|
56
56
|
/**
|
|
57
57
|
* Core application interface
|
|
58
58
|
*/
|
|
59
|
-
export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallProps> {
|
|
59
|
+
export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends NotificationCallProps> {
|
|
60
60
|
/**
|
|
61
61
|
* Settings
|
|
62
62
|
*/
|
|
@@ -112,7 +112,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
112
112
|
/**
|
|
113
113
|
* User data
|
|
114
114
|
*/
|
|
115
|
-
userData?:
|
|
115
|
+
userData?: U;
|
|
116
116
|
/**
|
|
117
117
|
* Search input element
|
|
118
118
|
*/
|
|
@@ -139,6 +139,12 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
139
139
|
* @param culture New culture definition
|
|
140
140
|
*/
|
|
141
141
|
changeCulture(culture: DataTypes.CultureDefinition): void;
|
|
142
|
+
/**
|
|
143
|
+
* Check the action result is about device invalid
|
|
144
|
+
* @param result Action result
|
|
145
|
+
* @returns true means device is invalid
|
|
146
|
+
*/
|
|
147
|
+
checkDeviceResult(result: IActionResult): boolean;
|
|
142
148
|
/**
|
|
143
149
|
* Clear cache data
|
|
144
150
|
*/
|
|
@@ -373,7 +379,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
373
379
|
* @param refreshToken Refresh token
|
|
374
380
|
* @param keep Keep login or not
|
|
375
381
|
*/
|
|
376
|
-
userLogin(user:
|
|
382
|
+
userLogin(user: U, refreshToken: string, keep?: boolean): void;
|
|
377
383
|
/**
|
|
378
384
|
* User logout
|
|
379
385
|
* @param clearToken Clear refresh token or not
|
|
@@ -393,7 +399,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
393
399
|
/**
|
|
394
400
|
* Core application
|
|
395
401
|
*/
|
|
396
|
-
export declare abstract class CoreApp<S extends IAppSettings, N, C extends NotificationCallProps> implements ICoreApp<S, N, C> {
|
|
402
|
+
export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N, C extends NotificationCallProps> implements ICoreApp<U, S, N, C> {
|
|
397
403
|
/**
|
|
398
404
|
* Settings
|
|
399
405
|
*/
|
|
@@ -452,8 +458,8 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
452
458
|
/**
|
|
453
459
|
* User data
|
|
454
460
|
*/
|
|
455
|
-
get userData():
|
|
456
|
-
protected set userData(value:
|
|
461
|
+
get userData(): U | undefined;
|
|
462
|
+
protected set userData(value: U | undefined);
|
|
457
463
|
private ipDetectCallbacks?;
|
|
458
464
|
/**
|
|
459
465
|
* Search input element
|
|
@@ -533,7 +539,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
533
539
|
* @param result Action result
|
|
534
540
|
* @returns true means device is invalid
|
|
535
541
|
*/
|
|
536
|
-
|
|
542
|
+
checkDeviceResult(result: IActionResult): boolean;
|
|
537
543
|
/**
|
|
538
544
|
* Init call
|
|
539
545
|
* @param callback Callback
|
|
@@ -816,7 +822,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
816
822
|
* @param refreshToken Refresh token
|
|
817
823
|
* @param keep Keep login or not
|
|
818
824
|
*/
|
|
819
|
-
userLogin(user:
|
|
825
|
+
userLogin(user: U, refreshToken: string, keep?: boolean): void;
|
|
820
826
|
/**
|
|
821
827
|
* User logout
|
|
822
828
|
* @param clearToken Clear refresh token or not
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IdLabelDto } from '../dto/IdLabelDto';
|
|
|
7
7
|
import { InitCallDto } from '../dto/InitCallDto';
|
|
8
8
|
import { IActionResult } from '../result/IActionResult';
|
|
9
9
|
import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
|
|
10
|
-
import {
|
|
10
|
+
import { IUser } from '../state/User';
|
|
11
11
|
import { IAppSettings } from './AppSettings';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
13
|
/**
|
|
@@ -56,7 +56,7 @@ export declare type IAppFields = {
|
|
|
56
56
|
/**
|
|
57
57
|
* Core application interface
|
|
58
58
|
*/
|
|
59
|
-
export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallProps> {
|
|
59
|
+
export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends NotificationCallProps> {
|
|
60
60
|
/**
|
|
61
61
|
* Settings
|
|
62
62
|
*/
|
|
@@ -112,7 +112,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
112
112
|
/**
|
|
113
113
|
* User data
|
|
114
114
|
*/
|
|
115
|
-
userData?:
|
|
115
|
+
userData?: U;
|
|
116
116
|
/**
|
|
117
117
|
* Search input element
|
|
118
118
|
*/
|
|
@@ -139,6 +139,12 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
139
139
|
* @param culture New culture definition
|
|
140
140
|
*/
|
|
141
141
|
changeCulture(culture: DataTypes.CultureDefinition): void;
|
|
142
|
+
/**
|
|
143
|
+
* Check the action result is about device invalid
|
|
144
|
+
* @param result Action result
|
|
145
|
+
* @returns true means device is invalid
|
|
146
|
+
*/
|
|
147
|
+
checkDeviceResult(result: IActionResult): boolean;
|
|
142
148
|
/**
|
|
143
149
|
* Clear cache data
|
|
144
150
|
*/
|
|
@@ -373,7 +379,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
373
379
|
* @param refreshToken Refresh token
|
|
374
380
|
* @param keep Keep login or not
|
|
375
381
|
*/
|
|
376
|
-
userLogin(user:
|
|
382
|
+
userLogin(user: U, refreshToken: string, keep?: boolean): void;
|
|
377
383
|
/**
|
|
378
384
|
* User logout
|
|
379
385
|
* @param clearToken Clear refresh token or not
|
|
@@ -393,7 +399,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
393
399
|
/**
|
|
394
400
|
* Core application
|
|
395
401
|
*/
|
|
396
|
-
export declare abstract class CoreApp<S extends IAppSettings, N, C extends NotificationCallProps> implements ICoreApp<S, N, C> {
|
|
402
|
+
export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N, C extends NotificationCallProps> implements ICoreApp<U, S, N, C> {
|
|
397
403
|
/**
|
|
398
404
|
* Settings
|
|
399
405
|
*/
|
|
@@ -452,8 +458,8 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
452
458
|
/**
|
|
453
459
|
* User data
|
|
454
460
|
*/
|
|
455
|
-
get userData():
|
|
456
|
-
protected set userData(value:
|
|
461
|
+
get userData(): U | undefined;
|
|
462
|
+
protected set userData(value: U | undefined);
|
|
457
463
|
private ipDetectCallbacks?;
|
|
458
464
|
/**
|
|
459
465
|
* Search input element
|
|
@@ -533,7 +539,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
533
539
|
* @param result Action result
|
|
534
540
|
* @returns true means device is invalid
|
|
535
541
|
*/
|
|
536
|
-
|
|
542
|
+
checkDeviceResult(result: IActionResult): boolean;
|
|
537
543
|
/**
|
|
538
544
|
* Init call
|
|
539
545
|
* @param callback Callback
|
|
@@ -816,7 +822,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
816
822
|
* @param refreshToken Refresh token
|
|
817
823
|
* @param keep Keep login or not
|
|
818
824
|
*/
|
|
819
|
-
userLogin(user:
|
|
825
|
+
userLogin(user: U, refreshToken: string, keep?: boolean): void;
|
|
820
826
|
/**
|
|
821
827
|
* User logout
|
|
822
828
|
* @param clearToken Clear refresh token or not
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.72",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/ETSOO/AppScript#readme",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@etsoo/notificationbase": "^1.1.
|
|
56
|
-
"@etsoo/restclient": "^1.0.
|
|
57
|
-
"@etsoo/shared": "^1.1.
|
|
55
|
+
"@etsoo/notificationbase": "^1.1.5",
|
|
56
|
+
"@etsoo/restclient": "^1.0.70",
|
|
57
|
+
"@etsoo/shared": "^1.1.41",
|
|
58
58
|
"@types/crypto-js": "^4.1.1",
|
|
59
59
|
"crypto-js": "^4.1.1"
|
|
60
60
|
},
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -37,7 +37,7 @@ import { InitCallDto } from '../dto/InitCallDto';
|
|
|
37
37
|
import { ActionResultError } from '../result/ActionResultError';
|
|
38
38
|
import { IActionResult } from '../result/IActionResult';
|
|
39
39
|
import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
|
|
40
|
-
import { IUserData } from '../state/User';
|
|
40
|
+
import { IUser, IUserData } from '../state/User';
|
|
41
41
|
import { IAppSettings } from './AppSettings';
|
|
42
42
|
import { UserRole } from './UserRole';
|
|
43
43
|
|
|
@@ -104,6 +104,7 @@ export type IAppFields = { [key in typeof appFields[number]]: string };
|
|
|
104
104
|
* Core application interface
|
|
105
105
|
*/
|
|
106
106
|
export interface ICoreApp<
|
|
107
|
+
U extends IUser,
|
|
107
108
|
S extends IAppSettings,
|
|
108
109
|
N,
|
|
109
110
|
C extends NotificationCallProps
|
|
@@ -176,7 +177,7 @@ export interface ICoreApp<
|
|
|
176
177
|
/**
|
|
177
178
|
* User data
|
|
178
179
|
*/
|
|
179
|
-
userData?:
|
|
180
|
+
userData?: U;
|
|
180
181
|
|
|
181
182
|
/**
|
|
182
183
|
* Search input element
|
|
@@ -212,6 +213,13 @@ export interface ICoreApp<
|
|
|
212
213
|
*/
|
|
213
214
|
changeCulture(culture: DataTypes.CultureDefinition): void;
|
|
214
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Check the action result is about device invalid
|
|
218
|
+
* @param result Action result
|
|
219
|
+
* @returns true means device is invalid
|
|
220
|
+
*/
|
|
221
|
+
checkDeviceResult(result: IActionResult): boolean;
|
|
222
|
+
|
|
215
223
|
/**
|
|
216
224
|
* Clear cache data
|
|
217
225
|
*/
|
|
@@ -511,7 +519,7 @@ export interface ICoreApp<
|
|
|
511
519
|
* @param refreshToken Refresh token
|
|
512
520
|
* @param keep Keep login or not
|
|
513
521
|
*/
|
|
514
|
-
userLogin(user:
|
|
522
|
+
userLogin(user: U, refreshToken: string, keep?: boolean): void;
|
|
515
523
|
|
|
516
524
|
/**
|
|
517
525
|
* User logout
|
|
@@ -536,10 +544,11 @@ export interface ICoreApp<
|
|
|
536
544
|
* Core application
|
|
537
545
|
*/
|
|
538
546
|
export abstract class CoreApp<
|
|
547
|
+
U extends IUser,
|
|
539
548
|
S extends IAppSettings,
|
|
540
549
|
N,
|
|
541
550
|
C extends NotificationCallProps
|
|
542
|
-
> implements ICoreApp<S, N, C>
|
|
551
|
+
> implements ICoreApp<U, S, N, C>
|
|
543
552
|
{
|
|
544
553
|
/**
|
|
545
554
|
* Settings
|
|
@@ -621,14 +630,14 @@ export abstract class CoreApp<
|
|
|
621
630
|
this._ipData = value;
|
|
622
631
|
}
|
|
623
632
|
|
|
624
|
-
private _userData?:
|
|
633
|
+
private _userData?: U;
|
|
625
634
|
/**
|
|
626
635
|
* User data
|
|
627
636
|
*/
|
|
628
637
|
get userData() {
|
|
629
638
|
return this._userData;
|
|
630
639
|
}
|
|
631
|
-
protected set userData(value:
|
|
640
|
+
protected set userData(value: U | undefined) {
|
|
632
641
|
this._userData = value;
|
|
633
642
|
}
|
|
634
643
|
|
|
@@ -901,7 +910,7 @@ export abstract class CoreApp<
|
|
|
901
910
|
* @param result Action result
|
|
902
911
|
* @returns true means device is invalid
|
|
903
912
|
*/
|
|
904
|
-
|
|
913
|
+
checkDeviceResult(result: IActionResult): boolean {
|
|
905
914
|
if (result.type === 'NoValidData' && result.field === 'Device')
|
|
906
915
|
return true;
|
|
907
916
|
return false;
|
|
@@ -1863,7 +1872,7 @@ export abstract class CoreApp<
|
|
|
1863
1872
|
* @param refreshToken Refresh token
|
|
1864
1873
|
* @param keep Keep login or not
|
|
1865
1874
|
*/
|
|
1866
|
-
userLogin(user:
|
|
1875
|
+
userLogin(user: U, refreshToken: string, keep?: boolean) {
|
|
1867
1876
|
this.userData = user;
|
|
1868
1877
|
|
|
1869
1878
|
// Cache the encrypted serverside device id
|