@etsoo/appscript 1.6.36 → 1.6.38

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.
@@ -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", () => {
@@ -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
@@ -38,11 +39,7 @@ class EntityApi extends BaseApi_1.BaseApi {
38
39
  * @returns Result
39
40
  */
40
41
  listBase(rq, payload) {
41
- let { queryPaging, ...rest } = rq;
42
- if (typeof queryPaging === "number") {
43
- queryPaging = { currentPage: 0, batchSize: queryPaging };
44
- }
45
- return this.api.post(`${this.flag}/List`, { queryPaging, ...rest }, payload);
42
+ return this.api.post(`${this.flag}/List`, BusinessUtils_1.BusinessUtils.formatQuery(rq), payload);
46
43
  }
47
44
  /**
48
45
  * Merge
@@ -61,7 +58,7 @@ class EntityApi extends BaseApi_1.BaseApi {
61
58
  * @returns Result
62
59
  */
63
60
  queryBase(rq, payload, queryKey = "") {
64
- return this.api.post(`${this.flag}/Query${queryKey}`, rq, payload);
61
+ return this.api.post(`${this.flag}/Query${queryKey}`, BusinessUtils_1.BusinessUtils.formatQuery(rq), payload);
65
62
  }
66
63
  /**
67
64
  * Query favored country ids
@@ -1,5 +1,7 @@
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";
4
+ import { QueryRQ } from "../api/rq/QueryRQ";
3
5
  /**
4
6
  * Business utils
5
7
  */
@@ -12,6 +14,18 @@ export declare namespace BusinessUtils {
12
14
  * @returns Result
13
15
  */
14
16
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
17
+ /**
18
+ * Format query, dealing with paging data
19
+ * @param rq Query
20
+ * @returns Result
21
+ */
22
+ function formatQuery<T extends IdType>(rq: QueryRQ<T>): {
23
+ id?: T | undefined;
24
+ ids?: T[] | undefined;
25
+ excludedIds?: T[] | undefined;
26
+ keyword?: string;
27
+ queryPaging: QueryPagingData | undefined;
28
+ };
15
29
  /**
16
30
  * Get 12-month items
17
31
  * @param monthLabels Month labels
@@ -39,6 +39,19 @@ var BusinessUtils;
39
39
  return defaultTitle;
40
40
  }
41
41
  BusinessUtils.formatAvatarTitle = formatAvatarTitle;
42
+ /**
43
+ * Format query, dealing with paging data
44
+ * @param rq Query
45
+ * @returns Result
46
+ */
47
+ function formatQuery(rq) {
48
+ let { queryPaging, ...rest } = rq;
49
+ if (typeof queryPaging === "number") {
50
+ queryPaging = { currentPage: 0, batchSize: queryPaging };
51
+ }
52
+ return { queryPaging, ...rest };
53
+ }
54
+ BusinessUtils.formatQuery = formatQuery;
42
55
  /**
43
56
  * Get 12-month items
44
57
  * @param monthLabels Month labels
@@ -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
@@ -35,11 +36,7 @@ export class EntityApi extends BaseApi {
35
36
  * @returns Result
36
37
  */
37
38
  listBase(rq, payload) {
38
- let { queryPaging, ...rest } = rq;
39
- if (typeof queryPaging === "number") {
40
- queryPaging = { currentPage: 0, batchSize: queryPaging };
41
- }
42
- return this.api.post(`${this.flag}/List`, { queryPaging, ...rest }, payload);
39
+ return this.api.post(`${this.flag}/List`, BusinessUtils.formatQuery(rq), payload);
43
40
  }
44
41
  /**
45
42
  * Merge
@@ -58,7 +55,7 @@ export class EntityApi extends BaseApi {
58
55
  * @returns Result
59
56
  */
60
57
  queryBase(rq, payload, queryKey = "") {
61
- return this.api.post(`${this.flag}/Query${queryKey}`, rq, payload);
58
+ return this.api.post(`${this.flag}/Query${queryKey}`, BusinessUtils.formatQuery(rq), payload);
62
59
  }
63
60
  /**
64
61
  * Query favored country ids
@@ -1,5 +1,7 @@
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";
4
+ import { QueryRQ } from "../api/rq/QueryRQ";
3
5
  /**
4
6
  * Business utils
5
7
  */
@@ -12,6 +14,18 @@ export declare namespace BusinessUtils {
12
14
  * @returns Result
13
15
  */
14
16
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
17
+ /**
18
+ * Format query, dealing with paging data
19
+ * @param rq Query
20
+ * @returns Result
21
+ */
22
+ function formatQuery<T extends IdType>(rq: QueryRQ<T>): {
23
+ id?: T | undefined;
24
+ ids?: T[] | undefined;
25
+ excludedIds?: T[] | undefined;
26
+ keyword?: string;
27
+ queryPaging: QueryPagingData | undefined;
28
+ };
15
29
  /**
16
30
  * Get 12-month items
17
31
  * @param monthLabels Month labels
@@ -36,6 +36,19 @@ export var BusinessUtils;
36
36
  return defaultTitle;
37
37
  }
38
38
  BusinessUtils.formatAvatarTitle = formatAvatarTitle;
39
+ /**
40
+ * Format query, dealing with paging data
41
+ * @param rq Query
42
+ * @returns Result
43
+ */
44
+ function formatQuery(rq) {
45
+ let { queryPaging, ...rest } = rq;
46
+ if (typeof queryPaging === "number") {
47
+ queryPaging = { currentPage: 0, batchSize: queryPaging };
48
+ }
49
+ return { queryPaging, ...rest };
50
+ }
51
+ BusinessUtils.formatQuery = formatQuery;
39
52
  /**
40
53
  * Get 12-month items
41
54
  * @param monthLabels Month labels
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.6.36",
3
+ "version": "1.6.38",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -42,14 +42,14 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@babel/cli": "^7.27.2",
45
- "@babel/core": "^7.27.1",
46
- "@babel/plugin-transform-runtime": "^7.27.1",
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.1",
48
+ "@babel/runtime-corejs3": "^7.27.6",
49
49
  "@types/crypto-js": "^4.2.2",
50
- "@vitejs/plugin-react": "^4.5.0",
50
+ "@vitejs/plugin-react": "^4.5.1",
51
51
  "jsdom": "^26.1.0",
52
52
  "typescript": "^5.8.3",
53
- "vitest": "^3.1.4"
53
+ "vitest": "^3.2.2"
54
54
  }
55
55
  }
@@ -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
@@ -66,13 +67,9 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
66
67
  rq: RQ,
67
68
  payload?: IApiPayload<R[]>
68
69
  ) {
69
- let { queryPaging, ...rest } = rq;
70
- if (typeof queryPaging === "number") {
71
- queryPaging = { currentPage: 0, batchSize: queryPaging };
72
- }
73
70
  return this.api.post(
74
71
  `${this.flag}/List`,
75
- { queryPaging, ...rest },
72
+ BusinessUtils.formatQuery(rq),
76
73
  payload
77
74
  );
78
75
  }
@@ -102,7 +99,11 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
102
99
  RQ extends QueryRQ<T>,
103
100
  R extends object
104
101
  >(rq: RQ, payload?: IApiPayload<R[]>, queryKey: string = "") {
105
- return this.api.post(`${this.flag}/Query${queryKey}`, rq, payload);
102
+ return this.api.post(
103
+ `${this.flag}/Query${queryKey}`,
104
+ BusinessUtils.formatQuery(rq),
105
+ payload
106
+ );
106
107
  }
107
108
 
108
109
  /**
@@ -1,5 +1,7 @@
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";
4
+ import { QueryRQ } from "../api/rq/QueryRQ";
3
5
 
4
6
  /**
5
7
  * Business utils
@@ -46,6 +48,19 @@ export namespace BusinessUtils {
46
48
  return defaultTitle;
47
49
  }
48
50
 
51
+ /**
52
+ * Format query, dealing with paging data
53
+ * @param rq Query
54
+ * @returns Result
55
+ */
56
+ export function formatQuery<T extends IdType>(rq: QueryRQ<T>) {
57
+ let { queryPaging, ...rest } = rq;
58
+ if (typeof queryPaging === "number") {
59
+ queryPaging = { currentPage: 0, batchSize: queryPaging };
60
+ }
61
+ return { queryPaging, ...rest };
62
+ }
63
+
49
64
  /**
50
65
  * Get 12-month items
51
66
  * @param monthLabels Month labels