@etsoo/appscript 1.1.6 → 1.1.7

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.
@@ -28,7 +28,7 @@ jobs:
28
28
  # Setup .npmrc file to publish to npm
29
29
  - uses: actions/setup-node@v1
30
30
  with:
31
- node-version: '14.8'
31
+ node-version: '14.18'
32
32
  registry-url: 'https://registry.npmjs.org'
33
33
 
34
34
  # Named after Continuous Integration, installs dependencies directly from package-lock.json
package/README.md CHANGED
@@ -17,8 +17,33 @@ $ yarn add @etsoo/appscript
17
17
 
18
18
  ## Structure
19
19
 
20
+ ### address - Address (region) related
21
+
22
+ #### AddressContinent.ts ####
23
+ - AddressContinent - Continent Enum
24
+
25
+ #### AddressRegion.ts ####
26
+ - IAddressRegion - Country or region interface
27
+ - AddressRegion - Address or region
28
+
29
+ #### AddressUtils.ts ####
30
+ - getContinents - Get all continents
31
+ - getRegion - Get region from regions and detected region and language
32
+
20
33
  ### app - Application related
21
34
 
35
+ #### AppSettings.ts ####
36
+ - IAppSettings - App settings interface
37
+
38
+ #### CoreApp.ts ####
39
+ - IDetectIPCallback - Detect IP callback interface
40
+ - ICoreApp - Core application interface
41
+ - CoreApp - Core application
42
+
43
+ #### ExternalSettings.ts ####
44
+ - IExternalSettings - External settings items
45
+ - IExternalSettingsHost - External settings host passed by external script
46
+
22
47
  ### bridges - Works with Electron
23
48
 
24
49
  #### ElectronBridge.ts ####
@@ -28,35 +53,60 @@ $ yarn add @etsoo/appscript
28
53
  - IAppData - App data interface.
29
54
 
30
55
  #### IBridge.ts ####
31
- - IBridgeUnsubscribe - Bridge unsubscribe interface.
32
- - IBridgeListener - Bridge listener interface.
33
- - IBridge - Bridge interface.
56
+ - IBridgeUnsubscribe - Bridge unsubscribe interface
57
+ - IBridgeListener - Bridge listener interface
58
+ - IBridge - Bridge interface
59
+
60
+ ### business - Business logics
61
+
62
+ #### BusinessTax.ts ####
63
+ - IBusinessTax - Business tax interface
64
+ - BusinessTax - Business tax
65
+
66
+ #### BusinessUtils.ts ####
67
+ - addIdLabelBlankItem - Add blank item to id/label data array
68
+ - getUnitLabel - Get product unit's label
69
+ - getUnits - Get all product units
70
+
71
+ #### ProductUnit.ts ####
72
+ - ProductUnit - Product units enum
73
+
74
+ ### dto - Data transfer object
75
+
76
+ #### IdDto.ts ####
77
+ - IdDto - Dto with id field
78
+
79
+ #### IdLabelDto.ts ####
80
+ - IdLabelDto - Dto with id and label field
81
+
82
+ #### UpdateDto.ts ####
83
+ - UpdateDto - Dto with id and changedFields
34
84
 
35
85
  ### result - API action result
36
86
 
37
87
  #### ActionResult.ts ####
38
- - ActionResult - API call action result extends IActionResult.
88
+ - ActionResult - API call action result extends IActionResult
39
89
 
40
90
  #### ActionResultError.ts ####
41
91
  - ActionResultError - Action result to error type.
42
92
 
43
93
  #### IActionResult.ts ####
44
- - IResultData - Result data interface.
45
- - IdResultData - extends IResultData for 'id' included return data.
46
- - IResultErrors - Result errors interface.
47
- - IActionResult - Action result interface.
94
+ - IResultData - Result data interface
95
+ - IdResultData - extends IResultData for 'id' included return data
96
+ - IResultErrors - Result errors interface
97
+ - IActionResult - Action result interface
48
98
  - ActionResultId - Action result with id data
49
99
 
50
100
  ### state - State management
51
101
 
