@etsoo/appscript 1.5.24 → 1.5.26

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.
@@ -90,6 +90,7 @@ 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);
93
94
  /**
94
95
  * Label delegate
95
96
  */
@@ -597,9 +598,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
597
598
  protected exchangeTokenUpdate(api: IApi, data: ApiRefreshTokenDto): void;
598
599
  /**
599
600
  * Exchange intergration tokens for all APIs
600
- * @param token Core system's refresh token to exchange
601
+ * @param coreData Core system's token data to exchange
602
+ * @param coreName Core system's name, default is 'core'
601
603
  */
602
- exchangeTokenAll(token: string): void;
604
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
603
605
  /**
604
606
  * API refresh token
605
607
  * @param api Current API
@@ -41,6 +41,9 @@ class CoreApp {
41
41
  get deviceId() {
42
42
  return this._deviceId;
43
43
  }
44
+ set deviceId(value) {
45
+ this._deviceId = value;
46
+ }
44
47
  /**
45
48
  * Label delegate
46
49
  */
@@ -1433,12 +1436,21 @@ class CoreApp {
1433
1436
  exchangeTokenUpdate(api, data) { }
1434
1437
  /**
1435
1438
  * Exchange intergration tokens for all APIs
1436
- * @param token Core system's refresh token to exchange
1439
+ * @param coreData Core system's token data to exchange
1440
+ * @param coreName Core system's name, default is 'core'
1437
1441
  */
1438
- exchangeTokenAll(token) {
1442
+ exchangeTokenAll(coreData, coreName) {
1443
+ coreName ?? (coreName = 'core');
1439
1444
  for (const name in this.apis) {
1440
1445
  const api = this.apis[name];
1441
- this.exchangeToken(api[0], token);
1446
+ // The core API
1447
+ if (api[0].name === coreName) {
1448
+ api[0].authorize(coreData.tokenType, coreData.accessToken);
1449
+ this.updateApi(api, coreData.refreshToken, coreData.expiresIn);
1450
+ }
1451
+ else {
1452
+ this.exchangeToken(api[0], coreData.refreshToken);
1453
+ }
1442
1454
  }
1443
1455
  }
1444
1456
  /**
@@ -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 token Core system's refresh token to exchange
283
+ * @param coreData Core system's token data to exchange
284
+ * @param coreName Core system's name, default is 'core'
283
285
  */
284
- exchangeTokenAll(token: string): void;
286
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
285
287
  /**
286
288
  * Format date to string
287
289
  * @param input Input date
@@ -90,6 +90,7 @@ 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);
93
94
  /**
94
95
  * Label delegate
95
96
  */
@@ -597,9 +598,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
597
598
  protected exchangeTokenUpdate(api: IApi, data: ApiRefreshTokenDto): void;
598
599
  /**
599
600
  * Exchange intergration tokens for all APIs
600
- * @param token Core system's refresh token to exchange
601
+ * @param coreData Core system's token data to exchange
602
+ * @param coreName Core system's name, default is 'core'
601
603
  */
602
- exchangeTokenAll(token: string): void;
604
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
603
605
  /**
604
606
  * API refresh token
605
607
  * @param api Current API
@@ -38,6 +38,9 @@ export class CoreApp {
38
38
  get deviceId() {
39
39
  return this._deviceId;
40
40
  }
41
+ set deviceId(value) {
42
+ this._deviceId = value;
43
+ }
41
44
  /**
42
45
  * Label delegate
43
46
  */
@@ -1430,12 +1433,21 @@ export class CoreApp {
1430
1433
  exchangeTokenUpdate(api, data) { }
1431
1434
  /**
1432
1435
  * Exchange intergration tokens for all APIs
1433
- * @param token Core system's refresh token to exchange
1436
+ * @param coreData Core system's token data to exchange
1437
+ * @param coreName Core system's name, default is 'core'
1434
1438
  */
1435
- exchangeTokenAll(token) {
1439
+ exchangeTokenAll(coreData, coreName) {
1440
+ coreName ?? (coreName = 'core');
1436
1441
  for (const name in this.apis) {
1437
1442
  const api = this.apis[name];
1438
- this.exchangeToken(api[0], token);
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
+ }
1439
1451
  }
1440
1452
  }
1441
1453
  /**
@@ -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 token Core system's refresh token to exchange
283
+ * @param coreData Core system's token data to exchange
284
+ * @param coreName Core system's name, default is 'core'
283
285
  */
284
- exchangeTokenAll(token: string): void;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.24",
3
+ "version": "1.5.26",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -68,6 +68,6 @@
68
68
  "jest": "^29.7.0",
69
69
  "jest-environment-jsdom": "^29.7.0",
70
70
  "ts-jest": "^29.2.5",
71
- "typescript": "^5.6.2"
71
+ "typescript": "^5.6.3"
72
72
  }
73
73
  }
@@ -172,6 +172,9 @@ export abstract class CoreApp<
172
172
  get deviceId() {
173
173
  return this._deviceId;
174
174
  }
175
+ protected set deviceId(value: string) {
176
+ this._deviceId = value;
177
+ }
175
178
 
176
179
  /**
177
180
  * Label delegate
@@ -1986,12 +1989,22 @@ export abstract class CoreApp<
1986
1989
 
1987
1990
  /**
1988
1991
  * Exchange intergration tokens for all APIs
1989
- * @param token Core system's refresh token to exchange
1992
+ * @param coreData Core system's token data to exchange
1993
+ * @param coreName Core system's name, default is 'core'
1990
1994
  */
1991
- exchangeTokenAll(token: string) {
1995
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string) {
1996
+ coreName ??= 'core';
1997
+
1992
1998
  for (const name in this.apis) {
1993
1999
  const api = this.apis[name];
1994
- this.exchangeToken(api[0], token);
2000
+
2001
+ // The core API
2002
+ if (api[0].name === coreName) {
2003
+ api[0].authorize(coreData.tokenType, coreData.accessToken);
2004
+ this.updateApi(api, coreData.refreshToken, coreData.expiresIn);
2005
+ } else {
2006
+ this.exchangeToken(api[0], coreData.refreshToken);
2007
+ }
1995
2008
  }
1996
2009
  }
1997
2010
 
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 token Core system's refresh token to exchange
386
+ * @param coreData Core system's token data to exchange
387
+ * @param coreName Core system's name, default is 'core'
386
388
  */
387
- exchangeTokenAll(token: string): void;
389
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
388
390
 
389
391
  /**
390
392
  * Format date to string