@etsoo/appscript 1.4.33 → 1.4.35
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 +8 -0
- package/lib/cjs/app/CoreApp.js +15 -0
- package/lib/cjs/app/IApp.d.ts +12 -0
- package/lib/cjs/app/IAppApi.d.ts +24 -0
- package/lib/cjs/app/IAppApi.js +2 -0
- package/lib/cjs/def/ListItem.d.ts +2 -2
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/mjs/app/CoreApp.d.ts +8 -0
- package/lib/mjs/app/CoreApp.js +15 -0
- package/lib/mjs/app/IApp.d.ts +12 -0
- package/lib/mjs/app/IAppApi.d.ts +24 -0
- package/lib/mjs/app/IAppApi.js +1 -0
- package/lib/mjs/def/ListItem.d.ts +2 -2
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.js +1 -0
- package/package.json +2 -2
- package/src/app/CoreApp.ts +21 -0
- package/src/app/IApp.ts +18 -0
- package/src/app/IAppApi.ts +28 -0
- package/src/def/ListItem.ts +2 -2
- package/src/index.ts +1 -0
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { IUser } from '../state/User';
|
|
|
10
10
|
import { IAppSettings } from './AppSettings';
|
|
11
11
|
import { IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
|
+
import { IAppApi } from './IAppApi';
|
|
13
14
|
/**
|
|
14
15
|
* Core application interface
|
|
15
16
|
*/
|
|
@@ -219,6 +220,13 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
219
220
|
* @param callback Callback
|
|
220
221
|
*/
|
|
221
222
|
alertResult(result: IActionResult | string, callback?: NotificationReturn<void>): void;
|
|
223
|
+
/**
|
|
224
|
+
* Service application API login
|
|
225
|
+
* @param appApi Service application API
|
|
226
|
+
* @param relogin Relogin try
|
|
227
|
+
* @param callback Callback
|
|
228
|
+
*/
|
|
229
|
+
apiLogin(appApi: IAppApi, relogin?: boolean, callback?: (result: RefreshTokenResult, successData?: string) => void): Promise<boolean>;
|
|
222
230
|
/**
|
|
223
231
|
* Authorize
|
|
224
232
|
* @param token New token
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -488,6 +488,21 @@ class CoreApp {
|
|
|
488
488
|
const message = typeof result === 'string' ? result : this.formatResult(result);
|
|
489
489
|
this.notifier.alert(message, callback);
|
|
490
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Service application API login
|
|
493
|
+
* @param appApi Service application API
|
|
494
|
+
* @param relogin Relogin try
|
|
495
|
+
* @param callback Callback
|
|
496
|
+
*/
|
|
497
|
+
apiLogin(appApi, relogin = true, callback) {
|
|
498
|
+
return this.refreshToken({
|
|
499
|
+
callback,
|
|
500
|
+
data: appApi.getrefreshTokenData(),
|
|
501
|
+
relogin,
|
|
502
|
+
showLoading: false,
|
|
503
|
+
appApi
|
|
504
|
+
});
|
|
505
|
+
}
|
|
491
506
|
/**
|
|
492
507
|
* Authorize
|
|
493
508
|
* @param token New token
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { IUser } from '../state/User';
|
|
|
7
7
|
import { IAppSettings } from './AppSettings';
|
|
8
8
|
import { UserRole } from './UserRole';
|
|
9
9
|
import { EntityStatus } from '../business/EntityStatus';
|
|
10
|
+
import { IAppApi } from './IAppApi';
|
|
10
11
|
/**
|
|
11
12
|
* Detect IP callback interface
|
|
12
13
|
*/
|
|
@@ -46,6 +47,10 @@ export interface RefreshTokenProps<D extends object> {
|
|
|
46
47
|
* Show loading bar or not
|
|
47
48
|
*/
|
|
48
49
|
showLoading?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Service application API
|
|
52
|
+
*/
|
|
53
|
+
appApi?: IAppApi;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* App fields
|
|
@@ -153,6 +158,13 @@ export interface IApp {
|
|
|
153
158
|
* @param callback Callback
|
|
154
159
|
*/
|
|
155
160
|
alertResult(result: IActionResult | string, callback?: NotificationReturn<void>): void;
|
|
161
|
+
/**
|
|
162
|
+
* Service application API login
|
|
163
|
+
* @param appApi Service application API
|
|
164
|
+
* @param relogin Relogin try
|
|
165
|
+
* @param callback Callback
|
|
166
|
+
*/
|
|
167
|
+
apiLogin(appApi: IAppApi, relogin?: boolean, callback?: (result: RefreshTokenResult, successData?: string) => void): Promise<boolean>;
|
|
156
168
|
/**
|
|
157
169
|
* Authorize
|
|
158
170
|
* @param token New token
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IApi } from '@etsoo/restclient';
|
|
2
|
+
/**
|
|
3
|
+
* Service application API, Implement interface calls between different services
|
|
4
|
+
* 服务程序接口,实现不同服务之间的接口调用
|
|
5
|
+
*/
|
|
6
|
+
export interface IAppApi {
|
|
7
|
+
/**
|
|
8
|
+
* API
|
|
9
|
+
*/
|
|
10
|
+
readonly api: IApi<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Service id
|
|
13
|
+
*/
|
|
14
|
+
readonly serviceId: number;
|
|
15
|
+
/**
|
|
16
|
+
* Authorize the API
|
|
17
|
+
* @param token Access token
|
|
18
|
+
*/
|
|
19
|
+
authorize(token: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get refresh token data
|
|
22
|
+
*/
|
|
23
|
+
getrefreshTokenData(): Object;
|
|
24
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* List item definition
|
|
3
3
|
*/
|
|
4
|
-
export type ListItem<T> = {
|
|
4
|
+
export type ListItem<T, E = any> = {
|
|
5
5
|
/**
|
|
6
6
|
* Label, '-' for divider
|
|
7
7
|
*/
|
|
@@ -13,5 +13,5 @@ export type ListItem<T> = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Action, string for URL, any for state
|
|
15
15
|
*/
|
|
16
|
-
action?: string | [string, any] | (() => PromiseLike<void> | void);
|
|
16
|
+
action?: string | [string, any] | ((event: E) => PromiseLike<void> | void);
|
|
17
17
|
};
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './app/AppSettings';
|
|
|
12
12
|
export * from './app/CoreApp';
|
|
13
13
|
export * from './app/ExternalSettings';
|
|
14
14
|
export * from './app/IApp';
|
|
15
|
+
export * from './app/IAppApi';
|
|
15
16
|
export * from './app/UserRole';
|
|
16
17
|
export * from './bridges/BridgeUtils';
|
|
17
18
|
export * from './bridges/IBridgeHost';
|
package/lib/cjs/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("./app/AppSettings"), exports);
|
|
|
31
31
|
__exportStar(require("./app/CoreApp"), exports);
|
|
32
32
|
__exportStar(require("./app/ExternalSettings"), exports);
|
|
33
33
|
__exportStar(require("./app/IApp"), exports);
|
|
34
|
+
__exportStar(require("./app/IAppApi"), exports);
|
|
34
35
|
__exportStar(require("./app/UserRole"), exports);
|
|
35
36
|
// bridges
|
|
36
37
|
__exportStar(require("./bridges/BridgeUtils"), exports);
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { IUser } from '../state/User';
|
|
|
10
10
|
import { IAppSettings } from './AppSettings';
|
|
11
11
|
import { IApp, IAppFields, IDetectIPCallback, NavigateOptions, RefreshTokenProps, RefreshTokenResult } from './IApp';
|
|
12
12
|
import { UserRole } from './UserRole';
|
|
13
|
+
import { IAppApi } from './IAppApi';
|
|
13
14
|
/**
|
|
14
15
|
* Core application interface
|
|
15
16
|
*/
|
|
@@ -219,6 +220,13 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
219
220
|
* @param callback Callback
|
|
220
221
|
*/
|
|
221
222
|
alertResult(result: IActionResult | string, callback?: NotificationReturn<void>): void;
|
|
223
|
+
/**
|
|
224
|
+
* Service application API login
|
|
225
|
+
* @param appApi Service application API
|
|
226
|
+
* @param relogin Relogin try
|
|
227
|
+
* @param callback Callback
|
|
228
|
+
*/
|
|
229
|
+
apiLogin(appApi: IAppApi, relogin?: boolean, callback?: (result: RefreshTokenResult, successData?: string) => void): Promise<boolean>;
|
|
222
230
|
/**
|
|
223
231
|
* Authorize
|
|
224
232
|
* @param token New token
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -462,6 +462,21 @@ export class CoreApp {
|
|
|
462
462
|
const message = typeof result === 'string' ? result : this.formatResult(result);
|
|
463
463
|
this.notifier.alert(message, callback);
|
|
464
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* Service application API login
|
|
467
|
+
* @param appApi Service application API
|
|
468
|
+
* @param relogin Relogin try
|
|
469
|
+
* @param callback Callback
|
|
470
|
+
*/
|
|
471
|
+
apiLogin(appApi, relogin = true, callback) {
|
|
472
|
+
return this.refreshToken({
|
|
473
|
+
callback,
|
|
474
|
+
data: appApi.getrefreshTokenData(),
|
|
475
|
+
relogin,
|
|
476
|
+
showLoading: false,
|
|
477
|
+
appApi
|
|
478
|
+
});
|
|
479
|
+
}
|
|
465
480
|
/**
|
|
466
481
|
* Authorize
|
|
467
482
|
* @param token New token
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { IUser } from '../state/User';
|
|
|
7
7
|
import { IAppSettings } from './AppSettings';
|
|
8
8
|
import { UserRole } from './UserRole';
|
|
9
9
|
import { EntityStatus } from '../business/EntityStatus';
|
|
10
|
+
import { IAppApi } from './IAppApi';
|
|
10
11
|
/**
|
|
11
12
|
* Detect IP callback interface
|
|
12
13
|
*/
|
|
@@ -46,6 +47,10 @@ export interface RefreshTokenProps<D extends object> {
|
|
|
46
47
|
* Show loading bar or not
|
|
47
48
|
*/
|
|
48
49
|
showLoading?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Service application API
|
|
52
|
+
*/
|
|
53
|
+
appApi?: IAppApi;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* App fields
|
|
@@ -153,6 +158,13 @@ export interface IApp {
|
|
|
153
158
|
* @param callback Callback
|
|
154
159
|
*/
|
|
155
160
|
alertResult(result: IActionResult | string, callback?: NotificationReturn<void>): void;
|
|
161
|
+
/**
|
|
162
|
+
* Service application API login
|
|
163
|
+
* @param appApi Service application API
|
|
164
|
+
* @param relogin Relogin try
|
|
165
|
+
* @param callback Callback
|
|
166
|
+
*/
|
|
167
|
+
apiLogin(appApi: IAppApi, relogin?: boolean, callback?: (result: RefreshTokenResult, successData?: string) => void): Promise<boolean>;
|
|
156
168
|
/**
|
|
157
169
|
* Authorize
|
|
158
170
|
* @param token New token
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IApi } from '@etsoo/restclient';
|
|
2
|
+
/**
|
|
3
|
+
* Service application API, Implement interface calls between different services
|
|
4
|
+
* 服务程序接口,实现不同服务之间的接口调用
|
|
5
|
+
*/
|
|
6
|
+
export interface IAppApi {
|
|
7
|
+
/**
|
|
8
|
+
* API
|
|
9
|
+
*/
|
|
10
|
+
readonly api: IApi<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Service id
|
|
13
|
+
*/
|
|
14
|
+
readonly serviceId: number;
|
|
15
|
+
/**
|
|
16
|
+
* Authorize the API
|
|
17
|
+
* @param token Access token
|
|
18
|
+
*/
|
|
19
|
+
authorize(token: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get refresh token data
|
|
22
|
+
*/
|
|
23
|
+
getrefreshTokenData(): Object;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* List item definition
|
|
3
3
|
*/
|
|
4
|
-
export type ListItem<T> = {
|
|
4
|
+
export type ListItem<T, E = any> = {
|
|
5
5
|
/**
|
|
6
6
|
* Label, '-' for divider
|
|
7
7
|
*/
|
|
@@ -13,5 +13,5 @@ export type ListItem<T> = {
|
|
|
13
13
|
/**
|
|
14
14
|
* Action, string for URL, any for state
|
|
15
15
|
*/
|
|
16
|
-
action?: string | [string, any] | (() => PromiseLike<void> | void);
|
|
16
|
+
action?: string | [string, any] | ((event: E) => PromiseLike<void> | void);
|
|
17
17
|
};
|
package/lib/mjs/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './app/AppSettings';
|
|
|
12
12
|
export * from './app/CoreApp';
|
|
13
13
|
export * from './app/ExternalSettings';
|
|
14
14
|
export * from './app/IApp';
|
|
15
|
+
export * from './app/IAppApi';
|
|
15
16
|
export * from './app/UserRole';
|
|
16
17
|
export * from './bridges/BridgeUtils';
|
|
17
18
|
export * from './bridges/IBridgeHost';
|
package/lib/mjs/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './app/AppSettings';
|
|
|
14
14
|
export * from './app/CoreApp';
|
|
15
15
|
export * from './app/ExternalSettings';
|
|
16
16
|
export * from './app/IApp';
|
|
17
|
+
export * from './app/IAppApi';
|
|
17
18
|
export * from './app/UserRole';
|
|
18
19
|
// bridges
|
|
19
20
|
export * from './bridges/BridgeUtils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.35",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/ETSOO/AppScript#readme",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
+
"@etsoo/notificationbase": "^1.1.28",
|
|
56
56
|
"@etsoo/restclient": "^1.0.89",
|
|
57
57
|
"@etsoo/shared": "^1.2.10",
|
|
58
58
|
"crypto-js": "^4.1.1"
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
} from './IApp';
|
|
40
40
|
import { UserRole } from './UserRole';
|
|
41
41
|
import type CryptoJS from 'crypto-js';
|
|
42
|
+
import { IAppApi } from './IAppApi';
|
|
42
43
|
|
|
43
44
|
type CJType = typeof CryptoJS;
|
|
44
45
|
let CJ: CJType;
|
|
@@ -700,6 +701,26 @@ export abstract class CoreApp<
|
|
|
700
701
|
this.notifier.alert(message, callback);
|
|
701
702
|
}
|
|
702
703
|
|
|
704
|
+
/**
|
|
705
|
+
* Service application API login
|
|
706
|
+
* @param appApi Service application API
|
|
707
|
+
* @param relogin Relogin try
|
|
708
|
+
* @param callback Callback
|
|
709
|
+
*/
|
|
710
|
+
apiLogin(
|
|
711
|
+
appApi: IAppApi,
|
|
712
|
+
relogin: boolean = true,
|
|
713
|
+
callback?: (result: RefreshTokenResult, successData?: string) => void
|
|
714
|
+
) {
|
|
715
|
+
return this.refreshToken({
|
|
716
|
+
callback,
|
|
717
|
+
data: appApi.getrefreshTokenData(),
|
|
718
|
+
relogin,
|
|
719
|
+
showLoading: false,
|
|
720
|
+
appApi
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
|
|
703
724
|
/**
|
|
704
725
|
* Authorize
|
|
705
726
|
* @param token New token
|
package/src/app/IApp.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { IUser } from '../state/User';
|
|
|
19
19
|
import { IAppSettings } from './AppSettings';
|
|
20
20
|
import { UserRole } from './UserRole';
|
|
21
21
|
import { EntityStatus } from '../business/EntityStatus';
|
|
22
|
+
import { IAppApi } from './IAppApi';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Detect IP callback interface
|
|
@@ -69,6 +70,11 @@ export interface RefreshTokenProps<D extends object> {
|
|
|
69
70
|
* Show loading bar or not
|
|
70
71
|
*/
|
|
71
72
|
showLoading?: boolean;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Service application API
|
|
76
|
+
*/
|
|
77
|
+
appApi?: IAppApi;
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/**
|
|
@@ -208,6 +214,18 @@ export interface IApp {
|
|
|
208
214
|
callback?: NotificationReturn<void>
|
|
209
215
|
): void;
|
|
210
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Service application API login
|
|
219
|
+
* @param appApi Service application API
|
|
220
|
+
* @param relogin Relogin try
|
|
221
|
+
* @param callback Callback
|
|
222
|
+
*/
|
|
223
|
+
apiLogin(
|
|
224
|
+
appApi: IAppApi,
|
|
225
|
+
relogin?: boolean,
|
|
226
|
+
callback?: (result: RefreshTokenResult, successData?: string) => void
|
|
227
|
+
): Promise<boolean>;
|
|
228
|
+
|
|
211
229
|
/**
|
|
212
230
|
* Authorize
|
|
213
231
|
* @param token New token
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IApi } from '@etsoo/restclient';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Service application API, Implement interface calls between different services
|
|
5
|
+
* 服务程序接口,实现不同服务之间的接口调用
|
|
6
|
+
*/
|
|
7
|
+
export interface IAppApi {
|
|
8
|
+
/**
|
|
9
|
+
* API
|
|
10
|
+
*/
|
|
11
|
+
readonly api: IApi<any>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Service id
|
|
15
|
+
*/
|
|
16
|
+
readonly serviceId: number;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Authorize the API
|
|
20
|
+
* @param token Access token
|
|
21
|
+
*/
|
|
22
|
+
authorize(token: string): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get refresh token data
|
|
26
|
+
*/
|
|
27
|
+
getrefreshTokenData(): Object;
|
|
28
|
+
}
|
package/src/def/ListItem.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* List item definition
|
|
3
3
|
*/
|
|
4
|
-
export type ListItem<T> = {
|
|
4
|
+
export type ListItem<T, E = any> = {
|
|
5
5
|
/**
|
|
6
6
|
* Label, '-' for divider
|
|
7
7
|
*/
|
|
@@ -15,5 +15,5 @@ export type ListItem<T> = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Action, string for URL, any for state
|
|
17
17
|
*/
|
|
18
|
-
action?: string | [string, any] | (() => PromiseLike<void> | void);
|
|
18
|
+
action?: string | [string, any] | ((event: E) => PromiseLike<void> | void);
|
|
19
19
|
};
|