@etsoo/appscript 1.5.19 → 1.5.21
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 +17 -0
- package/lib/cjs/app/CoreApp.d.ts +60 -14
- package/lib/cjs/app/CoreApp.js +212 -54
- package/lib/cjs/app/ExternalSettings.d.ts +15 -14
- package/lib/cjs/app/ExternalSettings.js +3 -0
- package/lib/cjs/app/IApp.d.ts +35 -2
- package/lib/cjs/erp/AuthApi.js +1 -1
- package/lib/cjs/erp/dto/ApiRefreshTokenDto.d.ts +21 -0
- package/lib/cjs/erp/dto/ApiRefreshTokenDto.js +2 -0
- package/lib/mjs/app/CoreApp.d.ts +60 -14
- package/lib/mjs/app/CoreApp.js +214 -56
- package/lib/mjs/app/ExternalSettings.d.ts +15 -14
- package/lib/mjs/app/ExternalSettings.js +3 -0
- package/lib/mjs/app/IApp.d.ts +35 -2
- package/lib/mjs/erp/AuthApi.js +1 -1
- package/lib/mjs/erp/dto/ApiRefreshTokenDto.d.ts +21 -0
- package/lib/mjs/erp/dto/ApiRefreshTokenDto.js +1 -0
- package/package.json +9 -9
- package/src/app/CoreApp.ts +304 -65
- package/src/app/ExternalSettings.ts +21 -16
- package/src/app/IApp.ts +47 -2
- package/src/erp/AuthApi.ts +1 -1
- package/src/erp/dto/ApiRefreshTokenDto.ts +24 -0
package/src/app/IApp.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { IAppSettings } from './AppSettings';
|
|
|
22
22
|
import { UserRole } from './UserRole';
|
|
23
23
|
import { EntityStatus } from '../business/EntityStatus';
|
|
24
24
|
import { Currency } from '../business/Currency';
|
|
25
|
+
import { ExternalEndpoint } from './ExternalSettings';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Detect IP callback interface
|
|
@@ -212,6 +213,13 @@ export interface IApp {
|
|
|
212
213
|
*/
|
|
213
214
|
addRootUrl(url: string): string;
|
|
214
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Add scheduled task
|
|
218
|
+
* @param task Task, return false to stop
|
|
219
|
+
* @param interval Interval in milliseconds
|
|
220
|
+
*/
|
|
221
|
+
addTask(task: () => PromiseLike<void | false>, interval: number): void;
|
|
222
|
+
|
|
215
223
|
/**
|
|
216
224
|
* Alert result
|
|
217
225
|
* @param result Result message
|
|
@@ -282,6 +290,21 @@ export interface IApp {
|
|
|
282
290
|
*/
|
|
283
291
|
clearDeviceId(): void;
|
|
284
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Create API client, override to implement custom client creation by name
|
|
295
|
+
* @param name Client name
|
|
296
|
+
* @param item External endpoint item
|
|
297
|
+
* @returns Result
|
|
298
|
+
*/
|
|
299
|
+
createApi(
|
|
300
|
+
name: string,
|
|
301
|
+
item: ExternalEndpoint,
|
|
302
|
+
refresh?: (
|
|
303
|
+
api: IApi,
|
|
304
|
+
token: string
|
|
305
|
+
) => Promise<[string, number] | undefined>
|
|
306
|
+
): IApi;
|
|
307
|
+
|
|
285
308
|
/**
|
|
286
309
|
* Decrypt message
|
|
287
310
|
* @param messageEncrypted Encrypted message
|
|
@@ -343,6 +366,20 @@ export interface IApp {
|
|
|
343
366
|
iterations?: number
|
|
344
367
|
): string;
|
|
345
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Exchange token data
|
|
371
|
+
* @param api API
|
|
372
|
+
* @param token Core system's refresh token to exchange
|
|
373
|
+
* @returns Result
|
|
374
|
+
*/
|
|
375
|
+
exchangeToken(api: IApi, token: string): Promise<void>;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Exchange intergration tokens for all APIs
|
|
379
|
+
* @param token Core system's refresh token to exchange
|
|
380
|
+
*/
|
|
381
|
+
exchangeTokenAll(token: string): void;
|
|
382
|
+
|
|
346
383
|
/**
|
|
347
384
|
* Format date to string
|
|
348
385
|
* @param input Input date
|
|
@@ -688,9 +725,17 @@ export interface IApp {
|
|
|
688
725
|
/**
|
|
689
726
|
* Try login, returning false means is loading
|
|
690
727
|
* UI get involved while refreshToken not intended
|
|
691
|
-
* @param
|
|
728
|
+
* @param showLoading Show loading bar or not
|
|
729
|
+
*/
|
|
730
|
+
tryLogin(showLoading?: boolean): Promise<boolean>;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Update API token and expires
|
|
734
|
+
* @param name Api name
|
|
735
|
+
* @param token Refresh token
|
|
736
|
+
* @param seconds Access token expires in seconds
|
|
692
737
|
*/
|
|
693
|
-
|
|
738
|
+
updateApi(name: string, token: string | undefined, seconds: number): void;
|
|
694
739
|
|
|
695
740
|
/**
|
|
696
741
|
* User login
|
package/src/erp/AuthApi.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API refresh token data
|
|
3
|
+
*/
|
|
4
|
+
export type ApiRefreshTokenDto = {
|
|
5
|
+
/**
|
|
6
|
+
* Refresh token
|
|
7
|
+
*/
|
|
8
|
+
readonly refreshToken: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Access token
|
|
12
|
+
*/
|
|
13
|
+
readonly accessToken: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Token type
|
|
17
|
+
*/
|
|
18
|
+
readonly tokenType: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Expires in
|
|
22
|
+
*/
|
|
23
|
+
readonly expiresIn: number;
|
|
24
|
+
};
|