@equinor/fusion-framework-module-http 5.2.3 → 6.0.1
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 +162 -0
- package/README.md +759 -36
- package/dist/esm/configurator.js +10 -1
- package/dist/esm/configurator.js.map +1 -1
- package/dist/esm/errors.js +18 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/client/client-msal.js +35 -0
- package/dist/esm/lib/client/client-msal.js.map +1 -1
- package/dist/esm/lib/client/client.js +153 -6
- package/dist/esm/lib/client/client.js.map +1 -1
- package/dist/esm/lib/operators/http-request-handler.js +16 -0
- package/dist/esm/lib/operators/http-request-handler.js.map +1 -1
- package/dist/esm/lib/operators/http-response-handler.js +6 -0
- package/dist/esm/lib/operators/http-response-handler.js.map +1 -1
- package/dist/esm/lib/operators/process-operators.js +49 -1
- package/dist/esm/lib/operators/process-operators.js.map +1 -1
- package/dist/esm/lib/operators/request-operator-header.js +7 -0
- package/dist/esm/lib/operators/request-operator-header.js.map +1 -1
- package/dist/esm/lib/selectors/blob-selector.js +28 -3
- package/dist/esm/lib/selectors/blob-selector.js.map +1 -1
- package/dist/esm/lib/selectors/json-selector.js +24 -0
- package/dist/esm/lib/selectors/json-selector.js.map +1 -1
- package/dist/esm/module.js +40 -0
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/provider.js +65 -6
- package/dist/esm/provider.js.map +1 -1
- package/dist/esm/version.js +2 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/configurator.d.ts +76 -0
- package/dist/types/errors.d.ts +18 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/lib/client/client-msal.d.ts +43 -0
- package/dist/types/lib/client/client.d.ts +147 -3
- package/dist/types/lib/client/types.d.ts +156 -5
- package/dist/types/lib/operators/http-request-handler.d.ts +16 -0
- package/dist/types/lib/operators/http-response-handler.d.ts +6 -0
- package/dist/types/lib/operators/process-operators.d.ts +44 -0
- package/dist/types/lib/operators/request-operator-header.d.ts +7 -0
- package/dist/types/lib/operators/types.d.ts +57 -0
- package/dist/types/lib/selectors/blob-selector.d.ts +9 -1
- package/dist/types/lib/selectors/index.d.ts +1 -0
- package/dist/types/lib/selectors/json-selector.d.ts +16 -1
- package/dist/types/module.d.ts +35 -0
- package/dist/types/provider.d.ts +77 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/configurator.ts +38 -1
- package/src/errors.ts +11 -1
- package/src/lib/client/client-msal.ts +50 -5
- package/src/lib/client/client.ts +161 -12
- package/src/lib/client/types.ts +149 -71
- package/src/lib/operators/http-request-handler.ts +12 -4
- package/src/lib/operators/http-response-handler.ts +6 -0
- package/src/lib/operators/process-operators.ts +6 -1
- package/src/lib/operators/request-operator-header.ts +7 -0
- package/src/lib/operators/types.ts +22 -4
- package/src/lib/selectors/blob-selector.ts +26 -4
- package/src/lib/selectors/index.ts +2 -0
- package/src/lib/selectors/json-selector.ts +29 -9
- package/src/module.ts +55 -2
- package/src/provider.ts +76 -2
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,167 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 6.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2324](https://github.com/equinor/fusion-framework/pull/2324) [`788d0b9`](https://github.com/equinor/fusion-framework/commit/788d0b93edc25e5b682d88c58614560c204c1af9) Thanks [@odinr](https://github.com/odinr)! - Updated documentation in `README.md` for http module.
|
|
8
|
+
|
|
9
|
+
- added introduction to http module
|
|
10
|
+
- added concepts section which highlights the key concepts of http module
|
|
11
|
+
- added sequence diagram for http request execution
|
|
12
|
+
- added examples for http module
|
|
13
|
+
- improved documentation for configuring http module
|
|
14
|
+
- improved documentation for working with http clients
|
|
15
|
+
- improved the formatting of the documentation
|
|
16
|
+
|
|
17
|
+
- [#2333](https://github.com/equinor/fusion-framework/pull/2333) [`86d55b8`](https://github.com/equinor/fusion-framework/commit/86d55b8d27a572f3f62170b1e72aceda54f955e1) Thanks [@odinr](https://github.com/odinr)! - Updated `TypeScript` to 5.5.3
|
|
18
|
+
|
|
19
|
+
- [#2324](https://github.com/equinor/fusion-framework/pull/2324) [`788d0b9`](https://github.com/equinor/fusion-framework/commit/788d0b93edc25e5b682d88c58614560c204c1af9) Thanks [@odinr](https://github.com/odinr)! - Updated TsDoc for http module
|
|
20
|
+
|
|
21
|
+
- [#2324](https://github.com/equinor/fusion-framework/pull/2324) [`788d0b9`](https://github.com/equinor/fusion-framework/commit/788d0b93edc25e5b682d88c58614560c204c1af9) Thanks [@odinr](https://github.com/odinr)! - - Added a new type `ResponseSelector<TResult, TResponse>`: a function that takes a `Response` object and returns an observable stream of type `TResult`. The `ResponseSelector` type has two template parameters: `TResult` and `TResponse`.
|
|
22
|
+
|
|
23
|
+
- Updated the `FetchRequestInit` type to include a new property `selector` of type `ResponseSelector<TReturn, TResponse>`, which allows specifying a response selector function.
|
|
24
|
+
- Updated the blob-selector and json-selector functions to use the new `ResponseSelector` type.
|
|
25
|
+
|
|
26
|
+
- [#2320](https://github.com/equinor/fusion-framework/pull/2320) [`1dd85f3`](https://github.com/equinor/fusion-framework/commit/1dd85f3a408a73df556d1812a5f280945cc100ee) Thanks [@odinr](https://github.com/odinr)! - Removed the `removeComments` option from the `tsconfig.base.json` file.
|
|
27
|
+
|
|
28
|
+
Removing the `removeComments` option allows TypeScript to preserve comments in the compiled JavaScript output. This can be beneficial for several reasons:
|
|
29
|
+
|
|
30
|
+
1. Improved debugging: Preserved comments can help developers understand the code better during debugging sessions.
|
|
31
|
+
2. Documentation: JSDoc comments and other important code documentation will be retained in the compiled output.
|
|
32
|
+
3. Source map accuracy: Keeping comments can lead to more accurate source maps, which is crucial for debugging and error tracking.
|
|
33
|
+
|
|
34
|
+
No action is required from consumers of the library. This change affects the build process and doesn't introduce any breaking changes or new features.
|
|
35
|
+
|
|
36
|
+
Before:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"compilerOptions": {
|
|
41
|
+
"module": "ES2022",
|
|
42
|
+
"target": "ES6",
|
|
43
|
+
"incremental": true,
|
|
44
|
+
"removeComments": true,
|
|
45
|
+
"preserveConstEnums": true,
|
|
46
|
+
"sourceMap": true,
|
|
47
|
+
"moduleResolution": "node"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
After:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"compilerOptions": {
|
|
57
|
+
"module": "ES2022",
|
|
58
|
+
"target": "ES6",
|
|
59
|
+
"incremental": true,
|
|
60
|
+
"preserveConstEnums": true,
|
|
61
|
+
"sourceMap": true,
|
|
62
|
+
"moduleResolution": "node"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This change ensures that comments are preserved in the compiled output, potentially improving the development and debugging experience for users of the Fusion Framework.
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [[`2f74edc`](https://github.com/equinor/fusion-framework/commit/2f74edcd4a3ea2b87d69f0fd63492145c3c01663), [`86d55b8`](https://github.com/equinor/fusion-framework/commit/86d55b8d27a572f3f62170b1e72aceda54f955e1), [`1dd85f3`](https://github.com/equinor/fusion-framework/commit/1dd85f3a408a73df556d1812a5f280945cc100ee)]:
|
|
70
|
+
- @equinor/fusion-framework-module@4.3.2
|
|
71
|
+
- @equinor/fusion-framework-module-msal@3.1.2
|
|
72
|
+
|
|
73
|
+
## 6.0.0
|
|
74
|
+
|
|
75
|
+
### Major Changes
|
|
76
|
+
|
|
77
|
+
- [#2181](https://github.com/equinor/fusion-framework/pull/2181) [`ba2379b`](https://github.com/equinor/fusion-framework/commit/ba2379b177f23ccc023894e36e50d7fc56c929c8) Thanks [@odinr](https://github.com/odinr)! - The `blob` and `blob# Change Log methods in the `HttpClient` class have been updated to provide a more robust and flexible API for fetching blob resources.
|
|
78
|
+
|
|
79
|
+
1. The `blob` and `blob# Change Log methods now accept an optional `args`parameter of type`FetchRequestInit<T, TRequest, TResponse>`, where `T` is the type of the expected blob result. This allows consumers to customize the fetch request and response handling.
|
|
80
|
+
2. The `blob` and `blob# Change Log methods now return a `Promise<T>`and`StreamResponse<T>`respectively, where`T` is the type of the expected blob result. This allows consumers to handle the blob data in a more type-safe manner.
|
|
81
|
+
3. The `blobSelector` function has been updated to extract the filename (if available) from the `content-disposition` header and return it along with the blob data in a `BlobResult` object.
|
|
82
|
+
4. If you were previously using the `blob` or `blob# Change Log methods and expecting a `Blob`result, you must now use the new`BlobResult` type, which includes the filename (if available) and the blob data.
|
|
83
|
+
|
|
84
|
+
> [!WARNING]
|
|
85
|
+
> This alters the return type of the `blob` and `blob# Change Log methods, which is a **breaking change**.
|
|
86
|
+
|
|
87
|
+
Example:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const blobResult = await httpClient.blob('/path/to/blob');
|
|
91
|
+
console.log(blobResult.filename); // 'example.pdf'
|
|
92
|
+
console.log(blobResult.blob); // Blob instance
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
1. If you were providing a custom selector function to the `blob` or `blob# Change Log methods, you can now use the new `BlobResult` type in your selector function.
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const customBlobSelector = async (
|
|
101
|
+
response: Response,
|
|
102
|
+
): Promise<{ filename: string; blob: Blob }> => {
|
|
103
|
+
// Extract filename and blob from the response
|
|
104
|
+
const { filename, blob } = await blobSelector(response);
|
|
105
|
+
return { filename, blob };
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const blobResult = await httpClient.blob('/path/to/blob', { selector: customBlobSelector });
|
|
109
|
+
console.log(blobResult.filename); // 'example.pdf'
|
|
110
|
+
console.log(blobResult.blob); // Blob instance
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
3. If you were using the `blob# Change Log method and expecting a `StreamResponse<Blob>`, you can now use the new `StreamResponse<T>`type, where`T` is the type of the expected blob result.
|
|
114
|
+
|
|
115
|
+
Example:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const blobStream = httpClient.blob$('/path/to/blob');
|
|
119
|
+
blobStream.subscribe((blobResult) => {
|
|
120
|
+
console.log(blobResult.filename); // 'example.pdf'
|
|
121
|
+
console.log(blobResult.blob); // Blob instance
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- [#2196](https://github.com/equinor/fusion-framework/pull/2196) [`1e60919`](https://github.com/equinor/fusion-framework/commit/1e60919e83fb65528c88f604d7bd43299ec412e1) Thanks [@odinr](https://github.com/odinr)! - The `jsonSelector` function was not checking the error type in the `catch` block.
|
|
128
|
+
This lead to not throwing the error with parsed data, but always throwing a parser error, where the correct error was `cause` in the `ErrorOptions`
|
|
129
|
+
|
|
130
|
+
**BREAKING CHANGE:**
|
|
131
|
+
|
|
132
|
+
If for some reason developers has catched the error and assumed the `cause` property would give the proper error data, this will no longer be the case.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
try {
|
|
136
|
+
await jsonSelector(response);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof HttpJsonResponseError) {
|
|
139
|
+
const { data, cause } = error;
|
|
140
|
+
if (data) {
|
|
141
|
+
console.error('the request was not `ok`, see provided error data', data);
|
|
142
|
+
} else {
|
|
143
|
+
console.error('failed to parse data from response, see provided cause', cause);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```diff
|
|
150
|
+
try {
|
|
151
|
+
await jsonSelector(response);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if(error instanceof HttpJsonResponseError) {
|
|
154
|
+
- const data = error.cause instanceof HttpJsonResponseError ? err.cause.data : null;
|
|
155
|
+
+ const data = error instanceof HttpJsonResponseError ? error.data : null;
|
|
156
|
+
if(data) {
|
|
157
|
+
console.error('the request was not `ok`, see provided error data', data);
|
|
158
|
+
} else {
|
|
159
|
+
console.error('failed to parse data from response, see provided cause', error.cause);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
3
165
|
## 5.2.3
|
|
4
166
|
|
|
5
167
|
### Patch Changes
|