@etsoo/appscript 1.6.37 → 1.6.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.
@@ -25,6 +25,8 @@ await ExtendUtils.sleep(50);
25
25
  // Then change the culture to the first one (here is 'zh-CN')
26
26
  await app.changeCulture(app.settings.cultures[0]);
27
27
 
28
+ await ExtendUtils.sleep(50);
29
+
28
30
  test("Test for domain substitution", () => {
29
31
  expect(app.settings.endpoint).toBe("http://admin.etsoo.com:9000/api/");
30
32
 
@@ -39,8 +39,7 @@ class EntityApi extends BaseApi_1.BaseApi {
39
39
  * @returns Result
40
40
  */
41
41
  listBase(rq, payload) {
42
- let { queryPaging, ...rest } = rq;
43
- return this.api.post(`${this.flag}/List`, { queryPaging: BusinessUtils_1.BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
42
+ return this.api.post(`${this.flag}/List`, BusinessUtils_1.BusinessUtils.formatQuery(rq), payload);
44
43
  }
45
44
  /**
46
45
  * Merge
@@ -59,8 +58,7 @@ class EntityApi extends BaseApi_1.BaseApi {
59
58
  * @returns Result
60
59
  */
61
60
  queryBase(rq, payload, queryKey = "") {
62
- let { queryPaging, ...rest } = rq;
63
- return this.api.post(`${this.flag}/Query${queryKey}`, { queryPaging: BusinessUtils_1.BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
61
+ return this.api.post(`${this.flag}/Query${queryKey}`, BusinessUtils_1.BusinessUtils.formatQuery(rq), payload);
64
62
  }
65
63
  /**
66
64
  * Query favored country ids
@@ -1236,6 +1236,8 @@ class CoreApp {
1236
1236
  if (typeof id !== "number")
1237
1237
  return;
1238
1238
  const key = shared_1.DataTypes.getEnumKey(em, id);
1239
+ if (key == null)
1240
+ return;
1239
1241
  const label = this.get(getKey(key)) ?? key;
1240
1242
  list.push({ id, label });
1241
1243
  });
@@ -1,6 +1,6 @@
1
- import { DataTypes, ListType } from "@etsoo/shared";
1
+ import { DataTypes, IdType, ListType } from "@etsoo/shared";
2
2
  import { CustomCultureData } from "../def/CustomCulture";
3
- import { QueryPagingData } from "../api/rq/QueryPagingData";
3
+ import { QueryRQ } from "../api/rq/QueryRQ";
4
4
  /**
5
5
  * Business utils
6
6
  */
@@ -14,11 +14,17 @@ export declare namespace BusinessUtils {
14
14
  */
15
15
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
16
16
  /**
17
- * Format query paging data
18
- * @param query Query paging data or batch size
17
+ * Format query, dealing with paging data
18
+ * @param rq Query
19
19
  * @returns Result
20
20
  */
21
- function formatQueryPaging(query: QueryPagingData | number | undefined): QueryPagingData | undefined;
21
+ function formatQuery<T extends IdType>(rq: QueryRQ<T>): {
22
+ id?: T | undefined;
23
+ ids?: T[] | undefined;
24
+ excludedIds?: T[] | undefined;
25
+ keyword?: string;
26
+ queryPaging: import("..").QueryPagingData | undefined;
27
+ };
22
28
  /**
23
29
  * Get 12-month items
24
30
  * @param monthLabels Month labels
@@ -40,17 +40,18 @@ var BusinessUtils;
40
40
  }
41
41
  BusinessUtils.formatAvatarTitle = formatAvatarTitle;
42
42
  /**
43
- * Format query paging data
44
- * @param query Query paging data or batch size
43
+ * Format query, dealing with paging data
44
+ * @param rq Query
45
45
  * @returns Result
46
46
  */
47
- function formatQueryPaging(query) {
48
- if (typeof query === "number") {
49
- query = { currentPage: 0, batchSize: query };
47
+ function formatQuery(rq) {
48
+ let { queryPaging, ...rest } = rq;
49
+ if (typeof queryPaging === "number") {
50
+ queryPaging = { currentPage: 0, batchSize: queryPaging };
50
51
  }
51
- return query;
52
+ return { queryPaging, ...rest };
52
53
  }
53
- BusinessUtils.formatQueryPaging = formatQueryPaging;
54
+ BusinessUtils.formatQuery = formatQuery;
54
55
  /**
55
56
  * Get 12-month items
56
57
  * @param monthLabels Month labels
@@ -36,8 +36,7 @@ export class EntityApi extends BaseApi {
36
36
  * @returns Result
37
37
  */
38
38
  listBase(rq, payload) {
39
- let { queryPaging, ...rest } = rq;
40
- return this.api.post(`${this.flag}/List`, { queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
39
+ return this.api.post(`${this.flag}/List`, BusinessUtils.formatQuery(rq), payload);
41
40
  }
42
41
  /**
43
42
  * Merge
@@ -56,8 +55,7 @@ export class EntityApi extends BaseApi {
56
55
  * @returns Result
57
56
  */
58
57
  queryBase(rq, payload, queryKey = "") {
59
- let { queryPaging, ...rest } = rq;
60
- return this.api.post(`${this.flag}/Query${queryKey}`, { queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest }, payload);
58
+ return this.api.post(`${this.flag}/Query${queryKey}`, BusinessUtils.formatQuery(rq), payload);
61
59
  }
62
60
  /**
63
61
  * Query favored country ids
@@ -1233,6 +1233,8 @@ export class CoreApp {
1233
1233
  if (typeof id !== "number")
1234
1234
  return;
1235
1235
  const key = DataTypes.getEnumKey(em, id);
1236
+ if (key == null)
1237
+ return;
1236
1238
  const label = this.get(getKey(key)) ?? key;
1237
1239
  list.push({ id, label });
1238
1240
  });
@@ -1,6 +1,6 @@
1
- import { DataTypes, ListType } from "@etsoo/shared";
1
+ import { DataTypes, IdType, ListType } from "@etsoo/shared";
2
2
  import { CustomCultureData } from "../def/CustomCulture";
3
- import { QueryPagingData } from "../api/rq/QueryPagingData";
3
+ import { QueryRQ } from "../api/rq/QueryRQ";
4
4
  /**
5
5
  * Business utils
6
6
  */
@@ -14,11 +14,17 @@ export declare namespace BusinessUtils {
14
14
  */
15
15
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
16
16
  /**
17
- * Format query paging data
18
- * @param query Query paging data or batch size
17
+ * Format query, dealing with paging data
18
+ * @param rq Query
19
19
  * @returns Result
20
20
  */
21
- function formatQueryPaging(query: QueryPagingData | number | undefined): QueryPagingData | undefined;
21
+ function formatQuery<T extends IdType>(rq: QueryRQ<T>): {
22
+ id?: T | undefined;
23
+ ids?: T[] | undefined;
24
+ excludedIds?: T[] | undefined;
25
+ keyword?: string;
26
+ queryPaging: import("..").QueryPagingData | undefined;
27
+ };
22
28
  /**
23
29
  * Get 12-month items
24
30
  * @param monthLabels Month labels
@@ -37,17 +37,18 @@ export var BusinessUtils;
37
37
  }
38
38
  BusinessUtils.formatAvatarTitle = formatAvatarTitle;
39
39
  /**
40
- * Format query paging data
41
- * @param query Query paging data or batch size
40
+ * Format query, dealing with paging data
41
+ * @param rq Query
42
42
  * @returns Result
43
43
  */
44
- function formatQueryPaging(query) {
45
- if (typeof query === "number") {
46
- query = { currentPage: 0, batchSize: query };
44
+ function formatQuery(rq) {
45
+ let { queryPaging, ...rest } = rq;
46
+ if (typeof queryPaging === "number") {
47
+ queryPaging = { currentPage: 0, batchSize: queryPaging };
47
48
  }
48
- return query;
49
+ return { queryPaging, ...rest };
49
50
  }
50
- BusinessUtils.formatQueryPaging = formatQueryPaging;
51
+ BusinessUtils.formatQuery = formatQuery;
51
52
  /**
52
53
  * Get 12-month items
53
54
  * @param monthLabels Month labels
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.6.37",
3
+ "version": "1.6.39",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "homepage": "https://github.com/ETSOO/AppScript#readme",
37
37
  "dependencies": {
38
- "@etsoo/notificationbase": "^1.1.62",
39
- "@etsoo/restclient": "^1.1.29",
40
- "@etsoo/shared": "^1.2.74",
38
+ "@etsoo/notificationbase": "^1.1.63",
39
+ "@etsoo/restclient": "^1.1.30",
40
+ "@etsoo/shared": "^1.2.75",
41
41
  "crypto-js": "^4.2.0"
42
42
  },
43
43
  "devDependencies": {
@@ -47,9 +47,9 @@
47
47
  "@babel/preset-env": "^7.27.2",
48
48
  "@babel/runtime-corejs3": "^7.27.6",
49
49
  "@types/crypto-js": "^4.2.2",
50
- "@vitejs/plugin-react": "^4.5.1",
50
+ "@vitejs/plugin-react": "^4.5.2",
51
51
  "jsdom": "^26.1.0",
52
52
  "typescript": "^5.8.3",
53
- "vitest": "^3.2.2"
53
+ "vitest": "^3.2.3"
54
54
  }
55
55
  }
@@ -67,10 +67,9 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
67
67
  rq: RQ,
68
68
  payload?: IApiPayload<R[]>
69
69
  ) {
70
- let { queryPaging, ...rest } = rq;
71
70
  return this.api.post(
72
71
  `${this.flag}/List`,
73
- { queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest },
72
+ BusinessUtils.formatQuery(rq),
74
73
  payload
75
74
  );
76
75
  }
@@ -100,10 +99,9 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
100
99
  RQ extends QueryRQ<T>,
101
100
  R extends object
102
101
  >(rq: RQ, payload?: IApiPayload<R[]>, queryKey: string = "") {
103
- let { queryPaging, ...rest } = rq;
104
102
  return this.api.post(
105
103
  `${this.flag}/Query${queryKey}`,
106
- { queryPaging: BusinessUtils.formatQueryPaging(queryPaging), ...rest },
104
+ BusinessUtils.formatQuery(rq),
107
105
  payload
108
106
  );
109
107
  }
@@ -1748,6 +1748,7 @@ export abstract class CoreApp<
1748
1748
  filter.forEach((id) => {
1749
1749
  if (typeof id !== "number") return;
1750
1750
  const key = DataTypes.getEnumKey(em, id);
1751
+ if (key == null) return;
1751
1752
  const label = this.get<string>(getKey(key)) ?? key;
1752
1753
  list.push({ id, label });
1753
1754
  });
@@ -1,6 +1,6 @@
1
- import { DataTypes, ListType } from "@etsoo/shared";
1
+ import { DataTypes, IdType, ListType } from "@etsoo/shared";
2
2
  import { CustomCultureData } from "../def/CustomCulture";
3
- import { QueryPagingData } from "../api/rq/QueryPagingData";
3
+ import { QueryRQ } from "../api/rq/QueryRQ";
4
4
 
5
5
  /**
6
6
  * Business utils
@@ -48,17 +48,16 @@ export namespace BusinessUtils {
48
48
  }
49
49
 
50
50
  /**
51
- * Format query paging data
52
- * @param query Query paging data or batch size
51
+ * Format query, dealing with paging data
52
+ * @param rq Query
53
53
  * @returns Result
54
54
  */
55
- export function formatQueryPaging(
56
- query: QueryPagingData | number | undefined
57
- ) {
58
- if (typeof query === "number") {
59
- query = { currentPage: 0, batchSize: query };
55
+ export function formatQuery<T extends IdType>(rq: QueryRQ<T>) {
56
+ let { queryPaging, ...rest } = rq;
57
+ if (typeof queryPaging === "number") {
58
+ queryPaging = { currentPage: 0, batchSize: queryPaging };
60
59
  }
61
- return query;
60
+ return { queryPaging, ...rest };
62
61
  }
63
62
 
64
63
  /**