@etsoo/appscript 1.3.63 → 1.3.65

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,6 +28,12 @@ export declare class AddressApi extends BaseApi {
28
28
  * @returns Result
29
29
  */
30
30
  getRegion(id?: string): Promise<AddressRegionDb | AddressRegion | undefined>;
31
+ /**
32
+ * Get region label
33
+ * @param id Region id
34
+ * @returns Label
35
+ */
36
+ getRegionLabel(id: string): string;
31
37
  /**
32
38
  * Get all regions
33
39
  * @param rq Rquest data
@@ -48,12 +48,30 @@ class AddressApi extends BaseApi_1.BaseApi {
48
48
  return undefined;
49
49
  return regions[0];
50
50
  }
51
+ /**
52
+ * Get region label
53
+ * @param id Region id
54
+ * @returns Label
55
+ */
56
+ getRegionLabel(id) {
57
+ // Local defined region label
58
+ let label = this.app.getRegionLabel(id);
59
+ if (label === id) {
60
+ // Cache data, make sure called getRegions first
61
+ const regions = cachedRegions[this.app.culture];
62
+ const region = regions === null || regions === void 0 ? void 0 : regions.find((region) => region.id === id);
63
+ if (region)
64
+ return region.label;
65
+ }
66
+ return label;
67
+ }
51
68
  /**
52
69
  * Get all regions
53
70
  * @param rq Rquest data
54
71
  */
55
72
  async getRegions(rq) {
56
- const culture = this.app.culture;
73
+ var _a;
74
+ const culture = (_a = rq === null || rq === void 0 ? void 0 : rq.culture) !== null && _a !== void 0 ? _a : this.app.culture;
57
75
  let regions = cachedRegions[culture];
58
76
  if (regions == null) {
59
77
  regions = await this.api.get(`Address/RegionList?language=${culture}`, undefined, { defaultValue: [], showLoading: false });
@@ -19,7 +19,12 @@ export declare class PublicApi extends BaseApi {
19
19
  * Asset units
20
20
  * @returns Result
21
21
  */
22
- assetUnits(): ListType1[];
22
+ assetUnits(): ListType[];
23
+ /**
24
+ * Asset string id units
25
+ * @returns Result
26
+ */
27
+ assetStrUnits(): ListType1[];
23
28
  /**
24
29
  * Base units
25
30
  * @returns Result
@@ -24,6 +24,13 @@ class PublicApi extends BaseApi_1.BaseApi {
24
24
  * @returns Result
25
25
  */
26
26
  assetUnits() {
27
+ return this.app.getEnumList(ProductUnit_1.AssetUnits, unitPrefix);
28
+ }
29
+ /**
30
+ * Asset string id units
31
+ * @returns Result
32
+ */
33
+ assetStrUnits() {
27
34
  return this.app.getEnumStrList(ProductUnit_1.AssetUnits, unitPrefix);
28
35
  }
29
36
  /**
@@ -15,4 +15,8 @@ export type RegionsRQ = {
15
15
  * Filter keyword
16
16
  */
17
17
  keyword?: string;
18
+ /**
19
+ * Cultrue
20
+ */
21
+ culture?: string;
18
22
  };
@@ -28,6 +28,12 @@ export declare class AddressApi extends BaseApi {
28
28
  * @returns Result
29
29
  */
30
30
  getRegion(id?: string): Promise<AddressRegionDb | AddressRegion | undefined>;
31
+ /**
32
+ * Get region label
33
+ * @param id Region id
34
+ * @returns Label
35
+ */
36
+ getRegionLabel(id: string): string;
31
37
  /**
32
38
  * Get all regions
33
39
  * @param rq Rquest data
@@ -45,12 +45,30 @@ export class AddressApi extends BaseApi {
45
45
  return undefined;
46
46
  return regions[0];
47
47
  }
48
+ /**
49
+ * Get region label
50
+ * @param id Region id
51
+ * @returns Label
52
+ */
53
+ getRegionLabel(id) {
54
+ // Local defined region label
55
+ let label = this.app.getRegionLabel(id);
56
+ if (label === id) {
57
+ // Cache data, make sure called getRegions first
58
+ const regions = cachedRegions[this.app.culture];
59
+ const region = regions === null || regions === void 0 ? void 0 : regions.find((region) => region.id === id);
60
+ if (region)
61
+ return region.label;
62
+ }
63
+ return label;
64
+ }
48
65
  /**
49
66
  * Get all regions
50
67
  * @param rq Rquest data
51
68
  */
52
69
  async getRegions(rq) {
53
- const culture = this.app.culture;
70
+ var _a;
71
+ const culture = (_a = rq === null || rq === void 0 ? void 0 : rq.culture) !== null && _a !== void 0 ? _a : this.app.culture;
54
72
  let regions = cachedRegions[culture];
55
73
  if (regions == null) {
56
74
  regions = await this.api.get(`Address/RegionList?language=${culture}`, undefined, { defaultValue: [], showLoading: false });
@@ -19,7 +19,12 @@ export declare class PublicApi extends BaseApi {
19
19
  * Asset units
20
20
  * @returns Result
21
21
  */
22
- assetUnits(): ListType1[];
22
+ assetUnits(): ListType[];
23
+ /**
24
+ * Asset string id units
25
+ * @returns Result
26
+ */
27
+ assetStrUnits(): ListType1[];
23
28
  /**
24
29
  * Base units
25
30
  * @returns Result
@@ -21,6 +21,13 @@ export class PublicApi extends BaseApi {
21
21
  * @returns Result
22
22
  */
23
23
  assetUnits() {
24
+ return this.app.getEnumList(AssetUnits, unitPrefix);
25
+ }
26
+ /**
27
+ * Asset string id units
28
+ * @returns Result
29
+ */
30
+ assetStrUnits() {
24
31
  return this.app.getEnumStrList(AssetUnits, unitPrefix);
25
32
  }
26
33
  /**
@@ -15,4 +15,8 @@ export type RegionsRQ = {
15
15
  * Filter keyword
16
16
  */
17
17
  keyword?: string;
18
+ /**
19
+ * Cultrue
20
+ */
21
+ culture?: string;
18
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.3.63",
3
+ "version": "1.3.65",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,12 +54,29 @@ export class AddressApi extends BaseApi {
54
54
  return regions[0];
55
55
  }
56
56
 
57
+ /**
58
+ * Get region label
59
+ * @param id Region id
60
+ * @returns Label
61
+ */
62
+ getRegionLabel(id: string) {
63
+ // Local defined region label
64
+ let label = this.app.getRegionLabel(id);
65
+ if (label === id) {
66
+ // Cache data, make sure called getRegions first
67
+ const regions = cachedRegions[this.app.culture];
68
+ const region = regions?.find((region) => region.id === id);
69
+ if (region) return region.label;
70
+ }
71
+ return label;
72
+ }
73
+
57
74
  /**
58
75
  * Get all regions
59
76
  * @param rq Rquest data
60
77
  */
61
78
  async getRegions(rq?: RegionsRQ): Promise<AddressRegionDb[] | undefined> {
62
- const culture = this.app.culture;
79
+ const culture = rq?.culture ?? this.app.culture;
63
80
  let regions = cachedRegions[culture];
64
81
  if (regions == null) {
65
82
  regions = await this.api.get<AddressRegionDb[]>(
@@ -29,6 +29,14 @@ export class PublicApi extends BaseApi {
29
29
  * @returns Result
30
30
  */
31
31
  assetUnits() {
32
+ return this.app.getEnumList(AssetUnits, unitPrefix);
33
+ }
34
+
35
+ /**
36
+ * Asset string id units
37
+ * @returns Result
38
+ */
39
+ assetStrUnits() {
32
40
  return this.app.getEnumStrList(AssetUnits, unitPrefix);
33
41
  }
34
42
 
@@ -18,4 +18,9 @@ export type RegionsRQ = {
18
18
  * Filter keyword
19
19
  */
20
20
  keyword?: string;
21
+
22
+ /**
23
+ * Cultrue
24
+ */
25
+ culture?: string;
21
26
  };