@etsoo/appscript 1.4.88 → 1.4.90

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.
@@ -6,7 +6,12 @@ import {
6
6
  NotificationContainer,
7
7
  NotificationRenderProps
8
8
  } from '@etsoo/notificationbase';
9
- import { ApiAuthorizationScheme, createClient } from '@etsoo/restclient';
9
+ import {
10
+ ApiAuthorizationScheme,
11
+ ApiDataError,
12
+ ApiMethod,
13
+ createClient
14
+ } from '@etsoo/restclient';
10
15
  import {
11
16
  DataTypes,
12
17
  DomUtils,
@@ -259,6 +264,34 @@ test('Tests for formatResult', () => {
259
264
  );
260
265
  });
261
266
 
267
+ test('Tests for formatError', () => {
268
+ const error: ApiDataError = {
269
+ name: 'ApiDataError',
270
+ message: 'Api data error',
271
+ response: {
272
+ type: 'https://tools.ietf.org/html/rfc9110#section-15.5.1',
273
+ title: 'One or more validation errors occurred.',
274
+ status: 400,
275
+ errors: {
276
+ $: [
277
+ 'JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password'
278
+ ],
279
+ rq: ['The rq field is required.']
280
+ },
281
+ traceId: '00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00'
282
+ },
283
+ data: {
284
+ data: undefined,
285
+ headers: [],
286
+ method: ApiMethod.POST,
287
+ params: {},
288
+ url: ''
289
+ }
290
+ };
291
+
292
+ expect(app.formatError(error)).toBe('Api data error (ApiDataError)');
293
+ });
294
+
262
295
  test('Tests for isValidPassword', () => {
263
296
  expect(app.isValidPassword('12345678')).toBeFalsy();
264
297
  expect(app.isValidPassword('abcd3')).toBeFalsy();
@@ -38,7 +38,11 @@ class EntityApi extends BaseApi_1.BaseApi {
38
38
  * @returns Result
39
39
  */
40
40
  listBase(rq, payload) {
41
- return this.api.post(`${this.flag}/List`, 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
46
  }
43
47
  /**
44
48
  * Merge
@@ -33,7 +33,7 @@ class OrgApi extends EntityApi_1.EntityApi {
33
33
  else {
34
34
  if (typeof serviceId === 'object')
35
35
  return undefined;
36
- return this.listBase({ items, serviceId }, { defaultValue: [], showLoading: false });
36
+ return this.listBase({ queryPaging: items, serviceId }, { defaultValue: [], showLoading: false });
37
37
  }
38
38
  }
39
39
  /**
@@ -1,4 +1,5 @@
1
1
  import { IdType } from '@etsoo/shared';
2
+ import { QueryPagingData } from './QueryPagingData';
2
3
  /**
3
4
  * Tiplist request data
4
5
  * com.etsoo.CoreFramework.Models.TiplistRQ
@@ -17,7 +18,7 @@ export type TiplistRQ<T extends IdType = number> = {
17
18
  */
18
19
  keyword?: string;
19
20
  /**
20
- * Max items to return
21
+ * Query paging data or items to read
21
22
  */
22
- items?: number;
23
+ queryPaging?: QueryPagingData | number;
23
24
  };
@@ -35,7 +35,11 @@ export class EntityApi extends BaseApi {
35
35
  * @returns Result
36
36
  */
37
37
  listBase(rq, payload) {
38
- return this.api.post(`${this.flag}/List`, 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
43
  }
40
44
  /**
41
45
  * Merge
@@ -30,7 +30,7 @@ export class OrgApi extends EntityApi {
30
30
  else {
31
31
  if (typeof serviceId === 'object')
32
32
  return undefined;
33
- return this.listBase({ items, serviceId }, { defaultValue: [], showLoading: false });
33
+ return this.listBase({ queryPaging: items, serviceId }, { defaultValue: [], showLoading: false });
34
34
  }
35
35
  }
36
36
  /**
@@ -1,4 +1,5 @@
1
1
  import { IdType } from '@etsoo/shared';
2
+ import { QueryPagingData } from './QueryPagingData';
2
3
  /**
3
4
  * Tiplist request data
4
5
  * com.etsoo.CoreFramework.Models.TiplistRQ
@@ -17,7 +18,7 @@ export type TiplistRQ<T extends IdType = number> = {
17
18
  */
18
19
  keyword?: string;
19
20
  /**
20
- * Max items to return
21
+ * Query paging data or items to read
21
22
  */
22
- items?: number;
23
+ queryPaging?: QueryPagingData | number;
23
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.4.88",
3
+ "version": "1.4.90",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -53,7 +53,7 @@
53
53
  "homepage": "https://github.com/ETSOO/AppScript#readme",
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.1.42",
56
- "@etsoo/restclient": "^1.1.3",
56
+ "@etsoo/restclient": "^1.1.4",
57
57
  "@etsoo/shared": "^1.2.40",
58
58
  "crypto-js": "^4.2.0"
59
59
  },
@@ -74,7 +74,15 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
74
74
  RQ extends TiplistRQ<T>,
75
75
  R extends object
76
76
  >(rq: RQ, payload?: IApiPayload<R[]>) {
77
- return this.api.post(`${this.flag}/List`, rq, payload);
77
+ let { queryPaging, ...rest } = rq;
78
+ if (typeof queryPaging === 'number') {
79
+ queryPaging = { currentPage: 0, batchSize: queryPaging };
80
+ }
81
+ return this.api.post(
82
+ `${this.flag}/List`,
83
+ { queryPaging, ...rest },
84
+ payload
85
+ );
78
86
  }
79
87
 
80
88
  /**
package/src/erp/OrgApi.ts CHANGED
@@ -58,7 +58,7 @@ export class OrgApi extends EntityApi {
58
58
  } else {
59
59
  if (typeof serviceId === 'object') return undefined;
60
60
  return this.listBase<number, OrgListRQ, ListType>(
61
- { items, serviceId },
61
+ { queryPaging: items, serviceId },
62
62
  { defaultValue: [], showLoading: false }
63
63
  );
64
64
  }
@@ -1,4 +1,5 @@
1
1
  import { IdType } from '@etsoo/shared';
2
+ import { QueryPagingData } from './QueryPagingData';
2
3
 
3
4
  /**
4
5
  * Tiplist request data
@@ -21,7 +22,7 @@ export type TiplistRQ<T extends IdType = number> = {
21
22
  keyword?: string;
22
23
 
23
24
  /**
24
- * Max items to return
25
+ * Query paging data or items to read
25
26
  */
26
- items?: number;
27
+ queryPaging?: QueryPagingData | number;
27
28
  };