@etsoo/appscript 1.5.12 → 1.5.14

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.
@@ -98,9 +98,6 @@ class CoreAppTest extends CoreApp<
98
98
  */
99
99
  webUrl: 'http://localhost',
100
100
 
101
- // Authorization scheme
102
- authScheme: ApiAuthorizationScheme.Bearer,
103
-
104
101
  // Detected culture
105
102
  detectedCulture,
106
103
 
@@ -1,4 +1,3 @@
1
- import { ApiAuthorizationScheme } from '@etsoo/restclient';
2
1
  import { DataTypes } from '@etsoo/shared';
3
2
  import { AddressRegion } from '../address/AddressRegion';
4
3
  import { IExternalSettings } from './ExternalSettings';
@@ -6,10 +5,6 @@ import { IExternalSettings } from './ExternalSettings';
6
5
  * App settings interface
7
6
  */
8
7
  export interface IAppSettings extends IExternalSettings {
9
- /**
10
- * Authorization scheme
11
- */
12
- readonly authScheme: ApiAuthorizationScheme | string;
13
8
  /**
14
9
  * Supported country/region ids
15
10
  */
@@ -249,10 +249,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
249
249
  alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
250
250
  /**
251
251
  * Authorize
252
- * @param token New token
252
+ * @param token New access token
253
+ * @param schema Access token schema
253
254
  * @param refreshToken Refresh token
254
255
  */
255
- authorize(token?: string, refreshToken?: string): void;
256
+ authorize(token?: string, schema?: string, refreshToken?: string): void;
256
257
  /**
257
258
  * Change country or region
258
259
  * @param regionId New country or region
@@ -534,14 +534,16 @@ class CoreApp {
534
534
  }
535
535
  /**
536
536
  * Authorize
537
- * @param token New token
537
+ * @param token New access token
538
+ * @param schema Access token schema
538
539
  * @param refreshToken Refresh token
539
540
  */
540
- authorize(token, refreshToken) {
541
+ authorize(token, schema, refreshToken) {
541
542
  // State, when token is null, means logout
542
543
  this.authorized = token != null;
543
544
  // Token
544
- this.api.authorize(this.settings.authScheme, token);
545
+ schema ?? (schema = 'Bearer');
546
+ this.api.authorize(schema, token);
545
547
  // Overwrite the current value
546
548
  if (refreshToken !== '') {
547
549
  if (refreshToken != null)
@@ -1391,11 +1393,11 @@ class CoreApp {
1391
1393
  // Cache the encrypted serverside device id
1392
1394
  this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1393
1395
  if (keep) {
1394
- this.authorize(user.token, refreshToken);
1396
+ this.authorize(user.token, user.tokenScheme, refreshToken);
1395
1397
  }
1396
1398
  else {
1397
1399
  this.cachedRefreshToken = this.encrypt(refreshToken);
1398
- this.authorize(user.token, undefined);
1400
+ this.authorize(user.token, user.tokenScheme, undefined);
1399
1401
  }
1400
1402
  }
1401
1403
  /**
@@ -1404,7 +1406,7 @@ class CoreApp {
1404
1406
  * @param noTrigger No trigger for state change
1405
1407
  */
1406
1408
  userLogout(clearToken = true, noTrigger = false) {
1407
- this.authorize(undefined, clearToken ? undefined : '');
1409
+ this.authorize(undefined, undefined, clearToken ? undefined : '');
1408
1410
  }
1409
1411
  /**
1410
1412
  * User unauthorized
@@ -178,10 +178,11 @@ export interface IApp {
178
178
  alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
179
179
  /**
180
180
  * Authorize
181
- * @param token New token
181
+ * @param token New access token
182
+ * @param schema Access token schema
182
183
  * @param refreshToken Refresh token
183
184
  */
184
- authorize(token?: string, refreshToken?: string): void;
185
+ authorize(token?: string, schema?: string, refreshToken?: string): void;
185
186
  /**
186
187
  * Change country or region
187
188
  * @param region New country or region
@@ -122,6 +122,7 @@
122
122
  "no": "No",
123
123
  "noChanges": "No changes yet",
124
124
  "noData": "No valid data",
125
+ "noDataReturned": "No data returned",
125
126
  "noMatches": "No matches",
126
127
  "none": "None yet",
127
128
  "noOptions": "No options",
@@ -122,6 +122,7 @@
122
122
  "no": "否",
123
123
  "noChanges": "还没有任何修改",
124
124
  "noData": "没有有效数据",
125
+ "noDataReturned": "没有返回数据",
125
126
  "noMatches": "没有匹配项",
126
127
  "none": "暂时没有",
127
128
  "noOptions": "没有选项",
@@ -122,6 +122,7 @@
122
122
  "no": "否",
123
123
  "noChanges": "還沒有任何修改",
124
124
  "noData": "沒有有效數據",
125
+ "noDataReturned": "沒有回傳數據",
125
126
  "noMatches": "没有匹配项",
126
127
  "none": "暫時沒有",
127
128
  "noOptions": "沒有選項",
@@ -22,6 +22,16 @@ export interface IUserData {
22
22
  * 机构编号
23
23
  */
24
24
  readonly organization?: number;
25
+ /**
26
+ * Is from the channel organization
27
+ * 是否来自渠道机构
28
+ */
29
+ readonly isChannel?: boolean;
30
+ /**
31
+ * Is from the parent organization
32
+ * 是否来自父级机构
33
+ */
34
+ readonly isParent?: boolean;
25
35
  /**
26
36
  * User role value
27
37
  * 用户角色值
@@ -37,6 +47,11 @@ export interface IUserData {
37
47
  * 访问令牌
38
48
  */
39
49
  readonly token: string;
50
+ /**
51
+ * Access token scheme
52
+ * 访问令牌方案
53
+ */
54
+ readonly tokenScheme?: string;
40
55
  }
41
56
  /**
42
57
  * User data property keys
@@ -1,4 +1,3 @@
1
- import { ApiAuthorizationScheme } from '@etsoo/restclient';
2
1
  import { DataTypes } from '@etsoo/shared';
3
2
  import { AddressRegion } from '../address/AddressRegion';
4
3
  import { IExternalSettings } from './ExternalSettings';
@@ -6,10 +5,6 @@ import { IExternalSettings } from './ExternalSettings';
6
5
  * App settings interface
7
6
  */
8
7
  export interface IAppSettings extends IExternalSettings {
9
- /**
10
- * Authorization scheme
11
- */
12
- readonly authScheme: ApiAuthorizationScheme | string;
13
8
  /**
14
9
  * Supported country/region ids
15
10
  */
@@ -249,10 +249,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
249
249
  alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
250
250
  /**
251
251
  * Authorize
252
- * @param token New token
252
+ * @param token New access token
253
+ * @param schema Access token schema
253
254
  * @param refreshToken Refresh token
254
255
  */
255
- authorize(token?: string, refreshToken?: string): void;
256
+ authorize(token?: string, schema?: string, refreshToken?: string): void;
256
257
  /**
257
258
  * Change country or region
258
259
  * @param regionId New country or region
@@ -531,14 +531,16 @@ export class CoreApp {
531
531
  }
532
532
  /**
533
533
  * Authorize
534
- * @param token New token
534
+ * @param token New access token
535
+ * @param schema Access token schema
535
536
  * @param refreshToken Refresh token
536
537
  */
537
- authorize(token, refreshToken) {
538
+ authorize(token, schema, refreshToken) {
538
539
  // State, when token is null, means logout
539
540
  this.authorized = token != null;
540
541
  // Token
541
- this.api.authorize(this.settings.authScheme, token);
542
+ schema ?? (schema = 'Bearer');
543
+ this.api.authorize(schema, token);
542
544
  // Overwrite the current value
543
545
  if (refreshToken !== '') {
544
546
  if (refreshToken != null)
@@ -1388,11 +1390,11 @@ export class CoreApp {
1388
1390
  // Cache the encrypted serverside device id
1389
1391
  this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1390
1392
  if (keep) {
1391
- this.authorize(user.token, refreshToken);
1393
+ this.authorize(user.token, user.tokenScheme, refreshToken);
1392
1394
  }
1393
1395
  else {
1394
1396
  this.cachedRefreshToken = this.encrypt(refreshToken);
1395
- this.authorize(user.token, undefined);
1397
+ this.authorize(user.token, user.tokenScheme, undefined);
1396
1398
  }
1397
1399
  }
1398
1400
  /**
@@ -1401,7 +1403,7 @@ export class CoreApp {
1401
1403
  * @param noTrigger No trigger for state change
1402
1404
  */
1403
1405
  userLogout(clearToken = true, noTrigger = false) {
1404
- this.authorize(undefined, clearToken ? undefined : '');
1406
+ this.authorize(undefined, undefined, clearToken ? undefined : '');
1405
1407
  }
1406
1408
  /**
1407
1409
  * User unauthorized
@@ -178,10 +178,11 @@ export interface IApp {
178
178
  alertResult(result: IActionResult, callback?: NotificationReturn<void>, forceToLocal?: FormatResultCustomCallback): void;
179
179
  /**
180
180
  * Authorize
181
- * @param token New token
181
+ * @param token New access token
182
+ * @param schema Access token schema
182
183
  * @param refreshToken Refresh token
183
184
  */
184
- authorize(token?: string, refreshToken?: string): void;
185
+ authorize(token?: string, schema?: string, refreshToken?: string): void;
185
186
  /**
186
187
  * Change country or region
187
188
  * @param region New country or region
@@ -122,6 +122,7 @@
122
122
  "no": "No",
123
123
  "noChanges": "No changes yet",
124
124
  "noData": "No valid data",
125
+ "noDataReturned": "No data returned",
125
126
  "noMatches": "No matches",
126
127
  "none": "None yet",
127
128
  "noOptions": "No options",
@@ -122,6 +122,7 @@
122
122
  "no": "否",
123
123
  "noChanges": "还没有任何修改",
124
124
  "noData": "没有有效数据",
125
+ "noDataReturned": "没有返回数据",
125
126
  "noMatches": "没有匹配项",
126
127
  "none": "暂时没有",
127
128
  "noOptions": "没有选项",
@@ -122,6 +122,7 @@
122
122
  "no": "否",
123
123
  "noChanges": "還沒有任何修改",
124
124
  "noData": "沒有有效數據",
125
+ "noDataReturned": "沒有回傳數據",
125
126
  "noMatches": "没有匹配项",
126
127
  "none": "暫時沒有",
127
128
  "noOptions": "沒有選項",
@@ -22,6 +22,16 @@ export interface IUserData {
22
22
  * 机构编号
23
23
  */
24
24
  readonly organization?: number;
25
+ /**
26
+ * Is from the channel organization
27
+ * 是否来自渠道机构
28
+ */
29
+ readonly isChannel?: boolean;
30
+ /**
31
+ * Is from the parent organization
32
+ * 是否来自父级机构
33
+ */
34
+ readonly isParent?: boolean;
25
35
  /**
26
36
  * User role value
27
37
  * 用户角色值
@@ -37,6 +47,11 @@ export interface IUserData {
37
47
  * 访问令牌
38
48
  */
39
49
  readonly token: string;
50
+ /**
51
+ * Access token scheme
52
+ * 访问令牌方案
53
+ */
54
+ readonly tokenScheme?: string;
40
55
  }
41
56
  /**
42
57
  * User data property keys
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.12",
3
+ "version": "1.5.14",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -1,4 +1,3 @@
1
- import { ApiAuthorizationScheme } from '@etsoo/restclient';
2
1
  import { DataTypes } from '@etsoo/shared';
3
2
  import { AddressRegion } from '../address/AddressRegion';
4
3
  import { IExternalSettings } from './ExternalSettings';
@@ -7,11 +6,6 @@ import { IExternalSettings } from './ExternalSettings';
7
6
  * App settings interface
8
7
  */
9
8
  export interface IAppSettings extends IExternalSettings {
10
- /**
11
- * Authorization scheme
12
- */
13
- readonly authScheme: ApiAuthorizationScheme | string;
14
-
15
9
  /**
16
10
  * Supported country/region ids
17
11
  */
@@ -847,15 +847,17 @@ export abstract class CoreApp<
847
847
 
848
848
  /**
849
849
  * Authorize
850
- * @param token New token
850
+ * @param token New access token
851
+ * @param schema Access token schema
851
852
  * @param refreshToken Refresh token
852
853
  */
853
- authorize(token?: string, refreshToken?: string) {
854
+ authorize(token?: string, schema?: string, refreshToken?: string) {
854
855
  // State, when token is null, means logout
855
856
  this.authorized = token != null;
856
857
 
857
858
  // Token
858
- this.api.authorize(this.settings.authScheme, token);
859
+ schema ??= 'Bearer';
860
+ this.api.authorize(schema, token);
859
861
 
860
862
  // Overwrite the current value
861
863
  if (refreshToken !== '') {
@@ -1892,10 +1894,10 @@ export abstract class CoreApp<
1892
1894
  this.storage.setData(this.fields.serversideDeviceId, user.deviceId);
1893
1895
 
1894
1896
  if (keep) {
1895
- this.authorize(user.token, refreshToken);
1897
+ this.authorize(user.token, user.tokenScheme, refreshToken);
1896
1898
  } else {
1897
1899
  this.cachedRefreshToken = this.encrypt(refreshToken);
1898
- this.authorize(user.token, undefined);
1900
+ this.authorize(user.token, user.tokenScheme, undefined);
1899
1901
  }
1900
1902
  }
1901
1903
 
@@ -1905,7 +1907,7 @@ export abstract class CoreApp<
1905
1907
  * @param noTrigger No trigger for state change
1906
1908
  */
1907
1909
  userLogout(clearToken: boolean = true, noTrigger: boolean = false) {
1908
- this.authorize(undefined, clearToken ? undefined : '');
1910
+ this.authorize(undefined, undefined, clearToken ? undefined : '');
1909
1911
  }
1910
1912
 
1911
1913
  /**
package/src/app/IApp.ts CHANGED
@@ -243,10 +243,11 @@ export interface IApp {
243
243
 
244
244
  /**
245
245
  * Authorize
246
- * @param token New token
246
+ * @param token New access token
247
+ * @param schema Access token schema
247
248
  * @param refreshToken Refresh token
248
249
  */
249
- authorize(token?: string, refreshToken?: string): void;
250
+ authorize(token?: string, schema?: string, refreshToken?: string): void;
250
251
 
251
252
  /**
252
253
  * Change country or region
package/src/i18n/en.json CHANGED
@@ -122,6 +122,7 @@
122
122
  "no": "No",
123
123
  "noChanges": "No changes yet",
124
124
  "noData": "No valid data",
125
+ "noDataReturned": "No data returned",
125
126
  "noMatches": "No matches",
126
127
  "none": "None yet",
127
128
  "noOptions": "No options",
@@ -122,6 +122,7 @@
122
122
  "no": "否",
123
123
  "noChanges": "还没有任何修改",
124
124
  "noData": "没有有效数据",
125
+ "noDataReturned": "没有返回数据",
125
126
  "noMatches": "没有匹配项",
126
127
  "none": "暂时没有",
127
128
  "noOptions": "没有选项",
@@ -122,6 +122,7 @@
122
122
  "no": "否",
123
123
  "noChanges": "還沒有任何修改",
124
124
  "noData": "沒有有效數據",
125
+ "noDataReturned": "沒有回傳數據",
125
126
  "noMatches": "没有匹配项",
126
127
  "none": "暫時沒有",
127
128
  "noOptions": "沒有選項",
package/src/state/User.ts CHANGED
@@ -27,6 +27,18 @@ export interface IUserData {
27
27
  */
28
28
  readonly organization?: number;
29
29
 
30
+ /**
31
+ * Is from the channel organization
32
+ * 是否来自渠道机构
33
+ */
34
+ readonly isChannel?: boolean;
35
+
36
+ /**
37
+ * Is from the parent organization
38
+ * 是否来自父级机构
39
+ */
40
+ readonly isParent?: boolean;
41
+
30
42
  /**
31
43
  * User role value
32
44
  * 用户角色值
@@ -44,6 +56,12 @@ export interface IUserData {
44
56
  * 访问令牌
45
57
  */
46
58
  readonly token: string;
59
+
60
+ /**
61
+ * Access token scheme
62
+ * 访问令牌方案
63
+ */
64
+ readonly tokenScheme?: string;
47
65
  }
48
66
 
49
67
  /**