@twin.org/web 0.0.2-next.16 → 0.0.2-next.18
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/dist/cjs/index.cjs +8 -13
- package/dist/esm/index.mjs +9 -14
- package/docs/changelog.md +38 -0
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -463,11 +463,6 @@ class FetchHelper {
|
|
|
463
463
|
* @internal
|
|
464
464
|
*/
|
|
465
465
|
static _CACHE_PREFIX = "fetch_";
|
|
466
|
-
/**
|
|
467
|
-
* Runtime name for the class.
|
|
468
|
-
* @internal
|
|
469
|
-
*/
|
|
470
|
-
static _CLASS_NAME_CAMEL_CASE = core.StringHelper.camelCase("FetchHelper");
|
|
471
466
|
/**
|
|
472
467
|
* Perform a fetch request.
|
|
473
468
|
* @param source The source for the request.
|
|
@@ -542,7 +537,7 @@ class FetchHelper {
|
|
|
542
537
|
}
|
|
543
538
|
const response = await fetch(url, requestOptions);
|
|
544
539
|
if (!response.ok && retryCount > 1) {
|
|
545
|
-
lastError = new FetchError(source, `${
|
|
540
|
+
lastError = new FetchError(source, `${"fetchHelper"}.general`, response.status ?? HttpStatusCode.internalServerError, {
|
|
546
541
|
url,
|
|
547
542
|
statusText: response.statusText
|
|
548
543
|
});
|
|
@@ -554,7 +549,7 @@ class FetchHelper {
|
|
|
554
549
|
catch (err) {
|
|
555
550
|
const isErr = core.Is.object(err);
|
|
556
551
|
if (isErr && core.Is.stringValue(err.message) && err.message.includes("Failed to fetch")) {
|
|
557
|
-
lastError = new FetchError(source, `${
|
|
552
|
+
lastError = new FetchError(source, `${"fetchHelper"}.connectivity`, HttpStatusCode.serviceUnavailable, {
|
|
558
553
|
url
|
|
559
554
|
}, err);
|
|
560
555
|
}
|
|
@@ -571,7 +566,7 @@ class FetchHelper {
|
|
|
571
566
|
if (isErr && "statusText" in err) {
|
|
572
567
|
props.statusText = err.statusText;
|
|
573
568
|
}
|
|
574
|
-
lastError = new FetchError(source, `${
|
|
569
|
+
lastError = new FetchError(source, `${"fetchHelper"}.${isAbort ? "timeout" : "general"}`, httpStatus, props, err);
|
|
575
570
|
}
|
|
576
571
|
}
|
|
577
572
|
finally {
|
|
@@ -583,7 +578,7 @@ class FetchHelper {
|
|
|
583
578
|
if (retryCount > 1 && attempt === retryCount) {
|
|
584
579
|
// False positive as FetchError is derived from Error
|
|
585
580
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
586
|
-
throw new FetchError(source, `${
|
|
581
|
+
throw new FetchError(source, `${"fetchHelper"}.retryLimitExceeded`, HttpStatusCode.internalServerError, { url }, lastError);
|
|
587
582
|
}
|
|
588
583
|
throw lastError;
|
|
589
584
|
}
|
|
@@ -624,7 +619,7 @@ class FetchHelper {
|
|
|
624
619
|
catch (err) {
|
|
625
620
|
// False positive as FetchError is derived from Error
|
|
626
621
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
627
|
-
throw new FetchError(source, `${
|
|
622
|
+
throw new FetchError(source, `${"fetchHelper"}.decodingJSON`, HttpStatusCode.badRequest, { url }, err);
|
|
628
623
|
}
|
|
629
624
|
}
|
|
630
625
|
const errorResponseData = await response.json();
|
|
@@ -632,7 +627,7 @@ class FetchHelper {
|
|
|
632
627
|
const isErrorEmpty = core.BaseError.isEmpty(errorResponse);
|
|
633
628
|
// False positive as FetchError is derived from Error
|
|
634
629
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
635
|
-
throw new FetchError(source, `${
|
|
630
|
+
throw new FetchError(source, `${"fetchHelper"}.failureStatusText`, response.status, {
|
|
636
631
|
statusText: response.statusText,
|
|
637
632
|
url,
|
|
638
633
|
data: isErrorEmpty ? errorResponseData : undefined
|
|
@@ -677,7 +672,7 @@ class FetchHelper {
|
|
|
677
672
|
catch (err) {
|
|
678
673
|
// False positive as FetchError is derived from Error
|
|
679
674
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
680
|
-
throw new FetchError(source, `${
|
|
675
|
+
throw new FetchError(source, `${"fetchHelper"}.decodingJSON`, HttpStatusCode.badRequest, { url }, err);
|
|
681
676
|
}
|
|
682
677
|
}
|
|
683
678
|
const errorResponseData = await response.json();
|
|
@@ -685,7 +680,7 @@ class FetchHelper {
|
|
|
685
680
|
const isErrorEmpty = core.BaseError.isEmpty(errorResponse);
|
|
686
681
|
// False positive as FetchError is derived from Error
|
|
687
682
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
688
|
-
throw new FetchError(source, `${
|
|
683
|
+
throw new FetchError(source, `${"fetchHelper"}.failureStatusText`, response.status, {
|
|
689
684
|
statusText: response.statusText,
|
|
690
685
|
url,
|
|
691
686
|
data: isErrorEmpty ? errorResponseData : undefined
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseError,
|
|
1
|
+
import { BaseError, Guards, Is, AsyncCache, ObjectHelper, GeneralError, Converter, JsonHelper, StringHelper } from '@twin.org/core';
|
|
2
2
|
import { Ed25519, Sha256 } from '@twin.org/crypto';
|
|
3
3
|
import { importJWK, CompactSign, flattenedVerify, SignJWT, jwtVerify } from 'jose';
|
|
4
4
|
|
|
@@ -461,11 +461,6 @@ class FetchHelper {
|
|
|
461
461
|
* @internal
|
|
462
462
|
*/
|
|
463
463
|
static _CACHE_PREFIX = "fetch_";
|
|
464
|
-
/**
|
|
465
|
-
* Runtime name for the class.
|
|
466
|
-
* @internal
|
|
467
|
-
*/
|
|
468
|
-
static _CLASS_NAME_CAMEL_CASE = StringHelper.camelCase("FetchHelper");
|
|
469
464
|
/**
|
|
470
465
|
* Perform a fetch request.
|
|
471
466
|
* @param source The source for the request.
|
|
@@ -540,7 +535,7 @@ class FetchHelper {
|
|
|
540
535
|
}
|
|
541
536
|
const response = await fetch(url, requestOptions);
|
|
542
537
|
if (!response.ok && retryCount > 1) {
|
|
543
|
-
lastError = new FetchError(source, `${
|
|
538
|
+
lastError = new FetchError(source, `${"fetchHelper"}.general`, response.status ?? HttpStatusCode.internalServerError, {
|
|
544
539
|
url,
|
|
545
540
|
statusText: response.statusText
|
|
546
541
|
});
|
|
@@ -552,7 +547,7 @@ class FetchHelper {
|
|
|
552
547
|
catch (err) {
|
|
553
548
|
const isErr = Is.object(err);
|
|
554
549
|
if (isErr && Is.stringValue(err.message) && err.message.includes("Failed to fetch")) {
|
|
555
|
-
lastError = new FetchError(source, `${
|
|
550
|
+
lastError = new FetchError(source, `${"fetchHelper"}.connectivity`, HttpStatusCode.serviceUnavailable, {
|
|
556
551
|
url
|
|
557
552
|
}, err);
|
|
558
553
|
}
|
|
@@ -569,7 +564,7 @@ class FetchHelper {
|
|
|
569
564
|
if (isErr && "statusText" in err) {
|
|
570
565
|
props.statusText = err.statusText;
|
|
571
566
|
}
|
|
572
|
-
lastError = new FetchError(source, `${
|
|
567
|
+
lastError = new FetchError(source, `${"fetchHelper"}.${isAbort ? "timeout" : "general"}`, httpStatus, props, err);
|
|
573
568
|
}
|
|
574
569
|
}
|
|
575
570
|
finally {
|
|
@@ -581,7 +576,7 @@ class FetchHelper {
|
|
|
581
576
|
if (retryCount > 1 && attempt === retryCount) {
|
|
582
577
|
// False positive as FetchError is derived from Error
|
|
583
578
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
584
|
-
throw new FetchError(source, `${
|
|
579
|
+
throw new FetchError(source, `${"fetchHelper"}.retryLimitExceeded`, HttpStatusCode.internalServerError, { url }, lastError);
|
|
585
580
|
}
|
|
586
581
|
throw lastError;
|
|
587
582
|
}
|
|
@@ -622,7 +617,7 @@ class FetchHelper {
|
|
|
622
617
|
catch (err) {
|
|
623
618
|
// False positive as FetchError is derived from Error
|
|
624
619
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
625
|
-
throw new FetchError(source, `${
|
|
620
|
+
throw new FetchError(source, `${"fetchHelper"}.decodingJSON`, HttpStatusCode.badRequest, { url }, err);
|
|
626
621
|
}
|
|
627
622
|
}
|
|
628
623
|
const errorResponseData = await response.json();
|
|
@@ -630,7 +625,7 @@ class FetchHelper {
|
|
|
630
625
|
const isErrorEmpty = BaseError.isEmpty(errorResponse);
|
|
631
626
|
// False positive as FetchError is derived from Error
|
|
632
627
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
633
|
-
throw new FetchError(source, `${
|
|
628
|
+
throw new FetchError(source, `${"fetchHelper"}.failureStatusText`, response.status, {
|
|
634
629
|
statusText: response.statusText,
|
|
635
630
|
url,
|
|
636
631
|
data: isErrorEmpty ? errorResponseData : undefined
|
|
@@ -675,7 +670,7 @@ class FetchHelper {
|
|
|
675
670
|
catch (err) {
|
|
676
671
|
// False positive as FetchError is derived from Error
|
|
677
672
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
678
|
-
throw new FetchError(source, `${
|
|
673
|
+
throw new FetchError(source, `${"fetchHelper"}.decodingJSON`, HttpStatusCode.badRequest, { url }, err);
|
|
679
674
|
}
|
|
680
675
|
}
|
|
681
676
|
const errorResponseData = await response.json();
|
|
@@ -683,7 +678,7 @@ class FetchHelper {
|
|
|
683
678
|
const isErrorEmpty = BaseError.isEmpty(errorResponse);
|
|
684
679
|
// False positive as FetchError is derived from Error
|
|
685
680
|
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
686
|
-
throw new FetchError(source, `${
|
|
681
|
+
throw new FetchError(source, `${"fetchHelper"}.failureStatusText`, response.status, {
|
|
687
682
|
statusText: response.statusText,
|
|
688
683
|
url,
|
|
689
684
|
data: isErrorEmpty ? errorResponseData : undefined
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @twin.org/web - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.18](https://github.com/twinfoundation/framework/compare/web-v0.0.2-next.17...web-v0.0.2-next.18) (2025-09-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **web:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.2-next.17 to 0.0.2-next.18
|
|
16
|
+
* @twin.org/crypto bumped from 0.0.2-next.17 to 0.0.2-next.18
|
|
17
|
+
* @twin.org/nameof bumped from 0.0.2-next.17 to 0.0.2-next.18
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.17 to 0.0.2-next.18
|
|
20
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.17 to 0.0.2-next.18
|
|
21
|
+
|
|
22
|
+
## [0.0.2-next.17](https://github.com/twinfoundation/framework/compare/web-v0.0.2-next.16...web-v0.0.2-next.17) (2025-09-29)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* additional nameof operators ([a5aab60](https://github.com/twinfoundation/framework/commit/a5aab60bf66a86f1b7ff8af7c4f044cb03706d50))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Dependencies
|
|
31
|
+
|
|
32
|
+
* The following workspace dependencies were updated
|
|
33
|
+
* dependencies
|
|
34
|
+
* @twin.org/core bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
35
|
+
* @twin.org/crypto bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
36
|
+
* @twin.org/nameof bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
37
|
+
* devDependencies
|
|
38
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
39
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.16 to 0.0.2-next.17
|
|
40
|
+
|
|
3
41
|
## [0.0.2-next.16](https://github.com/twinfoundation/framework/compare/web-v0.0.2-next.15...web-v0.0.2-next.16) (2025-09-28)
|
|
4
42
|
|
|
5
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/web",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.18",
|
|
4
4
|
"description": "Contains classes for use with web operations",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0.2-next.
|
|
18
|
-
"@twin.org/crypto": "0.0.2-next.
|
|
19
|
-
"@twin.org/nameof": "0.0.2-next.
|
|
17
|
+
"@twin.org/core": "0.0.2-next.18",
|
|
18
|
+
"@twin.org/crypto": "0.0.2-next.18",
|
|
19
|
+
"@twin.org/nameof": "0.0.2-next.18",
|
|
20
20
|
"jose": "6.1.0"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/cjs/index.cjs",
|