@etsoo/appscript 1.2.39 → 1.2.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.
@@ -312,6 +312,11 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
312
312
  * Persist settings to source when application exit
313
313
  */
314
314
  persist(): void;
315
+ /**
316
+ * Redirect to the Url
317
+ * @param url Url
318
+ */
319
+ redirectTo(url: string): void;
315
320
  /**
316
321
  * Switch organization
317
322
  * @param id Organization id
@@ -684,6 +689,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
684
689
  * Callback where exit a page
685
690
  */
686
691
  pageExit(): void;
692
+ /**
693
+ * Redirect to the Url
694
+ * @param url Url
695
+ */
696
+ redirectTo(url: string): void;
687
697
  /**
688
698
  * Refresh countdown
689
699
  * @param seconds Seconds
@@ -802,6 +802,13 @@ class CoreApp {
802
802
  var _a;
803
803
  (_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.dismiss();
804
804
  }
805
+ /**
806
+ * Redirect to the Url
807
+ * @param url Url
808
+ */
809
+ redirectTo(url) {
810
+ window.location.href = url;
811
+ }
805
812
  /**
806
813
  * Refresh countdown
807
814
  * @param seconds Seconds
@@ -900,7 +907,7 @@ class CoreApp {
900
907
  */
901
908
  toLoginPage(tryLogin) {
902
909
  const url = this.transformUrl('/' + (tryLogin ? '' : '?tryLogin=false'));
903
- window.location.replace(this.transformUrl('/'));
910
+ this.redirectTo(url);
904
911
  }
905
912
  /**
906
913
  * Transform URL
@@ -1,4 +1,4 @@
1
- import { IActionResult, IResultData } from './IActionResult';
1
+ import { IActionResult } from './IActionResult';
2
2
  /**
3
3
  * Action result
4
4
  */
@@ -7,5 +7,5 @@ export declare class ActionResult {
7
7
  * Create a result from error
8
8
  * @returns Action result interface
9
9
  */
10
- static create<D extends IResultData = IResultData>(error: Error): IActionResult<D>;
10
+ static create<D extends {} = {}>(error: Error): IActionResult<D>;
11
11
  }
@@ -1,19 +1,4 @@
1
- /**
2
- * Result data
3
- * Indexable type
4
- */
5
- export interface IResultData {
6
- readonly [key: string]: any;
7
- }
8
- /**
9
- * Result data with id, follow this style to extend for specific model
10
- */
11
- export interface IdResultData extends IResultData {
12
- /**
13
- * Id
14
- */
15
- id: number | string;
16
- }
1
+ import { DataTypes } from '@etsoo/shared';
17
2
  /**
18
3
  * Result errors
19
4
  * Indexable type
@@ -24,7 +9,7 @@ export interface IResultErrors {
24
9
  /**
25
10
  * Operation result interface
26
11
  */
