@etsoo/appscript 1.6.0 → 1.6.2
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 +2 -2
- package/__tests__/app/TestApp.ts +2 -14
- package/lib/cjs/app/CoreApp.d.ts +5 -2
- package/lib/cjs/app/CoreApp.js +13 -8
- package/lib/cjs/app/ExternalSettings.d.ts +1 -1
- package/lib/cjs/app/IApp.d.ts +1 -2
- package/lib/mjs/app/CoreApp.d.ts +5 -2
- package/lib/mjs/app/CoreApp.js +13 -8
- package/lib/mjs/app/ExternalSettings.d.ts +1 -1
- package/lib/mjs/app/IApp.d.ts +1 -2
- package/package.json +5 -5
- package/src/app/CoreApp.ts +15 -10
- package/src/app/ExternalSettings.ts +1 -1
- package/src/app/IApp.ts +1 -2
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -22,10 +22,10 @@ const app = new appClass();
|
|
|
22
22
|
await app.changeCulture(app.settings.cultures[0]);
|
|
23
23
|
|
|
24
24
|
test("Test for domain substitution", () => {
|
|
25
|
-
expect(app.settings.endpoint).toBe("http://
|
|
25
|
+
expect(app.settings.endpoint).toBe("http://admin.etsoo.com:9000/api/");
|
|
26
26
|
|
|
27
27
|
expect(app.settings.endpoints?.core.endpoint).toBe(
|
|
28
|
-
"https://
|
|
28
|
+
"https://core.etsoo.com:9001/api/"
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
|
package/__tests__/app/TestApp.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
CoreApp,
|
|
12
12
|
createClient,
|
|
13
13
|
Culture,
|
|
14
|
-
ExternalSettings,
|
|
15
14
|
IAppSettings,
|
|
16
15
|
InitCallResultData,
|
|
17
16
|
IUser
|
|
@@ -87,6 +86,8 @@ export class TestApp extends CoreApp<
|
|
|
87
86
|
}
|
|
88
87
|
},
|
|
89
88
|
|
|
89
|
+
hostname: "admin.etsoo.com",
|
|
90
|
+
|
|
90
91
|
/**
|
|
91
92
|
* App root url
|
|
92
93
|
*/
|
|
@@ -126,19 +127,6 @@ export class TestApp extends CoreApp<
|
|
|
126
127
|
);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
// Example of local format settings
|
|
130
|
-
protected override formatSettings(settings: IAppSettings): IAppSettings {
|
|
131
|
-
const { endpoint, endpoints, ...rest } = settings;
|
|
132
|
-
return {
|
|
133
|
-
...rest,
|
|
134
|
-
endpoint: ExternalSettings.formatHost(endpoint, "localhost"),
|
|
135
|
-
endpoints:
|
|
136
|
-
endpoints == null
|
|
137
|
-
? undefined
|
|
138
|
-
: ExternalSettings.formatHost(endpoints, "localhost")
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
130
|
freshCountdownUI(callback?: () => PromiseLike<unknown>): void {
|
|
143
131
|
throw new Error("Method not implemented.");
|
|
144
132
|
}
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -147,6 +147,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
147
147
|
*/
|
|
148
148
|
get isTryingLogin(): boolean;
|
|
149
149
|
protected set isTryingLogin(value: boolean);
|
|
150
|
+
/**
|
|
151
|
+
* Get core API name
|
|
152
|
+
*/
|
|
153
|
+
protected get coreName(): string;
|
|
150
154
|
/**
|
|
151
155
|
* Last called with token refresh
|
|
152
156
|
*/
|
|
@@ -645,9 +649,8 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
645
649
|
/**
|
|
646
650
|
* Exchange intergration tokens for all APIs
|
|
647
651
|
* @param coreData Core system's token data to exchange
|
|
648
|
-
* @param coreName Core system's name, default is 'core'
|
|
649
652
|
*/
|
|
650
|
-
exchangeTokenAll(coreData: ApiRefreshTokenDto
|
|
653
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto): void;
|
|
651
654
|
/**
|
|
652
655
|
* API refresh token data
|
|
653
656
|
* @param api Current API
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -134,6 +134,12 @@ class CoreApp {
|
|
|
134
134
|
set isTryingLogin(value) {
|
|
135
135
|
this._isTryingLogin = value;
|
|
136
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Get core API name
|
|
139
|
+
*/
|
|
140
|
+
get coreName() {
|
|
141
|
+
return "core";
|
|
142
|
+
}
|
|
137
143
|
/**
|
|
138
144
|
* Protected constructor
|
|
139
145
|
* @param settings Settings
|
|
@@ -189,17 +195,19 @@ class CoreApp {
|
|
|
189
195
|
}
|
|
190
196
|
return undefined;
|
|
191
197
|
};
|
|
198
|
+
// Destruct the settings
|
|
199
|
+
const { currentCulture, currentRegion, endpoint, webUrl } = this.settings;
|
|
192
200
|
if (api) {
|
|
193
201
|
// Base URL of the API
|
|
194
|
-
api.baseUrl =
|
|
202
|
+
api.baseUrl = endpoint;
|
|
195
203
|
api.name = systemApi;
|
|
196
204
|
this.setApi(api, refresh);
|
|
197
205
|
this.api = api;
|
|
198
206
|
}
|
|
199
207
|
else {
|
|
200
208
|
this.api = this.createApi(systemApi, {
|
|
201
|
-
endpoint
|
|
202
|
-
webUrl
|
|
209
|
+
endpoint,
|
|
210
|
+
webUrl
|
|
203
211
|
}, refresh);
|
|
204
212
|
}
|
|
205
213
|
this.notifier = notifier;
|
|
@@ -220,7 +228,6 @@ class CoreApp {
|
|
|
220
228
|
// Embedded
|
|
221
229
|
this._embedded =
|
|
222
230
|
this.storage.getData(this.fields.embedded) ?? false;
|
|
223
|
-
const { currentCulture, currentRegion } = settings;
|
|
224
231
|
// Load resources
|
|
225
232
|
Promise.all([loadCrypto(), this.changeCulture(currentCulture)]).then(([cj, _resources]) => {
|
|
226
233
|
CJ = cj.default;
|
|
@@ -1562,10 +1569,8 @@ class CoreApp {
|
|
|
1562
1569
|
/**
|
|
1563
1570
|
* Exchange intergration tokens for all APIs
|
|
1564
1571
|
* @param coreData Core system's token data to exchange
|
|
1565
|
-
* @param coreName Core system's name, default is 'core'
|
|
1566
1572
|
*/
|
|
1567
|
-
exchangeTokenAll(coreData
|
|
1568
|
-
coreName ?? (coreName = "core");
|
|
1573
|
+
exchangeTokenAll(coreData) {
|
|
1569
1574
|
for (const name in this.apis) {
|
|
1570
1575
|
// Ignore the system API as it has its own logic with refreshToken
|
|
1571
1576
|
if (name === systemApi)
|
|
@@ -1573,7 +1578,7 @@ class CoreApp {
|
|
|
1573
1578
|
const data = this.apis[name];
|
|
1574
1579
|
const api = data[0];
|
|
1575
1580
|
// The core API
|
|
1576
|
-
if (name === coreName) {
|
|
1581
|
+
if (name === this.coreName) {
|
|
1577
1582
|
api.authorize(coreData.tokenType, coreData.accessToken);
|
|
1578
1583
|
this.updateApi(data, coreData.refreshToken, coreData.expiresIn);
|
|
1579
1584
|
}
|
|
@@ -36,7 +36,7 @@ export interface IExternalSettings extends ExternalEndpoint {
|
|
|
36
36
|
/**
|
|
37
37
|
* Endpoints to other services
|
|
38
38
|
*/
|
|
39
|
-
readonly endpoints?: Record<"core" | "admin" | "finance" | "crm" | "oa" | "agile" | string, ExternalEndpoint>;
|
|
39
|
+
readonly endpoints?: Record<"platform" | "core" | "admin" | "finance" | "crm" | "oa" | "agile" | string, ExternalEndpoint>;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* External settings namespace
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -342,9 +342,8 @@ export interface IApp {
|
|
|
342
342
|
/**
|
|
343
343
|
* Exchange intergration tokens for all APIs
|
|
344
344
|
* @param coreData Core system's token data to exchange
|
|
345
|
-
* @param coreName Core system's name, default is 'core'
|
|
346
345
|
*/
|
|
347
|
-
exchangeTokenAll(coreData: ApiRefreshTokenDto
|
|
346
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto): void;
|
|
348
347
|
/**
|
|
349
348
|
* Format date to string
|
|
350
349
|
* @param input Input date
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -147,6 +147,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
147
147
|
*/
|
|
148
148
|
get isTryingLogin(): boolean;
|
|
149
149
|
protected set isTryingLogin(value: boolean);
|
|
150
|
+
/**
|
|
151
|
+
* Get core API name
|
|
152
|
+
*/
|
|
153
|
+
protected get coreName(): string;
|
|
150
154
|
/**
|
|
151
155
|
* Last called with token refresh
|
|
152
156
|
*/
|
|
@@ -645,9 +649,8 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
645
649
|
/**
|
|
646
650
|
* Exchange intergration tokens for all APIs
|
|
647
651
|
* @param coreData Core system's token data to exchange
|
|
648
|
-
* @param coreName Core system's name, default is 'core'
|
|
649
652
|
*/
|
|
650
|
-
exchangeTokenAll(coreData: ApiRefreshTokenDto
|
|
653
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto): void;
|
|
651
654
|
/**
|
|
652
655
|
* API refresh token data
|
|
653
656
|
* @param api Current API
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -131,6 +131,12 @@ export class CoreApp {
|
|
|
131
131
|
set isTryingLogin(value) {
|
|
132
132
|
this._isTryingLogin = value;
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Get core API name
|
|
136
|
+
*/
|
|
137
|
+
get coreName() {
|
|
138
|
+
return "core";
|
|
139
|
+
}
|
|
134
140
|
/**
|
|
135
141
|
* Protected constructor
|
|
136
142
|
* @param settings Settings
|
|
@@ -186,17 +192,19 @@ export class CoreApp {
|
|
|
186
192
|
}
|
|
187
193
|
return undefined;
|
|
188
194
|
};
|
|
195
|
+
// Destruct the settings
|
|
196
|
+
const { currentCulture, currentRegion, endpoint, webUrl } = this.settings;
|
|
189
197
|
if (api) {
|
|
190
198
|
// Base URL of the API
|
|
191
|
-
api.baseUrl =
|
|
199
|
+
api.baseUrl = endpoint;
|
|
192
200
|
api.name = systemApi;
|
|
193
201
|
this.setApi(api, refresh);
|
|
194
202
|
this.api = api;
|
|
195
203
|
}
|
|
196
204
|
else {
|
|
197
205
|
this.api = this.createApi(systemApi, {
|
|
198
|
-
endpoint
|
|
199
|
-
webUrl
|
|
206
|
+
endpoint,
|
|
207
|
+
webUrl
|
|
200
208
|
}, refresh);
|
|
201
209
|
}
|
|
202
210
|
this.notifier = notifier;
|
|
@@ -217,7 +225,6 @@ export class CoreApp {
|
|
|
217
225
|
// Embedded
|
|
218
226
|
this._embedded =
|
|
219
227
|
this.storage.getData(this.fields.embedded) ?? false;
|
|
220
|
-
const { currentCulture, currentRegion } = settings;
|
|
221
228
|
// Load resources
|
|
222
229
|
Promise.all([loadCrypto(), this.changeCulture(currentCulture)]).then(([cj, _resources]) => {
|
|
223
230
|
CJ = cj.default;
|
|
@@ -1559,10 +1566,8 @@ export class CoreApp {
|
|
|
1559
1566
|
/**
|
|
1560
1567
|
* Exchange intergration tokens for all APIs
|
|
1561
1568
|
* @param coreData Core system's token data to exchange
|
|
1562
|
-
* @param coreName Core system's name, default is 'core'
|
|
1563
1569
|
*/
|
|
1564
|
-
exchangeTokenAll(coreData
|
|
1565
|
-
coreName ?? (coreName = "core");
|
|
1570
|
+
exchangeTokenAll(coreData) {
|
|
1566
1571
|
for (const name in this.apis) {
|
|
1567
1572
|
// Ignore the system API as it has its own logic with refreshToken
|
|
1568
1573
|
if (name === systemApi)
|
|
@@ -1570,7 +1575,7 @@ export class CoreApp {
|
|
|
1570
1575
|
const data = this.apis[name];
|
|
1571
1576
|
const api = data[0];
|
|
1572
1577
|
// The core API
|
|
1573
|
-
if (name === coreName) {
|
|
1578
|
+
if (name === this.coreName) {
|
|
1574
1579
|
api.authorize(coreData.tokenType, coreData.accessToken);
|
|
1575
1580
|
this.updateApi(data, coreData.refreshToken, coreData.expiresIn);
|
|
1576
1581
|
}
|
|
@@ -36,7 +36,7 @@ export interface IExternalSettings extends ExternalEndpoint {
|
|
|
36
36
|
/**
|
|
37
37
|
* Endpoints to other services
|
|
38
38
|
*/
|
|
39
|
-
readonly endpoints?: Record<"core" | "admin" | "finance" | "crm" | "oa" | "agile" | string, ExternalEndpoint>;
|
|
39
|
+
readonly endpoints?: Record<"platform" | "core" | "admin" | "finance" | "crm" | "oa" | "agile" | string, ExternalEndpoint>;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* External settings namespace
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -342,9 +342,8 @@ export interface IApp {
|
|
|
342
342
|
/**
|
|
343
343
|
* Exchange intergration tokens for all APIs
|
|
344
344
|
* @param coreData Core system's token data to exchange
|
|
345
|
-
* @param coreName Core system's name, default is 'core'
|
|
346
345
|
*/
|
|
347
|
-
exchangeTokenAll(coreData: ApiRefreshTokenDto
|
|
346
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto): void;
|
|
348
347
|
/**
|
|
349
348
|
* Format date to string
|
|
350
349
|
* @param input Input date
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@babel/cli": "^7.26.4",
|
|
45
|
-
"@babel/core": "^7.26.
|
|
46
|
-
"@babel/plugin-transform-runtime": "^7.26.
|
|
47
|
-
"@babel/preset-env": "^7.26.
|
|
48
|
-
"@babel/runtime-corejs3": "^7.26.
|
|
45
|
+
"@babel/core": "^7.26.9",
|
|
46
|
+
"@babel/plugin-transform-runtime": "^7.26.9",
|
|
47
|
+
"@babel/preset-env": "^7.26.9",
|
|
48
|
+
"@babel/runtime-corejs3": "^7.26.9",
|
|
49
49
|
"@types/crypto-js": "^4.2.2",
|
|
50
50
|
"@vitejs/plugin-react": "^4.3.4",
|
|
51
51
|
"jsdom": "^26.0.0",
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -293,6 +293,13 @@ export abstract class CoreApp<
|
|
|
293
293
|
this._isTryingLogin = value;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Get core API name
|
|
298
|
+
*/
|
|
299
|
+
protected get coreName() {
|
|
300
|
+
return "core";
|
|
301
|
+
}
|
|
302
|
+
|
|
296
303
|
/**
|
|
297
304
|
* Last called with token refresh
|
|
298
305
|
*/
|
|
@@ -365,9 +372,12 @@ export abstract class CoreApp<
|
|
|
365
372
|
return undefined;
|
|
366
373
|
};
|
|
367
374
|
|
|
375
|
+
// Destruct the settings
|
|
376
|
+
const { currentCulture, currentRegion, endpoint, webUrl } = this.settings;
|
|
377
|
+
|
|
368
378
|
if (api) {
|
|
369
379
|
// Base URL of the API
|
|
370
|
-
api.baseUrl =
|
|
380
|
+
api.baseUrl = endpoint;
|
|
371
381
|
api.name = systemApi;
|
|
372
382
|
this.setApi(api, refresh);
|
|
373
383
|
this.api = api;
|
|
@@ -375,8 +385,8 @@ export abstract class CoreApp<
|
|
|
375
385
|
this.api = this.createApi(
|
|
376
386
|
systemApi,
|
|
377
387
|
{
|
|
378
|
-
endpoint
|
|
379
|
-
webUrl
|
|
388
|
+
endpoint,
|
|
389
|
+
webUrl
|
|
380
390
|
},
|
|
381
391
|
refresh
|
|
382
392
|
);
|
|
@@ -408,8 +418,6 @@ export abstract class CoreApp<
|
|
|
408
418
|
this._embedded =
|
|
409
419
|
this.storage.getData<boolean>(this.fields.embedded) ?? false;
|
|
410
420
|
|
|
411
|
-
const { currentCulture, currentRegion } = settings;
|
|
412
|
-
|
|
413
421
|
// Load resources
|
|
414
422
|
Promise.all([loadCrypto(), this.changeCulture(currentCulture)]).then(
|
|
415
423
|
([cj, _resources]) => {
|
|
@@ -2111,11 +2119,8 @@ export abstract class CoreApp<
|
|
|
2111
2119
|
/**
|
|
2112
2120
|
* Exchange intergration tokens for all APIs
|
|
2113
2121
|
* @param coreData Core system's token data to exchange
|
|
2114
|
-
* @param coreName Core system's name, default is 'core'
|
|
2115
2122
|
*/
|
|
2116
|
-
exchangeTokenAll(coreData: ApiRefreshTokenDto
|
|
2117
|
-
coreName ??= "core";
|
|
2118
|
-
|
|
2123
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto) {
|
|
2119
2124
|
for (const name in this.apis) {
|
|
2120
2125
|
// Ignore the system API as it has its own logic with refreshToken
|
|
2121
2126
|
if (name === systemApi) continue;
|
|
@@ -2124,7 +2129,7 @@ export abstract class CoreApp<
|
|
|
2124
2129
|
const api = data[0];
|
|
2125
2130
|
|
|
2126
2131
|
// The core API
|
|
2127
|
-
if (name === coreName) {
|
|
2132
|
+
if (name === this.coreName) {
|
|
2128
2133
|
api.authorize(coreData.tokenType, coreData.accessToken);
|
|
2129
2134
|
this.updateApi(data, coreData.refreshToken, coreData.expiresIn);
|
|
2130
2135
|
} else {
|
|
@@ -43,7 +43,7 @@ export interface IExternalSettings extends ExternalEndpoint {
|
|
|
43
43
|
* Endpoints to other services
|
|
44
44
|
*/
|
|
45
45
|
readonly endpoints?: Record<
|
|
46
|
-
"core" | "admin" | "finance" | "crm" | "oa" | "agile" | string,
|
|
46
|
+
"platform" | "core" | "admin" | "finance" | "crm" | "oa" | "agile" | string,
|
|
47
47
|
ExternalEndpoint
|
|
48
48
|
>;
|
|
49
49
|
}
|
package/src/app/IApp.ts
CHANGED
|
@@ -454,9 +454,8 @@ export interface IApp {
|
|
|
454
454
|
/**
|
|
455
455
|
* Exchange intergration tokens for all APIs
|
|
456
456
|
* @param coreData Core system's token data to exchange
|
|
457
|
-
* @param coreName Core system's name, default is 'core'
|
|
458
457
|
*/
|
|
459
|
-
exchangeTokenAll(coreData: ApiRefreshTokenDto
|
|
458
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto): void;
|
|
460
459
|
|
|
461
460
|
/**
|
|
462
461
|
* Format date to string
|