@etsoo/appscript 1.1.79 → 1.1.83

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.
@@ -2,8 +2,9 @@ import { INotifier, NotificationAlign, NotificationCallProps, NotificationConten
2
2
  import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
3
3
  import { DataTypes, DateUtils } from '@etsoo/shared';
4
4
  import { AddressRegion } from '../address/AddressRegion';
5
+ import { InitCallDto } from '../dto/InitCallDto';
5
6
  import { IActionResult } from '../result/IActionResult';
6
- import { InitCallResultData } from '../result/InitCallResult';
7
+ import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
7
8
  import { IUserData } from '../state/User';
8
9
  import { IAppSettings } from './AppSettings';
9
10
  import { UserRole } from './UserRole';
@@ -26,7 +27,7 @@ export interface RefreshTokenProps<D extends {}> {
26
27
  /**
27
28
  * Callback
28
29
  */
29
- callback?: (result: RefreshTokenResult) => void;
30
+ callback?: (result: RefreshTokenResult, successData?: string) => void;
30
31
  /**
31
32
  * Data to pass
32
33
  */
@@ -402,6 +403,10 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
402
403
  * Device id field name
403
404
  */
404
405
  protected deviceIdField: string;
406
+ /**
407
+ * Init call Api URL
408
+ */
409
+ protected initCallApi: string;
405
410
  /**
406
411
  * Passphrase for encryption
407
412
  */
@@ -416,6 +421,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
416
421
  */
417
422
  protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, name: string);
418
423
  protected setApi(api: IApi): void;
424
+ /**
425
+ * Api init call
426
+ * @param data Data
427
+ * @returns Result
428
+ */
429
+ protected apiInitCall(data: InitCallDto): Promise<InitCallResult | undefined>;
419
430
  /**
420
431
  * Init call
421
432
  * @param callback Callback
@@ -39,6 +39,10 @@ class CoreApp {
39
39
  * Device id field name
40
40
  */
41
41
  this.deviceIdField = 'SmartERPDeviceId';
42
+ /**
43
+ * Init call Api URL
44
+ */
45
+ this.initCallApi = 'Auth/WebInitCall';
42
46
  /**
43
47
  * Passphrase for encryption
44
48
  */
@@ -127,6 +131,14 @@ class CoreApp {
127
131
  }
128
132
  };
129
133
  }
134
+ /**
135
+ * Api init call
136
+ * @param data Data
137
+ * @returns Result
138
+ */
139
+ async apiInitCall(data) {
140
+ return await this.api.put(this.initCallApi, data);
141
+ }
130
142
  /**
131
143
  * Init call
132
144
  * @param callback Callback
@@ -138,7 +150,7 @@ class CoreApp {
138
150
  timestamp: new Date().getTime(),
139
151
  deviceId: this.deviceId === '' ? undefined : this.deviceId
140
152
  };
141
- const result = await this.api.put('Auth/WebInitCall', data);
153
+ const result = await this.apiInitCall(data);
142
154
  if (result == null) {
143
155
  if (callback)
144
156
  callback(false);
@@ -569,10 +581,7 @@ class CoreApp {
569
581
  const refreshToken = shared_1.StorageUtils.getLocalData(this.headerTokenField, '');
570
582
  if (refreshToken === '')
571
583
  return null;
572
- const result = this.decrypt(refreshToken);
573
- if (result == undefined)
574
- return null;
575
- return result;
584
+ return refreshToken;
576
585
  }
577
586
  /**
578
587
  * Get all regions
@@ -690,7 +699,7 @@ class CoreApp {
690
699
  */
691
700
  async refreshToken(props) {
692
701
  if (props && props.callback)
693
- props.callback(true);
702
+ props.callback(true, undefined);
694
703
  return true;
695
704
  }
696
705
  /**
@@ -28,6 +28,10 @@ export interface IUserData {
28
28
  */
29
29
  readonly token: string;
30
30
  }
31
+ /**
32
+ * User data property keys
33
+ */
34
+ export declare type UserKey = keyof IUserData;
31
35
  /**
32
36
  * User interface
33
37
  */