27
- export interface IActionResult<D extends IResultData = IResultData> {
12
+ export interface IActionResult<D extends {} = {}> {
28
13
  /**
29
14
  * Status code
30
15
  */
@@ -65,4 +50,10 @@ export interface IActionResult<D extends IResultData = IResultData> {
65
50
  /**
66
51
  * Action result with id data
67
52
  */
68
- export declare type ActionResultId = IActionResult<IdResultData>;
53
+ export declare type IdActionResult<T extends DataTypes.IdType = number> = IActionResult<{
54
+ id: T;
55
+ }>;
56
+ /**
57
+ * Action result with dynamic data
58
+ */
59
+ export declare type DynamicActionResult = IActionResult<Record<string, any>>;
@@ -1,8 +1,8 @@
1
- import { IActionResult, IResultData } from './IActionResult';
1
+ import { IActionResult } from './IActionResult';
2
2
  /**
3
3
  * Init call result data
4
4
  */
5
- export interface InitCallResultData extends IResultData {
5
+ export interface InitCallResultData {
6
6
  /**
7
7
  * Device id
8
8
  */
@@ -312,6 +312,11 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
312
312
  * Persist settings to source when application exit
313
313
  */
314
314
  persist(): void;
315
+ /**
316
+ * Redirect to the Url
317
+ * @param url Url
318
+ */
319
+ redirectTo(url: string): void;
315
320
  /**
316
321
  * Switch organization
317
322
  * @param id Organization id
@@ -684,6 +689,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
684
689
  * Callback where exit a page
685
690
  */
686
691
  pageExit(): void;
692
+ /**
693
+ * Redirect to the Url
694
+ * @param url Url
695
+ */
696
+ redirectTo(url: string): void;
687
697
  /**
688
698
  * Refresh countdown
689
699
  * @param seconds Seconds
@@ -799,6 +799,13 @@ export class CoreApp {
799
799
  var _a;
800
800
  (_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.dismiss();
801
801
  }
802
+ /**
803
+ * Redirect to the Url
804
+ * @param url Url
805
+ */
806
+ redirectTo(url) {
807
+ window.location.href = url;
808
+ }
802
809
  /**
803
810
  * Refresh countdown
804
811
  * @param seconds Seconds
@@ -897,7 +904,7 @@ export class CoreApp {
897
904
  */
898
905
  toLoginPage(tryLogin) {
899
906
  const url = this.transformUrl('/' + (tryLogin ? '' : '?tryLogin=false'));
900
- window.location.replace(this.transformUrl('/'));
907
+ this.redirectTo(url);
901
908
  }
902
909
  /**
903
910
  * Transform URL
@@ -1,4 +1,4 @@
1
- import { IActionResult, IResultData } from './IActionResult';
1
+ import { IActionResult } from './IActionResult';
2
2
  /**
3
3
  * Action result
4
4
  */
@@ -7,5 +7,5 @@ export declare class ActionResult {
7
7
  * Create a result from error
8
8
  * @returns Action result interface
9
9
  */
10
- static create<D extends IResultData = IResultData>(error: Error): IActionResult<D>;
10
+ static create<D extends {} = {}>(error: Error): IActionResult<D>;
11
11
  }
@@ -1,19 +1,4 @@
1
- /**
2
- * Result data
3
- * Indexable type
4
- */
5
- export interface IResultData {
6
- readonly [key: string]: any;
7
- }
8
- /**
9
- * Result data with id, follow this style to extend for specific model
10
- */
11
- export interface IdResultData extends IResultData {
12
- /**
13
- * Id
14
- */
15
- id: number | string;
16
- }
1
+ import { DataTypes } from '@etsoo/shared';
17
2
  /**
18
3
  * Result errors
19
4
  * Indexable type
@@ -24,7 +9,7 @@ export interface IResultErrors {
24
9
  /**
25
10
  * Operation result interface
26
11
  */
27
- export interface IActionResult<D extends IResultData = IResultData> {
12
+ export interface IActionResult<D extends {} = {}> {
28
13
  /**
29
14
  * Status code
30
15
  */
@@ -65,4 +50,10 @@ export interface IActionResult<D extends IResultData = IResultData> {
65
50
  /**
66
51
  * Action result with id data
67
52
  */
68
- export declare type ActionResultId = IActionResult<IdResultData>;
53
+ export declare type IdActionResult<T extends DataTypes.IdType = number> = IActionResult<{
54
+ id: T;
55
+ }>;
56
+ /**
57
+ * Action result with dynamic data
58
+ */
59
+ export declare type DynamicActionResult = IActionResult<Record<string, any>>;
@@ -1,8 +1,8 @@
1
- import { IActionResult, IResultData } from './IActionResult';
1
+ import { IActionResult } from './IActionResult';
2
2
  /**
3
3
  * Init call result data
4
4
  */
5
- export interface InitCallResultData extends IResultData {
5
+ export interface InitCallResultData {
6
6
  /**
7
7
  * Device id
8
8
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.39",
3
+ "version": "1.2.43",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -428,6 +428,12 @@ export interface ICoreApp<
428
428
  */
429
429
  persist(): void;
430
430
 
431
+ /**
432
+ * Redirect to the Url
433
+ * @param url Url
434
+ */
435
+ redirectTo(url: string): void;
436
+
431
437
  /**
432
438
  * Switch organization
433
439
  * @param id Organization id
@@ -1496,6 +1502,14 @@ export abstract class CoreApp<
1496
1502
  this.lastWarning?.dismiss();
1497
1503
  }
1498
1504
 
1505
+ /**
1506
+ * Redirect to the Url
1507
+ * @param url Url
1508
+ */
1509
+ redirectTo(url: string): void {
1510
+ window.location.href = url;
1511
+ }
1512
+
1499
1513
  /**
1500
1514
  * Refresh countdown
1501
1515
  * @param seconds Seconds
@@ -1618,7 +1632,7 @@ export abstract class CoreApp<
1618
1632
  const url = this.transformUrl(
1619
1633
  '/' + (tryLogin ? '' : '?tryLogin=false')
1620
1634
  );
1621
- window.location.replace(this.transformUrl('/'));
1635
+ this.redirectTo(url);
1622
1636
  }
1623
1637
 
1624
1638
  /**
@@ -1,5 +1,5 @@
1
1
  import { ApiError } from '@etsoo/restclient';
2
- import { IActionResult, IResultData } from './IActionResult';
2
+ import { IActionResult } from './IActionResult';
3
3
 
4
4
  /**
5
5
  * Action result
@@ -9,7 +9,7 @@ export class ActionResult {
9
9
  * Create a result from error
10
10
  * @returns Action result interface
11
11
  */
12
- static create<D extends IResultData = IResultData>(error: Error) {
12
+ static create<D extends {} = {}>(error: Error) {
13
13
  // If the error is ApiError, hold the status
14
14
  const status = error instanceof ApiError ? error.status : undefined;
15
15
 
@@ -1,20 +1,4 @@
1
- /**
2
- * Result data
3
- * Indexable type
4
- */
5
- export interface IResultData {
6
- readonly [key: string]: any;
7
- }
8
-
9
- /**
10
- * Result data with id, follow this style to extend for specific model
11
- */
12
- export interface IdResultData extends IResultData {
13
- /**
14
- * Id
15
- */
16
- id: number | string;
17
- }
1
+ import { DataTypes } from '@etsoo/shared';
18
2
 
19
3
  /**
20
4
  * Result errors
@@ -27,7 +11,7 @@ export interface IResultErrors {
27
11
  /**
28
12
  * Operation result interface
29
13
  */
30
- export interface IActionResult<D extends IResultData = IResultData> {
14
+ export interface IActionResult<D extends {} = {}> {
31
15
  /**
32
16
  * Status code
33
17
  */
@@ -77,4 +61,12 @@ export interface IActionResult<D extends IResultData = IResultData> {
77
61
  /**
78
62
  * Action result with id data
79
63
  */
80
- export type ActionResultId = IActionResult<IdResultData>;
64
+ export type IdActionResult<T extends DataTypes.IdType = number> =
65
+ IActionResult<{
66
+ id: T;
67
+ }>;
68
+
69
+ /**
70
+ * Action result with dynamic data
71
+ */
72
+ export type DynamicActionResult = IActionResult<Record<string, any>>;
@@ -1,9 +1,9 @@
1
- import { IActionResult, IResultData } from './IActionResult';
1
+ import { IActionResult } from './IActionResult';
2
2
 
3
3
  /**
4
4
  * Init call result data
5
5
  */
6
- export interface InitCallResultData extends IResultData {
6
+ export interface InitCallResultData {
7
7
  /**
8
8
  * Device id
9
9
  */