@etsoo/appscript 1.3.64 → 1.3.66
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/lib/cjs/app/CoreApp.d.ts +5 -0
- package/lib/cjs/app/CoreApp.js +11 -0
- package/lib/cjs/app/IApp.d.ts +5 -0
- package/lib/cjs/erp/AddressApi.d.ts +6 -0
- package/lib/cjs/erp/AddressApi.js +19 -1
- package/lib/cjs/erp/rq/RegionsRQ.d.ts +4 -0
- package/lib/mjs/app/CoreApp.d.ts +5 -0
- package/lib/mjs/app/CoreApp.js +11 -0
- package/lib/mjs/app/IApp.d.ts +5 -0
- package/lib/mjs/erp/AddressApi.d.ts +6 -0
- package/lib/mjs/erp/AddressApi.js +19 -1
- package/lib/mjs/erp/rq/RegionsRQ.d.ts +4 -0
- package/package.json +3 -3
- package/src/app/CoreApp.ts +12 -0
- package/src/app/IApp.ts +6 -0
- package/src/erp/AddressApi.ts +18 -1
- package/src/erp/rq/RegionsRQ.ts +5 -0
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -347,6 +347,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
347
347
|
getLabels<T extends string>(...keys: T[]): {
|
|
348
348
|
[K in T]: string;
|
|
349
349
|
};
|
|
350
|
+
/**
|
|
351
|
+
* Get bool items
|
|
352
|
+
* @returns Bool items
|
|
353
|
+
*/
|
|
354
|
+
getBools(): ListType1[];
|
|
350
355
|
/**
|
|
351
356
|
* Get cached token
|
|
352
357
|
* @returns Cached token
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -853,6 +853,17 @@ class CoreApp {
|
|
|
853
853
|
const init = {};
|
|
854
854
|
return keys.reduce((a, v) => { var _a; return ({ ...a, [v]: (_a = this.get(v)) !== null && _a !== void 0 ? _a : '' }); }, init);
|
|
855
855
|
}
|
|
856
|
+
/**
|
|
857
|
+
* Get bool items
|
|
858
|
+
* @returns Bool items
|
|
859
|
+
*/
|
|
860
|
+
getBools() {
|
|
861
|
+
const { no = 'No', yes = 'Yes' } = this.getLabels('no', 'yes');
|
|
862
|
+
return [
|
|
863
|
+
{ id: 'false', label: no },
|
|
864
|
+
{ id: 'true', label: yes }
|
|
865
|
+
];
|
|
866
|
+
}
|
|
856
867
|
/**
|
|
857
868
|
* Get cached token
|
|
858
869
|
* @returns Cached token
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -283,6 +283,11 @@ export interface IApp {
|
|
|
283
283
|
getLabels<T extends string>(...keys: T[]): {
|
|
284
284
|
[K in T]: string;
|
|
285
285
|
};
|
|
286
|
+
/**
|
|
287
|
+
* Get bool items
|
|
288
|
+
* @returns Bool items
|
|
289
|
+
*/
|
|
290
|
+
getBools(): ListType1[];
|
|
286
291
|
/**
|
|
287
292
|
* Get cached token
|
|
288
293
|
* @returns Cached token
|
|
@@ -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
|
-
|
|
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 });
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -347,6 +347,11 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
347
347
|
getLabels<T extends string>(...keys: T[]): {
|
|
348
348
|
[K in T]: string;
|
|
349
349
|
};
|
|
350
|
+
/**
|
|
351
|
+
* Get bool items
|
|
352
|
+
* @returns Bool items
|
|
353
|
+
*/
|
|
354
|
+
getBools(): ListType1[];
|
|
350
355
|
/**
|
|
351
356
|
* Get cached token
|
|
352
357
|
* @returns Cached token
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -850,6 +850,17 @@ export class CoreApp {
|
|
|
850
850
|
const init = {};
|
|
851
851
|
return keys.reduce((a, v) => { var _a; return ({ ...a, [v]: (_a = this.get(v)) !== null && _a !== void 0 ? _a : '' }); }, init);
|
|
852
852
|
}
|
|
853
|
+
/**
|
|
854
|
+
* Get bool items
|
|
855
|
+
* @returns Bool items
|
|
856
|
+
*/
|
|
857
|
+
getBools() {
|
|
858
|
+
const { no = 'No', yes = 'Yes' } = this.getLabels('no', 'yes');
|
|
859
|
+
return [
|
|
860
|
+
{ id: 'false', label: no },
|
|
861
|
+
{ id: 'true', label: yes }
|
|
862
|
+
];
|
|
863
|
+
}
|
|
853
864
|
/**
|
|
854
865
|
* Get cached token
|
|
855
866
|
* @returns Cached token
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -283,6 +283,11 @@ export interface IApp {
|
|
|
283
283
|
getLabels<T extends string>(...keys: T[]): {
|
|
284
284
|
[K in T]: string;
|
|
285
285
|
};
|
|
286
|
+
/**
|
|
287
|
+
* Get bool items
|
|
288
|
+
* @returns Bool items
|
|
289
|
+
*/
|
|
290
|
+
getBools(): ListType1[];
|
|
286
291
|
/**
|
|
287
292
|
* Get cached token
|
|
288
293
|
* @returns Cached token
|
|
@@ -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
|
-
|
|
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 });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.66",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"@babel/preset-env": "^7.20.2",
|
|
66
66
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
67
67
|
"@types/jest": "^29.4.0",
|
|
68
|
-
"jest": "^29.4.
|
|
69
|
-
"jest-environment-jsdom": "^29.4.
|
|
68
|
+
"jest": "^29.4.3",
|
|
69
|
+
"jest-environment-jsdom": "^29.4.3",
|
|
70
70
|
"ts-jest": "^29.0.5",
|
|
71
71
|
"typescript": "^4.9.5"
|
|
72
72
|
}
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -1178,6 +1178,18 @@ export abstract class CoreApp<
|
|
|
1178
1178
|
);
|
|
1179
1179
|
}
|
|
1180
1180
|
|
|
1181
|
+
/**
|
|
1182
|
+
* Get bool items
|
|
1183
|
+
* @returns Bool items
|
|
1184
|
+
*/
|
|
1185
|
+
getBools(): ListType1[] {
|
|
1186
|
+
const { no = 'No', yes = 'Yes' } = this.getLabels('no', 'yes');
|
|
1187
|
+
return [
|
|
1188
|
+
{ id: 'false', label: no },
|
|
1189
|
+
{ id: 'true', label: yes }
|
|
1190
|
+
];
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1181
1193
|
/**
|
|
1182
1194
|
* Get cached token
|
|
1183
1195
|
* @returns Cached token
|
package/src/app/IApp.ts
CHANGED
|
@@ -379,6 +379,12 @@ export interface IApp {
|
|
|
379
379
|
*/
|
|
380
380
|
getLabels<T extends string>(...keys: T[]): { [K in T]: string };
|
|
381
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Get bool items
|
|
384
|
+
* @returns Bool items
|
|
385
|
+
*/
|
|
386
|
+
getBools(): ListType1[];
|
|
387
|
+
|
|
382
388
|
/**
|
|
383
389
|
* Get cached token
|
|
384
390
|
* @returns Cached token
|
package/src/erp/AddressApi.ts
CHANGED
|
@@ -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[]>(
|