@etsoo/appscript 1.4.86 → 1.4.88

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.
@@ -7,7 +7,13 @@ import {
7
7
  NotificationRenderProps
8
8
  } from '@etsoo/notificationbase';
9
9
  import { ApiAuthorizationScheme, createClient } from '@etsoo/restclient';
10
- import { DataTypes, DomUtils, Utils, WindowStorage } from '@etsoo/shared';
10
+ import {
11
+ DataTypes,
12
+ DomUtils,
13
+ IActionResult,
14
+ Utils,
15
+ WindowStorage
16
+ } from '@etsoo/shared';
11
17
  import {
12
18
  AddressApi,
13
19
  en,
@@ -211,13 +217,15 @@ test('Tests for formatFullName', () => {
211
217
  });
212
218
 
213
219
  test('Tests for getRoles', () => {
214
- var roles = app.getRoles(UserRole.User | UserRole.Manager | UserRole.Admin);
220
+ const roles = app.getRoles(
221
+ UserRole.User | UserRole.Manager | UserRole.Admin
222
+ );
215
223
  expect(roles.length).toBe(3);
216
224
  expect(roles.map((r) => r.id)).toEqual([8, 128, 8192]);
217
225
  });
218
226
 
219
227
  test('Tests for getStatusList', () => {
220
- var statuses = app.getStatusList([
228
+ const statuses = app.getStatusList([
221
229
  EntityStatus.Normal,
222
230
  EntityStatus.Approved,
223
231
  EntityStatus.Doing,
@@ -230,6 +238,27 @@ test('Tests for getStatusList', () => {
230
238
  expect(app.getStatusList().length).toBe(9);
231
239
  });
232
240
 
241
+ test('Tests for formatResult', () => {
242
+ const result: IActionResult = {
243
+ ok: false,
244
+ type: 'https://tools.ietf.org/html/rfc9110#section-15.5.1',
245
+ title: 'One or more validation errors occurred.',
246
+ status: 400,
247
+ errors: {
248
+ $: [
249
+ 'JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password'
250
+ ],
251
+ rq: ['The rq field is required.']
252
+ },
253
+ traceId: '00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00'
254
+ };
255
+
256
+ const formatted = app.formatResult(result);
257
+ expect(formatted).toBe(
258
+ 'One or more validation errors occurred. (400, https://tools.ietf.org/html/rfc9110#section-15.5.1)'
259
+ );
260
+ });
261
+
233
262
  test('Tests for isValidPassword', () => {
234
263
  expect(app.isValidPassword('12345678')).toBeFalsy();
235
264
  expect(app.isValidPassword('abcd3')).toBeFalsy();
@@ -1,4 +1,4 @@
1
- import { IdType, ListType, ListType1 } from '@etsoo/shared';
1
+ import { ListType, ListType1 } from '@etsoo/shared';
2
2
  import { CultureGridItem } from './CultureItem';
3
3
  /**
4
4
  * Business utils
@@ -27,13 +27,4 @@ export declare namespace BusinessUtils {
27
27
  * @returns 12 months
28
28
  */
29
29
  function getMonths(monthLabels: string[], startMonth?: number): ListType[];
30
- /**
31
- * Set id value
32
- * @param item QueryRQ or TiplistRQ or similiar item
33
- * @param id Id value
34
- */
35
- function setIdValue<T extends {
36
- id?: number;
37
- sid?: string;
38
- }>(item: T, id?: IdType): void;
39
30
  }
@@ -78,18 +78,4 @@ var BusinessUtils;
78
78
  return months;
79
79
  }
80
80
  BusinessUtils.getMonths = getMonths;
81
- /**
82
- * Set id value
83
- * @param item QueryRQ or TiplistRQ or similiar item
84
- * @param id Id value
85
- */
86
- function setIdValue(item, id) {
87
- if (id == null)
88
- return;
89
- if (typeof id === 'number')
90
- item.id = id;
91
- else
92
- item.sid = id;
93
- }
94
- BusinessUtils.setIdValue = setIdValue;
95
81
  })(BusinessUtils || (exports.BusinessUtils = BusinessUtils = {}));
@@ -9,10 +9,6 @@ export type QueryRQ<T extends IdType = number> = {
9
9
  * Number id
10
10
  */
11
11
  id?: T;
12
- /**
13
- * String id
14
- */
15
- sid?: string;
16
12
  /**
17
13
  * Query paging data
18
14
  */
@@ -8,10 +8,6 @@ export type TiplistRQ<T extends IdType = number> = {
8
8
  * number id
9
9
  */
10
10
  id?: T;
11
- /**
12
- * String id
13
- */
14
- sid?: string;
15
11
  /**
16
12
  * Excluded ids
17
13
  */
@@ -19,11 +19,7 @@ class ActionResultError extends Error {
19
19
  if (result.field)
20
20
  addtions.push(result.field);
21
21
  const add = addtions.length > 0 ? ` (${addtions.join(', ')})` : '';
22
- let title = result.title;
23
- if (title && result.traceId) {
24
- title += ` [${result.traceId}]`;
25
- }
26
- return `${title || 'Error'}${add}`;
22
+ return `${result.title || 'Error'}${add}`;
27
23
  }
28
24
  /**
29
25
  * Constructor
@@ -1,4 +1,4 @@
1
- import { IdType, ListType, ListType1 } from '@etsoo/shared';
1
+ import { ListType, ListType1 } from '@etsoo/shared';
2
2
  import { CultureGridItem } from './CultureItem';
3
3
  /**
4
4
  * Business utils
@@ -27,13 +27,4 @@ export declare namespace BusinessUtils {
27
27
  * @returns 12 months
28
28
  */
29
29
  function getMonths(monthLabels: string[], startMonth?: number): ListType[];
30
- /**
31
- * Set id value
32
- * @param item QueryRQ or TiplistRQ or similiar item
33
- * @param id Id value
34
- */
35
- function setIdValue<T extends {
36
- id?: number;
37
- sid?: string;
38
- }>(item: T, id?: IdType): void;
39
30
  }
@@ -75,18 +75,4 @@ export var BusinessUtils;
75
75
  return months;
76
76
  }
77
77
  BusinessUtils.getMonths = getMonths;
78
- /**
79
- * Set id value
80
- * @param item QueryRQ or TiplistRQ or similiar item
81
- * @param id Id value
82
- */
83
- function setIdValue(item, id) {
84
- if (id == null)
85
- return;
86
- if (typeof id === 'number')
87
- item.id = id;
88
- else
89
- item.sid = id;
90
- }
91
- BusinessUtils.setIdValue = setIdValue;
92
78
  })(BusinessUtils || (BusinessUtils = {}));
@@ -9,10 +9,6 @@ export type QueryRQ<T extends IdType = number> = {
9
9
  * Number id
10
10
  */
11
11
  id?: T;
12
- /**
13
- * String id
14
- */
15
- sid?: string;
16
12
  /**
17
13
  * Query paging data
18
14
  */
@@ -8,10 +8,6 @@ export type TiplistRQ<T extends IdType = number> = {
8
8
  * number id
9
9
  */
10
10
  id?: T;
11
- /**
12
- * String id
13
- */
14
- sid?: string;
15
11
  /**
16
12
  * Excluded ids
17
13
  */
@@ -16,11 +16,7 @@ export class ActionResultError extends Error {
16
16
  if (result.field)
17
17
  addtions.push(result.field);
18
18
  const add = addtions.length > 0 ? ` (${addtions.join(', ')})` : '';
19
- let title = result.title;
20
- if (title && result.traceId) {
21
- title += ` [${result.traceId}]`;
22
- }
23
- return `${title || 'Error'}${add}`;
19
+ return `${result.title || 'Error'}${add}`;
24
20
  }
25
21
  /**
26
22
  * Constructor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.4.86",
3
+ "version": "1.4.88",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.1.42",
56
56
  "@etsoo/restclient": "^1.1.3",
57
- "@etsoo/shared": "^1.2.37",
57
+ "@etsoo/shared": "^1.2.40",
58
58
  "crypto-js": "^4.2.0"
59
59
  },
60
60
  "devDependencies": {
@@ -1,4 +1,4 @@
1
- import { IdType, ListType, ListType1 } from '@etsoo/shared';
1
+ import { ListType, ListType1 } from '@etsoo/shared';
2
2
  import { CultureGridItem } from './CultureItem';
3
3
 
4
4
  /**
@@ -94,18 +94,4 @@ export namespace BusinessUtils {
94
94
 
95
95
  return months;
96
96
  }
97
-
98
- /**
99
- * Set id value
100
- * @param item QueryRQ or TiplistRQ or similiar item
101
- * @param id Id value
102
- */
103
- export function setIdValue<T extends { id?: number; sid?: string }>(
104
- item: T,
105
- id?: IdType
106
- ) {
107
- if (id == null) return;
108
- if (typeof id === 'number') item.id = id;
109
- else item.sid = id;
110
- }
111
97
  }
@@ -11,11 +11,6 @@ export type QueryRQ<T extends IdType = number> = {
11
11
  */
12
12
  id?: T;
13
13
 
14
- /**
15
- * String id
16
- */
17
- sid?: string;
18
-
19
14
  /**
20
15
  * Query paging data
21
16
  */
@@ -10,11 +10,6 @@ export type TiplistRQ<T extends IdType = number> = {
10
10
  */
11
11
  id?: T;
12
12
 
13
- /**
14
- * String id
15
- */
16
- sid?: string;
17
-
18
13
  /**
19
14
  * Excluded ids
20
15
  */
@@ -16,12 +16,8 @@ export class ActionResultError extends Error {
16
16
  if (result.field) addtions.push(result.field);
17
17
 
18
18
  const add = addtions.length > 0 ? ` (${addtions.join(', ')})` : '';
19
- let title = result.title;
20
- if (title && result.traceId) {
21
- title += ` [${result.traceId}]`;
22
- }
23
19
 
24
- return `${title || 'Error'}${add}`;
20
+ return `${result.title || 'Error'}${add}`;
25
21
  }
26
22
 
27
23
  /**