@etsoo/appscript 1.5.24 → 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.
@@ -597,9 +597,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
597
597
  protected exchangeTokenUpdate(api: IApi, data: ApiRefreshTokenDto): void;
598
598
  /**
599
599
  * Exchange intergration tokens for all APIs
600
- * @param token Core system's refresh token to exchange
600
+ * @param coreData Core system's token data to exchange
601
+ * @param coreName Core system's name, default is 'core'
601
602
  */
602
- exchangeTokenAll(token: string): void;
603
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
603
604
  /**
604
605
  * API refresh token
605
606
  * @param api Current API
@@ -1433,12 +1433,21 @@ class CoreApp {
1433
1433
  exchangeTokenUpdate(api, data) { }
1434
1434
  /**
1435
1435
  * Exchange intergration tokens for all APIs
1436
- * @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'
1437
1438
  */
1438
- exchangeTokenAll(token) {
1439
+ exchangeTokenAll(coreData, coreName) {
1440
+ coreName ?? (coreName = 'core');
1439
1441
  for (const name in this.apis) {
1440
1442
  const api = this.apis[name];
1441
- 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
+ }
1442
1451
  }
1443
1452
  }
1444
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
@@ -597,9 +597,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
597
597
  protected exchangeTokenUpdate(api: IApi, data: ApiRefreshTokenDto): void;
598
598
  /**
599
599
  * Exchange intergration tokens for all APIs
600
- * @param token Core system's refresh token to exchange
600
+ * @param coreData Core system's token data to exchange
601
+ * @param coreName Core system's name, default is 'core'
601
602
  */
602
- exchangeTokenAll(token: string): void;
603
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string): void;
603
604
  /**
604
605
  * API refresh token
605
606
  * @param api Current API
@@ -1430,12 +1430,21 @@ export class CoreApp {
1430
1430
  exchangeTokenUpdate(api, data) { }
1431
1431
  /**
1432
1432
  * Exchange intergration tokens for all APIs
1433
- * @param token Core system's refresh token to exchange
1433
+ * @param coreData Core system's token data to exchange
1434
+ * @param coreName Core system's name, default is 'core'
1434
1435
  */
1435
- exchangeTokenAll(token) {
1436
+ exchangeTokenAll(coreData, coreName) {
1437
+ coreName ?? (coreName = 'core');
1436
1438
  for (const name in this.apis) {
1437
1439
  const api = this.apis[name];
1438
- this.exchangeToken(api[0], token);
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
+ }
1439
1448
  }
1440
1449
  }
1441
1450
  /**
@@ -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.25",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -1986,12 +1986,22 @@ export abstract class CoreApp<
1986
1986
 
1987
1987
  /**
1988
1988
  * Exchange intergration tokens for all APIs
1989
- * @param token Core system's refresh token to exchange
1989
+ * @param coreData Core system's token data to exchange
1990
+ * @param coreName Core system's name, default is 'core'
1990
1991
  */
1991
- exchangeTokenAll(token: string) {
1992
+ exchangeTokenAll(coreData: ApiRefreshTokenDto, coreName?: string) {
1993
+ coreName ??= 'core';
1994
+
1992
1995
  for (const name in this.apis) {
1993
1996
  const api = this.apis[name];
1994
- this.exchangeToken(api[0], token);
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
+ }
1995
2005
  }
1996
2006
  }
1997
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 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