@etsoo/appscript 1.2.41 → 1.2.45

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
@@ -470,6 +475,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
470
475
  * Persist settings to source when application exit
471
476
  */
472
477
  persist(): void;
478
+ /**
479
+ * Add app name as identifier
480
+ * @param field Field
481
+ * @returns Result
482
+ */
483
+ protected addIdentifier(field: string): string;
473
484
  /**
474
485
  * Setup Api
475
486
  * @param api Api
@@ -684,6 +695,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
684
695
  * Callback where exit a page
685
696
  */
686
697
  pageExit(): void;
698
+ /**
699
+ * Redirect to the Url
700
+ * @param url Url
701
+ */
702
+ redirectTo(url: string): void;
687
703
  /**
688
704
  * Refresh countdown
689
705
  * @param seconds Seconds
@@ -119,7 +119,7 @@ class CoreApp {
119
119
  get persistedFields() {
120
120
  return [
121
121
  CoreApp.deviceIdField,
122
- CoreApp.devicePassphraseField,
122
+ this.addIdentifier(CoreApp.devicePassphraseField),
123
123
  CoreApp.serversideDeviceIdField,
124
124
  CoreApp.headerTokenField
125
125
  ];
@@ -129,7 +129,7 @@ class CoreApp {
129
129
  }
130
130
  resetKeys() {
131
131
  this.storage.clear([
132
- CoreApp.devicePassphraseField,
132
+ this.addIdentifier(CoreApp.devicePassphraseField),
133
133
  CoreApp.headerTokenField,
134
134
  CoreApp.serversideDeviceIdField
135
135
  ], false);
@@ -158,7 +158,8 @@ class CoreApp {
158
158
  this.resetKeys();
159
159
  return false;
160
160
  }
161
- const passphraseEncrypted = this.storage.getData(CoreApp.devicePassphraseField);
161
+ // this.name to identifier different app's secret
162
+ const passphraseEncrypted = this.storage.getData(this.addIdentifier(CoreApp.devicePassphraseField));
162
163
  if (passphraseEncrypted) {
163
164
  const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
164
165
  if (passphraseDecrypted != null) {
@@ -191,6 +192,14 @@ class CoreApp {
191
192
  return;
192
193
  this.storage.copyTo(this.persistedFields);
193
194
  }
195
+ /**
196
+ * Add app name as identifier
197
+ * @param field Field
198
+ * @returns Result
199
+ */
200
+ addIdentifier(field) {
201
+ return field + '-' + this.name;
202
+ }
194
203
  /**
195
204
  * Setup Api
196
205
  * @param api Api
@@ -313,7 +322,7 @@ class CoreApp {
313
322
  this.storage.setPersistedData(CoreApp.devicesField, devices);
314
323
  // Current passphrase
315
324
  this.passphrase = passphrase;
316
- this.storage.setData(CoreApp.devicePassphraseField, this.encrypt(passphrase, this.name));
325
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), this.encrypt(passphrase, this.name));
317
326
  // Previous passphrase
318
327
  if (data.previousPassphrase) {
319
328
  const prev = this.decrypt(data.previousPassphrase, timestamp.toString());
@@ -443,7 +452,7 @@ class CoreApp {
443
452
  */
444
453
  clearCacheData() {
445
454
  this.clearCacheToken();
446
- this.storage.setData(CoreApp.devicePassphraseField, undefined);
455
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), undefined);
447
456
  }
448
457
  /**
449
458
  * Clear cached token
@@ -802,6 +811,13 @@ class CoreApp {
802
811
  var _a;
803
812
  (_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.dismiss();
804
813
  }
814
+ /**
815
+ * Redirect to the Url
816
+ * @param url Url
817
+ */
818
+ redirectTo(url) {
819
+ window.location.href = url;
820
+ }
805
821
  /**
806
822
  * Refresh countdown
807
823
  * @param seconds Seconds
@@ -900,7 +916,7 @@ class CoreApp {
900
916
  */
901
917
  toLoginPage(tryLogin) {
902
918
  const url = this.transformUrl('/' + (tryLogin ? '' : '?tryLogin=false'));
903
- window.location.replace(this.transformUrl('/'));
919
+ this.redirectTo(url);
904
920
  }
