@etsoo/appscript 1.4.87 → 1.4.89
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.
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -6,8 +6,19 @@ import {
|
|
|
6
6
|
NotificationContainer,
|
|
7
7
|
NotificationRenderProps
|
|
8
8
|
} from '@etsoo/notificationbase';
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
ApiAuthorizationScheme,
|
|
11
|
+
ApiDataError,
|
|
12
|
+
ApiMethod,
|
|
13
|
+
createClient
|
|
14
|
+
} from '@etsoo/restclient';
|
|
15
|
+
import {
|
|
16
|
+
DataTypes,
|
|
17
|
+
DomUtils,
|
|
18
|
+
IActionResult,
|
|
19
|
+
Utils,
|
|
20
|
+
WindowStorage
|
|
21
|
+
} from '@etsoo/shared';
|
|
11
22
|
import {
|
|
12
23
|
AddressApi,
|
|
13
24
|
en,
|
|
@@ -211,13 +222,15 @@ test('Tests for formatFullName', () => {
|
|
|
211
222
|
});
|
|
212
223
|
|
|
213
224
|
test('Tests for getRoles', () => {
|
|
214
|
-
|
|
225
|
+
const roles = app.getRoles(
|
|
226
|
+
UserRole.User | UserRole.Manager | UserRole.Admin
|
|
227
|
+
);
|
|
215
228
|
expect(roles.length).toBe(3);
|
|
216
229
|
expect(roles.map((r) => r.id)).toEqual([8, 128, 8192]);
|
|
217
230
|
});
|
|
218
231
|
|
|
219
232
|
test('Tests for getStatusList', () => {
|
|
220
|
-
|
|
233
|
+
const statuses = app.getStatusList([
|
|
221
234
|
EntityStatus.Normal,
|
|
222
235
|
EntityStatus.Approved,
|
|
223
236
|
EntityStatus.Doing,
|
|
@@ -230,6 +243,55 @@ test('Tests for getStatusList', () => {
|
|
|
230
243
|
expect(app.getStatusList().length).toBe(9);
|
|
231
244
|
});
|
|
232
245
|
|
|
246
|
+
test('Tests for formatResult', () => {
|
|
247
|
+
const result: IActionResult = {
|
|
248
|
+
ok: false,
|
|
249
|
+
type: 'https://tools.ietf.org/html/rfc9110#section-15.5.1',
|
|
250
|
+
title: 'One or more validation errors occurred.',
|
|
251
|
+
status: 400,
|
|
252
|
+
errors: {
|
|
253
|
+
$: [
|
|
254
|
+
'JSON deserialization for type \u0027com.etsoo.CMS.RQ.User.UserCreateRQ\u0027 was missing required properties, including the following: password'
|
|
255
|
+
],
|
|
256
|
+
rq: ['The rq field is required.']
|
|
257
|
+
},
|
|
258
|
+
traceId: '00-ed96a4f0c83f066594ecc69b77da9803-df770e3cd714fedd-00'
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const formatted = app.formatResult(result);
|
|
262
|
+
expect(formatted).toBe(
|
|
263
|
+
'One or more validation errors occurred. (400, https://tools.ietf.org/html/rfc9110#section-15.5.1)'
|
|
264
|
+
);
|
|
265
|
+
});
|
|
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
|
+
|
|
233
295
|
test('Tests for isValidPassword', () => {
|
|
234
296
|
expect(app.isValidPassword('12345678')).toBeFalsy();
|
|
235
297
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "1.4.89",
|
|
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.
|
|
56
|
+
"@etsoo/restclient": "^1.1.4",
|
|
57
57
|
"@etsoo/shared": "^1.2.40",
|
|
58
58
|
"crypto-js": "^4.2.0"
|
|
59
59
|
},
|
|
@@ -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
|
/**
|