@etsoo/appscript 1.5.23 → 1.5.25
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 +0 -2
- package/lib/cjs/app/CoreApp.d.ts +3 -3
- package/lib/cjs/app/CoreApp.js +13 -10
- package/lib/cjs/app/IApp.d.ts +4 -2
- package/lib/mjs/app/CoreApp.d.ts +3 -3
- package/lib/mjs/app/CoreApp.js +13 -10
- package/lib/mjs/app/IApp.d.ts +4 -2
- package/package.json +1 -1
- package/src/app/CoreApp.ts +14 -10
- package/src/app/IApp.ts +4 -2
package/__tests__/app/CoreApp.ts
CHANGED
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -90,7 +90,6 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
90
90
|
* Device id, randome string from ServiceBase.InitCallAsync
|
|
91
91
|
*/
|
|
92
92
|
get deviceId(): string;
|
|
93
|
-
protected set deviceId(value: string);
|
|
94
93
|
/**
|
|
95
94
|
* Label delegate
|
|
96
95
|
*/
|
|
@@ -598,9 +597,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
598
597
|
protected exchangeTokenUpdate(api: IApi, data: ApiRefreshTokenDto): void;
|
|
599
598
|
/**
|
|
600
599
|
* Exchange intergration tokens for all APIs
|
|
601
|
-
* @param
|
|
600
|
+
* @param coreData Core system's token data to exchange
|
|
601
|
+
* @param coreName Core system's name, default is 'core'
|
|
602
602
|
*/
|
|
603
|
-
exchangeTokenAll(
|
|
603
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
|
|
604
604
|
/**
|
|
605
605
|
* API refresh token
|
|
606
606
|
* @param api Current API
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -39,14 +39,8 @@ class CoreApp {
|
|
|
39
39
|
* Device id, randome string from ServiceBase.InitCallAsync
|
|
40
40
|
*/
|
|
41
41
|
get deviceId() {
|
|
42
|
-
if (this._deviceId === '') {
|
|
43
|
-
throw new Error('Device id is empty');
|
|
44
|
-
}
|
|
45
42
|
return this._deviceId;
|
|
46
43
|
}
|
|
47
|
-
set deviceId(value) {
|
|
48
|
-
this._deviceId = value;
|
|
49
|
-
}
|
|
50
44
|
/**
|
|
51
45
|
* Label delegate
|
|
52
46
|
*/
|
|
@@ -233,7 +227,7 @@ class CoreApp {
|
|
|
233
227
|
async restore() {
|
|
234
228
|
// Devices
|
|
235
229
|
const devices = this.storage.getPersistedData(this.fields.devices, []);
|
|
236
|
-
if (this.
|
|
230
|
+
if (this._deviceId === '') {
|
|
237
231
|
// First vist, restore and keep the source
|
|
238
232
|
this.storage.copyFrom(this.persistedFields, false);
|
|
239
233
|
// Reset device id
|
|
@@ -1439,12 +1433,21 @@ class CoreApp {
|
|
|
1439
1433
|
exchangeTokenUpdate(api, data) { }
|
|
1440
1434
|
/**
|
|
1441
1435
|
* Exchange intergration tokens for all APIs
|
|
1442
|
-
* @param
|
|
1436
|
+
* @param coreData Core system's token data to exchange
|
|
1437
|
+
* @param coreName Core system's name, default is 'core'
|
|
1443
1438
|
*/
|
|
1444
|
-
exchangeTokenAll(
|
|
1439
|
+
exchangeTokenAll(coreData, coreName) {
|
|
1440
|
+
coreName ?? (coreName = 'core');
|
|
1445
1441
|
for (const name in this.apis) {
|
|
1446
1442
|
const api = this.apis[name];
|
|
1447
|
-
|
|
1443
|
+
// The core API
|
|
1444
|
+
if (api[0].name === coreName) {
|
|
1445
|
+
api[0].authorize(coreData.tokenType, coreData.accessToken);
|
|
1446
|
+
this.updateApi(api, coreData.refreshToken, coreData.expiresIn);
|
|
1447
|
+
}
|
|
1448
|
+
else {
|
|
1449
|
+
this.exchangeToken(api[0], coreData.refreshToken);
|
|
1450
|
+
}
|
|
1448
1451
|
}
|
|
1449
1452
|
}
|
|
1450
1453
|
/**
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { UserRole } from './UserRole';
|
|
|
8
8
|
import { EntityStatus } from '../business/EntityStatus';
|
|
9
9
|
import { Currency } from '../business/Currency';
|
|
10
10
|
import { ExternalEndpoint } from './ExternalSettings';
|
|
11
|
+
import { ApiRefreshTokenDto } from '../erp/dto/ApiRefreshTokenDto';
|
|
11
12
|
/**
|
|
12
13
|
* Detect IP callback interface
|
|
13
14
|
*/
|
|
@@ -279,9 +280,10 @@ export interface IApp {
|
|
|
279
280
|
exchangeToken(api: IApi, token: string): Promise<void>;
|
|
280
281
|
/**
|
|
281
282
|
* Exchange intergration tokens for all APIs
|
|
282
|
-
* @param
|
|
283
|
+
* @param coreData Core system's token data to exchange
|
|
284
|
+
* @param coreName Core system's name, default is 'core'
|
|
283
285
|
*/
|
|
284
|
-
exchangeTokenAll(
|
|
286
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
|
|
285
287
|
/**
|
|
286
288
|
* Format date to string
|
|
287
289
|
* @param input Input date
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -90,7 +90,6 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
90
90
|
* Device id, randome string from ServiceBase.InitCallAsync
|
|
91
91
|
*/
|
|
92
92
|
get deviceId(): string;
|
|
93
|
-
protected set deviceId(value: string);
|
|
94
93
|
/**
|
|
95
94
|
* Label delegate
|
|
96
95
|
*/
|
|
@@ -598,9 +597,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
598
597
|
protected exchangeTokenUpdate(api: IApi, data: ApiRefreshTokenDto): void;
|
|
599
598
|
/**
|
|
600
599
|
* Exchange intergration tokens for all APIs
|
|
601
|
-
* @param
|
|
600
|
+
* @param coreData Core system's token data to exchange
|
|
601
|
+
* @param coreName Core system's name, default is 'core'
|
|
602
602
|
*/
|
|
603
|
-
exchangeTokenAll(
|
|
603
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
|
|
604
604
|
/**
|
|
605
605
|
* API refresh token
|
|
606
606
|
* @param api Current API
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -36,14 +36,8 @@ export class CoreApp {
|
|
|
36
36
|
* Device id, randome string from ServiceBase.InitCallAsync
|
|
37
37
|
*/
|
|
38
38
|
get deviceId() {
|
|
39
|
-
if (this._deviceId === '') {
|
|
40
|
-
throw new Error('Device id is empty');
|
|
41
|
-
}
|
|
42
39
|
return this._deviceId;
|
|
43
40
|
}
|
|
44
|
-
set deviceId(value) {
|
|
45
|
-
this._deviceId = value;
|
|
46
|
-
}
|
|
47
41
|
/**
|
|
48
42
|
* Label delegate
|
|
49
43
|
*/
|
|
@@ -230,7 +224,7 @@ export class CoreApp {
|
|
|
230
224
|
async restore() {
|
|
231
225
|
// Devices
|
|
232
226
|
const devices = this.storage.getPersistedData(this.fields.devices, []);
|
|
233
|
-
if (this.
|
|
227
|
+
if (this._deviceId === '') {
|
|
234
228
|
// First vist, restore and keep the source
|
|
235
229
|
this.storage.copyFrom(this.persistedFields, false);
|
|
236
230
|
// Reset device id
|
|
@@ -1436,12 +1430,21 @@ export class CoreApp {
|
|
|
1436
1430
|
exchangeTokenUpdate(api, data) { }
|
|
1437
1431
|
/**
|
|
1438
1432
|
* Exchange intergration tokens for all APIs
|
|
1439
|
-
* @param
|
|
1433
|
+
* @param coreData Core system's token data to exchange
|
|
1434
|
+
* @param coreName Core system's name, default is 'core'
|
|
1440
1435
|
*/
|
|
1441
|
-
exchangeTokenAll(
|
|
1436
|
+
exchangeTokenAll(coreData, coreName) {
|
|
1437
|
+
coreName ?? (coreName = 'core');
|
|
1442
1438
|
for (const name in this.apis) {
|
|
1443
1439
|
const api = this.apis[name];
|
|
1444
|
-
|
|
1440
|
+
// The core API
|
|
1441
|
+
if (api[0].name === coreName) {
|
|
1442
|
+
api[0].authorize(coreData.tokenType, coreData.accessToken);
|
|
1443
|
+
this.updateApi(api, coreData.refreshToken, coreData.expiresIn);
|
|
1444
|
+
}
|
|
1445
|
+
else {
|
|
1446
|
+
this.exchangeToken(api[0], coreData.refreshToken);
|
|
1447
|
+
}
|
|
1445
1448
|
}
|
|
1446
1449
|
}
|
|
1447
1450
|
/**
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { UserRole } from './UserRole';
|
|
|
8
8
|
import { EntityStatus } from '../business/EntityStatus';
|
|
9
9
|
import { Currency } from '../business/Currency';
|
|
10
10
|
import { ExternalEndpoint } from './ExternalSettings';
|
|
11
|
+
import { ApiRefreshTokenDto } from '../erp/dto/ApiRefreshTokenDto';
|
|
11
12
|
/**
|
|
12
13
|
* Detect IP callback interface
|
|
13
14
|
*/
|
|
@@ -279,9 +280,10 @@ export interface IApp {
|
|
|
279
280
|
exchangeToken(api: IApi, token: string): Promise<void>;
|
|
280
281
|
/**
|
|
281
282
|
* Exchange intergration tokens for all APIs
|
|
282
|
-
* @param
|
|
283
|
+
* @param coreData Core system's token data to exchange
|
|
284
|
+
* @param coreName Core system's name, default is 'core'
|
|
283
285
|
*/
|
|
284
|
-
exchangeTokenAll(
|
|
286
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
|
|
285
287
|
/**
|
|
286
288
|
* Format date to string
|
|
287
289
|
* @param input Input date
|
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -170,14 +170,8 @@ export abstract class CoreApp<
|
|
|
170
170
|
* Device id, randome string from ServiceBase.InitCallAsync
|
|
171
171
|
*/
|
|
172
172
|
get deviceId() {
|
|
173
|
-
if (this._deviceId === '') {
|
|
174
|
-
throw new Error('Device id is empty');
|
|
175
|
-
}
|
|
176
173
|
return this._deviceId;
|
|
177
174
|
}
|
|
178
|
-
protected set deviceId(value: string) {
|
|
179
|
-
this._deviceId = value;
|
|
180
|
-
}
|
|
181
175
|
|
|
182
176
|
/**
|
|
183
177
|
* Label delegate
|
|
@@ -433,7 +427,7 @@ export abstract class CoreApp<
|
|
|
433
427
|
[]
|
|
434
428
|
);
|
|
435
429
|
|
|
436
|
-
if (this.
|
|
430
|
+
if (this._deviceId === '') {
|
|
437
431
|
// First vist, restore and keep the source
|
|
438
432
|
this.storage.copyFrom(this.persistedFields, false);
|
|
439
433
|
|
|
@@ -1992,12 +1986,22 @@ export abstract class CoreApp<
|
|
|
1992
1986
|
|
|
1993
1987
|
/**
|
|
1994
1988
|
* Exchange intergration tokens for all APIs
|
|
1995
|
-
* @param
|
|
1989
|
+
* @param coreData Core system's token data to exchange
|
|
1990
|
+
* @param coreName Core system's name, default is 'core'
|
|
1996
1991
|
*/
|
|
1997
|
-
exchangeTokenAll(
|
|
1992
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string) {
|
|
1993
|
+
coreName ??= 'core';
|
|
1994
|
+
|
|
1998
1995
|
for (const name in this.apis) {
|
|
1999
1996
|
const api = this.apis[name];
|
|
2000
|
-
|
|
1997
|
+
|
|
1998
|
+
// The core API
|
|
1999
|
+
if (api[0].name === coreName) {
|
|
2000
|
+
api[0].authorize(coreData.tokenType, coreData.accessToken);
|
|
2001
|
+
this.updateApi(api, coreData.refreshToken, coreData.expiresIn);
|
|
2002
|
+
} else {
|
|
2003
|
+
this.exchangeToken(api[0], coreData.refreshToken);
|
|
2004
|
+
}
|
|
2001
2005
|
}
|
|
2002
2006
|
}
|
|
2003
2007
|
|
package/src/app/IApp.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { UserRole } from './UserRole';
|
|
|
23
23
|
import { EntityStatus } from '../business/EntityStatus';
|
|
24
24
|
import { Currency } from '../business/Currency';
|
|
25
25
|
import { ExternalEndpoint } from './ExternalSettings';
|
|
26
|
+
import { ApiRefreshTokenDto } from '../erp/dto/ApiRefreshTokenDto';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Detect IP callback interface
|
|
@@ -382,9 +383,10 @@ export interface IApp {
|
|
|
382
383
|
|
|
383
384
|
/**
|
|
384
385
|
* Exchange intergration tokens for all APIs
|
|
385
|
-
* @param
|
|
386
|
+
* @param coreData Core system's token data to exchange
|
|
387
|
+
* @param coreName Core system's name, default is 'core'
|
|
386
388
|
*/
|
|
387
|
-
exchangeTokenAll(
|
|
389
|
+
exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
|
|
388
390
|
|
|
389
391
|
/**
|
|
390
392
|
* Format date to string
|