@@ -39,5 +43,5 @@ export interface IUser extends IUserData, IState {
39
43
  /**
40
44
  * Last update changed fields
41
45
  */
42
- lastChangedFields?: string[];
46
+ lastChangedFields?: UserKey[];
43
47
  }
@@ -2,8 +2,9 @@ import { INotifier, NotificationAlign, NotificationCallProps, NotificationConten
2
2
  import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
3
3
  import { DataTypes, DateUtils } from '@etsoo/shared';
4
4
  import { AddressRegion } from '../address/AddressRegion';
5
+ import { InitCallDto } from '../dto/InitCallDto';
5
6
  import { IActionResult } from '../result/IActionResult';
6
- import { InitCallResultData } from '../result/InitCallResult';
7
+ import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
7
8
  import { IUserData } from '../state/User';
8
9
  import { IAppSettings } from './AppSettings';
9
10
  import { UserRole } from './UserRole';
@@ -26,7 +27,7 @@ export interface RefreshTokenProps<D extends {}> {
26
27
  /**
27
28
  * Callback
28
29
  */
29
- callback?: (result: RefreshTokenResult) => void;
30
+ callback?: (result: RefreshTokenResult, successData?: string) => void;
30
31
  /**
31
32
  * Data to pass
32
33
  */
@@ -402,6 +403,10 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
402
403
  * Device id field name
403
404
  */
404
405
  protected deviceIdField: string;
406
+ /**
407
+ * Init call Api URL
408
+ */
409
+ protected initCallApi: string;
405
410
  /**
406
411
  * Passphrase for encryption
407
412
  */
@@ -416,6 +421,12 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
416
421
  */
417
422
  protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, name: string);
418
423
  protected setApi(api: IApi): void;
424
+ /**
425
+ * Api init call
426
+ * @param data Data
427
+ * @returns Result
428
+ */
429
+ protected apiInitCall(data: InitCallDto): Promise<InitCallResult | undefined>;
419
430
  /**
420
431
  * Init call
421
432
  * @param callback Callback
@@ -36,6 +36,10 @@ export class CoreApp {
36
36
  * Device id field name
37
37
  */
38
38
  this.deviceIdField = 'SmartERPDeviceId';
39
+ /**
40
+ * Init call Api URL
41
+ */
42
+ this.initCallApi = 'Auth/WebInitCall';
39
43
  /**
40
44
  * Passphrase for encryption
41
45
  */
@@ -124,6 +128,14 @@ export class CoreApp {
124
128
  }
125
129
  };
126
130
  }
131
+ /**
132
+ * Api init call
133
+ * @param data Data
134
+ * @returns Result
135
+ */
136
+ async apiInitCall(data) {
137
+ return await this.api.put(this.initCallApi, data);
138
+ }
127
139
  /**
128
140
  * Init call
129
141
  * @param callback Callback
@@ -135,7 +147,7 @@ export class CoreApp {
135
147
  timestamp: new Date().getTime(),
136
148
  deviceId: this.deviceId === '' ? undefined : this.deviceId
137
149
  };
138
- const result = await this.api.put('Auth/WebInitCall', data);
150
+ const result = await this.apiInitCall(data);
139
151
  if (result == null) {
140
152
  if (callback)
141
153
  callback(false);
@@ -566,10 +578,7 @@ export class CoreApp {
566
578
  const refreshToken = StorageUtils.getLocalData(this.headerTokenField, '');
567
579
  if (refreshToken === '')
568
580
  return null;
569
- const result = this.decrypt(refreshToken);
570
- if (result == undefined)
571
- return null;
572
- return result;
581
+ return refreshToken;
573
582
  }
574
583
  /**
575
584
  * Get all regions
@@ -687,7 +696,7 @@ export class CoreApp {
687
696
  */
688
697
  async refreshToken(props) {
689
698
  if (props && props.callback)
690
- props.callback(true);
699
+ props.callback(true, undefined);
691
700
  return true;
692
701
  }
693
702
  /**
@@ -28,6 +28,10 @@ export interface IUserData {
28
28
  */
29
29
  readonly token: string;
30
30
  }
31
+ /**
32
+ * User data property keys
33
+ */
34
+ export declare type UserKey = keyof IUserData;
31
35
  /**
32
36
  * User interface
33
37
  */
