@etsoo/appscript 1.6.35 → 1.6.37
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 +5 -1
- package/lib/cjs/api/EntityApi.js +4 -5
- package/lib/cjs/business/BusinessUtils.d.ts +7 -0
- package/lib/cjs/business/BusinessUtils.js +12 -0
- package/lib/mjs/api/EntityApi.js +4 -5
- package/lib/mjs/business/BusinessUtils.d.ts +7 -0
- package/lib/mjs/business/BusinessUtils.js +12 -0
- package/package.json +9 -9
- package/src/api/EntityApi.ts +8 -5
- package/src/business/BusinessUtils.ts +15 -0
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiDataError, ApiMethod } from "@etsoo/restclient";
|
|
2
|
-
import { DataTypes, IActionResult } from "@etsoo/shared";
|
|
2
|
+
import { DataTypes, ExtendUtils, IActionResult } from "@etsoo/shared";
|
|
3
3
|
import {
|
|
4
4
|
EntityStatus,
|
|
5
5
|
ExternalEndpoint,
|
|
@@ -19,6 +19,10 @@ function EnhanceApp<TBase extends DataTypes.MConstructor<TestApp>>(
|
|
|
19
19
|
const appClass = EnhanceApp(TestApp);
|
|
20
20
|
const app = new appClass();
|
|
21
21
|
|
|
22
|
+
// First make sure the default culture (here is 'en') is loaded
|
|
23
|
+
await ExtendUtils.sleep(50);
|
|
24
|
+
|
|
25
|
+
// Then change the culture to the first one (here is 'zh-CN')
|
|
22
26
|
await app.changeCulture(app.settings.cultures[0]);
|
|
23
27
|
|
|
24
28
|
test("Test for domain substitution", () => {
|
package/lib/cjs/api/EntityApi.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EntityApi = void 0;
|
|
4
4
|
const BaseApi_1 = require("./BaseApi");
|
|
5
|
+
const BusinessUtils_1 = require("../business/BusinessUtils");
|
|
5
6
|
/**
|
|
6
7
|
* Entity API
|
|
7
8
|
* Follow com.etsoo.CoreFramework.Services.EntityServiceBase
|
|
@@ -39,10 +40,7 @@ class EntityApi extends BaseApi_1.BaseApi {
|
|
|
39
40
|
*/
|
|
40
41
|
listBase(rq, payload) {
|
|
41
42
|
let { queryPaging, ...rest } = rq;
|
|
42
|
-
|
|
43
|
-
queryPaging = { currentPage: 0, batchSize: queryPaging };
|
|
44
|
-
}
|
|
45
|
-
return this.api.post(`${this.flag}/List`, { queryPaging, ...rest }, payload);
|
|
43
|
+
return this.api.post(`${this.flag}/List`, { queryPaging: BusinessUtils_1.BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
|
|
46
44
|
}
|
|
47
45
|
/**
|
|
48
46
|
* Merge
|
|
@@ -61,7 +59,8 @@ class EntityApi extends BaseApi_1.BaseApi {
|
|
|
61
59
|
* @returns Result
|
|
62
60
|
*/
|
|
63
61
|
queryBase(rq, payload, queryKey = "") {
|
|
64
|
-
|
|
62
|
+
let { queryPaging, ...rest } = rq;
|
|
63
|
+
return this.api.post(`${this.flag}/Query${queryKey}`, { queryPaging: BusinessUtils_1.BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
66
|
* Query favored country ids
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataTypes, ListType } from "@etsoo/shared";
|
|
2
2
|
import { CustomCultureData } from "../def/CustomCulture";
|
|
3
|
+
import { QueryPagingData } from "../api/rq/QueryPagingData";
|
|
3
4
|
/**
|
|
4
5
|
* Business utils
|
|
5
6
|
*/
|
|
@@ -12,6 +13,12 @@ export declare namespace BusinessUtils {
|
|
|
12
13
|
* @returns Result
|
|
13
14
|
*/
|
|
14
15
|
function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format query paging data
|
|
18
|
+
* @param query Query paging data or batch size
|
|
19
|
+
* @returns Result
|
|
20
|
+
*/
|
|
21
|
+
function formatQueryPaging(query: QueryPagingData | number | undefined): QueryPagingData | undefined;
|
|
15
22
|
/**
|
|
16
23
|
* Get 12-month items
|
|
17
24
|
* @param monthLabels Month labels
|
|
@@ -39,6 +39,18 @@ var BusinessUtils;
|
|
|
39
39
|
return defaultTitle;
|
|
40
40
|
}
|
|
41
41
|
BusinessUtils.formatAvatarTitle = formatAvatarTitle;
|
|
42
|
+
/**
|
|
43
|
+
* Format query paging data
|
|
44
|
+
* @param query Query paging data or batch size
|
|
45
|
+
* @returns Result
|
|
46
|
+
*/
|
|
47
|
+
function formatQueryPaging(query) {
|
|
48
|
+
if (typeof query === "number") {
|
|
49
|
+
query = { currentPage: 0, batchSize: query };
|
|
50
|
+
}
|
|
51
|
+
return query;
|
|
52
|
+
}
|
|
53
|
+
BusinessUtils.formatQueryPaging = formatQueryPaging;
|
|
42
54
|
/**
|
|
43
55
|
* Get 12-month items
|
|
44
56
|
* @param monthLabels Month labels
|
package/lib/mjs/api/EntityApi.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseApi } from "./BaseApi";
|
|
2
|
+
import { BusinessUtils } from "../business/BusinessUtils";
|
|
2
3
|
/**
|
|
3
4
|
* Entity API
|
|
4
5
|
* Follow com.etsoo.CoreFramework.Services.EntityServiceBase
|
|
@@ -36,10 +37,7 @@ export class EntityApi extends BaseApi {
|
|
|
36
37
|
*/
|
|
37
38
|
listBase(rq, payload) {
|
|
38
39
|
let { queryPaging, ...rest } = rq;
|
|
39
|
-
|
|
40
|
-
queryPaging = { currentPage: 0, batchSize: queryPaging };
|
|
41
|
-
}
|
|
42
|
-
return this.api.post(`${this.flag}/List`, { queryPaging, ...rest }, payload);
|
|
40
|
+
return this.api.post(`${this.flag}/List`, { queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* Merge
|
|
@@ -58,7 +56,8 @@ export class EntityApi extends BaseApi {
|
|
|
58
56
|
* @returns Result
|
|
59
57
|
*/
|
|
60
58
|
queryBase(rq, payload, queryKey = "") {
|
|
61
|
-
|
|
59
|
+
let { queryPaging, ...rest } = rq;
|
|
60
|
+
return this.api.post(`${this.flag}/Query${queryKey}`, { queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
|
|
62
61
|
}
|
|
63
62
|
/**
|
|
64
63
|
* Query favored country ids
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataTypes, ListType } from "@etsoo/shared";
|
|
2
2
|
import { CustomCultureData } from "../def/CustomCulture";
|
|
3
|
+
import { QueryPagingData } from "../api/rq/QueryPagingData";
|
|
3
4
|
/**
|
|
4
5
|
* Business utils
|
|
5
6
|
*/
|
|
@@ -12,6 +13,12 @@ export declare namespace BusinessUtils {
|
|
|
12
13
|
* @returns Result
|
|
13
14
|
*/
|
|
14
15
|
function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format query paging data
|
|
18
|
+
* @param query Query paging data or batch size
|
|
19
|
+
* @returns Result
|
|
20
|
+
*/
|
|
21
|
+
function formatQueryPaging(query: QueryPagingData | number | undefined): QueryPagingData | undefined;
|
|
15
22
|
/**
|
|
16
23
|
* Get 12-month items
|
|
17
24
|
* @param monthLabels Month labels
|
|
@@ -36,6 +36,18 @@ export var BusinessUtils;
|
|
|
36
36
|
return defaultTitle;
|
|
37
37
|
}
|
|
38
38
|
BusinessUtils.formatAvatarTitle = formatAvatarTitle;
|
|
39
|
+
/**
|
|
40
|
+
* Format query paging data
|
|
41
|
+
* @param query Query paging data or batch size
|
|
42
|
+
* @returns Result
|
|
43
|
+
*/
|
|
44
|
+
function formatQueryPaging(query) {
|
|
45
|
+
if (typeof query === "number") {
|
|
46
|
+
query = { currentPage: 0, batchSize: query };
|
|
47
|
+
}
|
|
48
|
+
return query;
|
|
49
|
+
}
|
|
50
|
+
BusinessUtils.formatQueryPaging = formatQueryPaging;
|
|
39
51
|
/**
|
|
40
52
|
* Get 12-month items
|
|
41
53
|
* @param monthLabels Month labels
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.37",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/ETSOO/AppScript#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@etsoo/notificationbase": "^1.1.
|
|
39
|
-
"@etsoo/restclient": "^1.1.
|
|
40
|
-
"@etsoo/shared": "^1.2.
|
|
38
|
+
"@etsoo/notificationbase": "^1.1.62",
|
|
39
|
+
"@etsoo/restclient": "^1.1.29",
|
|
40
|
+
"@etsoo/shared": "^1.2.74",
|
|
41
41
|
"crypto-js": "^4.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@babel/cli": "^7.27.2",
|
|
45
|
-
"@babel/core": "^7.27.
|
|
46
|
-
"@babel/plugin-transform-runtime": "^7.27.
|
|
45
|
+
"@babel/core": "^7.27.4",
|
|
46
|
+
"@babel/plugin-transform-runtime": "^7.27.4",
|
|
47
47
|
"@babel/preset-env": "^7.27.2",
|
|
48
|
-
"@babel/runtime-corejs3": "^7.27.
|
|
48
|
+
"@babel/runtime-corejs3": "^7.27.6",
|
|
49
49
|
"@types/crypto-js": "^4.2.2",
|
|
50
|
-
"@vitejs/plugin-react": "^4.
|
|
50
|
+
"@vitejs/plugin-react": "^4.5.1",
|
|
51
51
|
"jsdom": "^26.1.0",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
|
-
"vitest": "^3.
|
|
53
|
+
"vitest": "^3.2.2"
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/api/EntityApi.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ResultPayload } from "./dto/ResultPayload";
|
|
|
6
6
|
import { MergeRQ } from "./rq/MergeRQ";
|
|
7
7
|
import { QueryRQ } from "./rq/QueryRQ";
|
|
8
8
|
import { UpdateStatusRQ } from "./rq/UpdateStatusRQ";
|
|
9
|
+
import { BusinessUtils } from "../business/BusinessUtils";
|
|
9
10
|
/**
|
|
10
11
|
* Entity API
|
|
11
12
|
* Follow com.etsoo.CoreFramework.Services.EntityServiceBase
|
|
@@ -67,12 +68,9 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
|
|
|
67
68
|
payload?: IApiPayload<R[]>
|
|
68
69
|
) {
|
|
69
70
|
let { queryPaging, ...rest } = rq;
|
|
70
|
-
if (typeof queryPaging === "number") {
|
|
71
|
-
queryPaging = { currentPage: 0, batchSize: queryPaging };
|
|
72
|
-
}
|
|
73
71
|
return this.api.post(
|
|
74
72
|
`${this.flag}/List`,
|
|
75
|
-
{ queryPaging, ...rest },
|
|
73
|
+
{ queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest },
|
|
76
74
|
payload
|
|
77
75
|
);
|
|
78
76
|
}
|
|
@@ -102,7 +100,12 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
|
|
|
102
100
|
RQ extends QueryRQ<T>,
|
|
103
101
|
R extends object
|
|
104
102
|
>(rq: RQ, payload?: IApiPayload<R[]>, queryKey: string = "") {
|
|
105
|
-
|
|
103
|
+
let { queryPaging, ...rest } = rq;
|
|
104
|
+
return this.api.post(
|
|
105
|
+
`${this.flag}/Query${queryKey}`,
|
|
106
|
+
{ queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest },
|
|
107
|
+
payload
|
|
108
|
+
);
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataTypes, ListType } from "@etsoo/shared";
|
|
2
2
|
import { CustomCultureData } from "../def/CustomCulture";
|
|
3
|
+
import { QueryPagingData } from "../api/rq/QueryPagingData";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Business utils
|
|
@@ -46,6 +47,20 @@ export namespace BusinessUtils {
|
|
|
46
47
|
return defaultTitle;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Format query paging data
|
|
52
|
+
* @param query Query paging data or batch size
|
|
53
|
+
* @returns Result
|
|
54
|
+
*/
|
|
55
|
+
export function formatQueryPaging(
|
|
56
|
+
query: QueryPagingData | number | undefined
|
|
57
|
+
) {
|
|
58
|
+
if (typeof query === "number") {
|
|
59
|
+
query = { currentPage: 0, batchSize: query };
|
|
60
|
+
}
|
|
61
|
+
return query;
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
/**
|
|
50
65
|
* Get 12-month items
|
|
51
66
|
* @param monthLabels Month labels
|