@etsoo/appscript 1.3.38 → 1.3.39
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.
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -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
|
/*
|
|
@@ -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
|
|
@@ -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
|
package/package.json
CHANGED
package/src/erp/AddressApi.ts
CHANGED
|
@@ -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
|
*/
|