@etsoo/appscript 1.3.38 → 1.3.40

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.
@@ -214,6 +214,11 @@ test('Tests for addressApi', () => {
214
214
  expect(favoredRegions.find((region) => region.id === 'US')?.label).toBe(
215
215
  '美国'
216
216
  );
217
+
218
+ const region = app.addressApi.region('US');
219
+ expect(region?.label).toBe('美国');
220
+ const regionFailed = app.addressApi.region('ABC');
221
+ expect(regionFailed).toBeUndefined();
217
222
  });
218
223
 
219
224
  /*
@@ -249,7 +254,7 @@ test('Tests for publicApi', async () => {
249
254
  const currencies1 = app.publicApi.currencies(true);
250
255
  expect(currencies1.length >= 10).toBeTruthy();
251
256
 
252
- expect(app.publicApi.getCurrencyLabel('USD')).toBe('美元$');
257
+ expect(app.publicApi.getCurrencyLabel('USD')).toBe('美元');
253
258
 
254
259
  const defaultExchangeRate = await app.publicApi.exchangeRate('CNY', {
255
260
  showLoading: false
@@ -22,6 +22,12 @@ export declare class AddressApi extends BaseApi {
22
22
  * @returns Label
23
23
  */
24
24
  getContinentLabel(id: AddressContinent | string): string;
25
+ /**
26
+ * Get region by id
27
+ * @param id Region id
28
+ * @returns Result
29
+ */
30
+ getRegion(id?: string): Promise<AddressRegionDb | AddressRegion | undefined>;
25
31
  /**
26
32
  * Get all regions
27
33
  * @param rq Rquest data
@@ -33,6 +39,12 @@ export declare class AddressApi extends BaseApi {
33
39
  * @returns Result
34
40
  */
35
41
  regionCurrency(regionId?: string): "AUD" | "CAD" | "CNY" | "EUR" | "GBP" | "HKD" | "JPY" | "NZD" | "SGD" | "USD";
42
+ /**
43
+ * Get local region by id
44
+ * @param id Region id
45
+ * @returns Result
46
+ */
47
+ region(id?: string): AddressRegion | undefined;
36
48
  /**
37
49
  * Get all local regions
38
50
  */
@@ -35,6 +35,19 @@ class AddressApi extends BaseApi_1.BaseApi {
35
35
  var _a;
36
36
  return (_a = this.app.get('continent' + id)) !== null && _a !== void 0 ? _a : id;
37
37
  }