52
- #### Language.ts ####
53
- - LanguageLabels - Language labels, indexable, for simple i18n solution.
54
- - ILanguage - extends IState for language state.
102
+ #### Culture.ts ####
103
+ - ICulture - Culture resources state, simple i18n solution
104
+ - ICultureGet - Culture get delegate
55
105
 
56
106
  #### State.ts ####
57
107
  - IState - state interface.
58
- - IAction - state action interface.
108
+ - IAction - state action interface
59
109
 
60
110
  #### User.ts ####
61
111
  - IUserData - User basic data.
62
- - IUser - extends IState for user state.
112
+ - IUser - extends IState for user state
@@ -13,7 +13,7 @@ export declare namespace AddressUtils {
13
13
  */
14
14
  function getContinents(func: ICultureGet, isNumberKey?: boolean): IdLabelDto[];
15
15
  /**
16
- * Get region
16
+ * Get region from regions and detected region and language
17
17
  * @param regions Supported regions
18
18
  * @param detectedRegion Detected region
19
19
  * @param detectedLanguage Detected language
@@ -16,19 +16,16 @@ var AddressUtils;
16
16
  * @returns Continents
17
17
  */
18
18
  function getContinents(func, isNumberKey = false) {
19
- return shared_1.Utils.getEnumKeys(AddressContinent_1.AddressContinent).map((key) => {
20
- var _a;
21
- return ({
22
- id: isNumberKey
23
- ? AddressContinent_1.AddressContinent[key]
24
- : key,
25
- label: (_a = func('continent' + key)) !== null && _a !== void 0 ? _a : key
26
- });
27
- });
19
+ return shared_1.DataTypes.getEnumKeys(AddressContinent_1.AddressContinent).map((key) => ({
20
+ id: isNumberKey
21
+ ? AddressContinent_1.AddressContinent[key]
22
+ : key,
23
+ label: func('continent' + key) ?? key
24
+ }));
28
25
  }
29
26
  AddressUtils.getContinents = getContinents;
30
27
  /**
31
- * Get region
28
+ * Get region from regions and detected region and language
32
29
  * @param regions Supported regions
33
30
  * @param detectedRegion Detected region
34
31
  * @param detectedLanguage Detected language
@@ -3,7 +3,7 @@ import { DataTypes } from '@etsoo/shared';
3
3
  import { AddressRegion } from '../address/AddressRegion';
4
4
  import { IExternalSettings } from './ExternalSettings';
5
5
  /**
6
- * API settings interface
6
+ * App settings interface
7
7
  */
8
8
  export interface IAppSettings extends IExternalSettings {
9
9
  /**
@@ -30,7 +30,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
30
30
  /**
31
31
  * Label delegate
32
32
  */
33
- readonly labelDelegate: <T extends DataTypes.SimpleType = string>(key: string) => T | undefined;
33
+ readonly labelDelegate: <T = string>(key: string) => T | undefined;
34
34
  /**
35
35
  * Culture, like zh-CN
36
36
  */
@@ -114,7 +114,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
114
114
  * @param key key
115
115
  * @returns Resource
116
116
  */
117
- get<T extends DataTypes.SimpleType = string>(key: string): T | undefined;
117
+ get<T = string>(key: string): T | undefined;
118
118
  /**
119
119
  * Get multiple culture labels
120
120
  * @param keys Keys
@@ -203,7 +203,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
203
203
  /**
204
204
  * Label delegate
205
205
  */
206
- get labelDelegate(): <T extends DataTypes.SimpleType = string>(key: string) => T | undefined;
206
+ get labelDelegate(): <T = string>(key: string) => T | undefined;
207
207
  /**
208
208
  * IP data
209
209
  */
@@ -297,7 +297,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
297
297
  * @param key key
298
298
  * @returns Resource
299
299
  */
300
- get<T extends DataTypes.SimpleType = string>(key: string): T | undefined;
300
+ get<T = string>(key: string): T | undefined;
301
301
  /**
302
302
  * Get multiple culture labels
303
303
  * @param keys Keys
@@ -194,8 +194,7 @@ class CoreApp {
194
194
  }
195
195
  // Detect IP callbacks
196
196
  detectIPCallbacks() {
197
- var _a;
198
- (_a = this.ipDetectCallbacks) === null || _a === void 0 ? void 0 : _a.forEach((f) => f());
197
+ this.ipDetectCallbacks?.forEach((f) => f());
199
198
  }
200
199
  /**
201
200
  * Format date to string
@@ -206,7 +205,7 @@ class CoreApp {
206
205
  */
207
206
  formatDate(input, options, timeZone) {
208
207
  const { currentCulture, timeZone: defaultTimeZone } = this.settings;
209
- timeZone !== null && timeZone !== void 0 ? timeZone : (timeZone = defaultTimeZone);
208
+ timeZone ?? (timeZone = defaultTimeZone);
210
209
  return shared_1.DateUtils.format(input, currentCulture.name, options, timeZone);
211
210
  }
212
211
  /**
@@ -245,6 +244,9 @@ class CoreApp {
245
244
  const value = this.settings.currentCulture.resources[key];
246
245
  if (value == null)
247
246
  return undefined;
247
+ // No strict type convertion here
248
+ // Make sure the type is strictly match
249
+ // Otherwise even request number, may still return the source string type
248
250
  return value;
249
251
  }
250
252
  /**
@@ -253,7 +255,7 @@ class CoreApp {
253
255
  */
254
256
  getLabels(...keys) {
255
257
  const init = {};
256
- return keys.reduce((a, v) => { var _a; return ({ ...a, [v]: (_a = this.get(v)) !== null && _a !== void 0 ? _a : '' }); }, init);
258
+ return keys.reduce((a, v) => ({ ...a, [v]: this.get(v) ?? '' }), init);
257
259
  }
258
260
  /**
259
261
  * Get cached token
@@ -294,9 +296,8 @@ class CoreApp {
294
296
  * @returns Time zone
295
297
  */
296
298
  getTimeZone() {
297
- var _a, _b;
298
299
  // settings.timeZone = Utils.getTimeZone()
299
- return (_a = this.settings.timeZone) !== null && _a !== void 0 ? _a : (_b = this.ipData) === null || _b === void 0 ? void 0 : _b.timezone;
300
+ return this.settings.timeZone ?? this.ipData?.timezone;
300
301
  }
301
302
  /**
302
303
  * Callback where exit a page
@@ -1,5 +1,5 @@
1
1
  /**
2
- * External settings
2
+ * External settings items
3
3
  */
4
4
  export interface IExternalSettings {
5
5
  /**
@@ -52,4 +52,10 @@ BusinessTax.HK = new BusinessTax('HK', 'BRN', '00000000');
52
52
  /**
53
53
  * All countries and regions
54
54
  */
55
- BusinessTax.all = [BusinessTax.CN, BusinessTax.NZ, BusinessTax.US];
55
+ BusinessTax.all = [
56
+ BusinessTax.CN,
57
+ BusinessTax.NZ,
58
+ BusinessTax.US,
59
+ BusinessTax.CA,
60
+ BusinessTax.HK
61
+ ];
@@ -24,8 +24,7 @@ var BusinessUtils;
24
24
  BusinessUtils.addIdLabelBlankItem = addIdLabelBlankItem;
25
25
  // Get unit label by key
26
26
  function getUnitLabelByKey(func, key) {
27
- var _a;
28
- return (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
27
+ return func('unit' + key) ?? key;
29
28
  }
30
29
  /**
31
30
  * Get product unit's label
@@ -45,7 +44,7 @@ var BusinessUtils;
45
44
  * @returns Units
46
45
  */
47
46
  function getUnits(func) {
48
- return shared_1.Utils.getEnumKeys(ProductUnit_1.ProductUnit).map((key) => ({
47
+ return shared_1.DataTypes.getEnumKeys(ProductUnit_1.ProductUnit).map((key) => ({
49
48
  id: ProductUnit_1.ProductUnit[key],
50
49
  label: getUnitLabelByKey(func, key)
51
50
  }));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Id Dto
2
+ * Dto with id field
3
3
  */
4
4
  export declare type IdDto<T = number> = {
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
2
  /**
3
- * Id & label data
3
+ * Dto with id and label field
4
4
  */
5
5
  export declare type IdLabelDto = {
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { IdDto } from './IdDto';
2
2
  /**
3
- * Update Dto
3
+ * Dto with id and changedFields
4
4
  */
5
5
  export declare type UpdateDto<T = number> = IdDto<T> & {
6
6
  /**
@@ -13,7 +13,7 @@ export declare namespace AddressUtils {
13
13
  */
14
14
  function getContinents(func: ICultureGet, isNumberKey?: boolean): IdLabelDto[];
15
15
  /**
16
- * Get region
16
+ * Get region from regions and detected region and language
17
17
  * @param regions Supported regions
18
18
  * @param detectedRegion Detected region
19
19
  * @param detectedLanguage Detected language
@@ -1,4 +1,4 @@
1
- import { Utils } from '@etsoo/shared';
1
+ import { DataTypes } from '@etsoo/shared';
2
2
  import { AddressRegion } from '..';
3
3
  import { AddressContinent } from './AddressContinent';
4
4
  /**
@@ -13,19 +13,16 @@ export var AddressUtils;
13
13
  * @returns Continents
14
14
  */
15
15
  function getContinents(func, isNumberKey = false) {
16
- return Utils.getEnumKeys(AddressContinent).map((key) => {
17
- var _a;
18
- return ({
19
- id: isNumberKey
20
- ? AddressContinent[key]
21
- : key,
22
- label: (_a = func('continent' + key)) !== null && _a !== void 0 ? _a : key
23
- });
24
- });
16
+ return DataTypes.getEnumKeys(AddressContinent).map((key) => ({
17
+ id: isNumberKey
18
+ ? AddressContinent[key]
19
+ : key,
20
+ label: func('continent' + key) ?? key
21
+ }));
25
22
  }
26
23
  AddressUtils.getContinents = getContinents;
27
24
  /**
28
- * Get region
25
+ * Get region from regions and detected region and language
29
26
  * @param regions Supported regions
30
27
  * @param detectedRegion Detected region
31
28
  * @param detectedLanguage Detected language
@@ -3,7 +3,7 @@ import { DataTypes } from '@etsoo/shared';
3
3
  import { AddressRegion } from '../address/AddressRegion';
4
4
  import { IExternalSettings } from './ExternalSettings';
5
5
  /**
6
- * API settings interface
6
+ * App settings interface
7
7
  */
8
8
  export interface IAppSettings extends IExternalSettings {
9
9
  /**
@@ -30,7 +30,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
30
30
  /**
31
31
  * Label delegate
32
32
  */
33
- readonly labelDelegate: <T extends DataTypes.SimpleType = string>(key: string) => T | undefined;
33
+ readonly labelDelegate: <T = string>(key: string) => T | undefined;
34
34
  /**
35
35
  * Culture, like zh-CN
36
36
  */
@@ -114,7 +114,7 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
114
114
  * @param key key
115
115
  * @returns Resource
116
116
  */
117
- get<T extends DataTypes.SimpleType = string>(key: string): T | undefined;
117
+ get<T = string>(key: string): T | undefined;
118
118
  /**
119
119
  * Get multiple culture labels
120
120
  * @param keys Keys
@@ -203,7 +203,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
203
203
  /**
204
204
  * Label delegate
205
205
  */
206
- get labelDelegate(): <T extends DataTypes.SimpleType = string>(key: string) => T | undefined;
206
+ get labelDelegate(): <T = string>(key: string) => T | undefined;
207
207
  /**
208
208
  * IP data
209
209
  */
@@ -297,7 +297,7 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
297
297
  * @param key key
298
298
  * @returns Resource
299
299
  */
300
- get<T extends DataTypes.SimpleType = string>(key: string): T | undefined;
300
+ get<T = string>(key: string): T | undefined;
301
301
  /**
302
302
  * Get multiple culture labels
303
303
  * @param keys Keys
@@ -191,8 +191,7 @@ export class CoreApp {
191
191
  }
192
192
  // Detect IP callbacks
193
193
  detectIPCallbacks() {
194
- var _a;
195
- (_a = this.ipDetectCallbacks) === null || _a === void 0 ? void 0 : _a.forEach((f) => f());
194
+ this.ipDetectCallbacks?.forEach((f) => f());
196
195
  }
197
196
  /**
198
197
  * Format date to string
@@ -203,7 +202,7 @@ export class CoreApp {
203
202
  */
204
203
  formatDate(input, options, timeZone) {
205
204
  const { currentCulture, timeZone: defaultTimeZone } = this.settings;
206
- timeZone !== null && timeZone !== void 0 ? timeZone : (timeZone = defaultTimeZone);
205
+ timeZone ?? (timeZone = defaultTimeZone);
207
206
  return DateUtils.format(input, currentCulture.name, options, timeZone);
208
207
  }
209
208
  /**
@@ -242,6 +241,9 @@ export class CoreApp {
242
241
  const value = this.settings.currentCulture.resources[key];
243
242
  if (value == null)
244
243
  return undefined;
244
+ // No strict type convertion here
245
+ // Make sure the type is strictly match
246
+ // Otherwise even request number, may still return the source string type
245
247
  return value;
246
248
  }
247
249
  /**
@@ -250,7 +252,7 @@ export class CoreApp {
250
252
  */
251
253
  getLabels(...keys) {
252
254
  const init = {};
253
- return keys.reduce((a, v) => { var _a; return ({ ...a, [v]: (_a = this.get(v)) !== null && _a !== void 0 ? _a : '' }); }, init);
255
+ return keys.reduce((a, v) => ({ ...a, [v]: this.get(v) ?? '' }), init);
254
256
  }
255
257
  /**
256
258
  * Get cached token
@@ -291,9 +293,8 @@ export class CoreApp {
291
293
  * @returns Time zone
292
294
  */
293
295
  getTimeZone() {
294
- var _a, _b;
295
296
  // settings.timeZone = Utils.getTimeZone()
296
- return (_a = this.settings.timeZone) !== null && _a !== void 0 ? _a : (_b = this.ipData) === null || _b === void 0 ? void 0 : _b.timezone;
297
+ return this.settings.timeZone ?? this.ipData?.timezone;
297
298
  }
298
299
  /**
299
300
  * Callback where exit a page
@@ -1,5 +1,5 @@
1
1
  /**
2
- * External settings
2
+ * External settings items
3
3
  */
4
4
  export interface IExternalSettings {
5
5
  /**
@@ -48,4 +48,10 @@ BusinessTax.HK = new BusinessTax('HK', 'BRN', '00000000');
48
48
  /**
49
49
  * All countries and regions
50
50
  */
51
- BusinessTax.all = [BusinessTax.CN, BusinessTax.NZ, BusinessTax.US];
51
+ BusinessTax.all = [
52
+ BusinessTax.CN,
53
+ BusinessTax.NZ,
54
+ BusinessTax.US,
55
+ BusinessTax.CA,
56
+ BusinessTax.HK
57
+ ];
@@ -1,4 +1,4 @@
1
- import { Utils } from '@etsoo/shared';
1
+ import { DataTypes } from '@etsoo/shared';
2
2
  import { ProductUnit } from './ProductUnit';
3
3
  /**
4
4
  * Business utils
@@ -21,8 +21,7 @@ export var BusinessUtils;
21
21
  BusinessUtils.addIdLabelBlankItem = addIdLabelBlankItem;
22
22
  // Get unit label by key
23
23
  function getUnitLabelByKey(func, key) {
24
- var _a;
25
- return (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
24
+ return func('unit' + key) ?? key;
26
25
  }
27
26
  /**
28
27
  * Get product unit's label
@@ -42,7 +41,7 @@ export var BusinessUtils;
42
41
  * @returns Units
43
42
  */
44
43
  function getUnits(func) {
45
- return Utils.getEnumKeys(ProductUnit).map((key) => ({
44
+ return DataTypes.getEnumKeys(ProductUnit).map((key) => ({
46
45
  id: ProductUnit[key],
47
46
  label: getUnitLabelByKey(func, key)
48
47
  }));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Id Dto
2
+ * Dto with id field
3
3
  */
4
4
  export declare type IdDto<T = number> = {
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
2
  /**
3
- * Id & label data
3
+ * Dto with id and label field
4
4
  */
5
5
  export declare type IdLabelDto = {
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { IdDto } from './IdDto';
2
2
  /**
3
- * Update Dto
3
+ * Dto with id and changedFields
4
4
  */
5
5
  export declare type UpdateDto<T = number> = IdDto<T> & {
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -47,24 +47,24 @@
47
47
  },
48
48
  "homepage": "https://github.com/ETSOO/NotificationBase#readme",
49
49
  "dependencies": {
50
- "@etsoo/notificationbase": "^1.0.79",
51
- "@etsoo/restclient": "^1.0.51",
52
- "@etsoo/shared": "^1.0.46"
50
+ "@etsoo/notificationbase": "^1.0.82",
51
+ "@etsoo/restclient": "^1.0.52",
52
+ "@etsoo/shared": "^1.0.49"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@babel/cli": "^7.15.7",
56
- "@babel/core": "^7.15.5",
57
- "@babel/plugin-transform-runtime": "^7.15.0",
58
- "@babel/preset-env": "^7.15.6",
56
+ "@babel/core": "^7.15.8",
57
+ "@babel/plugin-transform-runtime": "^7.15.8",
58
+ "@babel/preset-env": "^7.15.8",
59
59
  "@babel/runtime-corejs3": "^7.15.4",
60
60
  "@types/jest": "^27.0.2",
61
- "@typescript-eslint/eslint-plugin": "^4.32.0",
62
- "@typescript-eslint/parser": "^4.32.0",
63
- "eslint": "^7.32.0",
61
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
62
+ "@typescript-eslint/parser": "^5.0.0",
63
+ "eslint": "^8.0.1",
64
64
  "eslint-config-airbnb-base": "^14.2.1",
65
- "eslint-plugin-import": "^2.24.2",
66
- "jest": "^27.2.4",
67
- "ts-jest": "^27.0.5",
68
- "typescript": "^4.4.3"
65
+ "eslint-plugin-import": "^2.25.2",
66
+ "jest": "^27.2.5",
67
+ "ts-jest": "^27.0.6",
68
+ "typescript": "^4.4.4"
69
69
  }
70
70
  }
@@ -1,4 +1,4 @@
1
- import { Utils } from '@etsoo/shared';
1
+ import { DataTypes } from '@etsoo/shared';
2
2
  import { AddressRegion } from '..';
3
3
  import { IdLabelDto } from '../dto/IdLabelDto';
4
4
  import { ICultureGet } from '../state/Culture';
@@ -18,7 +18,7 @@ export namespace AddressUtils {
18
18
  func: ICultureGet,
19
19
  isNumberKey: boolean = false
20
20
  ): IdLabelDto[] {
21
- return Utils.getEnumKeys(AddressContinent).map((key) => ({
21
+ return DataTypes.getEnumKeys(AddressContinent).map((key) => ({
22
22
  id: isNumberKey
23
23
  ? AddressContinent[key as keyof typeof AddressContinent]
24
24
  : key,
@@ -27,7 +27,7 @@ export namespace AddressUtils {
27
27
  }
28
28
 
29
29
  /**
30
- * Get region
30
+ * Get region from regions and detected region and language
31
31
  * @param regions Supported regions
32
32
  * @param detectedRegion Detected region
33
33
  * @param detectedLanguage Detected language
@@ -4,7 +4,7 @@ import { AddressRegion } from '../address/AddressRegion';
4
4
  import { IExternalSettings } from './ExternalSettings';
5
5
 
6
6
  /**
7
- * API settings interface
7
+ * App settings interface
8
8
  */
9
9
  export interface IAppSettings extends IExternalSettings {
10
10
  /**
@@ -46,9 +46,7 @@ export interface ICoreApp<
46
46
  /**
47
47
  * Label delegate
48
48
  */
49
- readonly labelDelegate: <T extends DataTypes.SimpleType = string>(
50
- key: string
51
- ) => T | undefined;
49
+ readonly labelDelegate: <T = string>(key: string) => T | undefined;
52
50
 
53
51
  /**
54
52
  * Culture, like zh-CN
@@ -159,7 +157,7 @@ export interface ICoreApp<
159
157
  * @param key key
160
158
  * @returns Resource
161
159
  */
162
- get<T extends DataTypes.SimpleType = string>(key: string): T | undefined;
160
+ get<T = string>(key: string): T | undefined;
163
161
 
164
162
  /**
165
163
  * Get multiple culture labels
@@ -560,9 +558,13 @@ export abstract class CoreApp<
560
558
  * @param key key
561
559
  * @returns Resource
562
560
  */
563
- get<T extends DataTypes.SimpleType = string>(key: string): T | undefined {
561
+ get<T = string>(key: string): T | undefined {
564
562
  const value = this.settings.currentCulture.resources[key];
565
563
  if (value == null) return undefined;
564
+
565
+ // No strict type convertion here
566
+ // Make sure the type is strictly match
567
+ // Otherwise even request number, may still return the source string type
566
568
  return value as T;
567
569
  }
568
570
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * External settings
2
+ * External settings items
3
3
  */
4
4
  export interface IExternalSettings {
5
5
  /**
@@ -58,7 +58,13 @@ export class BusinessTax implements IBusinessTax {
58
58
  /**
59
59
  * All countries and regions
60
60
  */
61
- static all = [BusinessTax.CN, BusinessTax.NZ, BusinessTax.US];
61
+ static all = [
62
+ BusinessTax.CN,
63
+ BusinessTax.NZ,
64
+ BusinessTax.US,
65
+ BusinessTax.CA,
66
+ BusinessTax.HK
67
+ ];
62
68
 
63
69
  /**
64
70
  * Get country or region by id
@@ -1,4 +1,4 @@
1
- import { Utils } from '@etsoo/shared';
1
+ import { DataTypes } from '@etsoo/shared';
2
2
  import { IdLabelDto } from '../dto/IdLabelDto';
3
3
  import { ICultureGet } from '../state/Culture';
4
4
  import { ProductUnit } from './ProductUnit';
@@ -47,7 +47,7 @@ export namespace BusinessUtils {
47
47
  * @returns Units
48
48
  */
49
49
  export function getUnits(func: ICultureGet): IdLabelDto[] {
50
- return Utils.getEnumKeys(ProductUnit).map((key) => ({
50
+ return DataTypes.getEnumKeys(ProductUnit).map((key) => ({
51
51
  id: ProductUnit[key as keyof typeof ProductUnit],
52
52
  label: getUnitLabelByKey(func, key)
53
53
  }));
package/src/dto/IdDto.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Id Dto
2
+ * Dto with id field
3
3
  */
4
4
  export type IdDto<T = number> = {
5
5
  /**
@@ -1,7 +1,7 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
2
 
3
3
  /**
4
- * Id & label data
4
+ * Dto with id and label field
5
5
  */
6
6
  export type IdLabelDto = {
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { IdDto } from './IdDto';
2
2
 
3
3
  /**
4
- * Update Dto
4
+ * Dto with id and changedFields
5
5
  */
6
6
  export type UpdateDto<T = number> = IdDto<T> & {
7
7
  /**
package/tsconfig.cjs.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
- "target": "ES2019",
4
+ "target": "ES2020",
5
5
  "module": "commonjs",
6
6
  "moduleResolution": "node",
7
7
  "isolatedModules": true,
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
- "target": "ES2019",
4
+ "target": "ES2020",
5
5
  "module": "ESNext",
6
6
  "moduleResolution": "node",
7
7
  "isolatedModules": true,