@@ -39,5 +43,5 @@ export interface IUser extends IUserData, IState {
39
43
  /**
40
44
  * Last update changed fields
41
45
  */
42
- lastChangedFields?: string[];
46
+ lastChangedFields?: UserKey[];
43
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.1.79",
3
+ "version": "1.1.83",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.0.94",
56
56
  "@etsoo/restclient": "^1.0.62",
57
- "@etsoo/shared": "^1.0.76",
57
+ "@etsoo/shared": "^1.0.78",
58
58
  "@types/crypto-js": "^4.0.2",
59
59
  "crypto-js": "^4.1.1"
60
60
  },
@@ -67,7 +67,7 @@
67
67
  "@types/jest": "^27.0.3",
68
68
  "@typescript-eslint/eslint-plugin": "^5.7.0",
69
69
  "@typescript-eslint/parser": "^5.7.0",
70
- "eslint": "^8.4.1",
70
+ "eslint": "^8.5.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.25.3",
73
73
  "jest": "^27.4.5",
@@ -61,7 +61,7 @@ export interface RefreshTokenProps<D extends {}> {
61
61
  /**
62
62
  * Callback
63
63
  */
64
- callback?: (result: RefreshTokenResult) => void;
64
+ callback?: (result: RefreshTokenResult, successData?: string) => void;
65
65
 
66
66
  /**
67
67
  * Data to pass
@@ -557,6 +557,11 @@ export abstract class CoreApp<
557
557
  */
558
558
  protected deviceIdField: string = 'SmartERPDeviceId';
559
559
 
560
+ /**
561
+ * Init call Api URL
562
+ */
563
+ protected initCallApi: string = 'Auth/WebInitCall';
564
+
560
565
  /**
561
566
  * Passphrase for encryption
562
567
  */
@@ -631,6 +636,15 @@ export abstract class CoreApp<
631
636
  };
632
637
  }
633
638
 
639
+ /**
640
+ * Api init call
641
+ * @param data Data
642
+ * @returns Result
643
+ */
644
+ protected async apiInitCall(data: InitCallDto) {
645
+ return await this.api.put<InitCallResult>(this.initCallApi, data);
646
+ }
647
+
634
648
  /**
635
649
  * Init call
636
650
  * @param callback Callback
@@ -641,10 +655,7 @@ export abstract class CoreApp<
641
655
  timestamp: new Date().getTime(),
642
656
  deviceId: this.deviceId === '' ? undefined : this.deviceId
643
657
  };
644
- const result = await this.api.put<InitCallResult>(
645
- 'Auth/WebInitCall',
646
- data
647
- );
658
+ const result = await this.apiInitCall(data);
648
659
  if (result == null) {
649
660
  if (callback) callback(false);
650
661
  return;
@@ -1180,9 +1191,7 @@ export abstract class CoreApp<
1180
1191
 
1181
1192
  if (refreshToken === '') return null;
1182
1193
 
1183
- const result = this.decrypt(refreshToken);
1184
- if (result == undefined) return null;
1185
- return result;
1194
+ return refreshToken;
1186
1195
  }
1187
1196
 
1188
1197
  /**
@@ -1312,7 +1321,7 @@ export abstract class CoreApp<
1312
1321
  * @param props Props
1313
1322
  */
1314
1323
  async refreshToken<D extends {} = {}>(props?: RefreshTokenProps<D>) {
1315
- if (props && props.callback) props.callback(true);
1324
+ if (props && props.callback) props.callback(true, undefined);
1316
1325
  return true;
1317
1326
  }
1318
1327
 
package/src/state/User.ts CHANGED
@@ -35,6 +35,11 @@ export interface IUserData {
35
35
  readonly token: string;
36
36
  }
37
37
 
38
+ /**
39
+ * User data property keys
40
+ */
41
+ export type UserKey = keyof IUserData;
42
+
38
43
  /**
39
44
  * User interface
40
45
  */
@@ -47,5 +52,5 @@ export interface IUser extends IUserData, IState {
47
52
  /**
48
53
  * Last update changed fields
49
54
  */
50
- lastChangedFields?: string[];
55
+ lastChangedFields?: UserKey[];
51
56
  }