@etsoo/appscript 1.6.37 → 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.
@@ -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
@@ -1,6 +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
3
  import { QueryPagingData } from "../api/rq/QueryPagingData";
4
+ import { QueryRQ } from "../api/rq/QueryRQ";
4
5
  /**
5
6
  * Business utils
6
7
  */
@@ -14,11 +15,17 @@ export declare namespace BusinessUtils {
14
15
  */
15
16
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
16
17
  /**
17
- * Format query paging data
18
- * @param query Query paging data or batch size
18
+ * Format query, dealing with paging data
19
+ * @param rq Query
19
20
  * @returns Result
20
21
  */
21
- function formatQueryPaging(query: QueryPagingData | number | undefined): QueryPagingData | undefined;
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
+ };
22
29
  /**
23
30
  * Get 12-month items
24
31
  * @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
@@ -1,6 +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
3
  import { QueryPagingData } from "../api/rq/QueryPagingData";
4
+ import { QueryRQ } from "../api/rq/QueryRQ";
4
5
  /**
5
6
  * Business utils
6
7
  */
@@ -14,11 +15,17 @@ export declare namespace BusinessUtils {
14
15
  */
15
16
  function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
16
17
  /**
17
- * Format query paging data
18
- * @param query Query paging data or batch size
18
+ * Format query, dealing with paging data
19
+ * @param rq Query
19
20
  * @returns Result
20
21
  */
21
- function formatQueryPaging(query: QueryPagingData | number | undefined): QueryPagingData | undefined;
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
+ };
22
29
  /**
23
30
  * Get 12-month items
24
31
  * @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.38",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -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
  }
@@ -1,6 +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
3
  import { QueryPagingData } from "../api/rq/QueryPagingData";
4
+ import { QueryRQ } from "../api/rq/QueryRQ";
4
5
 
5
6
  /**
6
7
  * Business utils
@@ -48,17 +49,16 @@ export namespace BusinessUtils {
48
49
  }
49
50
 
50
51
  /**
51
- * Format query paging data
52
- * @param query Query paging data or batch size
52
+ * Format query, dealing with paging data
53
+ * @param rq Query
53
54
  * @returns Result
54
55
  */
55
- export function formatQueryPaging(
56
- query: QueryPagingData | number | undefined
57
- ) {
58
- if (typeof query === "number") {
59
- query = { currentPage: 0, batchSize: query };
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
60
  }
61
- return query;
61
+ return { queryPaging, ...rest };
62
62
  }
63
63
 
64
64
  /**