@alwatr/fetch 2.0.0 → 2.0.2
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 +169 -159
- package/fetch.d.ts.map +1 -1
- package/fetch.js.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,29 +3,39 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## [2.0.2](https://github.com/AliMD/alwatr-eslib/compare/@alwatr/fetch@2.0.1...@alwatr/fetch@2.0.2) (2023-10-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @alwatr/fetch
|
|
9
|
+
|
|
10
|
+
## [2.0.1](https://github.com/AliMD/alwatr-eslib/compare/@alwatr/fetch@2.0.0...@alwatr/fetch@2.0.1) (2023-09-19)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- package repo urls ([466cbe9](https://github.com/AliMD/alwatr-eslib/commit/466cbe9188f24e1a1bc36d879a95b52538a58f16)) by @AliMD
|
|
15
|
+
|
|
16
|
+
# [2.0.0](https://github.com/AliMD/alwatr-eslib/compare/@alwatr/fetch@1.1.3...@alwatr/fetch@2.0.0) (2023-09-19)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
|
9
19
|
|
|
10
|
-
|
|
20
|
+
- **fetch:** remove @alwatr/signal ([03d947b](https://github.com/AliMD/alwatr-eslib/commit/03d947be3889d63805eabb7f4be618fed6da0d55)) by @AliMD
|
|
11
21
|
|
|
12
|
-
|
|
22
|
+
- fix(fetch)!: remove fetchContext ([eba9cf0](https://github.com/AliMD/alwatr-eslib/commit/eba9cf0a443564478b5b985a69d0f54fbd514440)) by @AliMD
|
|
13
23
|
|
|
14
24
|
### BREAKING CHANGES
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
- fetchContext method removed
|
|
17
27
|
|
|
18
28
|
## 1.1.3 (2023-09-19)
|
|
19
29
|
|
|
20
30
|
### Bug Fixes
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
- cleanup extra packages ([dfc0bd2](https://github.com/AliMD/alwatr-eslib/commit/dfc0bd2b42d49e1094ae0303d34e653aa289d358)) by @AliMD
|
|
23
33
|
|
|
24
|
-
## [1.1.2](https://github.com/AliMD/alwatr/compare/@alwatr/fetch@1.1.1...@alwatr/fetch@1.1.2) (2023-09-12)
|
|
34
|
+
## [1.1.2](https://github.com/AliMD/alwatr-eslib/compare/@alwatr/fetch@1.1.1...@alwatr/fetch@1.1.2) (2023-09-12)
|
|
25
35
|
|
|
26
36
|
**Note:** Version bump only for package @alwatr/fetch
|
|
27
37
|
|
|
28
|
-
## [1.1.1](https://github.com/AliMD/alwatr/compare/@alwatr/fetch@1.1.0...@alwatr/fetch@1.1.1) (2023-09-12)
|
|
38
|
+
## [1.1.1](https://github.com/AliMD/alwatr-eslib/compare/@alwatr/fetch@1.1.0...@alwatr/fetch@1.1.1) (2023-09-12)
|
|
29
39
|
|
|
30
40
|
**Note:** Version bump only for package @alwatr/fetch
|
|
31
41
|
|
|
@@ -37,51 +47,51 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
37
47
|
|
|
38
48
|
### Bug Fixes
|
|
39
49
|
|
|
40
|
-
- **fetch:** serviceRequest type ([44c1086](https://github.com/AliMD/alwatr/commit/44c10866e1c630bc3cf85b3e9be38b268b5b0c31))
|
|
41
|
-
- **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr/commit/f554b575584cb1464d48fbe8a8c4006125365853))
|
|
50
|
+
- **fetch:** serviceRequest type ([44c1086](https://github.com/AliMD/alwatr-eslib/commit/44c10866e1c630bc3cf85b3e9be38b268b5b0c31))
|
|
51
|
+
- **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr-eslib/commit/f554b575584cb1464d48fbe8a8c4006125365853))
|
|
42
52
|
|
|
43
53
|
# 0.31.0 (2023-05-08)
|
|
44
54
|
|
|
45
55
|
### Bug Fixes
|
|
46
56
|
|
|
47
|
-
- **fetch.ts:** compatible with node ([c3acb53](https://github.com/AliMD/alwatr/commit/c3acb53effd4a79e389bc4de1567b0285c03d71d))
|
|
48
|
-
- **fetch:** bodyJson type ([5740467](https://github.com/AliMD/alwatr/commit/57404673e7f031a73d1cf23501e6fa8d89759769))
|
|
49
|
-
- **fetch:** check node_mode before use navigator.online ([a688f48](https://github.com/AliMD/alwatr/commit/a688f48e9ce4b103c25ffd50f1b8c96e89c205d1))
|
|
50
|
-
- **fetch:** serviceRequest generic type ([074ef38](https://github.com/AliMD/alwatr/commit/074ef3876086f93486753559d8e3db0b60c52a0e))
|
|
51
|
-
- **fetch:** suppress fetch_cache_not_found extra error ([c04f609](https://github.com/AliMD/alwatr/commit/c04f60944106dbd8d1bf2fb5ce0e7be644c3abc6))
|
|
52
|
-
- new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
|
|
57
|
+
- **fetch.ts:** compatible with node ([c3acb53](https://github.com/AliMD/alwatr-eslib/commit/c3acb53effd4a79e389bc4de1567b0285c03d71d))
|
|
58
|
+
- **fetch:** bodyJson type ([5740467](https://github.com/AliMD/alwatr-eslib/commit/57404673e7f031a73d1cf23501e6fa8d89759769))
|
|
59
|
+
- **fetch:** check node_mode before use navigator.online ([a688f48](https://github.com/AliMD/alwatr-eslib/commit/a688f48e9ce4b103c25ffd50f1b8c96e89c205d1))
|
|
60
|
+
- **fetch:** serviceRequest generic type ([074ef38](https://github.com/AliMD/alwatr-eslib/commit/074ef3876086f93486753559d8e3db0b60c52a0e))
|
|
61
|
+
- **fetch:** suppress fetch_cache_not_found extra error ([c04f609](https://github.com/AliMD/alwatr-eslib/commit/c04f60944106dbd8d1bf2fb5ce0e7be644c3abc6))
|
|
62
|
+
- new logger api ([9d83a7d](https://github.com/AliMD/alwatr-eslib/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
|
|
53
63
|
|
|
54
64
|
### Features
|
|
55
65
|
|
|
56
|
-
- **fetch:** add user auth ([811fbc0](https://github.com/AliMD/alwatr/commit/811fbc018c2b4e3b808704e8623bd5dff2b2f3f7))
|
|
57
|
-
- **fetch:** StringifyableFetchOptions type ([e13fdb2](https://github.com/AliMD/alwatr/commit/e13fdb2550cf3a2102c331aa7980234ca6f86e08))
|
|
66
|
+
- **fetch:** add user auth ([811fbc0](https://github.com/AliMD/alwatr-eslib/commit/811fbc018c2b4e3b808704e8623bd5dff2b2f3f7))
|
|
67
|
+
- **fetch:** StringifyableFetchOptions type ([e13fdb2](https://github.com/AliMD/alwatr-eslib/commit/e13fdb2550cf3a2102c331aa7980234ca6f86e08))
|
|
58
68
|
|
|
59
69
|
# 0.30.0 (2023-03-06)
|
|
60
70
|
|
|
61
71
|
### Bug Fixes
|
|
62
72
|
|
|
63
|
-
- **fetch:** fetchContext duplicate setSignalValue ([8aa9b00](https://github.com/AliMD/alwatr/commit/8aa9b003a2d7b7ffc8243ff7092d9560763d7273))
|
|
64
|
-
- **fetch:** getClientId in nodejs ([c99e41c](https://github.com/AliMD/alwatr/commit/c99e41c9e9a979ca50cc01aeb5371a3487d9da2e))
|
|
73
|
+
- **fetch:** fetchContext duplicate setSignalValue ([8aa9b00](https://github.com/AliMD/alwatr-eslib/commit/8aa9b003a2d7b7ffc8243ff7092d9560763d7273))
|
|
74
|
+
- **fetch:** getClientId in nodejs ([c99e41c](https://github.com/AliMD/alwatr-eslib/commit/c99e41c9e9a979ca50cc01aeb5371a3487d9da2e))
|
|
65
75
|
|
|
66
76
|
### Features
|
|
67
77
|
|
|
68
|
-
- **fetch:** enhance fetchContext with dispatchOptions and only cache_only request in first time ([1f6b575](https://github.com/AliMD/alwatr/commit/1f6b575437104d64ede8a2c23d141160360d2cd5))
|
|
69
|
-
- **fetch:** fetchContext ([d63d17e](https://github.com/AliMD/alwatr/commit/d63d17ecb58221159dc45a473fdd1c992d306d2b))
|
|
70
|
-
- **fetch:** fetchContext skip online request when offline ([7c2b649](https://github.com/AliMD/alwatr/commit/7c2b6491f78acb961cdc0583112e3c709a177b79))
|
|
71
|
-
- **fetch:** fetchContext work on background ([2e12bfd](https://github.com/AliMD/alwatr/commit/2e12bfde0a0636c30e60906c4812ec66b2d36742))
|
|
72
|
-
- **fetch:** handle offline for all requests ([6a8d7b7](https://github.com/AliMD/alwatr/commit/6a8d7b7159732d834be052191935580331e36962))
|
|
78
|
+
- **fetch:** enhance fetchContext with dispatchOptions and only cache_only request in first time ([1f6b575](https://github.com/AliMD/alwatr-eslib/commit/1f6b575437104d64ede8a2c23d141160360d2cd5))
|
|
79
|
+
- **fetch:** fetchContext ([d63d17e](https://github.com/AliMD/alwatr-eslib/commit/d63d17ecb58221159dc45a473fdd1c992d306d2b))
|
|
80
|
+
- **fetch:** fetchContext skip online request when offline ([7c2b649](https://github.com/AliMD/alwatr-eslib/commit/7c2b6491f78acb961cdc0583112e3c709a177b79))
|
|
81
|
+
- **fetch:** fetchContext work on background ([2e12bfd](https://github.com/AliMD/alwatr-eslib/commit/2e12bfde0a0636c30e60906c4812ec66b2d36742))
|
|
82
|
+
- **fetch:** handle offline for all requests ([6a8d7b7](https://github.com/AliMD/alwatr-eslib/commit/6a8d7b7159732d834be052191935580331e36962))
|
|
73
83
|
|
|
74
84
|
# 0.29.0 (2023-02-10)
|
|
75
85
|
|
|
76
86
|
### Bug Fixes
|
|
77
87
|
|
|
78
|
-
- **fetch:** device id to client id ([077e467](https://github.com/AliMD/alwatr/commit/077e4671d804d43c8f61a9d163d8d51d7a69134e))
|
|
79
|
-
- **fetch:** headers type ([cd4b14e](https://github.com/AliMD/alwatr/commit/cd4b14e46b5090b6df8cb4f89d22b53966b9151e))
|
|
88
|
+
- **fetch:** device id to client id ([077e467](https://github.com/AliMD/alwatr-eslib/commit/077e4671d804d43c8f61a9d163d8d51d7a69134e))
|
|
89
|
+
- **fetch:** headers type ([cd4b14e](https://github.com/AliMD/alwatr-eslib/commit/cd4b14e46b5090b6df8cb4f89d22b53966b9151e))
|
|
80
90
|
|
|
81
91
|
### Features
|
|
82
92
|
|
|
83
|
-
- **fetch:** add update_cache to CacheStrategy ([e1406b1](https://github.com/AliMD/alwatr/commit/e1406b12e1276de3295c47506c8102ab3f8bfa79))
|
|
84
|
-
- **fetch:** clientId on service request ([9575a1d](https://github.com/AliMD/alwatr/commit/9575a1d595a0a4757581a29a66837cbe4be46ed3))
|
|
93
|
+
- **fetch:** add update_cache to CacheStrategy ([e1406b1](https://github.com/AliMD/alwatr-eslib/commit/e1406b12e1276de3295c47506c8102ab3f8bfa79))
|
|
94
|
+
- **fetch:** clientId on service request ([9575a1d](https://github.com/AliMD/alwatr-eslib/commit/9575a1d595a0a4757581a29a66837cbe4be46ed3))
|
|
85
95
|
|
|
86
96
|
# 0.28.0 (2023-01-20)
|
|
87
97
|
|
|
@@ -89,308 +99,308 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
89
99
|
|
|
90
100
|
### Bug Fixes
|
|
91
101
|
|
|
92
|
-
- review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8))
|
|
102
|
+
- review issue ([e5d192c](https://github.com/AliMD/alwatr-eslib/commit/e5d192cbee6917c2de01146cf8bd026895724ab8))
|
|
93
103
|
|
|
94
104
|
### Features
|
|
95
105
|
|
|
96
|
-
- **type:** add types ([2de3842](https://github.com/AliMD/alwatr/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4))
|
|
106
|
+
- **type:** add types ([2de3842](https://github.com/AliMD/alwatr-eslib/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4))
|
|
97
107
|
|
|
98
108
|
# 0.26.0 (2022-12-22)
|
|
99
109
|
|
|
100
110
|
### Bug Fixes
|
|
101
111
|
|
|
102
|
-
- all import without .js ([fa739ab](https://github.com/AliMD/alwatr/commit/fa739ab23f67bae1d10bfcc146920b71377a26fc))
|
|
103
|
-
- **
|
|
104
|
-
- **fetch:** always call revalidateCallback ([444edc5](https://github.com/AliMD/alwatr/commit/444edc52b6dd5de5418ae8630e1f2270f0114372))
|
|
105
|
-
- **fetch:** enhance handle and report errors in serviceRequest ([dbfc7ff](https://github.com/AliMD/alwatr/commit/dbfc7ff2a036216498dc8e2ff58b74b7eb8d9bc0))
|
|
106
|
-
- **fetch:** fetch_cache_not_found is not error ([3d1aa4e](https://github.com/AliMD/alwatr/commit/3d1aa4e572fbf4bc7b0a527a3fdcf4c521af18dd))
|
|
107
|
-
- **fetch:** fetch_failed error message ([3e98bd9](https://github.com/AliMD/alwatr/commit/3e98bd926a495c13d476f2f1cfb9e546a059d4d8))
|
|
108
|
-
- **fetch:** remove extra \_options ([ad24c81](https://github.com/AliMD/alwatr/commit/ad24c8104b944ebda52308e60d41976ac1eeee81))
|
|
109
|
-
- **fetch:** revalidateCallback issue ([7207909](https://github.com/AliMD/alwatr/commit/72079098edb438c28256dad03d7802bc2fab0858))
|
|
110
|
-
- set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
|
|
111
|
-
- **storage-engine:** AlwatrDocumentStorage ([ca9a7bf](https://github.com/AliMD/alwatr/commit/ca9a7bf5e17b333538e749ada5d481a06c847101))
|
|
112
|
-
- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
|
|
113
|
-
- tsconfig refrences ([cea0562](https://github.com/AliMD/alwatr/commit/cea05621ecfa499476c5b10a412e60f27ba6a06d))
|
|
112
|
+
- all import without .js ([fa739ab](https://github.com/AliMD/alwatr-eslib/commit/fa739ab23f67bae1d10bfcc146920b71377a26fc))
|
|
113
|
+
- **packages/fetch:** tsconfig refrences ([e6b9542](https://github.com/AliMD/alwatr-eslib/commit/e6b9542284e67b67600da4dcebd19daedb031c9c))
|
|
114
|
+
- **fetch:** always call revalidateCallback ([444edc5](https://github.com/AliMD/alwatr-eslib/commit/444edc52b6dd5de5418ae8630e1f2270f0114372))
|
|
115
|
+
- **fetch:** enhance handle and report errors in serviceRequest ([dbfc7ff](https://github.com/AliMD/alwatr-eslib/commit/dbfc7ff2a036216498dc8e2ff58b74b7eb8d9bc0))
|
|
116
|
+
- **fetch:** fetch_cache_not_found is not error ([3d1aa4e](https://github.com/AliMD/alwatr-eslib/commit/3d1aa4e572fbf4bc7b0a527a3fdcf4c521af18dd))
|
|
117
|
+
- **fetch:** fetch_failed error message ([3e98bd9](https://github.com/AliMD/alwatr-eslib/commit/3e98bd926a495c13d476f2f1cfb9e546a059d4d8))
|
|
118
|
+
- **fetch:** remove extra \_options ([ad24c81](https://github.com/AliMD/alwatr-eslib/commit/ad24c8104b944ebda52308e60d41976ac1eeee81))
|
|
119
|
+
- **fetch:** revalidateCallback issue ([7207909](https://github.com/AliMD/alwatr-eslib/commit/72079098edb438c28256dad03d7802bc2fab0858))
|
|
120
|
+
- set correct path ([d01ce6f](https://github.com/AliMD/alwatr-eslib/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
|
|
121
|
+
- **storage-engine:** AlwatrDocumentStorage ([ca9a7bf](https://github.com/AliMD/alwatr-eslib/commit/ca9a7bf5e17b333538e749ada5d481a06c847101))
|
|
122
|
+
- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr-eslib/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
|
|
123
|
+
- tsconfig refrences ([cea0562](https://github.com/AliMD/alwatr-eslib/commit/cea05621ecfa499476c5b10a412e60f27ba6a06d))
|
|
114
124
|
|
|
115
125
|
### Features
|
|
116
126
|
|
|
117
|
-
- **fetch:** add AlwatrDocumentStorage type ([44b84f0](https://github.com/AliMD/alwatr/commit/44b84f0754169a707472655811020f6e542a6e5d))
|
|
118
|
-
- **fetch:** serviceRequest ([b0b5478](https://github.com/AliMD/alwatr/commit/b0b5478d16b2cb590cfc29d644006e4a459dd6d6))
|
|
119
|
-
- **fetch:** serviceRequest ([#513](https://github.com/AliMD/alwatr/issues/513)) ([113ee49](https://github.com/AliMD/alwatr/commit/113ee498c778d9efc00cc4807bfef09e52336a31))
|
|
120
|
-
- improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c))
|
|
121
|
-
- improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
|
|
127
|
+
- **fetch:** add AlwatrDocumentStorage type ([44b84f0](https://github.com/AliMD/alwatr-eslib/commit/44b84f0754169a707472655811020f6e542a6e5d))
|
|
128
|
+
- **fetch:** serviceRequest ([b0b5478](https://github.com/AliMD/alwatr-eslib/commit/b0b5478d16b2cb590cfc29d644006e4a459dd6d6))
|
|
129
|
+
- **fetch:** serviceRequest ([#513](https://github.com/AliMD/alwatr-eslib/issues/513)) ([113ee49](https://github.com/AliMD/alwatr-eslib/commit/113ee498c778d9efc00cc4807bfef09e52336a31))
|
|
130
|
+
- improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr-eslib/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c))
|
|
131
|
+
- improve error debugging ([1fba504](https://github.com/AliMD/alwatr-eslib/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
|
|
122
132
|
|
|
123
|
-
# [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14)
|
|
133
|
+
# [1.0.0](https://github.com/AliMD/alwatr-eslib/compare/v0.32.0...v1.0.0) (2023-06-14)
|
|
124
134
|
|
|
125
135
|
**Note:** Version bump only for package @alwatr/fetch
|
|
126
136
|
|
|
127
|
-
# [0.32.0](https://github.com/AliMD/alwatr/compare/v0.31.0...v0.32.0) (2023-05-27)
|
|
137
|
+
# [0.32.0](https://github.com/AliMD/alwatr-eslib/compare/v0.31.0...v0.32.0) (2023-05-27)
|
|
128
138
|
|
|
129
139
|
### Bug Fixes
|
|
130
140
|
|
|
131
|
-
- **fetch:** serviceRequest type ([44c1086](https://github.com/AliMD/alwatr/commit/44c10866e1c630bc3cf85b3e9be38b268b5b0c31))
|
|
132
|
-
- **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr/commit/f554b575584cb1464d48fbe8a8c4006125365853))
|
|
141
|
+
- **fetch:** serviceRequest type ([44c1086](https://github.com/AliMD/alwatr-eslib/commit/44c10866e1c630bc3cf85b3e9be38b268b5b0c31))
|
|
142
|
+
- **fetch:** userAuth in StringifyableFetchOptions ([f554b57](https://github.com/AliMD/alwatr-eslib/commit/f554b575584cb1464d48fbe8a8c4006125365853))
|
|
133
143
|
|
|
134
|
-
# [0.31.0](https://github.com/AliMD/alwatr/compare/v0.30.0...v0.31.0) (2023-05-08)
|
|
144
|
+
# [0.31.0](https://github.com/AliMD/alwatr-eslib/compare/v0.30.0...v0.31.0) (2023-05-08)
|
|
135
145
|
|
|
136
146
|
### Bug Fixes
|
|
137
147
|
|
|
138
|
-
- **fetch.ts:** compatible with node ([c3acb53](https://github.com/AliMD/alwatr/commit/c3acb53effd4a79e389bc4de1567b0285c03d71d))
|
|
139
|
-
- **fetch:** bodyJson type ([5740467](https://github.com/AliMD/alwatr/commit/57404673e7f031a73d1cf23501e6fa8d89759769))
|
|
140
|
-
- **fetch:** check node_mode before use navigator.online ([a688f48](https://github.com/AliMD/alwatr/commit/a688f48e9ce4b103c25ffd50f1b8c96e89c205d1))
|
|
141
|
-
- **fetch:** serviceRequest generic type ([074ef38](https://github.com/AliMD/alwatr/commit/074ef3876086f93486753559d8e3db0b60c52a0e))
|
|
142
|
-
- **fetch:** suppress fetch_cache_not_found extra error ([c04f609](https://github.com/AliMD/alwatr/commit/c04f60944106dbd8d1bf2fb5ce0e7be644c3abc6))
|
|
143
|
-
- new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
|
|
148
|
+
- **fetch.ts:** compatible with node ([c3acb53](https://github.com/AliMD/alwatr-eslib/commit/c3acb53effd4a79e389bc4de1567b0285c03d71d))
|
|
149
|
+
- **fetch:** bodyJson type ([5740467](https://github.com/AliMD/alwatr-eslib/commit/57404673e7f031a73d1cf23501e6fa8d89759769))
|
|
150
|
+
- **fetch:** check node_mode before use navigator.online ([a688f48](https://github.com/AliMD/alwatr-eslib/commit/a688f48e9ce4b103c25ffd50f1b8c96e89c205d1))
|
|
151
|
+
- **fetch:** serviceRequest generic type ([074ef38](https://github.com/AliMD/alwatr-eslib/commit/074ef3876086f93486753559d8e3db0b60c52a0e))
|
|
152
|
+
- **fetch:** suppress fetch_cache_not_found extra error ([c04f609](https://github.com/AliMD/alwatr-eslib/commit/c04f60944106dbd8d1bf2fb5ce0e7be644c3abc6))
|
|
153
|
+
- new logger api ([9d83a7d](https://github.com/AliMD/alwatr-eslib/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
|
|
144
154
|
|
|
145
155
|
### Features
|
|
146
156
|
|
|
147
|
-
- **fetch:** add user auth ([811fbc0](https://github.com/AliMD/alwatr/commit/811fbc018c2b4e3b808704e8623bd5dff2b2f3f7))
|
|
148
|
-
- **fetch:** StringifyableFetchOptions type ([e13fdb2](https://github.com/AliMD/alwatr/commit/e13fdb2550cf3a2102c331aa7980234ca6f86e08))
|
|
157
|
+
- **fetch:** add user auth ([811fbc0](https://github.com/AliMD/alwatr-eslib/commit/811fbc018c2b4e3b808704e8623bd5dff2b2f3f7))
|
|
158
|
+
- **fetch:** StringifyableFetchOptions type ([e13fdb2](https://github.com/AliMD/alwatr-eslib/commit/e13fdb2550cf3a2102c331aa7980234ca6f86e08))
|
|
149
159
|
|
|
150
|
-
# [0.30.0](https://github.com/AliMD/alwatr/compare/v0.29.0...v0.30.0) (2023-03-06)
|
|
160
|
+
# [0.30.0](https://github.com/AliMD/alwatr-eslib/compare/v0.29.0...v0.30.0) (2023-03-06)
|
|
151
161
|
|
|
152
162
|
### Bug Fixes
|
|
153
163
|
|
|
154
|
-
- **fetch:** fetchContext duplicate setSignalValue ([8aa9b00](https://github.com/AliMD/alwatr/commit/8aa9b003a2d7b7ffc8243ff7092d9560763d7273))
|
|
155
|
-
- **fetch:** getClientId in nodejs ([c99e41c](https://github.com/AliMD/alwatr/commit/c99e41c9e9a979ca50cc01aeb5371a3487d9da2e))
|
|
164
|
+
- **fetch:** fetchContext duplicate setSignalValue ([8aa9b00](https://github.com/AliMD/alwatr-eslib/commit/8aa9b003a2d7b7ffc8243ff7092d9560763d7273))
|
|
165
|
+
- **fetch:** getClientId in nodejs ([c99e41c](https://github.com/AliMD/alwatr-eslib/commit/c99e41c9e9a979ca50cc01aeb5371a3487d9da2e))
|
|
156
166
|
|
|
157
167
|
### Features
|
|
158
168
|
|
|
159
|
-
- **fetch:** enhance fetchContext with dispatchOptions and only cache_only request in first time ([1f6b575](https://github.com/AliMD/alwatr/commit/1f6b575437104d64ede8a2c23d141160360d2cd5))
|
|
160
|
-
- **fetch:** fetchContext ([d63d17e](https://github.com/AliMD/alwatr/commit/d63d17ecb58221159dc45a473fdd1c992d306d2b))
|
|
161
|
-
- **fetch:** fetchContext skip online request when offline ([7c2b649](https://github.com/AliMD/alwatr/commit/7c2b6491f78acb961cdc0583112e3c709a177b79))
|
|
162
|
-
- **fetch:** fetchContext work on background ([2e12bfd](https://github.com/AliMD/alwatr/commit/2e12bfde0a0636c30e60906c4812ec66b2d36742))
|
|
163
|
-
- **fetch:** handle offline for all requests ([6a8d7b7](https://github.com/AliMD/alwatr/commit/6a8d7b7159732d834be052191935580331e36962))
|
|
169
|
+
- **fetch:** enhance fetchContext with dispatchOptions and only cache_only request in first time ([1f6b575](https://github.com/AliMD/alwatr-eslib/commit/1f6b575437104d64ede8a2c23d141160360d2cd5))
|
|
170
|
+
- **fetch:** fetchContext ([d63d17e](https://github.com/AliMD/alwatr-eslib/commit/d63d17ecb58221159dc45a473fdd1c992d306d2b))
|
|
171
|
+
- **fetch:** fetchContext skip online request when offline ([7c2b649](https://github.com/AliMD/alwatr-eslib/commit/7c2b6491f78acb961cdc0583112e3c709a177b79))
|
|
172
|
+
- **fetch:** fetchContext work on background ([2e12bfd](https://github.com/AliMD/alwatr-eslib/commit/2e12bfde0a0636c30e60906c4812ec66b2d36742))
|
|
173
|
+
- **fetch:** handle offline for all requests ([6a8d7b7](https://github.com/AliMD/alwatr-eslib/commit/6a8d7b7159732d834be052191935580331e36962))
|
|
164
174
|
|
|
165
|
-
# [0.29.0](https://github.com/AliMD/alwatr/compare/v0.28.0...v0.29.0) (2023-02-10)
|
|
175
|
+
# [0.29.0](https://github.com/AliMD/alwatr-eslib/compare/v0.28.0...v0.29.0) (2023-02-10)
|
|
166
176
|
|
|
167
177
|
### Bug Fixes
|
|
168
178
|
|
|
169
|
-
- **fetch:** device id to client id ([077e467](https://github.com/AliMD/alwatr/commit/077e4671d804d43c8f61a9d163d8d51d7a69134e))
|
|
170
|
-
- **fetch:** headers type ([cd4b14e](https://github.com/AliMD/alwatr/commit/cd4b14e46b5090b6df8cb4f89d22b53966b9151e))
|
|
179
|
+
- **fetch:** device id to client id ([077e467](https://github.com/AliMD/alwatr-eslib/commit/077e4671d804d43c8f61a9d163d8d51d7a69134e))
|
|
180
|
+
- **fetch:** headers type ([cd4b14e](https://github.com/AliMD/alwatr-eslib/commit/cd4b14e46b5090b6df8cb4f89d22b53966b9151e))
|
|
171
181
|
|
|
172
182
|
### Features
|
|
173
183
|
|
|
174
|
-
- **fetch:** add update_cache to CacheStrategy ([e1406b1](https://github.com/AliMD/alwatr/commit/e1406b12e1276de3295c47506c8102ab3f8bfa79))
|
|
175
|
-
- **fetch:** clientId on service request ([9575a1d](https://github.com/AliMD/alwatr/commit/9575a1d595a0a4757581a29a66837cbe4be46ed3))
|
|
184
|
+
- **fetch:** add update_cache to CacheStrategy ([e1406b1](https://github.com/AliMD/alwatr-eslib/commit/e1406b12e1276de3295c47506c8102ab3f8bfa79))
|
|
185
|
+
- **fetch:** clientId on service request ([9575a1d](https://github.com/AliMD/alwatr-eslib/commit/9575a1d595a0a4757581a29a66837cbe4be46ed3))
|
|
176
186
|
|
|
177
|
-
# [0.28.0](https://github.com/AliMD/alwatr/compare/v0.27.0...v0.28.0) (2023-01-20)
|
|
187
|
+
# [0.28.0](https://github.com/AliMD/alwatr-eslib/compare/v0.27.0...v0.28.0) (2023-01-20)
|
|
178
188
|
|
|
179
189
|
### Bug Fixes
|
|
180
190
|
|
|
181
|
-
- review issue ([e5d192c](https://github.com/AliMD/alwatr/commit/e5d192cbee6917c2de01146cf8bd026895724ab8))
|
|
191
|
+
- review issue ([e5d192c](https://github.com/AliMD/alwatr-eslib/commit/e5d192cbee6917c2de01146cf8bd026895724ab8))
|
|
182
192
|
|
|
183
193
|
### Features
|
|
184
194
|
|
|
185
|
-
- **type:** add types ([2de3842](https://github.com/AliMD/alwatr/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4))
|
|
195
|
+
- **type:** add types ([2de3842](https://github.com/AliMD/alwatr-eslib/commit/2de384297b70b9818ec8d62ce8d31be4822d95a4))
|
|
186
196
|
|
|
187
|
-
# [0.27.0](https://github.com/AliMD/alwatr/compare/v0.26.0...v0.27.0) (2022-12-29)
|
|
197
|
+
# [0.27.0](https://github.com/AliMD/alwatr-eslib/compare/v0.26.0...v0.27.0) (2022-12-29)
|
|
188
198
|
|
|
189
199
|
**Note:** Version bump only for package @alwatr/fetch
|
|
190
200
|
|
|
191
|
-
# [0.26.0](https://github.com/AliMD/alwatr/compare/v0.25.0...v0.26.0) (2022-12-22)
|
|
201
|
+
# [0.26.0](https://github.com/AliMD/alwatr-eslib/compare/v0.25.0...v0.26.0) (2022-12-22)
|
|
192
202
|
|
|
193
203
|
### Bug Fixes
|
|
194
204
|
|
|
195
|
-
- all import without .js ([fa739ab](https://github.com/AliMD/alwatr/commit/fa739ab23f67bae1d10bfcc146920b71377a26fc))
|
|
196
|
-
- **
|
|
197
|
-
- **fetch:** always call revalidateCallback ([444edc5](https://github.com/AliMD/alwatr/commit/444edc52b6dd5de5418ae8630e1f2270f0114372))
|
|
198
|
-
- **fetch:** enhance handle and report errors in serviceRequest ([dbfc7ff](https://github.com/AliMD/alwatr/commit/dbfc7ff2a036216498dc8e2ff58b74b7eb8d9bc0))
|
|
199
|
-
- **fetch:** fetch_cache_not_found is not error ([3d1aa4e](https://github.com/AliMD/alwatr/commit/3d1aa4e572fbf4bc7b0a527a3fdcf4c521af18dd))
|
|
200
|
-
- **fetch:** fetch_failed error message ([3e98bd9](https://github.com/AliMD/alwatr/commit/3e98bd926a495c13d476f2f1cfb9e546a059d4d8))
|
|
201
|
-
- **fetch:** remove extra \_options ([ad24c81](https://github.com/AliMD/alwatr/commit/ad24c8104b944ebda52308e60d41976ac1eeee81))
|
|
202
|
-
- **fetch:** revalidateCallback issue ([7207909](https://github.com/AliMD/alwatr/commit/72079098edb438c28256dad03d7802bc2fab0858))
|
|
203
|
-
- set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
|
|
204
|
-
- **storage-engine:** AlwatrDocumentStorage ([ca9a7bf](https://github.com/AliMD/alwatr/commit/ca9a7bf5e17b333538e749ada5d481a06c847101))
|
|
205
|
-
- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
|
|
206
|
-
- tsconfig refrences ([cea0562](https://github.com/AliMD/alwatr/commit/cea05621ecfa499476c5b10a412e60f27ba6a06d))
|
|
205
|
+
- all import without .js ([fa739ab](https://github.com/AliMD/alwatr-eslib/commit/fa739ab23f67bae1d10bfcc146920b71377a26fc))
|
|
206
|
+
- **packages/fetch:** tsconfig refrences ([e6b9542](https://github.com/AliMD/alwatr-eslib/commit/e6b9542284e67b67600da4dcebd19daedb031c9c))
|
|
207
|
+
- **fetch:** always call revalidateCallback ([444edc5](https://github.com/AliMD/alwatr-eslib/commit/444edc52b6dd5de5418ae8630e1f2270f0114372))
|
|
208
|
+
- **fetch:** enhance handle and report errors in serviceRequest ([dbfc7ff](https://github.com/AliMD/alwatr-eslib/commit/dbfc7ff2a036216498dc8e2ff58b74b7eb8d9bc0))
|
|
209
|
+
- **fetch:** fetch_cache_not_found is not error ([3d1aa4e](https://github.com/AliMD/alwatr-eslib/commit/3d1aa4e572fbf4bc7b0a527a3fdcf4c521af18dd))
|
|
210
|
+
- **fetch:** fetch_failed error message ([3e98bd9](https://github.com/AliMD/alwatr-eslib/commit/3e98bd926a495c13d476f2f1cfb9e546a059d4d8))
|
|
211
|
+
- **fetch:** remove extra \_options ([ad24c81](https://github.com/AliMD/alwatr-eslib/commit/ad24c8104b944ebda52308e60d41976ac1eeee81))
|
|
212
|
+
- **fetch:** revalidateCallback issue ([7207909](https://github.com/AliMD/alwatr-eslib/commit/72079098edb438c28256dad03d7802bc2fab0858))
|
|
213
|
+
- set correct path ([d01ce6f](https://github.com/AliMD/alwatr-eslib/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
|
|
214
|
+
- **storage-engine:** AlwatrDocumentStorage ([ca9a7bf](https://github.com/AliMD/alwatr-eslib/commit/ca9a7bf5e17b333538e749ada5d481a06c847101))
|
|
215
|
+
- tsconfig ([e96dcd3](https://github.com/AliMD/alwatr-eslib/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
|
|
216
|
+
- tsconfig refrences ([cea0562](https://github.com/AliMD/alwatr-eslib/commit/cea05621ecfa499476c5b10a412e60f27ba6a06d))
|
|
207
217
|
|
|
208
218
|
### Features
|
|
209
219
|
|
|
210
|
-
- **fetch:** add AlwatrDocumentStorage type ([44b84f0](https://github.com/AliMD/alwatr/commit/44b84f0754169a707472655811020f6e542a6e5d))
|
|
211
|
-
- **fetch:** serviceRequest ([b0b5478](https://github.com/AliMD/alwatr/commit/b0b5478d16b2cb590cfc29d644006e4a459dd6d6))
|
|
212
|
-
- **fetch:** serviceRequest ([#513](https://github.com/AliMD/alwatr/issues/513)) ([113ee49](https://github.com/AliMD/alwatr/commit/113ee498c778d9efc00cc4807bfef09e52336a31))
|
|
213
|
-
- improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c))
|
|
214
|
-
- improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
|
|
220
|
+
- **fetch:** add AlwatrDocumentStorage type ([44b84f0](https://github.com/AliMD/alwatr-eslib/commit/44b84f0754169a707472655811020f6e542a6e5d))
|
|
221
|
+
- **fetch:** serviceRequest ([b0b5478](https://github.com/AliMD/alwatr-eslib/commit/b0b5478d16b2cb590cfc29d644006e4a459dd6d6))
|
|
222
|
+
- **fetch:** serviceRequest ([#513](https://github.com/AliMD/alwatr-eslib/issues/513)) ([113ee49](https://github.com/AliMD/alwatr-eslib/commit/113ee498c778d9efc00cc4807bfef09e52336a31))
|
|
223
|
+
- improve accident debugging ([d697e6c](https://github.com/AliMD/alwatr-eslib/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c))
|
|
224
|
+
- improve error debugging ([1fba504](https://github.com/AliMD/alwatr-eslib/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
|
|
215
225
|
|
|
216
|
-
# [0.25.0](https://github.com/AliMD/alwatr/compare/v0.24.1...v0.25.0) (2022-12-07)
|
|
226
|
+
# [0.25.0](https://github.com/AliMD/alwatr-eslib/compare/v0.24.1...v0.25.0) (2022-12-07)
|
|
217
227
|
|
|
218
228
|
**Note:** Version bump only for package @alwatr/fetch
|
|
219
229
|
|
|
220
|
-
## [0.24.1](https://github.com/AliMD/alwatr/compare/v0.24.0...v0.24.1) (2022-12-01)
|
|
230
|
+
## [0.24.1](https://github.com/AliMD/alwatr-eslib/compare/v0.24.0...v0.24.1) (2022-12-01)
|
|
221
231
|
|
|
222
232
|
**Note:** Version bump only for package @alwatr/fetch
|
|
223
233
|
|
|
224
|
-
# [0.24.0](https://github.com/AliMD/alwatr/compare/v0.23.0...v0.24.0) (2022-11-28)
|
|
234
|
+
# [0.24.0](https://github.com/AliMD/alwatr-eslib/compare/v0.23.0...v0.24.0) (2022-11-28)
|
|
225
235
|
|
|
226
236
|
### Bug Fixes
|
|
227
237
|
|
|
228
|
-
- **fetch:** AlwatrServiceResponseSuccessWithMeta types ([b46f3f2](https://github.com/AliMD/alwatr/commit/b46f3f22a7c5a671385b0a8f58d0881501ce1b94))
|
|
229
|
-
- **fetch:** use nre method type ([1c63eca](https://github.com/AliMD/alwatr/commit/1c63eca994582c241112c3e5ae79bac49831532f))
|
|
230
|
-
- update types ([44cc57f](https://github.com/AliMD/alwatr/commit/44cc57f97a99ed810dae3fde39c9525bd0e8ff3c))
|
|
231
|
-
- use ~ for package version ([4e027ff](https://github.com/AliMD/alwatr/commit/4e027ff63875e03b088ebcdc1bdf2495f4494eec))
|
|
238
|
+
- **fetch:** AlwatrServiceResponseSuccessWithMeta types ([b46f3f2](https://github.com/AliMD/alwatr-eslib/commit/b46f3f22a7c5a671385b0a8f58d0881501ce1b94))
|
|
239
|
+
- **fetch:** use nre method type ([1c63eca](https://github.com/AliMD/alwatr-eslib/commit/1c63eca994582c241112c3e5ae79bac49831532f))
|
|
240
|
+
- update types ([44cc57f](https://github.com/AliMD/alwatr-eslib/commit/44cc57f97a99ed810dae3fde39c9525bd0e8ff3c))
|
|
241
|
+
- use ~ for package version ([4e027ff](https://github.com/AliMD/alwatr-eslib/commit/4e027ff63875e03b088ebcdc1bdf2495f4494eec))
|
|
232
242
|
|
|
233
|
-
# [0.23.0](https://github.com/AliMD/alwatr/compare/v0.22.1...v0.23.0) (2022-11-23)
|
|
243
|
+
# [0.23.0](https://github.com/AliMD/alwatr-eslib/compare/v0.22.1...v0.23.0) (2022-11-23)
|
|
234
244
|
|
|
235
245
|
### Bug Fixes
|
|
236
246
|
|
|
237
|
-
- **fetch:** types ([4ce81a7](https://github.com/AliMD/alwatr/commit/4ce81a7b82d01ab938754bc5e483ccb074671e33))
|
|
247
|
+
- **fetch:** types ([4ce81a7](https://github.com/AliMD/alwatr-eslib/commit/4ce81a7b82d01ab938754bc5e483ccb074671e33))
|
|
238
248
|
|
|
239
249
|
### Features
|
|
240
250
|
|
|
241
|
-
- **fetch:** set token in options ([033a638](https://github.com/AliMD/alwatr/commit/033a63846f8c43b86c7d0a662e4bb6aa7cae3af5))
|
|
251
|
+
- **fetch:** set token in options ([033a638](https://github.com/AliMD/alwatr-eslib/commit/033a63846f8c43b86c7d0a662e4bb6aa7cae3af5))
|
|
242
252
|
|
|
243
|
-
## [0.22.1](https://github.com/AliMD/alwatr/compare/v0.22.0...v0.22.1) (2022-11-21)
|
|
253
|
+
## [0.22.1](https://github.com/AliMD/alwatr-eslib/compare/v0.22.0...v0.22.1) (2022-11-21)
|
|
244
254
|
|
|
245
255
|
**Note:** Version bump only for package @alwatr/fetch
|
|
246
256
|
|
|
247
|
-
# [0.22.0](https://github.com/AliMD/alwatr/compare/v0.21.0...v0.22.0) (2022-11-20)
|
|
257
|
+
# [0.22.0](https://github.com/AliMD/alwatr-eslib/compare/v0.21.0...v0.22.0) (2022-11-20)
|
|
248
258
|
|
|
249
259
|
### Bug Fixes
|
|
250
260
|
|
|
251
|
-
- **fetch:** \_handleRetryPattern ([fe4ac12](https://github.com/AliMD/alwatr/commit/fe4ac12b4ad3086d44e545591c767cb322e32b8d))
|
|
252
|
-
- **fetch:** bodyJson issue ([5d8d6fa](https://github.com/AliMD/alwatr/commit/5d8d6fa4a0f608c2c5ed583aa54de9b836daaa5f))
|
|
261
|
+
- **fetch:** \_handleRetryPattern ([fe4ac12](https://github.com/AliMD/alwatr-eslib/commit/fe4ac12b4ad3086d44e545591c767cb322e32b8d))
|
|
262
|
+
- **fetch:** bodyJson issue ([5d8d6fa](https://github.com/AliMD/alwatr-eslib/commit/5d8d6fa4a0f608c2c5ed583aa54de9b836daaa5f))
|
|
253
263
|
|
|
254
264
|
### Features
|
|
255
265
|
|
|
256
|
-
- **fetch:** support nodejs ([2ed2ef4](https://github.com/AliMD/alwatr/commit/2ed2ef42e9f204d4896ada4e20b839cfabdc7284))
|
|
266
|
+
- **fetch:** support nodejs ([2ed2ef4](https://github.com/AliMD/alwatr-eslib/commit/2ed2ef42e9f204d4896ada4e20b839cfabdc7284))
|
|
257
267
|
|
|
258
268
|
### Performance Improvements
|
|
259
269
|
|
|
260
|
-
- **fetch:** Improve performance and decrease memory usage ([7c29333](https://github.com/AliMD/alwatr/commit/7c293339215bea3a5013effe4aea5b6267a7a75e))
|
|
270
|
+
- **fetch:** Improve performance and decrease memory usage ([7c29333](https://github.com/AliMD/alwatr-eslib/commit/7c293339215bea3a5013effe4aea5b6267a7a75e))
|
|
261
271
|
|
|
262
|
-
# [0.21.0](https://github.com/AliMD/alwatr/compare/v0.20.0...v0.21.0) (2022-11-13)
|
|
272
|
+
# [0.21.0](https://github.com/AliMD/alwatr-eslib/compare/v0.20.0...v0.21.0) (2022-11-13)
|
|
263
273
|
|
|
264
274
|
**Note:** Version bump only for package @alwatr/fetch
|
|
265
275
|
|
|
266
|
-
# [0.20.0](https://github.com/AliMD/alwatr/compare/v0.19.0...v0.20.0) (2022-11-05)
|
|
276
|
+
# [0.20.0](https://github.com/AliMD/alwatr-eslib/compare/v0.19.0...v0.20.0) (2022-11-05)
|
|
267
277
|
|
|
268
278
|
### Bug Fixes
|
|
269
279
|
|
|
270
|
-
- **fetch:** \_handleRemoveDuplicate ([6207b48](https://github.com/AliMD/alwatr/commit/6207b4867935d05a0e5a1c795de9efab4ff77c68))
|
|
271
|
-
- **fetch:** cacheStorageName issue ([e641ff7](https://github.com/AliMD/alwatr/commit/e641ff740055a68b6397f00bf46f1d05943c348a))
|
|
272
|
-
- **fetch:** method type and case ([8d4ba77](https://github.com/AliMD/alwatr/commit/8d4ba77e56ecfe2aeaa459dcd26039c38c4b2199))
|
|
273
|
-
- **fetch:** prevent duplicate revalidateCallback on first time ([2da7dc5](https://github.com/AliMD/alwatr/commit/2da7dc579e4850af06914590a231548cd469cd75))
|
|
280
|
+
- **fetch:** \_handleRemoveDuplicate ([6207b48](https://github.com/AliMD/alwatr-eslib/commit/6207b4867935d05a0e5a1c795de9efab4ff77c68))
|
|
281
|
+
- **fetch:** cacheStorageName issue ([e641ff7](https://github.com/AliMD/alwatr-eslib/commit/e641ff740055a68b6397f00bf46f1d05943c348a))
|
|
282
|
+
- **fetch:** method type and case ([8d4ba77](https://github.com/AliMD/alwatr-eslib/commit/8d4ba77e56ecfe2aeaa459dcd26039c38c4b2199))
|
|
283
|
+
- **fetch:** prevent duplicate revalidateCallback on first time ([2da7dc5](https://github.com/AliMD/alwatr-eslib/commit/2da7dc579e4850af06914590a231548cd469cd75))
|
|
274
284
|
|
|
275
285
|
### Features
|
|
276
286
|
|
|
277
|
-
- **fetch:** add retryDelay ([28e3244](https://github.com/AliMD/alwatr/commit/28e3244a2d35e7a1a91f9a5a4942f1bb4a56d981))
|
|
278
|
-
- **fetch:** revalidate callback for `stale_while_revalidate` cache strategy. ([8976cc4](https://github.com/AliMD/alwatr/commit/8976cc424b2a9e96e4cfa69941d5378a6640af6f))
|
|
279
|
-
- **fetch:** simple memory caching for remove duplicate/parallel requests ([74cd7f1](https://github.com/AliMD/alwatr/commit/74cd7f1500d730021a0f577c0ecfd7a2460fdb15))
|
|
287
|
+
- **fetch:** add retryDelay ([28e3244](https://github.com/AliMD/alwatr-eslib/commit/28e3244a2d35e7a1a91f9a5a4942f1bb4a56d981))
|
|
288
|
+
- **fetch:** revalidate callback for `stale_while_revalidate` cache strategy. ([8976cc4](https://github.com/AliMD/alwatr-eslib/commit/8976cc424b2a9e96e4cfa69941d5378a6640af6f))
|
|
289
|
+
- **fetch:** simple memory caching for remove duplicate/parallel requests ([74cd7f1](https://github.com/AliMD/alwatr-eslib/commit/74cd7f1500d730021a0f577c0ecfd7a2460fdb15))
|
|
280
290
|
|
|
281
|
-
# [0.19.0](https://github.com/AliMD/alwatr/compare/v0.18.0...v0.19.0) (2022-11-01)
|
|
291
|
+
# [0.19.0](https://github.com/AliMD/alwatr-eslib/compare/v0.18.0...v0.19.0) (2022-11-01)
|
|
282
292
|
|
|
283
293
|
**Note:** Version bump only for package @alwatr/fetch
|
|
284
294
|
|
|
285
|
-
# [0.18.0](https://github.com/AliMD/alwatr/compare/v0.17.0...v0.18.0) (2022-10-22)
|
|
295
|
+
# [0.18.0](https://github.com/AliMD/alwatr-eslib/compare/v0.17.0...v0.18.0) (2022-10-22)
|
|
286
296
|
|
|
287
297
|
### Bug Fixes
|
|
288
298
|
|
|
289
|
-
- **fetch:** update cache on network_first ([54b59cd](https://github.com/AliMD/alwatr/commit/54b59cdc64a543a0afcd09d2ec78d20661f3a06d))
|
|
299
|
+
- **fetch:** update cache on network_first ([54b59cd](https://github.com/AliMD/alwatr-eslib/commit/54b59cdc64a543a0afcd09d2ec78d20661f3a06d))
|
|
290
300
|
|
|
291
301
|
### Features
|
|
292
302
|
|
|
293
|
-
- **fetch:** cache strategy ([106eabd](https://github.com/AliMD/alwatr/commit/106eabdd10574b24f9919049d0b509ae40168a9a))
|
|
294
|
-
- **fetch:** optional cacheStorageName ([f2bd8f2](https://github.com/AliMD/alwatr/commit/f2bd8f2a899466628417294cb269fd569b87e17a))
|
|
295
|
-
- **fetch:** stale_while_revalidate cache strategy ([f758f49](https://github.com/AliMD/alwatr/commit/f758f495efb42ce7441e8f2058c1b67de0615a8c))
|
|
303
|
+
- **fetch:** cache strategy ([106eabd](https://github.com/AliMD/alwatr-eslib/commit/106eabdd10574b24f9919049d0b509ae40168a9a))
|
|
304
|
+
- **fetch:** optional cacheStorageName ([f2bd8f2](https://github.com/AliMD/alwatr-eslib/commit/f2bd8f2a899466628417294cb269fd569b87e17a))
|
|
305
|
+
- **fetch:** stale_while_revalidate cache strategy ([f758f49](https://github.com/AliMD/alwatr-eslib/commit/f758f495efb42ce7441e8f2058c1b67de0615a8c))
|
|
296
306
|
|
|
297
|
-
# [0.17.0](https://github.com/AliMD/alwatr/compare/v0.16.1...v0.17.0) (2022-10-21)
|
|
307
|
+
# [0.17.0](https://github.com/AliMD/alwatr-eslib/compare/v0.16.1...v0.17.0) (2022-10-21)
|
|
298
308
|
|
|
299
309
|
### Bug Fixes
|
|
300
310
|
|
|
301
|
-
- **fetch:** not ok retry condition ([0da1edd](https://github.com/AliMD/alwatr/commit/0da1edda64ec5abf70a83361d159e207691e368e))
|
|
311
|
+
- **fetch:** not ok retry condition ([0da1edd](https://github.com/AliMD/alwatr-eslib/commit/0da1edda64ec5abf70a83361d159e207691e368e))
|
|
302
312
|
|
|
303
313
|
### Features
|
|
304
314
|
|
|
305
|
-
- **fetch:** docs & pattern ([459ad1c](https://github.com/AliMD/alwatr/commit/459ad1c5996f851769306639136d79c0f7270770))
|
|
306
|
-
- **fetch:** logger & jsdocs ([36f652d](https://github.com/AliMD/alwatr/commit/36f652d5dad23b2aeb824af77d1b0e442119c6e8))
|
|
307
|
-
- **fetch:** retry pattern ([5350d1a](https://github.com/AliMD/alwatr/commit/5350d1a81b9134d598f46006a1baa880b280ea98))
|
|
315
|
+
- **fetch:** docs & pattern ([459ad1c](https://github.com/AliMD/alwatr-eslib/commit/459ad1c5996f851769306639136d79c0f7270770))
|
|
316
|
+
- **fetch:** logger & jsdocs ([36f652d](https://github.com/AliMD/alwatr-eslib/commit/36f652d5dad23b2aeb824af77d1b0e442119c6e8))
|
|
317
|
+
- **fetch:** retry pattern ([5350d1a](https://github.com/AliMD/alwatr-eslib/commit/5350d1a81b9134d598f46006a1baa880b280ea98))
|
|
308
318
|
|
|
309
319
|
### Performance Improvements
|
|
310
320
|
|
|
311
|
-
- **fetch:** syntax ([1fdd02e](https://github.com/AliMD/alwatr/commit/1fdd02ec8b52e32a124b8d7c1d1c7fd7c993e3af))
|
|
321
|
+
- **fetch:** syntax ([1fdd02e](https://github.com/AliMD/alwatr-eslib/commit/1fdd02ec8b52e32a124b8d7c1d1c7fd7c993e3af))
|
|
312
322
|
|
|
313
|
-
# [0.16.0](https://github.com/AliMD/alwatr/compare/v0.15.0...v0.16.0) (2022-09-08)
|
|
323
|
+
# [0.16.0](https://github.com/AliMD/alwatr-eslib/compare/v0.15.0...v0.16.0) (2022-09-08)
|
|
314
324
|
|
|
315
325
|
**Note:** Version bump only for package @alwatr/fetch
|
|
316
326
|
|
|
317
|
-
# [0.15.0](https://github.com/AliMD/alwatr/compare/v0.14.0...v0.15.0) (2022-09-01)
|
|
327
|
+
# [0.15.0](https://github.com/AliMD/alwatr-eslib/compare/v0.14.0...v0.15.0) (2022-09-01)
|
|
318
328
|
|
|
319
329
|
**Note:** Version bump only for package @alwatr/fetch
|
|
320
330
|
|
|
321
|
-
# [0.14.0](https://github.com/AliMD/alwatr/compare/v0.13.0...v0.14.0) (2022-08-19)
|
|
331
|
+
# [0.14.0](https://github.com/AliMD/alwatr-eslib/compare/v0.13.0...v0.14.0) (2022-08-19)
|
|
322
332
|
|
|
323
333
|
**Note:** Version bump only for package @alwatr/fetch
|
|
324
334
|
|
|
325
|
-
# [0.13.0](https://github.com/AliMD/alwatr/compare/v0.12.0...v0.13.0) (2022-08-06)
|
|
335
|
+
# [0.13.0](https://github.com/AliMD/alwatr-eslib/compare/v0.12.0...v0.13.0) (2022-08-06)
|
|
326
336
|
|
|
327
337
|
**Note:** Version bump only for package @alwatr/fetch
|
|
328
338
|
|
|
329
|
-
# [0.12.0](https://github.com/AliMD/alwatr/compare/v0.11.0...v0.12.0) (2022-07-22)
|
|
339
|
+
# [0.12.0](https://github.com/AliMD/alwatr-eslib/compare/v0.11.0...v0.12.0) (2022-07-22)
|
|
330
340
|
|
|
331
341
|
### Bug Fixes
|
|
332
342
|
|
|
333
|
-
- **fetch:** compatible with new ts types AbortSignal ([949655a](https://github.com/AliMD/alwatr/commit/949655a257852aaaaa311e32603ecc0819eedf51))
|
|
343
|
+
- **fetch:** compatible with new ts types AbortSignal ([949655a](https://github.com/AliMD/alwatr-eslib/commit/949655a257852aaaaa311e32603ecc0819eedf51))
|
|
334
344
|
|
|
335
|
-
# [0.11.0](https://github.com/AliMD/alwatr/compare/v0.10.1...v0.11.0) (2022-04-16)
|
|
345
|
+
# [0.11.0](https://github.com/AliMD/alwatr-eslib/compare/v0.10.1...v0.11.0) (2022-04-16)
|
|
336
346
|
|
|
337
347
|
**Note:** Version bump only for package @alwatr/fetch
|
|
338
348
|
|
|
339
|
-
# [0.10.0](https://github.com/AliMD/alwatr/compare/v0.9.0...v0.10.0) (2022-04-02)
|
|
349
|
+
# [0.10.0](https://github.com/AliMD/alwatr-eslib/compare/v0.9.0...v0.10.0) (2022-04-02)
|
|
340
350
|
|
|
341
351
|
**Note:** Version bump only for package @alwatr/fetch
|
|
342
352
|
|
|
343
|
-
# [0.9.0](https://github.com/AliMD/alwatr/compare/v0.8.0...v0.9.0) (2022-03-22)
|
|
353
|
+
# [0.9.0](https://github.com/AliMD/alwatr-eslib/compare/v0.8.0...v0.9.0) (2022-03-22)
|
|
344
354
|
|
|
345
355
|
**Note:** Version bump only for package @alwatr/fetch
|
|
346
356
|
|
|
347
|
-
# [0.8.0](https://github.com/AliMD/alwatr/compare/v0.7.2...v0.8.0) (2022-03-14)
|
|
357
|
+
# [0.8.0](https://github.com/AliMD/alwatr-eslib/compare/v0.7.2...v0.8.0) (2022-03-14)
|
|
348
358
|
|
|
349
359
|
**Note:** Version bump only for package @alwatr/fetch
|
|
350
360
|
|
|
351
|
-
## [0.7.2](https://github.com/AliMD/alwatr/compare/v0.7.1...v0.7.2) (2022-03-12)
|
|
361
|
+
## [0.7.2](https://github.com/AliMD/alwatr-eslib/compare/v0.7.1...v0.7.2) (2022-03-12)
|
|
352
362
|
|
|
353
363
|
**Note:** Version bump only for package @alwatr/fetch
|
|
354
364
|
|
|
355
|
-
# [0.7.0](https://github.com/AliMD/alwatr/compare/v0.6.1...v0.7.0) (2022-03-12)
|
|
365
|
+
# [0.7.0](https://github.com/AliMD/alwatr-eslib/compare/v0.6.1...v0.7.0) (2022-03-12)
|
|
356
366
|
|
|
357
367
|
**Note:** Version bump only for package @alwatr/fetch
|
|
358
368
|
|
|
359
|
-
# [0.6.0](https://github.com/AliMD/alwatr/compare/v0.5.0...v0.6.0) (2022-03-11)
|
|
369
|
+
# [0.6.0](https://github.com/AliMD/alwatr-eslib/compare/v0.5.0...v0.6.0) (2022-03-11)
|
|
360
370
|
|
|
361
371
|
### Bug Fixes
|
|
362
372
|
|
|
363
|
-
- alalwatr ([898aa6e](https://github.com/AliMD/alwatr/commit/898aa6ed0888eab9265c83b96a50f1b8c216d143))
|
|
364
|
-
- **packages:** duplicate alwatr keyword ([77d4aa2](https://github.com/AliMD/alwatr/commit/77d4aa2105ad47515c3eee251fd6b8c281d0d1fc))
|
|
373
|
+
- alalwatr ([898aa6e](https://github.com/AliMD/alwatr-eslib/commit/898aa6ed0888eab9265c83b96a50f1b8c216d143))
|
|
374
|
+
- **packages:** duplicate alwatr keyword ([77d4aa2](https://github.com/AliMD/alwatr-eslib/commit/77d4aa2105ad47515c3eee251fd6b8c281d0d1fc))
|
|
365
375
|
|
|
366
|
-
# [0.5.0](https://github.com/AliMD/alwatr/compare/v0.4.0...v0.5.0) (2022-03-11)
|
|
376
|
+
# [0.5.0](https://github.com/AliMD/alwatr-eslib/compare/v0.4.0...v0.5.0) (2022-03-11)
|
|
367
377
|
|
|
368
378
|
**Note:** Version bump only for package @alwatr/fetch
|
|
369
379
|
|
|
370
|
-
# [0.4.0](https://github.com/AliMD/alwatr/compare/v0.3.0...v0.4.0) (2022-03-11)
|
|
380
|
+
# [0.4.0](https://github.com/AliMD/alwatr-eslib/compare/v0.3.0...v0.4.0) (2022-03-11)
|
|
371
381
|
|
|
372
382
|
### Bug Fixes
|
|
373
383
|
|
|
374
|
-
- **fetch:** build issue [#73](https://github.com/AliMD/alwatr/issues/73) ([fb74463](https://github.com/AliMD/alwatr/commit/fb74463d367393706d16e482488a565bdfef70a1))
|
|
384
|
+
- **fetch:** build issue [#73](https://github.com/AliMD/alwatr-eslib/issues/73) ([fb74463](https://github.com/AliMD/alwatr-eslib/commit/fb74463d367393706d16e482488a565bdfef70a1))
|
|
375
385
|
|
|
376
|
-
# [0.3.0](https://github.com/AliMD/alwatr/compare/v0.2.1...v0.3.0) (2022-03-06)
|
|
386
|
+
# [0.3.0](https://github.com/AliMD/alwatr-eslib/compare/v0.2.1...v0.3.0) (2022-03-06)
|
|
377
387
|
|
|
378
388
|
**Note:** Version bump only for package @alwatr/fetch
|
|
379
389
|
|
|
380
|
-
## [0.2.1](https://github.com/AliMD/alwatr/compare/v0.2.0...v0.2.1) (2022-03-05)
|
|
390
|
+
## [0.2.1](https://github.com/AliMD/alwatr-eslib/compare/v0.2.0...v0.2.1) (2022-03-05)
|
|
381
391
|
|
|
382
392
|
**Note:** Version bump only for package @alwatr/fetch
|
|
383
393
|
|
|
384
|
-
# [0.2.0](https://github.com/AliMD/alwatr/compare/v0.1.2...v0.2.0) (2022-03-05)
|
|
394
|
+
# [0.2.0](https://github.com/AliMD/alwatr-eslib/compare/v0.1.2...v0.2.0) (2022-03-05)
|
|
385
395
|
|
|
386
396
|
### Bug Fixes
|
|
387
397
|
|
|
388
|
-
- **fetch:** error codes ([4e0be80](https://github.com/AliMD/alwatr/commit/4e0be80786b6667035ae82750f2351bd2da4f341))
|
|
398
|
+
- **fetch:** error codes ([4e0be80](https://github.com/AliMD/alwatr-eslib/commit/4e0be80786b6667035ae82750f2351bd2da4f341))
|
|
389
399
|
|
|
390
400
|
### Features
|
|
391
401
|
|
|
392
|
-
- **fetch:** add getData ([4a627c4](https://github.com/AliMD/alwatr/commit/4a627c43d2ad07acb340f058f02d41ce57288405))
|
|
393
|
-
- **fetch:** add postData and fetchJson ([b0262b8](https://github.com/AliMD/alwatr/commit/b0262b83b5b7d8b7c376dce68aae3e16bd8e2610))
|
|
394
|
-
- **fetch:** base fetch api ([925cdab](https://github.com/AliMD/alwatr/commit/925cdab8700ffb801e1d836ffc5d3245b66815cf))
|
|
395
|
-
- **fetch:** FetchOptions type ([dd2d141](https://github.com/AliMD/alwatr/commit/dd2d1418d090387e1afa8277f78ae88ace17fd17))
|
|
396
|
-
- **fetch:** new enhanced fetch package ([7e90472](https://github.com/AliMD/alwatr/commit/7e904720c983372317358ce107f6ad0f79c65647))
|
|
402
|
+
- **fetch:** add getData ([4a627c4](https://github.com/AliMD/alwatr-eslib/commit/4a627c43d2ad07acb340f058f02d41ce57288405))
|
|
403
|
+
- **fetch:** add postData and fetchJson ([b0262b8](https://github.com/AliMD/alwatr-eslib/commit/b0262b83b5b7d8b7c376dce68aae3e16bd8e2610))
|
|
404
|
+
- **fetch:** base fetch api ([925cdab](https://github.com/AliMD/alwatr-eslib/commit/925cdab8700ffb801e1d836ffc5d3245b66815cf))
|
|
405
|
+
- **fetch:** FetchOptions type ([dd2d141](https://github.com/AliMD/alwatr-eslib/commit/dd2d1418d090387e1afa8277f78ae88ace17fd17))
|
|
406
|
+
- **fetch:** new enhanced fetch package ([7e90472](https://github.com/AliMD/alwatr-eslib/commit/7e904720c983372317358ce107f6ad0f79c65647))
|
package/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAC;AAExD,mBAAmB,WAAW,CAAC;AAc/B;;GAEG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAC;AAExD,mBAAmB,WAAW,CAAC;AAc/B;;GAEG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,qBAAqB,GAAG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C,GAAG,EAAE;YAChC,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;YACnC,eAAe,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACzC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAEpB,IAAI,mBAAmB,IAAI,IAAI,EAAE;YAC/B,gCAAgC;YAChC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;SAC5F;QAED,2DAA2D;QAC3D,oFAAoF;QACpF,6CAA6C;QAC7C,QAAQ;QACR,MAAM;QAEN,UAAU;aACL,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC;aAC3B,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;aACtC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;aACjC,OAAO,CAAC,GAAG,EAAE;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,sCAAsC;YAC7D,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {createLogger, globalAlwatr, NODE_MODE} from '@alwatr/logger';\nimport {getClientId, delay} from '@alwatr/util';\n\nimport type {FetchOptions} from './type.js';\nimport type {AlwatrServiceResponse} from '@alwatr/type';\n\nexport type * from './type.js';\n\nconst logger = createLogger('alwatr/fetch');\n\nglobalAlwatr.registeredList.push({\n name: '@alwatr/fetch',\n version: _ALWATR_VERSION_,\n});\n\nlet alwatrCacheStorage: Cache;\nconst cacheSupported = 'caches' in globalThis;\n\nconst duplicateRequestStorage: Record<string, Promise<Response>> = {};\n\n/**\n * Fetch from alwatr services and return standard response.\n */\nexport async function serviceRequest<T extends AlwatrServiceResponse = AlwatrServiceResponse>(\n options: FetchOptions,\n): Promise<T> {\n logger.logMethodArgs?.('serviceRequest', {url: options.url});\n\n if (!NODE_MODE) {\n options.headers ??= {};\n if (!options.headers['client-id']) {\n options.headers['client-id'] = getClientId();\n }\n }\n\n let response: Response;\n try {\n response = await fetch(options);\n }\n catch (err) {\n const errMessage = (err as Error).message;\n if (errMessage !== 'fetch_cache_not_found') {\n logger.error('serviceRequest', (err as Error).message || 'fetch_failed', err, options);\n }\n throw err;\n }\n\n let responseText: string;\n try {\n responseText = await response.text();\n }\n catch (err) {\n logger.error('serviceRequest', 'invalid_response', err, {\n response,\n });\n throw err;\n }\n\n let responseJson: T;\n try {\n responseJson = JSON.parse(responseText);\n }\n catch (err) {\n logger.error('serviceRequest', 'invalid_json', err, {responseText});\n throw err;\n }\n\n if (responseJson.ok !== true) {\n if (typeof responseJson.errorCode === 'string') {\n logger.accident('serviceRequest', responseJson.errorCode, 'fetch response not ok', {responseJson});\n throw new Error(responseJson.errorCode);\n }\n else {\n logger.error('serviceRequest', 'fetch_nok', 'fetch response not ok', {responseJson});\n throw new Error('fetch_nok');\n }\n }\n\n // TODO: generate fetch signals hook (for easier handle loading and show error toast)\n\n return responseJson;\n}\n\n/**\n * It's a wrapper around the browser's `fetch` function that adds retry pattern, timeout, cacheStrategy,\n * remove duplicates, etc.\n *\n * Example:\n *\n * ```ts\n * const response = await fetch({\n * url: '/api/products',\n * queryParameters: {limit: 10},\n * timeout: 10_000,\n * retry: 3,\n * cacheStrategy: 'stale_while_revalidate',\n * cacheDuplicate: 'auto',\n * });\n * ```\n */\nexport function fetch(options: FetchOptions): Promise<Response> {\n options = _processOptions(options);\n logger.logMethodArgs?.('fetch', {options});\n return _handleCacheStrategy(options as Required<FetchOptions>);\n}\n\n/**\n * Process fetch options and set defaults, etc.\n */\nfunction _processOptions(options: FetchOptions): Required<FetchOptions> {\n options.method ??= 'GET';\n options.window ??= null;\n\n options.timeout ??= 10_000;\n options.retry ??= 3;\n options.retryDelay ??= 1_000;\n options.cacheStrategy ??= 'network_only';\n options.removeDuplicate ??= 'never';\n options.headers ??= {};\n\n if (options.cacheStrategy !== 'network_only' && cacheSupported !== true) {\n logger.incident?.('fetch', 'fetch_cache_strategy_ignore', 'Cache storage not support in this browser', {\n cacheSupported,\n });\n options.cacheStrategy = 'network_only';\n }\n\n if (options.removeDuplicate === 'auto') {\n options.removeDuplicate = cacheSupported ? 'until_load' : 'always';\n }\n\n if (options.url.lastIndexOf('?') === -1 && options.queryParameters != null) {\n const queryParameters = options.queryParameters;\n // prettier-ignore\n const queryArray = Object\n .keys(queryParameters)\n .map((key) => `${key}=${String(queryParameters[key])}`);\n\n if (queryArray.length > 0) {\n options.url += '?' + queryArray.join('&');\n }\n }\n\n if (options.bodyJson != null) {\n options.body = JSON.stringify(options.bodyJson);\n options.headers['Content-Type'] = 'application/json';\n }\n\n if (options.token != null) {\n options.headers.Authorization = `Bearer ${options.token}`;\n }\n\n if (options.userAuth != null) {\n options.headers.Authorization = `Bearer ${options.userAuth.id}/${options.userAuth.token}`;\n }\n\n return options as Required<FetchOptions>;\n}\n\n/**\n * Handle Cache Strategy over `_handleRemoveDuplicate`.\n */\nasync function _handleCacheStrategy(options: Required<FetchOptions>): Promise<Response> {\n if (options.cacheStrategy === 'network_only') {\n return _handleRemoveDuplicate(options);\n }\n // else handle cache strategies!\n logger.logMethod?.('_handleCacheStrategy');\n\n if (alwatrCacheStorage == null && options.cacheStorageName == null) {\n alwatrCacheStorage = await caches.open('alwatr_fetch_cache');\n }\n\n const cacheStorage =\n options.cacheStorageName != null ? await caches.open(options.cacheStorageName) : alwatrCacheStorage;\n\n const request = new Request(options.url, options);\n\n switch (options.cacheStrategy) {\n case 'cache_first': {\n const cachedResponse = await cacheStorage.match(request);\n if (cachedResponse != null) {\n return cachedResponse;\n }\n // else\n const response = await _handleRemoveDuplicate(options);\n if (response.ok) {\n cacheStorage.put(request, response.clone());\n }\n return response;\n }\n\n case 'cache_only': {\n const cachedResponse = await cacheStorage.match(request);\n if (cachedResponse == null) {\n logger.accident(\n '_handleCacheStrategy',\n 'fetch_cache_not_found',\n 'cacheStorage is cache_only but no cache found',\n {url: request.url},\n );\n throw new Error('fetch_cache_not_found');\n }\n // else\n return cachedResponse;\n }\n\n case 'network_first': {\n try {\n const networkResponse = await _handleRemoveDuplicate(options);\n if (networkResponse.ok) {\n cacheStorage.put(request, networkResponse.clone());\n }\n return networkResponse;\n }\n catch (err) {\n const cachedResponse = await cacheStorage.match(request);\n if (cachedResponse != null) {\n return cachedResponse;\n }\n // else\n throw err;\n }\n }\n\n case 'update_cache': {\n const networkResponse = await _handleRemoveDuplicate(options);\n if (networkResponse.ok) {\n cacheStorage.put(request, networkResponse.clone());\n }\n return networkResponse;\n }\n\n case 'stale_while_revalidate': {\n const cachedResponse = await cacheStorage.match(request);\n const fetchedResponsePromise = _handleRemoveDuplicate(options).then((networkResponse) => {\n if (networkResponse.ok) {\n cacheStorage.put(request, networkResponse.clone());\n if (typeof options.revalidateCallback === 'function') {\n setTimeout(options.revalidateCallback, 0, networkResponse.clone());\n }\n }\n return networkResponse;\n });\n\n return cachedResponse ?? fetchedResponsePromise;\n }\n\n default: {\n return _handleRemoveDuplicate(options);\n }\n }\n}\n\n/**\n * Handle Remove Duplicates over `_handleRetryPattern`.\n */\nasync function _handleRemoveDuplicate(options: Required<FetchOptions>): Promise<Response> {\n if (options.removeDuplicate === 'never') return _handleRetryPattern(options);\n\n logger.logMethod?.('_handleRemoveDuplicate');\n\n const cacheKey = options.method + ' ' + options.url;\n\n // We must cache fetch promise without await for handle other parallel requests.\n duplicateRequestStorage[cacheKey] ??= _handleRetryPattern(options);\n\n try {\n // For all requests need to await for clone responses.\n const response = await duplicateRequestStorage[cacheKey];\n\n if (duplicateRequestStorage[cacheKey] != null) {\n if (response.ok !== true || options.removeDuplicate === 'until_load') {\n delete duplicateRequestStorage[cacheKey];\n }\n }\n\n return response.clone();\n }\n catch (err) {\n // clean cache on any error.\n delete duplicateRequestStorage[cacheKey];\n throw err;\n }\n}\n\n/**\n * Handle retry pattern over `_handleTimeout`.\n */\nasync function _handleRetryPattern(options: Required<FetchOptions>): Promise<Response> {\n if (!(options.retry > 1)) return _handleTimeout(options);\n\n logger.logMethod?.('_handleRetryPattern');\n options.retry--;\n\n const externalAbortSignal = options.signal;\n\n try {\n const response = await _handleTimeout(options);\n\n if (response.status < 500) {\n return response;\n }\n // else\n throw new Error('fetch_server_error');\n }\n catch (err) {\n logger.accident('fetch', 'fetch_failed_retry', (err as Error)?.message || 'fetch failed and retry', err);\n\n if (globalThis.navigator?.onLine === false) {\n throw new Error('offline');\n }\n\n await delay(options.retryDelay);\n\n options.signal = externalAbortSignal;\n return _handleRetryPattern(options);\n }\n}\n\n/**\n * It's a wrapper around the browser's `fetch` with timeout.\n */\nfunction _handleTimeout(options: FetchOptions): Promise<Response> {\n if (options.timeout === 0) {\n return globalThis.fetch(options.url, options);\n }\n // else\n logger.logMethod?.('_handleTimeout');\n return new Promise((resolved, reject) => {\n // TODO: AbortController polyfill\n const abortController = new AbortController();\n const externalAbortSignal = options.signal;\n options.signal = abortController.signal;\n\n const timeoutId = setTimeout(() => {\n reject(new Error('fetch_timeout'));\n abortController.abort('fetch_timeout');\n }, options.timeout);\n\n if (externalAbortSignal != null) {\n // Respect external abort signal\n externalAbortSignal.addEventListener('abort', () => abortController.abort(), {once: true});\n }\n\n // abortController.signal.addEventListener('abort', () => {\n // logger.incident('fetch', 'fetch_abort_signal', 'fetch abort signal received', {\n // reason: abortController.signal.reason,\n // });\n // });\n\n globalThis\n .fetch(options.url, options)\n .then((response) => resolved(response))\n .catch((reason) => reject(reason))\n .finally(() => {\n delete options.signal; // try to avoid memory leak in nodejs!\n clearTimeout(timeoutId);\n });\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,SAAS,E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CAAC,CAAC;SAC5F;QAED,2DAA2D;QAC3D,oFAAoF;QACpF,6CAA6C;QAC7C,QAAQ;QACR,MAAM;QAEN,UAAU;aACP,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC;aAC3B,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;aACtC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;aACjC,OAAO,CAAC,GAAG,EAAE;YACZ,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,sCAAsC;YAC7D,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {createLogger, globalAlwatr, NODE_MODE} from '@alwatr/logger';\nimport {getClientId, delay} from '@alwatr/util';\n\nimport type {FetchOptions} from './type.js';\nimport type {AlwatrServiceResponse} from '@alwatr/type';\n\nexport type * from './type.js';\n\nconst logger = createLogger('alwatr/fetch');\n\nglobalAlwatr.registeredList.push({\n name: '@alwatr/fetch',\n version: _ALWATR_VERSION_,\n});\n\nlet alwatrCacheStorage: Cache;\nconst cacheSupported = 'caches' in globalThis;\n\nconst duplicateRequestStorage: Record<string, Promise<Response>> = {};\n\n/**\n * Fetch from alwatr services and return standard response.\n */\nexport async function serviceRequest<T extends AlwatrServiceResponse = AlwatrServiceResponse>(\n options: FetchOptions,\n): Promise<T> {\n logger.logMethodArgs?.('serviceRequest', {url: options.url});\n\n if (!NODE_MODE) {\n options.headers ??= {};\n if (!options.headers['client-id']) {\n options.headers['client-id'] = getClientId();\n }\n }\n\n let response: Response;\n try {\n response = await fetch(options);\n }\n catch (err) {\n const errMessage = (err as Error).message;\n if (errMessage !== 'fetch_cache_not_found') {\n logger.error('serviceRequest', (err as Error).message || 'fetch_failed', err, options);\n }\n throw err;\n }\n\n let responseText: string;\n try {\n responseText = await response.text();\n }\n catch (err) {\n logger.error('serviceRequest', 'invalid_response', err, {\n response,\n });\n throw err;\n }\n\n let responseJson: T;\n try {\n responseJson = JSON.parse(responseText);\n }\n catch (err) {\n logger.error('serviceRequest', 'invalid_json', err, {responseText});\n throw err;\n }\n\n if (responseJson.ok !== true) {\n if (typeof responseJson.errorCode === 'string') {\n logger.accident('serviceRequest', responseJson.errorCode, 'fetch response not ok', {responseJson});\n throw new Error(responseJson.errorCode);\n }\n else {\n logger.error('serviceRequest', 'fetch_nok', 'fetch response not ok', {responseJson});\n throw new Error('fetch_nok');\n }\n }\n\n // TODO: generate fetch signals hook (for easier handle loading and show error toast)\n\n return responseJson;\n}\n\n/**\n * It's a wrapper around the browser's `fetch` function that adds retry pattern, timeout, cacheStrategy,\n * remove duplicates, etc.\n *\n * Example:\n *\n * ```ts\n * const response = await fetch({\n * url: '/api/products',\n * queryParameters: {limit: 10},\n * timeout: 10_000,\n * retry: 3,\n * cacheStrategy: 'stale_while_revalidate',\n * cacheDuplicate: 'auto',\n * });\n * ```\n */\nexport function fetch(options: FetchOptions): Promise<Response> {\n options = _processOptions(options);\n logger.logMethodArgs?.('fetch', {options});\n return _handleCacheStrategy(options as Required<FetchOptions>);\n}\n\n/**\n * Process fetch options and set defaults, etc.\n */\nfunction _processOptions(options: FetchOptions): Required<FetchOptions> {\n options.method ??= 'GET';\n options.window ??= null;\n\n options.timeout ??= 10_000;\n options.retry ??= 3;\n options.retryDelay ??= 1_000;\n options.cacheStrategy ??= 'network_only';\n options.removeDuplicate ??= 'never';\n options.headers ??= {};\n\n if (options.cacheStrategy !== 'network_only' && cacheSupported !== true) {\n logger.incident?.('fetch', 'fetch_cache_strategy_ignore', 'Cache storage not support in this browser', {\n cacheSupported,\n });\n options.cacheStrategy = 'network_only';\n }\n\n if (options.removeDuplicate === 'auto') {\n options.removeDuplicate = cacheSupported ? 'until_load' : 'always';\n }\n\n if (options.url.lastIndexOf('?') === -1 && options.queryParameters != null) {\n const queryParameters = options.queryParameters;\n // prettier-ignore\n const queryArray = Object\n .keys(queryParameters)\n .map((key) => `${key}=${String(queryParameters[key])}`);\n\n if (queryArray.length > 0) {\n options.url += '?' + queryArray.join('&');\n }\n }\n\n if (options.bodyJson != null) {\n options.body = JSON.stringify(options.bodyJson);\n options.headers['Content-Type'] = 'application/json';\n }\n\n if (options.token != null) {\n options.headers.Authorization = `Bearer ${options.token}`;\n }\n\n if (options.userAuth != null) {\n options.headers.Authorization = `Bearer ${options.userAuth.id}/${options.userAuth.token}`;\n }\n\n return options as Required<FetchOptions>;\n}\n\n/**\n * Handle Cache Strategy over `_handleRemoveDuplicate`.\n */\nasync function _handleCacheStrategy(options: Required<FetchOptions>): Promise<Response> {\n if (options.cacheStrategy === 'network_only') {\n return _handleRemoveDuplicate(options);\n }\n // else handle cache strategies!\n logger.logMethod?.('_handleCacheStrategy');\n\n if (alwatrCacheStorage == null && options.cacheStorageName == null) {\n alwatrCacheStorage = await caches.open('alwatr_fetch_cache');\n }\n\n const cacheStorage =\n options.cacheStorageName != null ? await caches.open(options.cacheStorageName) : alwatrCacheStorage;\n\n const request = new Request(options.url, options);\n\n switch (options.cacheStrategy) {\n case 'cache_first': {\n const cachedResponse = await cacheStorage.match(request);\n if (cachedResponse != null) {\n return cachedResponse;\n }\n // else\n const response = await _handleRemoveDuplicate(options);\n if (response.ok) {\n cacheStorage.put(request, response.clone());\n }\n return response;\n }\n\n case 'cache_only': {\n const cachedResponse = await cacheStorage.match(request);\n if (cachedResponse == null) {\n logger.accident(\n '_handleCacheStrategy',\n 'fetch_cache_not_found',\n 'cacheStorage is cache_only but no cache found',\n {url: request.url},\n );\n throw new Error('fetch_cache_not_found');\n }\n // else\n return cachedResponse;\n }\n\n case 'network_first': {\n try {\n const networkResponse = await _handleRemoveDuplicate(options);\n if (networkResponse.ok) {\n cacheStorage.put(request, networkResponse.clone());\n }\n return networkResponse;\n }\n catch (err) {\n const cachedResponse = await cacheStorage.match(request);\n if (cachedResponse != null) {\n return cachedResponse;\n }\n // else\n throw err;\n }\n }\n\n case 'update_cache': {\n const networkResponse = await _handleRemoveDuplicate(options);\n if (networkResponse.ok) {\n cacheStorage.put(request, networkResponse.clone());\n }\n return networkResponse;\n }\n\n case 'stale_while_revalidate': {\n const cachedResponse = await cacheStorage.match(request);\n const fetchedResponsePromise = _handleRemoveDuplicate(options).then((networkResponse) => {\n if (networkResponse.ok) {\n cacheStorage.put(request, networkResponse.clone());\n if (typeof options.revalidateCallback === 'function') {\n setTimeout(options.revalidateCallback, 0, networkResponse.clone());\n }\n }\n return networkResponse;\n });\n\n return cachedResponse ?? fetchedResponsePromise;\n }\n\n default: {\n return _handleRemoveDuplicate(options);\n }\n }\n}\n\n/**\n * Handle Remove Duplicates over `_handleRetryPattern`.\n */\nasync function _handleRemoveDuplicate(options: Required<FetchOptions>): Promise<Response> {\n if (options.removeDuplicate === 'never') return _handleRetryPattern(options);\n\n logger.logMethod?.('_handleRemoveDuplicate');\n\n const cacheKey = options.method + ' ' + options.url;\n\n // We must cache fetch promise without await for handle other parallel requests.\n duplicateRequestStorage[cacheKey] ??= _handleRetryPattern(options);\n\n try {\n // For all requests need to await for clone responses.\n const response = await duplicateRequestStorage[cacheKey];\n\n if (duplicateRequestStorage[cacheKey] != null) {\n if (response.ok !== true || options.removeDuplicate === 'until_load') {\n delete duplicateRequestStorage[cacheKey];\n }\n }\n\n return response.clone();\n }\n catch (err) {\n // clean cache on any error.\n delete duplicateRequestStorage[cacheKey];\n throw err;\n }\n}\n\n/**\n * Handle retry pattern over `_handleTimeout`.\n */\nasync function _handleRetryPattern(options: Required<FetchOptions>): Promise<Response> {\n if (!(options.retry > 1)) return _handleTimeout(options);\n\n logger.logMethod?.('_handleRetryPattern');\n options.retry--;\n\n const externalAbortSignal = options.signal;\n\n try {\n const response = await _handleTimeout(options);\n\n if (response.status < 500) {\n return response;\n }\n // else\n throw new Error('fetch_server_error');\n }\n catch (err) {\n logger.accident('fetch', 'fetch_failed_retry', (err as Error)?.message || 'fetch failed and retry', err);\n\n if (globalThis.navigator?.onLine === false) {\n throw new Error('offline');\n }\n\n await delay(options.retryDelay);\n\n options.signal = externalAbortSignal;\n return _handleRetryPattern(options);\n }\n}\n\n/**\n * It's a wrapper around the browser's `fetch` with timeout.\n */\nfunction _handleTimeout(options: FetchOptions): Promise<Response> {\n if (options.timeout === 0) {\n return globalThis.fetch(options.url, options);\n }\n // else\n logger.logMethod?.('_handleTimeout');\n return new Promise((resolved, reject) => {\n // TODO: AbortController polyfill\n const abortController = new AbortController();\n const externalAbortSignal = options.signal;\n options.signal = abortController.signal;\n\n const timeoutId = setTimeout(() => {\n reject(new Error('fetch_timeout'));\n abortController.abort('fetch_timeout');\n }, options.timeout);\n\n if (externalAbortSignal != null) {\n // Respect external abort signal\n externalAbortSignal.addEventListener('abort', () => abortController.abort(), {once: true});\n }\n\n // abortController.signal.addEventListener('abort', () => {\n // logger.incident('fetch', 'fetch_abort_signal', 'fetch abort signal received', {\n // reason: abortController.signal.reason,\n // });\n // });\n\n globalThis\n .fetch(options.url, options)\n .then((response) => resolved(response))\n .catch((reason) => reject(reason))\n .finally(() => {\n delete options.signal; // try to avoid memory leak in nodejs!\n clearTimeout(timeoutId);\n });\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/fetch",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Enhanced fetch API with cache strategy, retry pattern, timeout, helper methods and enhanced types written in tiny TypeScript, ES module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "https://github.com/AliMD/alwatr",
|
|
30
|
-
"directory": "
|
|
29
|
+
"url": "https://github.com/AliMD/alwatr-eslib",
|
|
30
|
+
"directory": "packages/fetch"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://github.com/AliMD/alwatr/tree/
|
|
32
|
+
"homepage": "https://github.com/AliMD/alwatr-eslib/tree/next/packages/fetch#readme",
|
|
33
33
|
"bugs": {
|
|
34
|
-
"url": "https://github.com/AliMD/alwatr/issues"
|
|
34
|
+
"url": "https://github.com/AliMD/alwatr-eslib/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@alwatr/logger": "^1.1.
|
|
38
|
-
"@alwatr/util": "^1.2.
|
|
37
|
+
"@alwatr/logger": "^1.1.5",
|
|
38
|
+
"@alwatr/util": "^1.2.4",
|
|
39
39
|
"tslib": "^2.6.2"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a5972f171b8e34b4e2bccc3ac023d9f7f6f36d72"
|
|
42
42
|
}
|