@etsoo/appscript 1.3.33 → 1.3.35
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 +27 -4
- package/lib/cjs/address/AddressContinent.d.ts +1 -1
- package/lib/cjs/address/AddressRegion.d.ts +7 -1
- package/lib/cjs/address/AddressRegion.js +21 -20
- package/lib/cjs/address/AddressState.d.ts +1 -1
- package/lib/cjs/app/CoreApp.js +45 -45
- package/lib/cjs/app/IApp.d.ts +2 -2
- package/lib/cjs/bridges/FlutterHost.d.ts +2 -1
- package/lib/cjs/bridges/FlutterHost.js +1 -0
- package/lib/cjs/bridges/IBridgeHost.d.ts +5 -0
- package/lib/cjs/business/BusinessTax.js +6 -6
- package/lib/cjs/business/Currency.d.ts +1 -1
- package/lib/cjs/business/ProductUnit.d.ts +1 -1
- package/lib/cjs/def/ListItem.d.ts +1 -1
- package/lib/cjs/erp/AddressApi.d.ts +16 -2
- package/lib/cjs/erp/AddressApi.js +43 -12
- package/lib/cjs/erp/BaseApi.js +6 -6
- package/lib/cjs/erp/EntityApi.d.ts +5 -0
- package/lib/cjs/erp/EntityApi.js +13 -0
- package/lib/cjs/erp/dto/AuditLineDto.d.ts +3 -3
- package/lib/cjs/erp/dto/CurrencyDto.d.ts +1 -1
- package/lib/cjs/erp/dto/ExchangeRateDto.d.ts +1 -1
- package/lib/cjs/erp/dto/ExchangeRateHistoryDto.d.ts +1 -1
- package/lib/cjs/erp/dto/IdLabelDto.d.ts +1 -1
- package/lib/cjs/erp/dto/IdLabelPrimaryDto.d.ts +1 -1
- package/lib/cjs/erp/dto/InitCallDto.d.ts +1 -1
- package/lib/cjs/erp/dto/OrgDto.d.ts +1 -1
- package/lib/cjs/erp/dto/OrgQueryDto.d.ts +1 -1
- package/lib/cjs/erp/dto/PublicProductDto.d.ts +2 -2
- package/lib/cjs/erp/dto/ResultPayload.d.ts +3 -3
- package/lib/cjs/erp/rq/MemberListRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/OrgListRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/OrgQueryRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/QueryRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/RefreshTokenRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/RegionsRQ.d.ts +14 -0
- package/lib/cjs/erp/rq/RegionsRQ.js +2 -0
- package/lib/cjs/erp/rq/TiplistRQ.d.ts +1 -1
- package/lib/cjs/i18n/en-US.json +1 -0
- package/lib/cjs/i18n/zh-CN.json +1 -0
- package/lib/cjs/i18n/zh-HK.json +1 -0
- package/lib/cjs/result/ActionResultError.js +12 -12
- package/lib/cjs/result/IActionResult.d.ts +2 -2
- package/lib/cjs/result/InitCallResult.d.ts +1 -1
- package/lib/cjs/state/User.d.ts +1 -1
- package/lib/mjs/address/AddressContinent.d.ts +1 -1
- package/lib/mjs/address/AddressRegion.d.ts +7 -1
- package/lib/mjs/address/AddressRegion.js +21 -20
- package/lib/mjs/address/AddressState.d.ts +1 -1
- package/lib/mjs/app/CoreApp.js +45 -45
- package/lib/mjs/app/IApp.d.ts +2 -2
- package/lib/mjs/bridges/FlutterHost.d.ts +2 -1
- package/lib/mjs/bridges/FlutterHost.js +1 -0
- package/lib/mjs/bridges/IBridgeHost.d.ts +5 -0
- package/lib/mjs/business/BusinessTax.js +6 -6
- package/lib/mjs/business/Currency.d.ts +1 -1
- package/lib/mjs/business/ProductUnit.d.ts +1 -1
- package/lib/mjs/def/ListItem.d.ts +1 -1
- package/lib/mjs/erp/AddressApi.d.ts +16 -2
- package/lib/mjs/erp/AddressApi.js +43 -12
- package/lib/mjs/erp/BaseApi.js +6 -6
- package/lib/mjs/erp/EntityApi.d.ts +5 -0
- package/lib/mjs/erp/EntityApi.js +13 -0
- package/lib/mjs/erp/dto/AuditLineDto.d.ts +3 -3
- package/lib/mjs/erp/dto/CurrencyDto.d.ts +1 -1
- package/lib/mjs/erp/dto/ExchangeRateDto.d.ts +1 -1
- package/lib/mjs/erp/dto/ExchangeRateHistoryDto.d.ts +1 -1
- package/lib/mjs/erp/dto/IdLabelDto.d.ts +1 -1
- package/lib/mjs/erp/dto/IdLabelPrimaryDto.d.ts +1 -1
- package/lib/mjs/erp/dto/InitCallDto.d.ts +1 -1
- package/lib/mjs/erp/dto/OrgDto.d.ts +1 -1
- package/lib/mjs/erp/dto/OrgQueryDto.d.ts +1 -1
- package/lib/mjs/erp/dto/PublicProductDto.d.ts +2 -2
- package/lib/mjs/erp/dto/ResultPayload.d.ts +3 -3
- package/lib/mjs/erp/rq/MemberListRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/OrgListRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/OrgQueryRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/QueryRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/RefreshTokenRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/RegionsRQ.d.ts +14 -0
- package/lib/mjs/erp/rq/RegionsRQ.js +1 -0
- package/lib/mjs/erp/rq/TiplistRQ.d.ts +1 -1
- package/lib/mjs/i18n/en-US.json +1 -0
- package/lib/mjs/i18n/zh-CN.json +1 -0
- package/lib/mjs/i18n/zh-HK.json +1 -0
- package/lib/mjs/result/ActionResultError.js +12 -12
- package/lib/mjs/result/IActionResult.d.ts +2 -2
- package/lib/mjs/result/InitCallResult.d.ts +1 -1
- package/lib/mjs/state/User.d.ts +1 -1
- package/package.json +9 -9
- package/src/address/AddressRegion.ts +29 -10
- package/src/bridges/FlutterHost.ts +2 -0
- package/src/bridges/IBridgeHost.ts +6 -0
- package/src/erp/AddressApi.ts +72 -25
- package/src/erp/EntityApi.ts +13 -0
- package/src/erp/rq/RegionsRQ.ts +16 -0
- package/src/i18n/en-US.json +1 -0
- package/src/i18n/zh-CN.json +1 -0
- package/src/i18n/zh-HK.json +1 -0
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -204,13 +204,36 @@ test('Tests for isValidPassword', () => {
|
|
|
204
204
|
expect(app.isValidPassword('1234abcd')).toBeTruthy();
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
-
test('Tests for addressApi',
|
|
208
|
-
const continents = await app.addressApi.continents();
|
|
209
|
-
expect(continents.length).toBe(7);
|
|
210
|
-
|
|
207
|
+
test('Tests for addressApi', () => {
|
|
211
208
|
const regions = app.addressApi.regions();
|
|
212
209
|
const cn = regions.find((r) => r.id === 'CN');
|
|
213
210
|
expect(cn?.label).toBe('中国大陆');
|
|
211
|
+
|
|
212
|
+
const favoredRegions = app.addressApi.regions(['US', 'CA']);
|
|
213
|
+
expect(favoredRegions.length).toBe(2);
|
|
214
|
+
expect(favoredRegions.find((region) => region.id === 'US')?.label).toBe(
|
|
215
|
+
'美国'
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
/*
|
|
220
|
+
test('Tests for addressApi Async', async () => {
|
|
221
|
+
const regions = await app.addressApi.getRegions({
|
|
222
|
+
items: 3,
|
|
223
|
+
favoredIds: ['US', 'AU', 'CA', 'NZ']
|
|
224
|
+
});
|
|
225
|
+
expect(regions?.length).toBe(3);
|
|
226
|
+
expect(regions![2].id).toBe('CA');
|
|
227
|
+
});
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
test('Tests for addressApi.continents', () => {
|
|
231
|
+
const continents1 = app.addressApi.continents();
|
|
232
|
+
const continents2 = app.addressApi.continents(true, true);
|
|
233
|
+
expect(continents1.length).toBe(6);
|
|
234
|
+
expect(continents1.some((item) => item.id === 'AN')).toBeFalsy();
|
|
235
|
+
expect(continents2.length).toBe(7);
|
|
236
|
+
expect(continents2[0].id).toBe(1);
|
|
214
237
|
});
|
|
215
238
|
|
|
216
239
|
test('Tests for publicApi', async () => {
|
|
@@ -30,6 +30,11 @@ export interface AddressRegionDb {
|
|
|
30
30
|
* 国际拨号的电话退出代码
|
|
31
31
|
*/
|
|
32
32
|
readonly exitCode: string;
|
|
33
|
+
/**
|
|
34
|
+
* National (truck) prefix
|
|
35
|
+
* 国内呼叫的拨号
|
|
36
|
+
*/
|
|
37
|
+
readonly nationalPrefix?: string;
|
|
33
38
|
/**
|
|
34
39
|
* Area code for international dial, like 86 for China
|
|
35
40
|
* 国际电话区号
|
|
@@ -71,6 +76,7 @@ export declare class AddressRegion implements IAddressRegion {
|
|
|
71
76
|
continent: AddressContinent;
|
|
72
77
|
exitCode: string;
|
|
73
78
|
idd: string;
|
|
79
|
+
nationalPrefix: string | undefined;
|
|
74
80
|
currency: Currency;
|
|
75
81
|
languages: string[];
|
|
76
82
|
label: string;
|
|
@@ -147,5 +153,5 @@ export declare class AddressRegion implements IAddressRegion {
|
|
|
147
153
|
* 洲编号
|
|
148
154
|
*/
|
|
149
155
|
readonly continentId: AddressContinentId;
|
|
150
|
-
constructor(id: string, id3: string, nid: string, continent: AddressContinent, exitCode: string, idd: string, currency: Currency, languages: string[], label?: string);
|
|
156
|
+
constructor(id: string, id3: string, nid: string, continent: AddressContinent, exitCode: string, idd: string, nationalPrefix: string | undefined, currency: Currency, languages: string[], label?: string);
|
|
151
157
|
}
|
|
@@ -6,87 +6,88 @@ const AddressContinent_1 = require("./AddressContinent");
|
|
|
6
6
|
* Address or region
|
|
7
7
|
*/
|
|
8
8
|
class AddressRegion {
|
|
9
|
+
/**
|
|
10
|
+
* Get country or region by id
|
|
11
|
+
* @param id Country id
|
|
12
|
+
*/
|
|
13
|
+
static getById(id) {
|
|
14
|
+
return AddressRegion.all.find((c) => c.id === id);
|
|
15
|
+
}
|
|
9
16
|
// Typescript constructor shorthand
|
|
10
|
-
constructor(id, id3, nid, continent, exitCode, idd, currency, languages, label = id) {
|
|
17
|
+
constructor(id, id3, nid, continent, exitCode, idd, nationalPrefix, currency, languages, label = id) {
|
|
11
18
|
this.id = id;
|
|
12
19
|
this.id3 = id3;
|
|
13
20
|
this.nid = nid;
|
|
14
21
|
this.continent = continent;
|
|
15
22
|
this.exitCode = exitCode;
|
|
16
23
|
this.idd = idd;
|
|
24
|
+
this.nationalPrefix = nationalPrefix;
|
|
17
25
|
this.currency = currency;
|
|
18
26
|
this.languages = languages;
|
|
19
27
|
this.label = label;
|
|
20
28
|
this.continentId = AddressContinent_1.AddressContinent[continent];
|
|
21
29
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Get country or region by id
|
|
24
|
-
* @param id Country id
|
|
25
|
-
*/
|
|
26
|
-
static getById(id) {
|
|
27
|
-
return AddressRegion.all.find((c) => c.id === id);
|
|
28
|
-
}
|
|
29
30
|
}
|
|
30
31
|
exports.AddressRegion = AddressRegion;
|
|
31
32
|
/**
|
|
32
33
|
* CN - China
|
|
33
34
|
*/
|
|
34
|
-
AddressRegion.CN = new AddressRegion('CN', 'CHN', '156', AddressContinent_1.AddressContinent.AS, '00', '86', 'CNY', ['zh-CN']);
|
|
35
|
+
AddressRegion.CN = new AddressRegion('CN', 'CHN', '156', AddressContinent_1.AddressContinent.AS, '00', '+86', '0', 'CNY', ['zh-CN']);
|
|
35
36
|
/**
|
|
36
37
|
* HK - HK, China
|
|
37
38
|
* 中国香港
|
|
38
39
|
*/
|
|
39
|
-
AddressRegion.HK = new AddressRegion('HK', 'HKG', '344', AddressContinent_1.AddressContinent.AS, '001', '852', 'HKD', ['zh-HK', 'en-HK']);
|
|
40
|
+
AddressRegion.HK = new AddressRegion('HK', 'HKG', '344', AddressContinent_1.AddressContinent.AS, '001', '+852', undefined, 'HKD', ['zh-HK', 'en-HK']);
|
|
40
41
|
/**
|
|
41
42
|
* SG - Singapore
|
|
42
43
|
* 新加坡
|
|
43
44
|
*/
|
|
44
|
-
AddressRegion.SG = new AddressRegion('SG', 'SGP', '702', AddressContinent_1.AddressContinent.AS, '000', '65', 'SGD', ['zh-SG', 'en-SG']);
|
|
45
|
+
AddressRegion.SG = new AddressRegion('SG', 'SGP', '702', AddressContinent_1.AddressContinent.AS, '000', '+65', undefined, 'SGD', ['zh-SG', 'en-SG']);
|
|
45
46
|
/**
|
|
46
47
|
* JP - Japan
|
|
47
48
|
* 日本
|
|
48
49
|
*/
|
|
49
|
-
AddressRegion.JP = new AddressRegion('JP', 'JPN', '392', AddressContinent_1.AddressContinent.AS, '010', '81', 'JPY', ['ja-JP']);
|
|
50
|
+
AddressRegion.JP = new AddressRegion('JP', 'JPN', '392', AddressContinent_1.AddressContinent.AS, '010', '+81', '0', 'JPY', ['ja-JP']);
|
|
50
51
|
/**
|
|
51
52
|
* US - United States
|
|
52
53
|
* 美国
|
|
53
54
|
*/
|
|
54
|
-
AddressRegion.US = new AddressRegion('US', 'USA', '840', AddressContinent_1.AddressContinent.NA, '011', '1', 'USD', ['en-US']);
|
|
55
|
+
AddressRegion.US = new AddressRegion('US', 'USA', '840', AddressContinent_1.AddressContinent.NA, '011', '+1', '1', 'USD', ['en-US']);
|
|
55
56
|
/**
|
|
56
57
|
* CA - Canada
|
|
57
58
|
* 加拿大
|
|
58
59
|
*/
|
|
59
|
-
AddressRegion.CA = new AddressRegion('CA', 'CAN', '124', AddressContinent_1.AddressContinent.NA, '011', '1', 'CAD', ['en-CA', 'fr-CA']);
|
|
60
|
+
AddressRegion.CA = new AddressRegion('CA', 'CAN', '124', AddressContinent_1.AddressContinent.NA, '011', '+1', '1', 'CAD', ['en-CA', 'fr-CA']);
|
|
60
61
|
/**
|
|
61
62
|
* AU - Australia
|
|
62
63
|
* 澳大利亚
|
|
63
64
|
*/
|
|
64
|
-
AddressRegion.AU = new AddressRegion('AU', 'AUS', '036', AddressContinent_1.AddressContinent.OC, '0011', '61', 'AUD', ['en-AU']);
|
|
65
|
+
AddressRegion.AU = new AddressRegion('AU', 'AUS', '036', AddressContinent_1.AddressContinent.OC, '0011', '+61', '0', 'AUD', ['en-AU']);
|
|
65
66
|
/**
|
|
66
67
|
* NZ - New Zealand
|
|
67
68
|
* 新西兰
|
|
68
69
|
*/
|
|
69
|
-
AddressRegion.NZ = new AddressRegion('NZ', 'NZL', '554', AddressContinent_1.AddressContinent.OC, '00', '64', 'NZD', ['en-NZ', 'mi-NZ']);
|
|
70
|
+
AddressRegion.NZ = new AddressRegion('NZ', 'NZL', '554', AddressContinent_1.AddressContinent.OC, '00', '+64', '0', 'NZD', ['en-NZ', 'mi-NZ']);
|
|
70
71
|
/**
|
|
71
72
|
* GB - Great Britain
|
|
72
73
|
* 英国
|
|
73
74
|
*/
|
|
74
|
-
AddressRegion.GB = new AddressRegion('GB', 'GBR', '826', AddressContinent_1.AddressContinent.EU, '00', '44', 'GBP', ['en-GB']);
|
|
75
|
+
AddressRegion.GB = new AddressRegion('GB', 'GBR', '826', AddressContinent_1.AddressContinent.EU, '00', '+44', '0', 'GBP', ['en-GB']);
|
|
75
76
|
/**
|
|
76
77
|
* IE - Ireland
|
|
77
78
|
* 爱尔兰
|
|
78
79
|
*/
|
|
79
|
-
AddressRegion.IE = new AddressRegion('IE', 'IRL', '372', AddressContinent_1.AddressContinent.EU, '00', '353', 'EUR', ['en-IE']);
|
|
80
|
+
AddressRegion.IE = new AddressRegion('IE', 'IRL', '372', AddressContinent_1.AddressContinent.EU, '00', '+353', '0', 'EUR', ['en-IE']);
|
|
80
81
|
/**
|
|
81
82
|
* DE - Germany
|
|
82
83
|
* 德国
|
|
83
84
|
*/
|
|
84
|
-
AddressRegion.DE = new AddressRegion('DE', 'DEU', '276', AddressContinent_1.AddressContinent.EU, '00', '49', 'EUR', ['de-DE']);
|
|
85
|
+
AddressRegion.DE = new AddressRegion('DE', 'DEU', '276', AddressContinent_1.AddressContinent.EU, '00', '+49', '0', 'EUR', ['de-DE']);
|
|
85
86
|
/**
|
|
86
87
|
* FR - France
|
|
87
88
|
* 法国
|
|
88
89
|
*/
|
|
89
|
-
AddressRegion.FR = new AddressRegion('FR', 'FRA', '250', AddressContinent_1.AddressContinent.EU, '00', '33', 'EUR', ['fr-FR']);
|
|
90
|
+
AddressRegion.FR = new AddressRegion('FR', 'FRA', '250', AddressContinent_1.AddressContinent.EU, '00', '+33', '0', 'EUR', ['fr-FR']);
|
|
90
91
|
/**
|
|
91
92
|
* All countries and regions
|
|
92
93
|
*/
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -15,51 +15,6 @@ const UserRole_1 = require("./UserRole");
|
|
|
15
15
|
* Core application
|
|
16
16
|
*/
|
|
17
17
|
class CoreApp {
|
|
18
|
-
/**
|
|
19
|
-
* Protected constructor
|
|
20
|
-
* @param settings Settings
|
|
21
|
-
* @param api API
|
|
22
|
-
* @param notifier Notifier
|
|
23
|
-
* @param storage Storage
|
|
24
|
-
* @param name Application name
|
|
25
|
-
*/
|
|
26
|
-
constructor(settings, api, notifier, storage, name) {
|
|
27
|
-
this._authorized = false;
|
|
28
|
-
this._isTryingLogin = false;
|
|
29
|
-
/**
|
|
30
|
-
* Last called with token refresh
|
|
31
|
-
*/
|
|
32
|
-
this.lastCalled = false;
|
|
33
|
-
/**
|
|
34
|
-
* Token refresh count down seed
|
|
35
|
-
*/
|
|
36
|
-
this.refreshCountdownSeed = 0;
|
|
37
|
-
/**
|
|
38
|
-
* Init call Api URL
|
|
39
|
-
*/
|
|
40
|
-
this.initCallApi = 'Auth/WebInitCall';
|
|
41
|
-
/**
|
|
42
|
-
* Passphrase for encryption
|
|
43
|
-
*/
|
|
44
|
-
this.passphrase = '';
|
|
45
|
-
this.settings = settings;
|
|
46
|
-
this.api = api;
|
|
47
|
-
this.notifier = notifier;
|
|
48
|
-
this.storage = storage;
|
|
49
|
-
this.name = name;
|
|
50
|
-
// Fields, attach with the name identifier
|
|
51
|
-
this.fields = IApp_1.appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
52
|
-
// Device id
|
|
53
|
-
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
54
|
-
// Restore
|
|
55
|
-
this.restore();
|
|
56
|
-
this.setApi(api);
|
|
57
|
-
const { currentCulture, currentRegion } = settings;
|
|
58
|
-
this.changeCulture(currentCulture);
|
|
59
|
-
this.changeRegion(currentRegion);
|
|
60
|
-
// Setup callback
|
|
61
|
-
this.setup();
|
|
62
|
-
}
|
|
63
18
|
/**
|
|
64
19
|
* Culture, like zh-CN
|
|
65
20
|
*/
|
|
@@ -128,6 +83,51 @@ class CoreApp {
|
|
|
128
83
|
this.fields.headerToken
|
|
129
84
|
];
|
|
130
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Protected constructor
|
|
88
|
+
* @param settings Settings
|
|
89
|
+
* @param api API
|
|
90
|
+
* @param notifier Notifier
|
|
91
|
+
* @param storage Storage
|
|
92
|
+
* @param name Application name
|
|
93
|
+
*/
|
|
94
|
+
constructor(settings, api, notifier, storage, name) {
|
|
95
|
+
this._authorized = false;
|
|
96
|
+
this._isTryingLogin = false;
|
|
97
|
+
/**
|
|
98
|
+
* Last called with token refresh
|
|
99
|
+
*/
|
|
100
|
+
this.lastCalled = false;
|
|
101
|
+
/**
|
|
102
|
+
* Token refresh count down seed
|
|
103
|
+
*/
|
|
104
|
+
this.refreshCountdownSeed = 0;
|
|
105
|
+
/**
|
|
106
|
+
* Init call Api URL
|
|
107
|
+
*/
|
|
108
|
+
this.initCallApi = 'Auth/WebInitCall';
|
|
109
|
+
/**
|
|
110
|
+
* Passphrase for encryption
|
|
111
|
+
*/
|
|
112
|
+
this.passphrase = '';
|
|
113
|
+
this.settings = settings;
|
|
114
|
+
this.api = api;
|
|
115
|
+
this.notifier = notifier;
|
|
116
|
+
this.storage = storage;
|
|
117
|
+
this.name = name;
|
|
118
|
+
// Fields, attach with the name identifier
|
|
119
|
+
this.fields = IApp_1.appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
120
|
+
// Device id
|
|
121
|
+
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
122
|
+
// Restore
|
|
123
|
+
this.restore();
|
|
124
|
+
this.setApi(api);
|
|
125
|
+
const { currentCulture, currentRegion } = settings;
|
|
126
|
+
this.changeCulture(currentCulture);
|
|
127
|
+
this.changeRegion(currentRegion);
|
|
128
|
+
// Setup callback
|
|
129
|
+
this.setup();
|
|
130
|
+
}
|
|
131
131
|
getDeviceId() {
|
|
132
132
|
return this.deviceId.substring(0, 15);
|
|
133
133
|
}
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface NavigateOptions {
|
|
|
24
24
|
* true means success, false means failed but no any message
|
|
25
25
|
* other cases means failed with differnet message
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export type RefreshTokenResult = boolean | string | ApiDataError | IActionResult;
|
|
28
28
|
/**
|
|
29
29
|
* Refresh token props
|
|
30
30
|
*/
|
|
@@ -53,7 +53,7 @@ export declare const appFields: readonly ["headerToken", "serversideDeviceId", "
|
|
|
53
53
|
/**
|
|
54
54
|
* Basic type template
|
|
55
55
|
*/
|
|
56
|
-
export
|
|
56
|
+
export type IAppFields = {
|
|
57
57
|
[key in typeof appFields[number]]: string;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
2
|
import { IBridgeHost } from './IBridgeHost';
|
|
3
|
-
|
|
3
|
+
type CallHandlerType = (name: string, ...args: unknown[]) => PromiseLike<DataTypes.StringRecord | void>;
|
|
4
4
|
/**
|
|
5
5
|
* Flutter JavaScript Host
|
|
6
6
|
* https://inappwebview.dev/docs/javascript/communication/
|
|
@@ -31,5 +31,6 @@ export declare class FlutterHost implements IBridgeHost {
|
|
|
31
31
|
loadApp(name: string, startUrl?: string): void;
|
|
32
32
|
userAuthorization(authorized: boolean): void;
|
|
33
33
|
onUpdate(func: (app: string, version: string) => void): void;
|
|
34
|
+
setTitle(title: string): void;
|
|
34
35
|
}
|
|
35
36
|
export {};
|
|
@@ -6,12 +6,6 @@ exports.BusinessTax = void 0;
|
|
|
6
6
|
* https://imask.js.org/
|
|
7
7
|
*/
|
|
8
8
|
class BusinessTax {
|
|
9
|
-
// Typescript constructor shorthand
|
|
10
|
-
constructor(id, name, mask) {
|
|
11
|
-
this.id = id;
|
|
12
|
-
this.name = name;
|
|
13
|
-
this.mask = mask;
|
|
14
|
-
}
|
|
15
9
|
/**
|
|
16
10
|
* Get country or region by id
|
|
17
11
|
* @param id Country id
|
|
@@ -19,6 +13,12 @@ class BusinessTax {
|
|
|
19
13
|
static getById(id) {
|
|
20
14
|
return BusinessTax.all.find((c) => c.id === id);
|
|
21
15
|
}
|
|
16
|
+
// Typescript constructor shorthand
|
|
17
|
+
constructor(id, name, mask) {
|
|
18
|
+
this.id = id;
|
|
19
|
+
this.name = name;
|
|
20
|
+
this.mask = mask;
|
|
21
|
+
}
|
|
22
22
|
/**
|
|
23
23
|
* Get label key
|
|
24
24
|
*/
|
|
@@ -4,6 +4,7 @@ import { AddressState } from '../address/AddressState';
|
|
|
4
4
|
import { IdLabelConditional } from './dto/IdLabelDto';
|
|
5
5
|
import { BaseApi } from './BaseApi';
|
|
6
6
|
import { IApiPayload } from '@etsoo/restclient';
|
|
7
|
+
import { RegionsRQ } from './rq/RegionsRQ';
|
|
7
8
|
/**
|
|
8
9
|
* Address Api
|
|
9
10
|
*/
|
|
@@ -11,17 +12,30 @@ export declare class AddressApi extends BaseApi {
|
|
|
11
12
|
/**
|
|
12
13
|
* Get all continents
|
|
13
14
|
* @param isNumberKey Is number key or key as id
|
|
15
|
+
* @param includeAntarctica Include Antarctica or not
|
|
14
16
|
* @returns Continents
|
|
15
17
|
*/
|
|
16
|
-
continents<T extends boolean>(isNumberKey?: T):
|
|
18
|
+
continents<T extends boolean>(isNumberKey?: T, includeAntarctica?: boolean): IdLabelConditional<T>;
|
|
17
19
|
/**
|
|
18
20
|
* Get continent label
|
|
19
21
|
* @param id Region id
|
|
20
22
|
* @returns Label
|
|
21
23
|
*/
|
|
22
24
|
getContinentLabel(id: AddressContinent | string): string;
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Get all regions
|
|
27
|
+
* @param rq Rquest data
|
|
28
|
+
*/
|
|
29
|
+
getRegions(rq?: RegionsRQ): Promise<AddressRegionDb[] | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Get all local regions
|
|
32
|
+
*/
|
|
24
33
|
regions(): AddressRegion[];
|
|
34
|
+
/**
|
|
35
|
+
* Get all local regions limited to favored ids
|
|
36
|
+
* @param favoredIds Favored ids
|
|
37
|
+
*/
|
|
38
|
+
regions(favoredIds: string[]): AddressRegion[];
|
|
25
39
|
/**
|
|
26
40
|
* Get state list
|
|
27
41
|
* @param regionId Region id
|
|
@@ -5,6 +5,7 @@ const shared_1 = require("@etsoo/shared");
|
|
|
5
5
|
const AddressContinent_1 = require("../address/AddressContinent");
|
|
6
6
|
const AddressRegion_1 = require("../address/AddressRegion");
|
|
7
7
|
const BaseApi_1 = require("./BaseApi");
|
|
8
|
+
const cachedRegions = {};
|
|
8
9
|
/**
|
|
9
10
|
* Address Api
|
|
10
11
|
*/
|
|
@@ -12,10 +13,13 @@ class AddressApi extends BaseApi_1.BaseApi {
|
|
|
12
13
|
/**
|
|
13
14
|
* Get all continents
|
|
14
15
|
* @param isNumberKey Is number key or key as id
|
|
16
|
+
* @param includeAntarctica Include Antarctica or not
|
|
15
17
|
* @returns Continents
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
return shared_1.DataTypes.getEnumKeys(AddressContinent_1.AddressContinent)
|
|
19
|
+
continents(isNumberKey = false, includeAntarctica = false) {
|
|
20
|
+
return shared_1.DataTypes.getEnumKeys(AddressContinent_1.AddressContinent)
|
|
21
|
+
.filter((item) => includeAntarctica || item !== 'AN')
|
|
22
|
+
.map((key) => ({
|
|
19
23
|
id: isNumberKey
|
|
20
24
|
? shared_1.DataTypes.getEnumByKey(AddressContinent_1.AddressContinent, key)
|
|
21
25
|
: key.toString(),
|
|
@@ -32,20 +36,47 @@ class AddressApi extends BaseApi_1.BaseApi {
|
|
|
32
36
|
return (_a = this.app.get('continent' + id)) !== null && _a !== void 0 ? _a : id;
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
|
-
* Get
|
|
36
|
-
* @param
|
|
37
|
-
* @returns Result
|
|
39
|
+
* Get all regions
|
|
40
|
+
* @param rq Rquest data
|
|
38
41
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
async getRegions(rq) {
|
|
43
|
+
const culture = this.app.culture;
|
|
44
|
+
let regions = cachedRegions[culture];
|
|
45
|
+
if (regions == null) {
|
|
46
|
+
regions = await this.api.get(`Address/RegionList?language=${culture}`, undefined, { defaultValue: [], showLoading: false });
|
|
47
|
+
if (regions == null)
|
|
48
|
+
return undefined;
|
|
49
|
+
cachedRegions[culture] = regions;
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
const { favoredIds = [], items = 8, keyword } = rq !== null && rq !== void 0 ? rq : {};
|
|
52
|
+
// Keyword filter
|
|
53
|
+
if (keyword)
|
|
54
|
+
regions = regions.filter((region) => region.label.includes(keyword) || region.id === keyword);
|
|
55
|
+
// Order by favoredIds
|
|
56
|
+
if (favoredIds.length > 0) {
|
|
57
|
+
regions = [...regions].sort((r1, r2) => {
|
|
58
|
+
const n1 = favoredIds.indexOf(r1.id);
|
|
59
|
+
const n2 = favoredIds.indexOf(r2.id);
|
|
60
|
+
if (n1 === n2)
|
|
61
|
+
return 0;
|
|
62
|
+
if (n1 === -1)
|
|
63
|
+
return 1;
|
|
64
|
+
if (n2 === -1)
|
|
65
|
+
return -1;
|
|
66
|
+
return n1 - n2;
|
|
47
67
|
});
|
|
48
68
|
}
|
|
69
|
+
// Return the top items
|
|
70
|
+
return regions.slice(0, items);
|
|
71
|
+
}
|
|
72
|
+
regions(p) {
|
|
73
|
+
const items = p == null || p.length === 0
|
|
74
|
+
? AddressRegion_1.AddressRegion.all
|
|
75
|
+
: AddressRegion_1.AddressRegion.all.filter((ad) => p.includes(ad.id));
|
|
76
|
+
return items.map((region) => ({
|
|
77
|
+
...region,
|
|
78
|
+
label: this.app.getRegionLabel(region.id)
|
|
79
|
+
}));
|
|
49
80
|
}
|
|
50
81
|
/**
|
|
51
82
|
* Get state list
|
package/lib/cjs/erp/BaseApi.js
CHANGED
|
@@ -5,6 +5,12 @@ exports.BaseApi = void 0;
|
|
|
5
5
|
* SmartERP base API
|
|
6
6
|
*/
|
|
7
7
|
class BaseApi {
|
|
8
|
+
/**
|
|
9
|
+
* API Last error
|
|
10
|
+
*/
|
|
11
|
+
get lastError() {
|
|
12
|
+
return this.api.lastError;
|
|
13
|
+
}
|
|
8
14
|
/**
|
|
9
15
|
* Constructor
|
|
10
16
|
* @param app Application
|
|
@@ -14,11 +20,5 @@ class BaseApi {
|
|
|
14
20
|
this.app = app;
|
|
15
21
|
this.api = api;
|
|
16
22
|
}
|
|
17
|
-
/**
|
|
18
|
-
* API Last error
|
|
19
|
-
*/
|
|
20
|
-
get lastError() {
|
|
21
|
-
return this.api.lastError;
|
|
22
|
-
}
|
|
23
23
|
}
|
|
24
24
|
exports.BaseApi = BaseApi;
|
|
@@ -54,6 +54,11 @@ export declare class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
|
|
|
54
54
|
* @returns Result
|
|
55
55
|
*/
|
|
56
56
|
protected queryAuditBase<T extends DataTypes.IdType, R extends QueryRQ<T>>(rq: R, payload?: AuditLinePayload): Promise<AuditLineDto[] | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Query favored country ids
|
|
59
|
+
* @returns Result
|
|
60
|
+
*/
|
|
61
|
+
protected queryFavoredCountryIdsBase(api?: string): Promise<string[]>;
|
|
57
62
|
/**
|
|
58
63
|
* Read
|
|
59
64
|
* @param id Id
|
package/lib/cjs/erp/EntityApi.js
CHANGED
|
@@ -59,6 +59,19 @@ class EntityApi extends BaseApi_1.BaseApi {
|
|
|
59
59
|
queryAuditBase(rq, payload) {
|
|
60
60
|
return this.api.post(`${this.flag}/QueryAudit`, rq, payload);
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Query favored country ids
|
|
64
|
+
* @returns Result
|
|
65
|
+
*/
|
|
66
|
+
async queryFavoredCountryIdsBase(api) {
|
|
67
|
+
api !== null && api !== void 0 ? api : (api = `${this.flag}/QueryFavoredCountryIds`);
|
|
68
|
+
const result = await this.api.get(api, undefined, {
|
|
69
|
+
showLoading: false
|
|
70
|
+
});
|
|
71
|
+
if (result == null)
|
|
72
|
+
return [];
|
|
73
|
+
return result.map((item) => item.id);
|
|
74
|
+
}
|
|
62
75
|
/**
|
|
63
76
|
* Read
|
|
64
77
|
* @param id Id
|
|
@@ -2,7 +2,7 @@ import { IApiPayload } from '@etsoo/restclient';
|
|
|
2
2
|
/**
|
|
3
3
|
* Audit line data
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type AuditLineDto = {
|
|
6
6
|
id: number;
|
|
7
7
|
creation: Date;
|
|
8
8
|
user: string;
|
|
@@ -14,11 +14,11 @@ export declare type AuditLineDto = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Audit line changes data
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type AuditLineChangesDto = {
|
|
18
18
|
oldData: Record<string, unknown>;
|
|
19
19
|
newData: Record<string, unknown>;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* Audit line API payload
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export type AuditLinePayload = IApiPayload<AuditLineDto[]>;
|
|
@@ -2,4 +2,4 @@ import { ListType, ListType1 } from '@etsoo/shared';
|
|
|
2
2
|
/**
|
|
3
3
|
* Conditional IdLabel type
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type IdLabelConditional<T extends boolean> = T extends true ? ListType[] : ListType1[];
|
|
@@ -2,7 +2,7 @@ import { DataTypes } from '@etsoo/shared';
|
|
|
2
2
|
/**
|
|
3
3
|
* Dto with id, label and primary field
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type IdLabelPrimaryDto<T extends DataTypes.IdType = number> = DataTypes.IdLabelItem<T> & {
|
|
6
6
|
/**
|
|
7
7
|
* Is primary
|
|
8
8
|
*/
|