38
+ /**
39
+ * Get region by id
40
+ * @param id Region id
41
+ * @returns Result
42
+ */
43
+ async getRegion(id) {
44
+ if (!id)
45
+ return this.app.defaultRegion;
46
+ const regions = await this.getRegions({ id });
47
+ if (regions == null || regions.length === 0)
48
+ return undefined;
49
+ return regions[0];
50
+ }
38
51
  /**
39
52
  * Get all regions
40
53
  * @param rq Rquest data
@@ -90,6 +103,16 @@ class AddressApi extends BaseApi_1.BaseApi {
90
103
  : null)) !== null && _a !== void 0 ? _a : this.app.settings.currentRegion;
91
104
  return region.currency;
92
105
  }
106
+ /**
107
+ * Get local region by id
108
+ * @param id Region id
109
+ * @returns Result
110
+ */
111
+ region(id) {
112
+ if (!id)
113
+ return this.app.defaultRegion;
114
+ return this.regions().find((region) => region.id === id);
115
+ }
93
116
  regions(p) {
94
117
  const items = p == null || p.length === 0
95
118
  ? AddressRegion_1.AddressRegion.all
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "Current password",
29
29
  "currentPasswordRequired": "Please enter your current password",
30
30
  "currency": "Currency",
31
- "currencyAUD": "Australia Dollar $",
32
- "currencyCAD": "Canada Dollar $",
33
- "currencyCNY": "Renminbi(RMB) ¥",
34
- "currencyEUR": "Euro",
35
- "currencyGBP": "British Pound £",
36
- "currencyHKD": "Hong Kong Dollar $",
37
- "currencyJPY": "Japan Yen ¥",
38
- "currencyNZD": "New Zealand Dollar $",
39
- "currencySGD": "Singapore Dollar $",
40
- "currencyUSD": "U.S. Dollar $",
31
+ "currencyAUD": "Australia Dollar",
32
+ "currencyCAD": "Canada Dollar",
33
+ "currencyCNY": "Renminbi(RMB)",
34
+ "currencyEUR": "Euro",
35
+ "currencyGBP": "British Pound",
36
+ "currencyHKD": "Hong Kong Dollar",
37
+ "currencyJPY": "Japan Yen",
38
+ "currencyNZD": "New Zealand Dollar",
39
+ "currencySGD": "Singapore Dollar",
40
+ "currencyUSD": "U.S. Dollar",
41
41
  "data": "Data",
42
42
  "dataComparison": "Data comparison",
43
43
  "delete": "Delete",
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "当前密码",
29
29
  "currentPasswordRequired": "请输入现在使用的密码",
30
30
  "currency": "币种",
31
- "currencyAUD": "澳元$",
32
- "currencyCAD": "加元$",
33
- "currencyCNY": "人民币¥",
34
- "currencyEUR": "欧元€",
35
- "currencyGBP": "英镑£",
36
- "currencyHKD": "港币$",
37
- "currencyJPY": "日元¥",
38
- "currencyNZD": "纽币$",
39
- "currencySGD": "新币$",
40
- "currencyUSD": "美元$",
31
+ "currencyAUD": "澳元",
32
+ "currencyCAD": "加元",
33
+ "currencyCNY": "人民币",
34
+ "currencyEUR": "欧元",
35
+ "currencyGBP": "英镑",
36
+ "currencyHKD": "港币",
37
+ "currencyJPY": "日元",
38
+ "currencyNZD": "纽币",
39
+ "currencySGD": "新币",
40
+ "currencyUSD": "美元",
41
41
  "data": "数据",
42
42
  "dataComparison": "数据对比",
43
43
  "delete": "删除",
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "當前密碼",
29
29
  "currentPasswordRequired": "請輸入現在使用的密碼",
30
30
  "currency": "幣種",
31
- "currencyAUD": "澳元$",
32
- "currencyCAD": "加元$",
33
- "currencyCNY": "人民幣¥",
34
- "currencyEUR": "歐元€",
35
- "currencyGBP": "英鎊£",
36
- "currencyHKD": "港幣$",
37
- "currencyJPY": "日元¥",
38
- "currencyNZD": "紐幣$",
39
- "currencySGD": "新幣$",
40
- "currencyUSD": "美元$",
31
+ "currencyAUD": "澳元",
32
+ "currencyCAD": "加元",
33
+ "currencyCNY": "人民幣",
34
+ "currencyEUR": "歐元",
35
+ "currencyGBP": "英鎊",
36
+ "currencyHKD": "港幣",
37
+ "currencyJPY": "日元",
38
+ "currencyNZD": "紐幣",
39
+ "currencySGD": "新幣",
40
+ "currencyUSD": "美元",
41
41
  "data": "數據",
42
42
  "dataComparison": "數據對比",
43
43
  "delete": "刪除",
@@ -22,6 +22,12 @@ export declare class AddressApi extends BaseApi {
22
22
  * @returns Label
23
23
  */
24
24
  getContinentLabel(id: AddressContinent | string): string;
25
+ /**
26
+ * Get region by id
27
+ * @param id Region id
28
+ * @returns Result
29
+ */
30
+ getRegion(id?: string): Promise<AddressRegionDb | AddressRegion | undefined>;
25
31
  /**
26
32
  * Get all regions
27
33
  * @param rq Rquest data
@@ -33,6 +39,12 @@ export declare class AddressApi extends BaseApi {
33
39
  * @returns Result
34
40
  */
35
41
  regionCurrency(regionId?: string): "AUD" | "CAD" | "CNY" | "EUR" | "GBP" | "HKD" | "JPY" | "NZD" | "SGD" | "USD";
42
+ /**
43
+ * Get local region by id
44
+ * @param id Region id
45
+ * @returns Result
46
+ */
47
+ region(id?: string): AddressRegion | undefined;
36
48
  /**
37
49
  * Get all local regions
38
50
  */
@@ -32,6 +32,19 @@ export class AddressApi extends BaseApi {
32
32
  var _a;
33
33
  return (_a = this.app.get('continent' + id)) !== null && _a !== void 0 ? _a : id;
34
34
  }
35
+ /**
36
+ * Get region by id
37
+ * @param id Region id
38
+ * @returns Result
39
+ */
40
+ async getRegion(id) {
41
+ if (!id)
42
+ return this.app.defaultRegion;
43
+ const regions = await this.getRegions({ id });
44
+ if (regions == null || regions.length === 0)
45
+ return undefined;
46
+ return regions[0];
47
+ }
35
48
  /**
36
49
  * Get all regions
37
50
  * @param rq Rquest data
@@ -87,6 +100,16 @@ export class AddressApi extends BaseApi {
87
100
  : null)) !== null && _a !== void 0 ? _a : this.app.settings.currentRegion;
88
101
  return region.currency;
89
102
  }
103
+ /**
104
+ * Get local region by id
105
+ * @param id Region id
106
+ * @returns Result
107
+ */
108
+ region(id) {
109
+ if (!id)
110
+ return this.app.defaultRegion;
111
+ return this.regions().find((region) => region.id === id);
112
+ }
90
113
  regions(p) {
91
114
  const items = p == null || p.length === 0
92
115
  ? AddressRegion.all
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "Current password",
29
29
  "currentPasswordRequired": "Please enter your current password",
30
30
  "currency": "Currency",
31
- "currencyAUD": "Australia Dollar $",
32
- "currencyCAD": "Canada Dollar $",
33
- "currencyCNY": "Renminbi(RMB) ¥",
34
- "currencyEUR": "Euro",
35
- "currencyGBP": "British Pound £",
36
- "currencyHKD": "Hong Kong Dollar $",
37
- "currencyJPY": "Japan Yen ¥",
38
- "currencyNZD": "New Zealand Dollar $",
39
- "currencySGD": "Singapore Dollar $",
40
- "currencyUSD": "U.S. Dollar $",
31
+ "currencyAUD": "Australia Dollar",
32
+ "currencyCAD": "Canada Dollar",
33
+ "currencyCNY": "Renminbi(RMB)",
34
+ "currencyEUR": "Euro",
35
+ "currencyGBP": "British Pound",
36
+ "currencyHKD": "Hong Kong Dollar",
37
+ "currencyJPY": "Japan Yen",
38
+ "currencyNZD": "New Zealand Dollar",
39
+ "currencySGD": "Singapore Dollar",
40
+ "currencyUSD": "U.S. Dollar",
41
41
  "data": "Data",
42
42
  "dataComparison": "Data comparison",
43
43
  "delete": "Delete",
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "当前密码",
29
29
  "currentPasswordRequired": "请输入现在使用的密码",
30
30
  "currency": "币种",
31
- "currencyAUD": "澳元$",
32
- "currencyCAD": "加元$",
33
- "currencyCNY": "人民币¥",
34
- "currencyEUR": "欧元€",
35
- "currencyGBP": "英镑£",
36
- "currencyHKD": "港币$",
37
- "currencyJPY": "日元¥",
38
- "currencyNZD": "纽币$",
39
- "currencySGD": "新币$",
40
- "currencyUSD": "美元$",
31
+ "currencyAUD": "澳元",
32
+ "currencyCAD": "加元",
33
+ "currencyCNY": "人民币",
34
+ "currencyEUR": "欧元",
35
+ "currencyGBP": "英镑",
36
+ "currencyHKD": "港币",
37
+ "currencyJPY": "日元",
38
+ "currencyNZD": "纽币",
39
+ "currencySGD": "新币",
40
+ "currencyUSD": "美元",
41
41
  "data": "数据",
42
42
  "dataComparison": "数据对比",
43
43
  "delete": "删除",
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "當前密碼",
29
29
  "currentPasswordRequired": "請輸入現在使用的密碼",
30
30
  "currency": "幣種",
31
- "currencyAUD": "澳元$",
32
- "currencyCAD": "加元$",
33
- "currencyCNY": "人民幣¥",
34
- "currencyEUR": "歐元€",
35
- "currencyGBP": "英鎊£",
36
- "currencyHKD": "港幣$",
37
- "currencyJPY": "日元¥",
38
- "currencyNZD": "紐幣$",
39
- "currencySGD": "新幣$",
40
- "currencyUSD": "美元$",
31
+ "currencyAUD": "澳元",
32
+ "currencyCAD": "加元",
33
+ "currencyCNY": "人民幣",
34
+ "currencyEUR": "歐元",
35
+ "currencyGBP": "英鎊",
36
+ "currencyHKD": "港幣",
37
+ "currencyJPY": "日元",
38
+ "currencyNZD": "紐幣",
39
+ "currencySGD": "新幣",
40
+ "currencyUSD": "美元",
41
41
  "data": "數據",
42
42
  "dataComparison": "數據對比",
43
43
  "delete": "刪除",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.3.38",
3
+ "version": "1.3.40",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -42,6 +42,18 @@ export class AddressApi extends BaseApi {
42
42
  return this.app.get('continent' + id) ?? (id as string);
43
43
  }
44
44
 
45
+ /**
46
+ * Get region by id
47
+ * @param id Region id
48
+ * @returns Result
49
+ */
50
+ async getRegion(id?: string) {
51
+ if (!id) return this.app.defaultRegion;
52
+ const regions = await this.getRegions({ id });
53
+ if (regions == null || regions.length === 0) return undefined;
54
+ return regions[0];
55
+ }
56
+
45
57
  /**
46
58
  * Get all regions
47
59
  * @param rq Rquest data
@@ -105,6 +117,16 @@ export class AddressApi extends BaseApi {
105
117
  return region.currency;
106
118
  }
107
119
 
120
+ /**
121
+ * Get local region by id
122
+ * @param id Region id
123
+ * @returns Result
124
+ */
125
+ region(id?: string) {
126
+ if (!id) return this.app.defaultRegion;
127
+ return this.regions().find((region) => region.id === id);
128
+ }
129
+
108
130
  /**
109
131
  * Get all local regions
110
132
  */
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "Current password",
29
29
  "currentPasswordRequired": "Please enter your current password",
30
30
  "currency": "Currency",
31
- "currencyAUD": "Australia Dollar $",
32
- "currencyCAD": "Canada Dollar $",
33
- "currencyCNY": "Renminbi(RMB) ¥",
34
- "currencyEUR": "Euro",
35
- "currencyGBP": "British Pound £",
36
- "currencyHKD": "Hong Kong Dollar $",
37
- "currencyJPY": "Japan Yen ¥",
38
- "currencyNZD": "New Zealand Dollar $",
39
- "currencySGD": "Singapore Dollar $",
40
- "currencyUSD": "U.S. Dollar $",
31
+ "currencyAUD": "Australia Dollar",
32
+ "currencyCAD": "Canada Dollar",
33
+ "currencyCNY": "Renminbi(RMB)",
34
+ "currencyEUR": "Euro",
35
+ "currencyGBP": "British Pound",
36
+ "currencyHKD": "Hong Kong Dollar",
37
+ "currencyJPY": "Japan Yen",
38
+ "currencyNZD": "New Zealand Dollar",
39
+ "currencySGD": "Singapore Dollar",
40
+ "currencyUSD": "U.S. Dollar",
41
41
  "data": "Data",
42
42
  "dataComparison": "Data comparison",
43
43
  "delete": "Delete",
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "当前密码",
29
29
  "currentPasswordRequired": "请输入现在使用的密码",
30
30
  "currency": "币种",
31
- "currencyAUD": "澳元$",
32
- "currencyCAD": "加元$",
33
- "currencyCNY": "人民币¥",
34
- "currencyEUR": "欧元€",
35
- "currencyGBP": "英镑£",
36
- "currencyHKD": "港币$",
37
- "currencyJPY": "日元¥",
38
- "currencyNZD": "纽币$",
39
- "currencySGD": "新币$",
40
- "currencyUSD": "美元$",
31
+ "currencyAUD": "澳元",
32
+ "currencyCAD": "加元",
33
+ "currencyCNY": "人民币",
34
+ "currencyEUR": "欧元",
35
+ "currencyGBP": "英镑",
36
+ "currencyHKD": "港币",
37
+ "currencyJPY": "日元",
38
+ "currencyNZD": "纽币",
39
+ "currencySGD": "新币",
40
+ "currencyUSD": "美元",
41
41
  "data": "数据",
42
42
  "dataComparison": "数据对比",
43
43
  "delete": "删除",
@@ -28,16 +28,16 @@
28
28
  "currentPassword": "當前密碼",
29
29
  "currentPasswordRequired": "請輸入現在使用的密碼",
30
30
  "currency": "幣種",
31
- "currencyAUD": "澳元$",
32
- "currencyCAD": "加元$",
33
- "currencyCNY": "人民幣¥",
34
- "currencyEUR": "歐元€",
35
- "currencyGBP": "英鎊£",
36
- "currencyHKD": "港幣$",
37
- "currencyJPY": "日元¥",
38
- "currencyNZD": "紐幣$",
39
- "currencySGD": "新幣$",
40
- "currencyUSD": "美元$",
31
+ "currencyAUD": "澳元",
32
+ "currencyCAD": "加元",
33
+ "currencyCNY": "人民幣",
34
+ "currencyEUR": "歐元",
35
+ "currencyGBP": "英鎊",
36
+ "currencyHKD": "港幣",
37
+ "currencyJPY": "日元",
38
+ "currencyNZD": "紐幣",
39
+ "currencySGD": "新幣",
40
+ "currencyUSD": "美元",
41
41
  "data": "數據",
42
42
  "dataComparison": "數據對比",
43
43
  "delete": "刪除",