@etsoo/appscript 1.5.20 → 1.5.22
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 +64 -12
- package/lib/cjs/app/CoreApp.js +223 -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 +38 -1
- package/lib/cjs/app/IApp.js +2 -1
- 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 +64 -12
- package/lib/mjs/app/CoreApp.js +225 -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 +38 -1
- package/lib/mjs/app/IApp.js +2 -1
- 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 +317 -66
- package/src/app/ExternalSettings.ts +21 -16
- package/src/app/IApp.ts +52 -1
- package/src/erp/AuthApi.ts +1 -1
- package/src/erp/dto/ApiRefreshTokenDto.ts +24 -0
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* External
|
|
2
|
+
* External endpoint
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ExternalEndpoint = {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* API endpoint
|
|
7
7
|
*/
|
|
8
8
|
readonly endpoint: string;
|
|
9
|
+
/**
|
|
10
|
+
* Web url
|
|
11
|
+
*/
|
|
12
|
+
readonly webUrl: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* External settings items
|
|
16
|
+
*/
|
|
17
|
+
export interface IExternalSettings extends ExternalEndpoint {
|
|
9
18
|
/**
|
|
10
19
|
* Message hub endpoint
|
|
11
20
|
*/
|
|
12
21
|
readonly messageHub?: string;
|
|
13
22
|
/**
|
|
14
|
-
*
|
|
23
|
+
* App root url
|
|
15
24
|
*/
|
|
16
25
|
readonly homepage: string;
|
|
17
26
|
/**
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
readonly webUrl: string;
|
|
21
|
-
/**
|
|
22
|
-
* Service API endpoint
|
|
23
|
-
*/
|
|
24
|
-
readonly serviceEndpoint?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Service web Url
|
|
27
|
+
* Endpoints to other services
|
|
27
28
|
*/
|
|
28
|
-
readonly
|
|
29
|
+
readonly endpoints?: Record<'core' | 'accounting' | 'crm' | 'calandar' | 'task' | string, ExternalEndpoint>;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* External settings namespace
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { IAppSettings } from './AppSettings';
|
|
|
7
7
|
import { UserRole } from './UserRole';
|
|
8
8
|
import { EntityStatus } from '../business/EntityStatus';
|
|
9
9
|
import { Currency } from '../business/Currency';
|
|
10
|
+
import { ExternalEndpoint } from './ExternalSettings';
|
|
10
11
|
/**
|
|
11
12
|
* Detect IP callback interface
|
|
12
13
|
*/
|
|
@@ -54,7 +55,7 @@ export interface RefreshTokenProps {
|
|
|
54
55
|
/**
|
|
55
56
|
* App fields
|
|
56
57
|
*/
|
|
57
|
-
export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase"];
|
|
58
|
+
export declare const appFields: readonly ["headerToken", "serversideDeviceId", "deviceId", "devices", "devicePassphrase", "cachedUrl"];
|
|
58
59
|
/**
|
|
59
60
|
* Basic type template
|
|
60
61
|
*/
|
|
@@ -129,6 +130,10 @@ export interface IApp {
|
|
|
129
130
|
* Is debug mode
|
|
130
131
|
*/
|
|
131
132
|
readonly debug: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Cached URL
|
|
135
|
+
*/
|
|
136
|
+
cachedUrl: string | undefined | null;
|
|
132
137
|
/**
|
|
133
138
|
* IP data
|
|
134
139
|
*/
|
|
@@ -155,6 +160,12 @@ export interface IApp {
|
|
|
155
160
|
* @returns Result
|
|
156
161
|
*/
|
|
157
162
|
addRootUrl(url: string): string;
|
|
163
|
+
/**
|
|
164
|
+
* Add scheduled task
|
|
165
|
+
* @param task Task, return false to stop
|
|
166
|
+
* @param interval Interval in milliseconds
|
|
167
|
+
*/
|
|
168
|
+
addTask(task: () => PromiseLike<void | false>, interval: number): void;
|
|
158
169
|
/**
|
|
159
170
|
* Alert result
|
|
160
171
|
* @param result Result message
|
|
@@ -209,6 +220,13 @@ export interface IApp {
|
|
|
209
220
|
* Clear device id
|
|
210
221
|
*/
|
|
211
222
|
clearDeviceId(): void;
|
|
223
|
+
/**
|
|
224
|
+
* Create API client, override to implement custom client creation by name
|
|
225
|
+
* @param name Client name
|
|
226
|
+
* @param item External endpoint item
|
|
227
|
+
* @returns Result
|
|
228
|
+
*/
|
|
229
|
+
createApi(name: string, item: ExternalEndpoint, refresh?: (api: IApi, token: string) => Promise<[string, number] | undefined>): IApi;
|
|
212
230
|
/**
|
|
213
231
|
* Decrypt message
|
|
214
232
|
* @param messageEncrypted Encrypted message
|
|
@@ -252,6 +270,18 @@ export interface IApp {
|
|
|
252
270
|
* @returns Result
|
|
253
271
|
*/
|
|
254
272
|
encryptEnhanced(message: string, passphrase?: string, iterations?: number): string;
|
|
273
|
+
/**
|
|
274
|
+
* Exchange token data
|
|
275
|
+
* @param api API
|
|
276
|
+
* @param token Core system's refresh token to exchange
|
|
277
|
+
* @returns Result
|
|
278
|
+
*/
|
|
279
|
+
exchangeToken(api: IApi, token: string): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Exchange intergration tokens for all APIs
|
|
282
|
+
* @param token Core system's refresh token to exchange
|
|
283
|
+
*/
|
|
284
|
+
exchangeTokenAll(token: string): void;
|
|
255
285
|
/**
|
|
256
286
|
* Format date to string
|
|
257
287
|
* @param input Input date
|
|
@@ -508,6 +538,13 @@ export interface IApp {
|
|
|
508
538
|
* @param showLoading Show loading bar or not
|
|
509
539
|
*/
|
|
510
540
|
tryLogin(showLoading?: boolean): Promise<boolean>;
|
|
541
|
+
/**
|
|
542
|
+
* Update API token and expires
|
|
543
|
+
* @param name Api name
|
|
544
|
+
* @param token Refresh token
|
|
545
|
+
* @param seconds Access token expires in seconds
|
|
546
|
+
*/
|
|
547
|
+
updateApi(name: string, token: string | undefined, seconds: number): void;
|
|
511
548
|
/**
|
|
512
549
|
* User login
|
|
513
550
|
* @param user User data
|
package/lib/mjs/app/IApp.js
CHANGED
package/lib/mjs/erp/AuthApi.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API refresh token data
|
|
3
|
+
*/
|
|
4
|
+
export type ApiRefreshTokenDto = {
|
|
5
|
+
/**
|
|
6
|
+
* Refresh token
|
|
7
|
+
*/
|
|
8
|
+
readonly refreshToken: string;
|
|
9
|
+
/**
|
|
10
|
+
* Access token
|
|
11
|
+
*/
|
|
12
|
+
readonly accessToken: string;
|
|
13
|
+
/**
|
|
14
|
+
* Token type
|
|
15
|
+
*/
|
|
16
|
+
readonly tokenType: string;
|
|
17
|
+
/**
|
|
18
|
+
* Expires in
|
|
19
|
+
*/
|
|
20
|
+
readonly expiresIn: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.22",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/ETSOO/AppScript#readme",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@etsoo/notificationbase": "^1.1.
|
|
56
|
-
"@etsoo/restclient": "^1.1.
|
|
57
|
-
"@etsoo/shared": "^1.2.
|
|
55
|
+
"@etsoo/notificationbase": "^1.1.48",
|
|
56
|
+
"@etsoo/restclient": "^1.1.10",
|
|
57
|
+
"@etsoo/shared": "^1.2.46",
|
|
58
58
|
"crypto-js": "^4.2.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@babel/cli": "^7.25.
|
|
62
|
-
"@babel/core": "^7.25.
|
|
63
|
-
"@babel/plugin-transform-runtime": "^7.25.
|
|
64
|
-
"@babel/preset-env": "^7.25.
|
|
65
|
-
"@babel/runtime-corejs3": "^7.25.
|
|
61
|
+
"@babel/cli": "^7.25.7",
|
|
62
|
+
"@babel/core": "^7.25.7",
|
|
63
|
+
"@babel/plugin-transform-runtime": "^7.25.7",
|
|
64
|
+
"@babel/preset-env": "^7.25.7",
|
|
65
|
+
"@babel/runtime-corejs3": "^7.25.7",
|
|
66
66
|
"@types/crypto-js": "^4.2.2",
|
|
67
67
|
"@types/jest": "^29.5.13",
|
|
68
68
|
"jest": "^29.7.0",
|