@etsoo/appscript 1.5.42 → 1.5.43

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.
@@ -420,17 +420,6 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
420
420
  * @returns Error message
421
421
  */
422
422
  formatError(error: ApiDataError): string;
423
- /**
424
- * Refresh token failed
425
- */
426
- protected refreshTokenFailed(): void;
427
- /**
428
- * Do refresh token result
429
- * @param result Result
430
- * @param initCallCallback InitCall callback
431
- * @param silent Silent without any popups
432
- */
433
- doRefreshTokenResult(result: RefreshTokenResult<IActionResult<U>>, initCallCallback?: (result: boolean) => void, silent?: boolean): void;
434
423
  /**
435
424
  * Format as full name
436
425
  * @param familyName Family name
@@ -442,7 +431,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
442
431
  * @param result Refresh token result
443
432
  * @returns Message
444
433
  */
445
- formatRefreshTokenResult(result: RefreshTokenResult<IActionResult<U>>): string | undefined;
434
+ protected formatRefreshTokenResult(result: RefreshTokenResult<IActionResult<U>>): string | undefined;
446
435
  private getFieldLabel;
447
436
  /**
448
437
  * Format result text
@@ -593,7 +582,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
593
582
  * Refresh token
594
583
  * @param props Props
595
584
  */
596
- refreshToken(props?: RefreshTokenProps): Promise<boolean>;
585
+ refreshToken(props?: RefreshTokenProps): Promise<void>;
597
586
  /**
598
587
  * Setup callback
599
588
  */
@@ -643,7 +632,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
643
632
  * UI get involved while refreshToken not intended
644
633
  * @param params Login parameters
645
634
  */
646
- tryLogin(params?: AppLoginParams): Promise<boolean>;
635
+ tryLogin(params?: AppLoginParams): Promise<void>;
647
636
  /**
648
637
  * Update embedded status
649
638
  * @param embedded New embedded status
@@ -1004,44 +1004,6 @@ class CoreApp {
1004
1004
  formatError(error) {
1005
1005
  return `${error.message} (${error.name})`;
1006
1006
  }
1007
- /**
1008
- * Refresh token failed
1009
- */
1010
- refreshTokenFailed() {
1011
- this.userUnauthorized();
1012
- this.toLoginPage();
1013
- }
1014
- /**
1015
- * Do refresh token result
1016
- * @param result Result
1017
- * @param initCallCallback InitCall callback
1018
- * @param silent Silent without any popups
1019
- */
1020
- doRefreshTokenResult(result, initCallCallback, silent = false) {
1021
- if (Array.isArray(result) &&
1022
- !(result instanceof restclient_1.ApiDataError) &&
1023
- this.checkDeviceResult(result[1])) {
1024
- initCallCallback ?? (initCallCallback = (result) => {
1025
- if (!result)
1026
- return;
1027
- this.notifier.alert(this.get('environmentChanged') ??
1028
- 'Environment changed', () => {
1029
- // Reload the page
1030
- history.go(0);
1031
- });
1032
- });
1033
- this.initCall(initCallCallback, true);
1034
- return;
1035
- }
1036
- const message = this.formatRefreshTokenResult(result);
1037
- if (message == null || silent) {
1038
- this.refreshTokenFailed();
1039
- return;
1040
- }
1041
- this.notifier.alert(message, () => {
1042
- this.refreshTokenFailed();
1043
- });
1044
- }
1045
1007
  /**
1046
1008
  * Format as full name
1047
1009
  * @param familyName Family name
@@ -1415,9 +1377,7 @@ class CoreApp {
1415
1377
  * Refresh token
1416
1378
  * @param props Props
1417
1379
  */
1418
- async refreshToken(props) {
1419
- return true;
1420
- }
1380
+ async refreshToken(props) { }
1421
1381
  /**
1422
1382
  * Setup callback
1423
1383
  */
