@soleil-se/app-util 5.6.3 → 5.6.5
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/CHANGELOG.md +10 -2
- package/client/fetch-json/index.js +6 -5
- package/common/index.js +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ All notable changes to this project will be documented in this file.
|
|
|
7
7
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
8
8
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
9
9
|
|
|
10
|
+
## [5.6.5] - 2024-01-25
|
|
11
|
+
|
|
12
|
+
- Fix asynchronous handling of error in `fetchJson`.
|
|
13
|
+
|
|
14
|
+
## [5.6.4] - 2024-01-18
|
|
15
|
+
|
|
16
|
+
- Cast `Packages.java.util.UUID.randomUUID()` to `string`.
|
|
17
|
+
|
|
10
18
|
## [5.6.3] - 2024-01-15
|
|
11
19
|
|
|
12
20
|
- Only remove values in `stringifyParams` if they are `undefined`, `null` or an empty string.
|
|
@@ -116,14 +124,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
116
124
|
## [4.0.0] - 2021-01-27
|
|
117
125
|
|
|
118
126
|
A much needed major overhaul of the package.
|
|
119
|
-
See [MIGRATION](
|
|
127
|
+
See [MIGRATION](/packages/soleil-api/webapp-util/migration/).
|
|
120
128
|
|
|
121
129
|
- Major refactoring of package.
|
|
122
130
|
- Exports for render functions are moved.
|
|
123
131
|
- All documented constants and functions from base import (`@soleil-api/webapp-util`) now works both in a server and client context.
|
|
124
132
|
- Settings for selector is moved from server to client rendering functions.
|
|
125
133
|
- Removed `noScript` option in `render` (formerly `renderApp`) has been removed. If a no script message is needed use the `html` option wrapped in `<noscript>`.
|
|
126
|
-
- Removed `@soleil-api/webapp-util/app-data` has been removed, use
|
|
134
|
+
- Removed `@soleil-api/webapp-util/app-data` has been removed, use getAppData from `@soleil-api/webapp-util`.
|
|
127
135
|
|
|
128
136
|
## [3.0.3] - 2020-11-03
|
|
129
137
|
|
|
@@ -16,19 +16,20 @@ async function toJson(response) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
async function
|
|
19
|
+
async function responseError(response) {
|
|
20
20
|
const json = await toJson(response) || {};
|
|
21
21
|
const error = new Error(json?.message || response?.statusText);
|
|
22
22
|
Object.entries(json).forEach(([key, value]) => {
|
|
23
23
|
error[key] = value;
|
|
24
24
|
});
|
|
25
25
|
error.status = response.status;
|
|
26
|
-
|
|
26
|
+
return error;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async function handleResponse(response) {
|
|
30
|
-
if (!response.ok)
|
|
31
|
-
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw await responseError(response);
|
|
32
|
+
}
|
|
32
33
|
const json = await toJson(response);
|
|
33
34
|
if (!json) {
|
|
34
35
|
throw new Error('Response could not be parsed as JSON.');
|
|
@@ -40,7 +41,7 @@ export default function fetchJson(uri, { params = {}, retries = 0, ...options }
|
|
|
40
41
|
return fetch(getUrl(uri, params), options)
|
|
41
42
|
.then(handleResponse)
|
|
42
43
|
.catch((error) => {
|
|
43
|
-
const isTimeout = error.status === 504 || error.status === 408 || error.message
|
|
44
|
+
const isTimeout = error.status === 504 || error.status === 408 || error.message?.includes('SocketTimeoutException');
|
|
44
45
|
if (isTimeout && retries > 0) {
|
|
45
46
|
return fetchJson(uri, { ...options, params, retries: retries - 1 });
|
|
46
47
|
}
|
package/common/index.js
CHANGED
|
@@ -63,7 +63,9 @@ export function getNamespace(prefix = 'app') {
|
|
|
63
63
|
* @returns {string} Unique identifier.
|
|
64
64
|
*/
|
|
65
65
|
export function generateId(prefix = 'id') {
|
|
66
|
-
const uuid = isServer
|
|
66
|
+
const uuid = isServer
|
|
67
|
+
? Packages.java.util.UUID.randomUUID().toString()
|
|
68
|
+
: window.crypto.randomUUID();
|
|
67
69
|
return `${prefix}_${uuid}`.replace(/-/g, '');
|
|
68
70
|
}
|
|
69
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/app-util",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.5",
|
|
4
4
|
"description": "Utility and rendering functions for WebApps.",
|
|
5
5
|
"main": "./common/index.js",
|
|
6
6
|
"author": "Soleil AB",
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@sitevision/api": "*"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "856a9af56cc90fa6bd3e02a1a167a486e89c84e3",
|
|
18
18
|
"dependencies": {}
|
|
19
19
|
}
|