905
921
  /**
906
922
  * Transform URL
@@ -14,6 +14,7 @@ export interface IBridgeHost {
14
14
  /**
15
15
  * Load application
16
16
  * @param name App name
17
+ * @param startUrl Start Url
17
18
  */
18
- loadApp(name: string): void;
19
+ loadApp(name: string, startUrl?: string): void;
19
20
  }
@@ -87,7 +87,7 @@
87
87
  "settings": "系统设置",
88
88
  "showIt": "显示",
89
89
  "signout": "退出",
90
- "smartERP": "司友云ERP",
90
+ "smartERP": "司友®云ERP",
91
91
  "sortTip": "拖拽项目进行排序",
92
92
  "status": "状态",
93
93
  "statusApproved": "已批准",
@@ -87,7 +87,7 @@
87
87
  "settings": "系統設置",
88
88
  "showIt": "顯示",
89
89
  "signout": "退出",
90
- "smartERP": "司友雲ERP",
90
+ "smartERP": "司友®雲ERP",
91
91
  "sortTip": "拖拽項目進行排序",
92
92
  "status": "狀態",
93
93
  "statusApproved": "已批准",
@@ -53,3 +53,7 @@ export interface IActionResult<D extends {} = {}> {
53
53
  export declare type IdActionResult<T extends DataTypes.IdType = number> = IActionResult<{
54
54
  id: T;
55
55
  }>;
56
+ /**
57
+ * Action result with dynamic data
58
+ */
59
+ export declare type DynamicActionResult = IActionResult<Record<string, any>>;
@@ -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
@@ -470,6 +475,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
470
475
  * Persist settings to source when application exit
471
476
  */
472
477
  persist(): void;
478
+ /**
479
+ * Add app name as identifier
480
+ * @param field Field
481
+ * @returns Result
482
+ */
483
+ protected addIdentifier(field: string): string;
473
484
  /**
474
485
  * Setup Api
475
486
  * @param api Api
@@ -684,6 +695,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
684
695
  * Callback where exit a page
685
696
  */
686
697
  pageExit(): void;
698
+ /**
699
+ * Redirect to the Url
700
+ * @param url Url
701
+ */
702
+ redirectTo(url: string): void;
687
703
  /**
688
704
  * Refresh countdown
689
705
  * @param seconds Seconds
@@ -116,7 +116,7 @@ export class CoreApp {
116
116
  get persistedFields() {
117
117
  return [
118
118
  CoreApp.deviceIdField,
119
- CoreApp.devicePassphraseField,
119
+ this.addIdentifier(CoreApp.devicePassphraseField),
120
120
  CoreApp.serversideDeviceIdField,
121
121
  CoreApp.headerTokenField
122
122
  ];
@@ -126,7 +126,7 @@ export class CoreApp {
126
126
  }
127
127
  resetKeys() {
128
128
  this.storage.clear([
129
- CoreApp.devicePassphraseField,
129
+ this.addIdentifier(CoreApp.devicePassphraseField),
130
130
  CoreApp.headerTokenField,
131
131
  CoreApp.serversideDeviceIdField
132
132
  ], false);
@@ -155,7 +155,8 @@ export class CoreApp {
155
155
  this.resetKeys();
156
156
  return false;
157
157
  }
158
- const passphraseEncrypted = this.storage.getData(CoreApp.devicePassphraseField);
158
+ // this.name to identifier different app's secret
159
+ const passphraseEncrypted = this.storage.getData(this.addIdentifier(CoreApp.devicePassphraseField));
159
160
  if (passphraseEncrypted) {
160
161
  const passphraseDecrypted = this.decrypt(passphraseEncrypted, this.name);
161
162
  if (passphraseDecrypted != null) {
@@ -188,6 +189,14 @@ export class CoreApp {
188
189
  return;
189
190
  this.storage.copyTo(this.persistedFields);
190
191
  }
192
+ /**
193
+ * Add app name as identifier
194
+ * @param field Field
195
+ * @returns Result
196
+ */
197
+ addIdentifier(field) {
198
+ return field + '-' + this.name;
199
+ }
191
200
  /**
192
201
  * Setup Api
193
202
  * @param api Api
@@ -310,7 +319,7 @@ export class CoreApp {
310
319
  this.storage.setPersistedData(CoreApp.devicesField, devices);
311
320
  // Current passphrase
312
321
  this.passphrase = passphrase;
313
- this.storage.setData(CoreApp.devicePassphraseField, this.encrypt(passphrase, this.name));
322
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), this.encrypt(passphrase, this.name));
314
323
  // Previous passphrase
315
324
  if (data.previousPassphrase) {
316
325
  const prev = this.decrypt(data.previousPassphrase, timestamp.toString());
@@ -440,7 +449,7 @@ export class CoreApp {
440
449
  */
441
450
  clearCacheData() {
442
451
  this.clearCacheToken();
443
- this.storage.setData(CoreApp.devicePassphraseField, undefined);
452
+ this.storage.setData(this.addIdentifier(CoreApp.devicePassphraseField), undefined);
444
453
  }
445
454
  /**
446
455
  * Clear cached token
@@ -799,6 +808,13 @@ export class CoreApp {
799
808
  var _a;
800
809
  (_a = this.lastWarning) === null || _a === void 0 ? void 0 : _a.dismiss();
801
810
  }
811
+ /**
812
+ * Redirect to the Url
813
+ * @param url Url
814
+ */
815
+ redirectTo(url) {
816
+ window.location.href = url;
817
+ }
802
818
  /**
803
819
  * Refresh countdown
804
820
  * @param seconds Seconds
@@ -897,7 +913,7 @@ export class CoreApp {
897
913
  */
898
914
  toLoginPage(tryLogin) {
899
915
  const url = this.transformUrl('/' + (tryLogin ? '' : '?tryLogin=false'));
900
- window.location.replace(this.transformUrl('/'));
916
+ this.redirectTo(url);
901
917
  }
902
918
  /**
903
919
  * Transform URL
@@ -14,6 +14,7 @@ export interface IBridgeHost {
14
14
  /**
15
15
  * Load application
16
16
  * @param name App name
17
+ * @param startUrl Start Url
17
18
  */
18
- loadApp(name: string): void;
19
+ loadApp(name: string, startUrl?: string): void;
19
20
  }