@@ -1611,10 +1571,9 @@ class CoreApp {
1611
1571
  async tryLogin(params) {
1612
1572
  // Check status
1613
1573
  if (this._isTryingLogin)
1614
- return false;
1574
+ return;
1615
1575
  this._isTryingLogin = true;
1616
1576
  this.toLoginPage(params);
1617
- return true;
1618
1577
  }
1619
1578
  /**
1620
1579
  * Update embedded status
@@ -65,6 +65,11 @@ export interface RefreshTokenProps {
65
65
  * API name
66
66
  */
67
67
  api?: string;
68
+ /**
69
+ * Callback
70
+ * @param result Result
71
+ */
72
+ callback?: (result: boolean) => void;
68
73
  /**
69
74
  * Show loading bar or not
70
75
  */
@@ -350,25 +355,12 @@ export interface IApp {
350
355
  * @returns Result
351
356
  */
352
357
  formatNumber(input: number | bigint, options?: Intl.NumberFormatOptions): string;
353
- /**
354
- * Do refresh token result
355
- * @param result Result
356
- * @param initCallCallback InitCall callback
357
- * @param silent Silent without any popups
358
- */
359
- doRefreshTokenResult(result: RefreshTokenResult<IActionResult<IUser>>, initCallCallback?: (result: boolean) => void, silent?: boolean): void;
360
358
  /**
361
359
  * Format as full name
362
360
  * @param familyName Family name
363
361
  * @param givenName Given name
364
362
  */
365
363
  formatFullName(familyName: string | undefined | null, givenName: string | undefined | null): string;
366
- /**
367
- * Format refresh token result
368
- * @param result Refresh token result
369
- * @returns Message
370
- */
371
- formatRefreshTokenResult(result: RefreshTokenResult<IActionResult<IUser>>): string | undefined;
372
364
  /**
373
365
  * Format result text
374
366
  * @param result Action result
@@ -531,7 +523,7 @@ export interface IApp {
531
523
  * Refresh token
532
524
  * @param props Props
533
525
  */
534
- refreshToken(props?: RefreshTokenProps): Promise<boolean>;
526
+ refreshToken(props?: RefreshTokenProps): Promise<void>;
535
527
  /**
536
528
  * Setup Api error handler
537
529
  * @param api Api
@@ -567,7 +559,7 @@ export interface IApp {
567
559
  * UI get involved while refreshToken not intended
568
560
  * @param params Login parameters
569
561
  */
570
- tryLogin(params?: AppLoginParams): Promise<boolean>;
562
+ tryLogin(params?: AppLoginParams): Promise<void>;
571
563
  /**
572
564
  * Update API token and expires
573
565
  * @param name Api name
@@ -63,7 +63,7 @@ export declare class OrgApi extends EntityApi {
63
63
  * @param serviceId Service id
64
64
  * @param payload Payload
65
65
  */
66
- switch(id: number, serviceId?: number, payload?: IApiPayload<boolean>): Promise<boolean | undefined>;
66
+ switch(id: number, serviceId?: number, payload?: IApiPayload<boolean>): Promise<false | void>;
67
67
  /**
68
68
  * Update
69
69
  * @param data Modal data
@@ -420,17 +420,6 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
420
420
  * @returns Error message
421
421
  */
422
422
  formatError(error: ApiDataError): string;
423
- /**
424
- * Refresh token failed
425
- */
426
- protected refreshTokenFailed(): void;
427
- /**
428
- * Do refresh token result
429
- * @param result Result
430
- * @param initCallCallback InitCall callback
431
- * @param silent Silent without any popups
432
- */
433
- doRefreshTokenResult(result: RefreshTokenResult<IActionResult<U>>, initCallCallback?: (result: boolean) => void, silent?: boolean): void;
434
423
  /**
435
424
  * Format as full name
436
425
  * @param familyName Family name
@@ -442,7 +431,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
442
431
  * @param result Refresh token result
443
432
  * @returns Message
444
433
  */
445
- formatRefreshTokenResult(result: RefreshTokenResult<IActionResult<U>>): string | undefined;
434
+ protected formatRefreshTokenResult(result: RefreshTokenResult<IActionResult<U>>): string | undefined;
446
435
  private getFieldLabel;
447
436
  /**
448
437
  * Format result text
@@ -593,7 +582,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
593
582
  * Refresh token
594
583
  * @param props Props
595
584
  */
596
- refreshToken(props?: RefreshTokenProps): Promise<boolean>;
585
+ refreshToken(props?: RefreshTokenProps): Promise<void>;
597
586
  /**
598
587
  * Setup callback
599
588
  */
@@ -643,7 +632,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
643
632
  * UI get involved while refreshToken not intended
644
633
  * @param params Login parameters
645
634
  */
646
- tryLogin(params?: AppLoginParams): Promise<boolean>;
635
+ tryLogin(params?: AppLoginParams): Promise<void>;
647
636
  /**
648
637
  * Update embedded status
649
638
  * @param embedded New embedded status
@@ -1001,44 +1001,6 @@ export class CoreApp {
1001
1001
  formatError(error) {
1002
1002
  return `${error.message} (${error.name})`;
1003
1003
  }
1004
- /**
1005
- * Refresh token failed
1006
- */
1007
- refreshTokenFailed() {
1008
- this.userUnauthorized();
1009
- this.toLoginPage();
1010
- }
1011
- /**
1012
- * Do refresh token result
1013
- * @param result Result
1014
- * @param initCallCallback InitCall callback
1015
- * @param silent Silent without any popups
1016
- */
1017
- doRefreshTokenResult(result, initCallCallback, silent = false) {
1018
- if (Array.isArray(result) &&
1019
- !(result instanceof ApiDataError) &&
1020
- this.checkDeviceResult(result[1])) {
1021
- initCallCallback ?? (initCallCallback = (result) => {
1022
- if (!result)
1023
- return;
1024
- this.notifier.alert(this.get('environmentChanged') ??
1025
- 'Environment changed', () => {
1026
- // Reload the page
1027
- history.go(0);
1028
- });
1029
- });
1030
- this.initCall(initCallCallback, true);
1031
- return;
1032
- }
1033
- const message = this.formatRefreshTokenResult(result);
1034
- if (message == null || silent) {
1035
- this.refreshTokenFailed();
1036
- return;
1037
- }
1038
- this.notifier.alert(message, () => {
1039
- this.refreshTokenFailed();
1040
- });
1041
- }
1042
1004
  /**
1043
1005
  * Format as full name
1044
1006
  * @param familyName Family name
@@ -1412,9 +1374,7 @@ export class CoreApp {
1412
1374
  * Refresh token
1413
1375
  * @param props Props
1414
1376
  */
1415
- async refreshToken(props) {
1416
- return true;
1417
- }
1377
+ async refreshToken(props) { }
1418
1378
  /**
1419
1379
  * Setup callback
1420
1380
  */
@@ -1608,10 +1568,9 @@ export class CoreApp {
1608
1568
  async tryLogin(params) {
1609
1569
  // Check status
1610
1570
  if (this._isTryingLogin)
1611
- return false;
1571
+ return;
1612
1572
  this._isTryingLogin = true;
1613
1573
  this.toLoginPage(params);
1614
- return true;
1615
1574
  }
1616
1575
  /**
1617
1576
  * Update embedded status
@@ -65,6 +65,11 @@ export interface RefreshTokenProps {
65
65
  * API name
66
66
  */
67
67
  api?: string;
68
+ /**
69
+ * Callback
70
+ * @param result Result
71
+ */
72
+ callback?: (result: boolean) => void;
68
73
  /**
69
74
  * Show loading bar or not
70
75
  */
@@ -350,25 +355,12 @@ export interface IApp {
350
355
  * @returns Result
351
356
  */
352
357
  formatNumber(input: number | bigint, options?: Intl.NumberFormatOptions): string;
353
- /**
354
- * Do refresh token result
355
- * @param result Result
356
- * @param initCallCallback InitCall callback
357
- * @param silent Silent without any popups
358
- */
359
- doRefreshTokenResult(result: RefreshTokenResult<IActionResult<IUser>>, initCallCallback?: (result: boolean) => void, silent?: boolean): void;
360
358
  /**
361
359
  * Format as full name
362
360
  * @param familyName Family name
363
361
  * @param givenName Given name
364
362
  */
365
363
  formatFullName(familyName: string | undefined | null, givenName: string | undefined | null): string;
366
- /**
367
- * Format refresh token result
368
- * @param result Refresh token result
369
- * @returns Message
370
- */
371
- formatRefreshTokenResult(result: RefreshTokenResult<IActionResult<IUser>>): string | undefined;
372
364
  /**
373
365
  * Format result text
374
366
  * @param result Action result
@@ -531,7 +523,7 @@ export interface IApp {
531
523
  * Refresh token
532
524
  * @param props Props
533
525
  */
534
- refreshToken(props?: RefreshTokenProps): Promise<boolean>;
526
+ refreshToken(props?: RefreshTokenProps): Promise<void>;
535
527
  /**
536
528
  * Setup Api error handler
537
529
  * @param api Api
@@ -567,7 +559,7 @@ export interface IApp {
567
559
  * UI get involved while refreshToken not intended
568
560
  * @param params Login parameters
569
561
  */
570
- tryLogin(params?: AppLoginParams): Promise<boolean>;
562
+ tryLogin(params?: AppLoginParams): Promise<void>;
571
563
  /**
572
564
  * Update API token and expires
573
565
  * @param name Api name
@@ -63,7 +63,7 @@ export declare class OrgApi extends EntityApi {
63
63
  * @param serviceId Service id
64
64
  * @param payload Payload
65
65
  */
66
- switch(id: number, serviceId?: number, payload?: IApiPayload<boolean>): Promise<boolean | undefined>;
66
+ switch(id: number, serviceId?: number, payload?: IApiPayload<boolean>): Promise<false | void>;
67
67
  /**
68
68
  * Update
69
69
  * @param data Modal data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.42",
3
+ "version": "1.5.43",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -1476,57 +1476,6 @@ export abstract class CoreApp<
1476
1476
  return `${error.message} (${error.name})`;
1477
1477
  }
1478
1478
 
1479
- /**
1480
- * Refresh token failed
1481
- */
1482
- protected refreshTokenFailed() {
1483
- this.userUnauthorized();
1484
- this.toLoginPage();
1485
- }
1486
-
1487
- /**
1488
- * Do refresh token result
1489
- * @param result Result
1490
- * @param initCallCallback InitCall callback
1491
- * @param silent Silent without any popups
1492
- */
1493
- doRefreshTokenResult(
1494
- result: RefreshTokenResult<IActionResult<U>>,
1495
- initCallCallback?: (result: boolean) => void,
1496
- silent: boolean = false
1497
- ) {
1498
- if (
1499
- Array.isArray(result) &&
1500
- !(result instanceof ApiDataError) &&
1501
- this.checkDeviceResult(result[1])
1502
- ) {
1503
- initCallCallback ??= (result) => {
1504
- if (!result) return;
1505
- this.notifier.alert(
1506
- this.get<string>('environmentChanged') ??
1507
- 'Environment changed',
1508
- () => {
1509
- // Reload the page
1510
- history.go(0);
1511
- }
1512
- );
1513
- };
1514
-
1515
- this.initCall(initCallCallback, true);
1516
- return;
1517
- }
1518
-
1519
- const message = this.formatRefreshTokenResult(result);
1520
- if (message == null || silent) {
1521
- this.refreshTokenFailed();
1522
- return;
1523
- }
1524
-
1525
- this.notifier.alert(message, () => {
1526
- this.refreshTokenFailed();
1527
- });
1528
- }
1529
-
1530
1479
  /**
1531
1480
  * Format as full name
1532
1481
  * @param familyName Family name
@@ -1550,7 +1499,9 @@ export abstract class CoreApp<
1550
1499
  * @param result Refresh token result
1551
1500
  * @returns Message
1552
1501
  */
1553
- formatRefreshTokenResult(result: RefreshTokenResult<IActionResult<U>>) {
1502
+ protected formatRefreshTokenResult(
1503
+ result: RefreshTokenResult<IActionResult<U>>
1504
+ ): string | undefined {
1554
1505
  // Error message
1555
1506
  if (typeof result === 'string') return result;
1556
1507
 
@@ -1958,9 +1909,7 @@ export abstract class CoreApp<
1958
1909
  * Refresh token
1959
1910
  * @param props Props
1960
1911
  */
1961
- async refreshToken(props?: RefreshTokenProps) {
1962
- return true;
1963
- }
1912
+ async refreshToken(props?: RefreshTokenProps) {}
1964
1913
 
1965
1914
  /**
1966
1915
  * Setup callback
@@ -2203,12 +2152,10 @@ export abstract class CoreApp<
2203
2152
  */
2204
2153
  async tryLogin(params?: AppLoginParams) {
2205
2154
  // Check status
2206
- if (this._isTryingLogin) return false;
2155
+ if (this._isTryingLogin) return;
2207
2156
  this._isTryingLogin = true;
2208
2157
 
2209
2158
  this.toLoginPage(params);
2210
-
2211
- return true;
2212
2159
  }
2213
2160
 
2214
2161
  /**
package/src/app/IApp.ts CHANGED
@@ -92,6 +92,12 @@ export interface RefreshTokenProps {
92
92
  */
93
93
  api?: string;
94
94
 
95
+ /**
96
+ * Callback
97
+ * @param result Result
98
+ */
99
+ callback?: (result: boolean) => void;
100
+
95
101
  /**
96
102
  * Show loading bar or not
97
103
  */
@@ -473,18 +479,6 @@ export interface IApp {
473
479
  options?: Intl.NumberFormatOptions
474
480
  ): string;
475
481
 
476
- /**
477
- * Do refresh token result
478
- * @param result Result
479
- * @param initCallCallback InitCall callback
480
- * @param silent Silent without any popups
481
- */
482
- doRefreshTokenResult(
483
- result: RefreshTokenResult<IActionResult<IUser>>,
484
- initCallCallback?: (result: boolean) => void,
485
- silent?: boolean
486
- ): void;
487
-
488
482
  /**
489
483
  * Format as full name
490
484
  * @param familyName Family name
@@ -495,15 +489,6 @@ export interface IApp {
495
489
  givenName: string | undefined | null
496
490
  ): string;
497
491
 
498
- /**
499
- * Format refresh token result
500
- * @param result Refresh token result
501
- * @returns Message
502
- */
503
- formatRefreshTokenResult(
504
- result: RefreshTokenResult<IActionResult<IUser>>
505
- ): string | undefined;
506
-
507
492
  /**
508
493
  * Format result text
509
494
  * @param result Action result
@@ -719,7 +704,7 @@ export interface IApp {
719
704
  * Refresh token
720
705
  * @param props Props
721
706
  */
722
- refreshToken(props?: RefreshTokenProps): Promise<boolean>;
707
+ refreshToken(props?: RefreshTokenProps): Promise<void>;
723
708
 
724
709
  /**
725
710
  * Setup Api error handler
@@ -768,7 +753,7 @@ export interface IApp {
768
753
  * UI get involved while refreshToken not intended
769
754
  * @param params Login parameters
770
755
  */
771
- tryLogin(params?: AppLoginParams): Promise<boolean>;
756
+ tryLogin(params?: AppLoginParams): Promise<void>;
772
757
 
773
758
  /**
774
759
  * Update API token and expires