@etsoo/appscript 1.4.87 → 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();
@@ -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
@@ -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.87",
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",
@@ -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
  /**