@@ -87,7 +87,7 @@
87
87
  "settings": "系统设置",
88
88
  "showIt": "显示",
89
89
  "signout": "退出",
90
- "smartERP": "司友云ERP",
90
+ "smartERP": "司友®云ERP",
91
91
  "sortTip": "拖拽项目进行排序",
92
92
  "status": "状态",
93
93
  "statusApproved": "已批准",
@@ -87,7 +87,7 @@
87
87
  "settings": "系統設置",
88
88
  "showIt": "顯示",
89
89
  "signout": "退出",
90
- "smartERP": "司友雲ERP",
90
+ "smartERP": "司友®雲ERP",
91
91
  "sortTip": "拖拽項目進行排序",
92
92
  "status": "狀態",
93
93
  "statusApproved": "已批准",
@@ -53,3 +53,7 @@ export interface IActionResult<D extends {} = {}> {
53
53
  export declare type IdActionResult<T extends DataTypes.IdType = number> = IActionResult<{
54
54
  id: T;
55
55
  }>;
56
+ /**
57
+ * Action result with dynamic data
58
+ */
59
+ export declare type DynamicActionResult = IActionResult<Record<string, any>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.41",
3
+ "version": "1.2.45",
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
@@ -627,7 +633,7 @@ export abstract class CoreApp<
627
633
  protected get persistedFields() {
628
634
  return [
629
635
  CoreApp.deviceIdField,
630
- CoreApp.devicePassphraseField,
636
+ this.addIdentifier(CoreApp.devicePassphraseField),
631
637
  CoreApp.serversideDeviceIdField,
632
638
  CoreApp.headerTokenField
633
639
  ];
@@ -678,7 +684,7 @@ export abstract class CoreApp<
678
684
  private resetKeys() {
679
685
  this.storage.clear(
680
686
  [
681
- CoreApp.devicePassphraseField,
687
+ this.addIdentifier(CoreApp.devicePassphraseField),
682
688
  CoreApp.headerTokenField,
683
689
  CoreApp.serversideDeviceIdField
684
690
  ],
@@ -717,8 +723,9 @@ export abstract class CoreApp<
717
723
  return false;
718
724
  }
719
725
 
726
+ // this.name to identifier different app's secret
720
727
  const passphraseEncrypted = this.storage.getData<string>(
721
- CoreApp.devicePassphraseField
728
+ this.addIdentifier(CoreApp.devicePassphraseField)
722
729
  );
723
730
  if (passphraseEncrypted) {
724
731
  const passphraseDecrypted = this.decrypt(
@@ -763,6 +770,15 @@ export abstract class CoreApp<
763
770
  this.storage.copyTo(this.persistedFields);
764
771
  }
765
772
 
773
+ /**
774
+ * Add app name as identifier
775
+ * @param field Field
776
+ * @returns Result
777
+ */
778
+ protected addIdentifier(field: string) {
779
+ return field + '-' + this.name;
780
+ }
781
+
766
782
  /**
767
783
  * Setup Api
768
784
  * @param api Api
@@ -907,7 +923,7 @@ export abstract class CoreApp<
907
923
  // Current passphrase
908
924
  this.passphrase = passphrase;
909
925
  this.storage.setData(
910
- CoreApp.devicePassphraseField,
926
+ this.addIdentifier(CoreApp.devicePassphraseField),
911
927
  this.encrypt(passphrase, this.name)
912
928
  );
913
929
 
@@ -1069,7 +1085,10 @@ export abstract class CoreApp<
1069
1085
  */
1070
1086
  clearCacheData() {
1071
1087
  this.clearCacheToken();
1072
- this.storage.setData(CoreApp.devicePassphraseField, undefined);
1088
+ this.storage.setData(
1089
+ this.addIdentifier(CoreApp.devicePassphraseField),
1090
+ undefined
1091
+ );
1073
1092
  }
1074
1093
 
1075
1094
  /**
@@ -1496,6 +1515,14 @@ export abstract class CoreApp<
1496
1515
  this.lastWarning?.dismiss();
1497
1516
  }
1498
1517
 
1518
+ /**
1519
+ * Redirect to the Url
1520
+ * @param url Url
1521
+ */
1522
+ redirectTo(url: string): void {
1523
+ window.location.href = url;
1524
+ }
1525
+
1499
1526
  /**
1500
1527
  * Refresh countdown
1501
1528
  * @param seconds Seconds
@@ -1618,7 +1645,7 @@ export abstract class CoreApp<
1618
1645
  const url = this.transformUrl(
1619
1646
  '/' + (tryLogin ? '' : '?tryLogin=false')
1620
1647
  );
1621
- window.location.replace(this.transformUrl('/'));
1648
+ this.redirectTo(url);
1622
1649
  }
1623
1650
 
1624
1651
  /**
@@ -16,6 +16,7 @@ export interface IBridgeHost {
16
16
  /**
17
17
  * Load application
18
18
  * @param name App name
19
+ * @param startUrl Start Url
19
20
  */
20
- loadApp(name: string): void;
21
+ loadApp(name: string, startUrl?: string): void;
21
22
  }
@@ -87,7 +87,7 @@
87
87
  "settings": "系统设置",
88
88
  "showIt": "显示",
89
89
  "signout": "退出",
90
- "smartERP": "司友云ERP",
90
+ "smartERP": "司友®云ERP",
91
91
  "sortTip": "拖拽项目进行排序",
92
92
  "status": "状态",
93
93
  "statusApproved": "已批准",
@@ -87,7 +87,7 @@
87
87
  "settings": "系統設置",
88
88
  "showIt": "顯示",
89
89
  "signout": "退出",
90
- "smartERP": "司友雲ERP",
90
+ "smartERP": "司友®雲ERP",
91
91
  "sortTip": "拖拽項目進行排序",
92
92
  "status": "狀態",
93
93
  "statusApproved": "已批准",
@@ -65,3 +65,8 @@ export type IdActionResult<T extends DataTypes.IdType = number> =
65
65
  IActionResult<{
66
66
  id: T;
67
67
  }>;
68
+
69
+ /**
70
+ * Action result with dynamic data
71
+ */
72
+ export type DynamicActionResult = IActionResult<Record<string, any>>;