@equinor/fusion-framework-module-http 6.2.4 → 6.3.0

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +182 -17
  3. package/dist/esm/configurator.js +15 -10
  4. package/dist/esm/configurator.js.map +1 -1
  5. package/dist/esm/errors.js +27 -3
  6. package/dist/esm/errors.js.map +1 -1
  7. package/dist/esm/lib/client/client-msal.js +6 -9
  8. package/dist/esm/lib/client/client-msal.js.map +1 -1
  9. package/dist/esm/lib/client/client.js +82 -43
  10. package/dist/esm/lib/client/client.js.map +1 -1
  11. package/dist/esm/lib/operators/capitalize-request-method.operator.js +2 -3
  12. package/dist/esm/lib/operators/capitalize-request-method.operator.js.map +1 -1
  13. package/dist/esm/lib/operators/fetch-request.schema.js +1 -1
  14. package/dist/esm/lib/operators/fetch-request.schema.js.map +1 -1
  15. package/dist/esm/lib/operators/process-operators.js +9 -3
  16. package/dist/esm/lib/operators/process-operators.js.map +1 -1
  17. package/dist/esm/lib/operators/request-operator-header.js +1 -1
  18. package/dist/esm/lib/operators/request-operator-header.js.map +1 -1
  19. package/dist/esm/lib/operators/request-validation.operator.js +1 -1
  20. package/dist/esm/lib/operators/request-validation.operator.js.map +1 -1
  21. package/dist/esm/lib/operators/sse.operator.js +33 -0
  22. package/dist/esm/lib/operators/sse.operator.js.map +1 -0
  23. package/dist/esm/lib/selectors/blob-selector.js +9 -15
  24. package/dist/esm/lib/selectors/blob-selector.js.map +1 -1
  25. package/dist/esm/lib/selectors/json-selector.js +3 -12
  26. package/dist/esm/lib/selectors/json-selector.js.map +1 -1
  27. package/dist/esm/lib/selectors/sse-selector.js +164 -0
  28. package/dist/esm/lib/selectors/sse-selector.js.map +1 -0
  29. package/dist/esm/module.js +7 -16
  30. package/dist/esm/module.js.map +1 -1
  31. package/dist/esm/provider.js +2 -1
  32. package/dist/esm/provider.js.map +1 -1
  33. package/dist/esm/version.js +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/types/errors.d.ts +21 -0
  36. package/dist/types/lib/client/client.d.ts +24 -0
  37. package/dist/types/lib/operators/fetch-request.schema.d.ts +7 -7
  38. package/dist/types/lib/operators/sse.operator.d.ts +32 -0
  39. package/dist/types/lib/selectors/sse-selector.d.ts +63 -0
  40. package/dist/types/version.d.ts +1 -1
  41. package/package.json +4 -20
  42. package/src/errors.ts +27 -0
  43. package/src/lib/client/client.ts +52 -0
  44. package/src/lib/operators/sse.operator.ts +44 -0
  45. package/src/lib/selectors/sse-selector.ts +262 -0
  46. package/src/version.ts +1 -1
  47. package/tests/sse.selector.test.ts +150 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3038](https://github.com/equinor/fusion-framework/pull/3038) [`7a0a510`](https://github.com/equinor/fusion-framework/commit/7a0a510e0af1f0769c596e1b9aaa391250efd95d) Thanks [@odinr](https://github.com/odinr)! - ### Added
8
+
9
+ - Introduced support for Server-Sent Events (SSE) in the HTTP module.
10
+ - Added `sse# Change Log method to `HttpClient` for subscribing to SSE streams.
11
+ - Added `sseMap` operator for handling SSE in RxJS pipelines.
12
+ - Added `createSseSelector` for transforming SSE responses into observables.
13
+ - Enhanced error handling with `ServerSentEventResponseError`.
14
+
15
+ ### Documentation
16
+
17
+ - Updated README with examples and usage details for SSE support.
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [[`efd70a3`](https://github.com/equinor/fusion-framework/commit/efd70a34f734e0c155d3440e35ce4fa11a7abc42)]:
22
+ - @equinor/fusion-framework-module@4.4.0
23
+ - @equinor/fusion-framework-module-msal@4.0.4
24
+
25
+ ## 6.2.5
26
+
27
+ ### Patch Changes
28
+
29
+ - [#3012](https://github.com/equinor/fusion-framework/pull/3012) [`f53b60b`](https://github.com/equinor/fusion-framework/commit/f53b60b7805706ce7617e614f0ac0c24317a2e43) Thanks [@odinr](https://github.com/odinr)! - removed `typesVersions` from packages, since we no longer support TS < 4.7, also corrected `types` path in package.json
30
+
31
+ - Updated dependencies [[`f53b60b`](https://github.com/equinor/fusion-framework/commit/f53b60b7805706ce7617e614f0ac0c24317a2e43)]:
32
+ - @equinor/fusion-framework-module@4.3.8
33
+ - @equinor/fusion-framework-module-msal@4.0.3
34
+
3
35
  ## 6.2.4
4
36
 
5
37
  ### Patch Changes
package/README.md CHANGED
@@ -18,13 +18,13 @@ Whether you're building a simple application or a complex portal, the Fusion Fra
18
18
 
19
19
  ## Package
20
20
 
21
- | Namespace | Description |
22
- |-----------|-------------|
23
- | `@equinor/fusion-framework-module-http` | http module
24
- | `@equinor/fusion-framework-module-http/client` | http clients
25
- | `@equinor/fusion-framework-module-http/selectors` | http selectors
26
- | `@equinor/fusion-framework-module-http/operators` | http client operators
27
- | `@equinor/fusion-framework-module-http/errors` | http client errors
21
+ | Namespace | Description |
22
+ | ------------------------------------------------- | --------------------- |
23
+ | `@equinor/fusion-framework-module-http` | http module |
24
+ | `@equinor/fusion-framework-module-http/client` | http clients |
25
+ | `@equinor/fusion-framework-module-http/selectors` | http selectors |
26
+ | `@equinor/fusion-framework-module-http/operators` | http client operators |
27
+ | `@equinor/fusion-framework-module-http/errors` | http client errors |
28
28
 
29
29
  ## Usage
30
30
  Working with Fusion Framework, HTTP clients are defined during the configuration phase. The configuration is called by the Framework during initialization, ensuring that the HTTP clients are ready to be used. This approach allows for centralized and optimized client configuration, promoting consistency, performance, and security in HTTP communication within the Fusion Framework ecosystem.
@@ -179,15 +179,15 @@ By following this approach, you can enhance the efficiency, consistency, securit
179
179
 
180
180
  When configuring an HTTP client in the Fusion Framework, you can specify various settings to customize its behavior. The following options are available for configuring an HTTP client:
181
181
 
182
- | Property | Description |
183
- |----------|-------------|
184
- | `baseUri` | The base URI for the API endpoint. |
185
- | `defaultScopes` | The default scopes for MSAL authentication. |
186
- | `selector` | The response selector for processing the response. |
187
- | `onCreate` | A callback function to execute when the client is created. |
188
- | `requestHandler` | The request operators for processing outgoing requests. |
189
- | `responseHandler` | The response operators for processing incoming responses. |
190
- | `ctor` | The constructor function for a custom client. |
182
+ | Property | Description |
183
+ | ----------------- | ---------------------------------------------------------- |
184
+ | `baseUri` | The base URI for the API endpoint. |
185
+ | `defaultScopes` | The default scopes for MSAL authentication. |
186
+ | `selector` | The response selector for processing the response. |
187
+ | `onCreate` | A callback function to execute when the client is created. |
188
+ | `requestHandler` | The request operators for processing outgoing requests. |
189
+ | `responseHandler` | The response operators for processing incoming responses. |
190
+ | `ctor` | The constructor function for a custom client. |
191
191
 
192
192
 
193
193
  ### Basic configuration
@@ -807,6 +807,12 @@ client.blob('/image.jpg').then(
807
807
  }
808
808
  );
809
809
 
810
+ /** example of Server Sent Events */
811
+ client.sse$('/chatbot', {
812
+ method: 'POST',
813
+ body: { prompt: 'Tell me a joke' }
814
+ })
815
+
810
816
  /** Example of executing named function */
811
817
  client.execute<Users>('json', '/users'); // same as client.json<Users>('/users');
812
818
 
@@ -826,4 +832,163 @@ client.request$.subscribe(request => {
826
832
  client.response$.subscribe(response => {
827
833
  console.log('Incoming response:', response);
828
834
  });
829
- ```
835
+ ```
836
+
837
+ ### Server-Sent Events (SSE)
838
+
839
+ The HTTP client supports Server-Sent Events (SSE) through the `sse$` method. While this feature is versatile and can be used for various real-time communication scenarios, such as notifications, dashboards, or collaborative tools, it was primarily developed to facilitate streaming responses from chatbots.
840
+
841
+ Key benefits of SSE:
842
+ - Ideal for live updates, such as chatbot interactions, notifications, or collaborative tools.
843
+ - Provides an efficient way to handle server-driven data updates.
844
+ - Simplifies real-time communication with minimal setup.
845
+
846
+ The `sse$` method enables you to subscribe to a continuous stream of events sent by the server, making it particularly useful for applications requiring dynamic, real-time interactions, such as conversational AI or chatbot systems. This functionality ensures seamless and efficient communication between the client and server, enhancing the user experience in scenarios where immediate feedback or updates are critical.
847
+
848
+ #### Usage
849
+
850
+ The `sse$` method returns an observable that emits events as they are received from the server. It uses `client.fetch$` under the hood, abstracting common boilerplate code such as setting headers, configuring the request, and handling the response stream.
851
+
852
+ ```typescript
853
+ /** Example of using the sse$ method to subscribe to server-sent events */
854
+ const eventStream$ = client.sse$<{ message: string }>('/events');
855
+
856
+ const subscription = eventStream$.subscribe({
857
+ next: (event) => console.log('Received event:', event),
858
+ error: (error) => console.error('An error occurred:', error),
859
+ complete: () => console.log('Event stream completed'),
860
+ });
861
+
862
+ // To stop listening to events, unsubscribe from the observable
863
+ subscription.unsubscribe();
864
+ ```
865
+
866
+ #### Options
867
+
868
+ | Option | Description |
869
+ | ---------------- | ------------------------------------------------------------------------------------ |
870
+ | `dataParser` | A function to parse the raw event data into a desired format. |
871
+ | `skipHeartbeats` | A boolean indicating whether to skip heartbeat events (default: `false`). |
872
+ | `eventFilter` | An array of event types to filter. Only events matching these types will be emitted. |
873
+
874
+ #### Customizing SSE Behavior
875
+
876
+ You can customize the behavior of the SSE stream by providing options to the `sse$` method. For example, you can specify a custom data parser or handle reconnection logic.
877
+
878
+ ```typescript
879
+ /** Example of customizing SSE behavior with options */
880
+ const customEventStream$ = client.sse$<MyEventData & { timestamp: Date }>(
881
+ '/custom-events',
882
+ { method: 'POST', body: 'tell me a joke' },
883
+ {
884
+ dataParser: (data) => {
885
+ const parsedData = JSON.parse(data) as MyEventData;
886
+ return { ...parsedData, timestamp: new Date() };
887
+ },
888
+ }
889
+ );
890
+
891
+ customEventStream$.subscribe({
892
+ next: (event) => console.log('Custom event received:', event),
893
+ error: (error) => console.error('An error occurred:', error),
894
+ complete: () => console.log('Custom event stream completed'),
895
+ });
896
+ ```
897
+
898
+ #### Aborting SSE Requests
899
+
900
+ You can abort an SSE request by using the `abort` method of the HTTP client or by unsubscribing from the observable.
901
+
902
+ ```typescript
903
+ /** Example of aborting an SSE request */
904
+ const abortController = new AbortController();
905
+
906
+ const abortableEventStream$ = client.sse$<{ message: string }>('/abortable-events', {
907
+ signal: abortController.signal,
908
+ });
909
+
910
+ const subscription = abortableEventStream$.subscribe({
911
+ next: (event) => console.log('Received event:', event),
912
+ error: (error) => console.error('An error occurred:', error),
913
+ complete: () => console.log('Event stream completed'),
914
+ });
915
+
916
+ // Abort the request
917
+ abortController.abort();
918
+ ```
919
+
920
+ > [!NOTE]
921
+ > Unsubscribing from the observable will also abort the SSE request automatically.
922
+
923
+ #### Using `sseSelector` with `httpClient.fetch`
924
+
925
+ If you need to create an SSE call from scratch without using the `sse$` method, you can use the `sseSelector` directly with the `httpClient.fetch` method. Here's an example:
926
+
927
+ ```typescript
928
+ import { createSseSelector } from '@equinor/fusion-framework-module-http/selectors';
929
+
930
+ /** Example of using sseSelector with httpClient.fetch */
931
+ const sseSelector = createSseSelector<{ message: string }>({
932
+ dataParser: (data) => JSON.parse(data),
933
+ skipHeartbeats: true,
934
+ eventFilter: ['message', 'update'],
935
+ });
936
+
937
+ const headers = new Headers({
938
+ 'Accept': 'text/event-stream',
939
+ 'Cache-Control': 'no-cache',
940
+ 'Connection': 'keep-alive',
941
+ });
942
+
943
+ const sseStream$ = client.fetch('/events', {
944
+ selector: sseSelector,
945
+ headers,
946
+ method: 'GET', // SSE calls typically use GET
947
+ });
948
+
949
+ const subscription = sseStream$.subscribe({
950
+ next: (event) => console.log('Received event:', event),
951
+ error: (error) => console.error('An error occurred:', error),
952
+ complete: () => console.log('Event stream completed'),
953
+ });
954
+
955
+ // To stop listening to events, unsubscribe from the observable
956
+ subscription.unsubscribe();
957
+ ```
958
+
959
+ #### Using `sseMap` with `client.fetch$`
960
+
961
+ The `sseMap` operator can be used with `client.fetch$` to process Server-Sent Events (SSE) in a declarative manner. This approach allows you to handle SSE streams while leveraging the flexibility of RxJS.
962
+
963
+ ```typescript
964
+ import { sseMap } from '@equinor/fusion-framework-module-http/operators';
965
+
966
+ /** Example of using sseMap with client.fetch$ */
967
+ const sseStream$ = client.fetch$('/events', {
968
+ method: 'GET',
969
+ headers: {
970
+ 'Accept': 'text/event-stream',
971
+ 'Cache-Control': 'no-cache',
972
+ 'Connection': 'keep-alive',
973
+ },
974
+ }).pipe(
975
+ sseMap<{ message: string }>({
976
+ dataParser: (data) => JSON.parse(data),
977
+ skipHeartbeats: true,
978
+ eventFilter: ['message', 'update'],
979
+ }),
980
+ );
981
+
982
+ const subscription = sseStream$.subscribe({
983
+ next: (event) => console.log('Received event:', event),
984
+ error: (error) => console.error('An error occurred:', error),
985
+ complete: () => console.log('SSE stream completed'),
986
+ });
987
+
988
+ // To stop listening to events, unsubscribe from the observable
989
+ subscription.unsubscribe();
990
+ ```
991
+
992
+ This example demonstrates how to use `sseMap` with `client.fetch$` to process SSE data efficiently.
993
+
994
+ This approach provides more flexibility for customizing the SSE behavior while still leveraging the `httpClient.fetch` method. However, for most use cases, `client.sse$` is recommended as it simplifies the process by abstracting common boilerplate code.
@@ -1,23 +1,25 @@
1
1
  import { capitalizeRequestMethodOperator, requestValidationOperator, HttpRequestHandler, } from './lib/operators';
2
2
  /** @inheritdoc */
3
3
  export class HttpClientConfigurator {
4
+ _clients = {};
4
5
  /** Get a clone of all configured clients */
5
6
  get clients() {
6
- return Object.assign({}, this._clients);
7
+ return { ...this._clients };
7
8
  }
9
+ /** default class for creation of http clients */
10
+ defaultHttpClientCtor;
11
+ /** default request handler for http clients, applied on creation */
12
+ defaultHttpRequestHandler = new HttpRequestHandler({
13
+ // convert all request methods to uppercase
14
+ 'capitalize-method': capitalizeRequestMethodOperator(),
15
+ // validate the request object
16
+ 'request-validation': requestValidationOperator(),
17
+ });
8
18
  /**
9
19
  * Create a instance of http configuration
10
20
  * @param client defaultHttpRequestHandler
11
21
  */
12
22
  constructor(client) {
13
- this._clients = {};
14
- /** default request handler for http clients, applied on creation */
15
- this.defaultHttpRequestHandler = new HttpRequestHandler({
16
- // convert all request methods to uppercase
17
- 'capitalize-method': capitalizeRequestMethodOperator(),
18
- // validate the request object
19
- 'request-validation': requestValidationOperator(),
20
- });
21
23
  this.defaultHttpClientCtor = client;
22
24
  }
23
25
  /** @inheritdoc */
@@ -28,7 +30,10 @@ export class HttpClientConfigurator {
28
30
  configureClient(name, args) {
29
31
  const argFn = typeof args === 'string' ? { baseUri: args } : args;
30
32
  const options = typeof argFn === 'function' ? { onCreate: argFn } : argFn;
31
- this._clients[name] = Object.assign(Object.assign({}, this._clients[name]), options);
33
+ this._clients[name] = {
34
+ ...this._clients[name],
35
+ ...options,
36
+ };
32
37
  return this;
33
38
  }
34
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"configurator.js","sourceRoot":"","sources":["../../src/configurator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAwHzB,kBAAkB;AAClB,MAAM,OAAO,sBAAsB;IAKjC,4CAA4C;IAC5C,IAAW,OAAO;QAChB,yBAAY,IAAI,CAAC,QAAQ,EAAG;IAC9B,CAAC;IAaD;;;OAGG;IACH,YAAY,MAAsC;QAtBxC,aAAQ,GAA+C,EAAE,CAAC;QAUpE,oEAAoE;QAC3D,8BAAyB,GAAG,IAAI,kBAAkB,CAAqC;YAC9F,2CAA2C;YAC3C,mBAAmB,EAAE,+BAA+B,EAAE;YACtD,8BAA8B;YAC9B,oBAAoB,EAAE,yBAAyB,EAAE;SAClD,CAAC,CAAC;QAOD,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC;IACtC,CAAC;IAED,kBAAkB;IAClB,SAAS,CAAC,IAAY;QACpB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,kBAAkB;IAClB,eAAe,CACb,IAAY,EACZ,IAAsE;QAEtE,MAAM,KAAK,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAE,EAAE,OAAO,EAAE,IAAI,EAA2B,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5F,MAAM,OAAO,GAAG,OAAO,KAAK,K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C5F,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1E,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG;YACpB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACtB,GAAI,OAAiD;SACtD,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,eAAe,sBAAsB,CAAC"}
@@ -3,12 +3,13 @@
3
3
  * @template TResponse The type of the HTTP response.
4
4
  */
5
5
  export class HttpResponseError extends Error {
6
+ response;
7
+ static Name = 'HttpResponseError';
6
8
  constructor(message, response, options) {
7
9
  super(message, options);
8
10
  this.response = response;
9
11
  }
10
12
  }
11
- HttpResponseError.Name = 'HttpResponseError';
12
13
  /**
13
14
  * Represents an error that occurs when handling a JSON response in an HTTP request.
14
15
  * Extends the base `HttpResponseError` class.
@@ -17,6 +18,8 @@ HttpResponseError.Name = 'HttpResponseError';
17
18
  * @template TResponse - The type of the HTTP response.
18
19
  */
19
20
  export class HttpJsonResponseError extends HttpResponseError {
21
+ static Name = 'HttpJsonResponseError';
22
+ data;
20
23
  /**
21
24
  * Creates a new instance of `HttpJsonResponseError`.
22
25
  *
@@ -27,8 +30,29 @@ export class HttpJsonResponseError extends HttpResponseError {
27
30
  constructor(message, response, options) {
28
31
  super(message, response, options);
29
32
  this.name = HttpJsonResponseError.Name;
30
- this.data = options === null || options === void 0 ? void 0 : options.data;
33
+ this.data = options?.data;
34
+ }
35
+ }
36
+ /**
37
+ * Represents an error that occurs when handling a server-sent event (SSE) HTTP response.
38
+ *
39
+ * @template TType - The type of additional data associated with the error.
40
+ * @template TResponse - The type of the HTTP response object.
41
+ *
42
+ * @extends HttpResponseError<TResponse>
43
+ */
44
+ export class ServerSentEventResponseError extends HttpResponseError {
45
+ static Name = 'ServerSentEventResponseError';
46
+ /**
47
+ * Creates a new instance of the error.
48
+ *
49
+ * @param message - The error message describing the cause of the error.
50
+ * @param response - The HTTP response associated with the error.
51
+ * @param options - Optional error options, which may include additional data of type `TType`.
52
+ */
53
+ constructor(message, response, options) {
54
+ super(message, response, options);
55
+ this.name = ServerSentEventResponseError.Name;
31
56
  }
32
57
  }
33
- HttpJsonResponseError.Name = 'HttpJsonResponseError';
34
58
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,iBAAwC,SAAQ,KAAK;IAEhE,YACE,OAAe,EACC,QAAmB,EACnC,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAHR,aAAQ,GAAR,QAAQ,CAAW;IAIrC,CAAC;;AAPM,sBAAI,GAAG,mBAAmB,CAAC;AAUpC;;;;;;GAMG;AACH,MAAM,OAAO,qBAGX,SAAQ,iBAA4B;IAIpC;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,QAAmB,EAAE,OAAyC;QACzF,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC;IAC5B,CAAC;;AAdM,0BAAI,GAAG,uBAAuB,CAAC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,iBAAwC,SAAQ,KAAK;IAI9C;IAHlB,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,YACE,OAAe,EACC,QAAmB,EACnC,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAHR,aAAQ,GAAR,QAAQ,CAAW;IAIrC,CAAC;;AAGH;;;;;;GAMG;AACH,MAAM,OAAO,qBAGX,SAAQ,iBAA4B;IACpC,MAAM,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtB,IAAI,CAAS;IAE7B;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,QAAmB,EAAE,OAAyC;QACzF,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;IAC5B,CAAC;;AAGH;;;;;;;GAOG;AACH,MAAM,OAAO,4BAGX,SAAQ,iBAA4B;IACpC,MAAM,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAE7C;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,QAAmB,EAAE,OAAyC;QACzF,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC,IAAI,CAAC;IAChD,CAAC"}
@@ -14,14 +14,11 @@ import { HttpClient } from './client';
14
14
  * @template TResponse - The type of the response object. Defaults to `FetchResponse`.
15
15
  */
16
16
  export class HttpClientMsal extends HttpClient {
17
- constructor() {
18
- super(...arguments);
19
- /**
20
- * An array of default scopes to be used for all requests, unless overridden in the request object.
21
- * This property is used by the `HttpClientMsal` class to add MSAL authentication support to requests.
22
- */
23
- this.defaultScopes = [];
24
- }
17
+ /**
18
+ * An array of default scopes to be used for all requests, unless overridden in the request object.
19
+ * This property is used by the `HttpClientMsal` class to add MSAL authentication support to requests.
20
+ */
21
+ defaultScopes = [];
25
22
  /**
26
23
  * Fetches a resource from the specified path, with optional MSAL authentication scopes.
27
24
  *
@@ -41,7 +38,7 @@ export class HttpClientMsal extends HttpClient {
41
38
  * This ensures that the request includes the necessary scopes for MSAL authentication.
42
39
  */
43
40
  const args = Object.assign(init || {}, {
44
- scopes: this.defaultScopes.concat((init === null || init === void 0 ? void 0 : init.scopes) || []),
41
+ scopes: this.defaultScopes.concat(init?.scopes || []),
45
42
  });
46
43
  return super._fetch$(path, args);
47
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client-msal.js","sourceRoot":"","sources":["../../../../src/lib/client/client-msal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAsBtC;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAGX,SAAQ,UAA+B;IAHzC;;QAIE;;;WAGG;QACI,kBAAa,GAAa,EAAE,CAAC;IA6BtC,CAAC;IA3BC;;;;;;;;;;;;OAYG;IACI,MAAM,CACX,IAAY,EACZ,IAAmD;QAEnD;;;WAGG;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE;YACrC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,KAAI,EAAE,CAAC;SACtD,CAA6C,CAAC;QAE/C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"client-msal.js","sourceRoot":"","sources":["../../../../src/lib/client/client-msal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAsBtC;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAGX,SAAQ,UAA+B;IACvC;;;OAGG;IACI,aAAa,GAAa,EAAE,CAAC;IAEpC;;;;;;;;;;;;OAYG;IACI,MAAM,CACX,IAAY,EACZ,IAAmD;QAEnD;;;WAGG;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE;YACrC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,CAAC;SACtD,CAA6C,CAAC;QAE/C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED,eAAe,cAAc,CAAC"}
@@ -1,22 +1,38 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import { firstValueFrom, of, Subject } from 'rxjs';
13
2
  import { switchMap, takeUntil, tap } from 'rxjs/operators';
14
3
  import { fromFetch } from 'rxjs/fetch';
15
4
  import { HttpRequestHandler, HttpResponseHandler } from '../operators';
16
5
  import { blobSelector, jsonSelector } from '../selectors';
17
6
  import { HttpResponseError } from '../../errors';
7
+ import { createSseSelector, } from '../selectors/sse-selector';
18
8
  /** Base http client for executing requests */
19
9
  export class HttpClient {
10
+ uri;
11
+ /**
12
+ * A request handler that can be used to customize the request before it is sent.
13
+ * This property is part of the `HttpClientCreateOptions` configuration object used to create an `HttpClient` instance.
14
+ */
15
+ requestHandler;
16
+ /**
17
+ * A handler for customizing the response after it is received.
18
+ * This property is part of the `HttpClientCreateOptions` configuration object used to create an `HttpClient` instance.
19
+ */
20
+ responseHandler;
21
+ /**
22
+ * A stream of requests that are about to be executed.
23
+ * This property is used internally by the `HttpClient` class to manage the lifecycle of requests.
24
+ */
25
+ _request$ = new Subject();
26
+ /**
27
+ * A stream of responses that have been received.
28
+ * This property is used internally by the `HttpClient` class to manage the lifecycle of responses.
29
+ */
30
+ _response$ = new Subject();
31
+ /**
32
+ * A stream that is used to signal the abortion of requests.
33
+ * This property is used internally by the `HttpClient` class to manage the lifecycle of requests.
34
+ */
35
+ _abort$ = new Subject();
20
36
  /**
21
37
  * A stream of requests that are about to be executed.
22
38
  */
@@ -31,23 +47,8 @@ export class HttpClient {
31
47
  }
32
48
  constructor(uri, options) {
33
49
  this.uri = uri;
34
- /**
35
- * A stream of requests that are about to be executed.
36
- * This property is used internally by the `HttpClient` class to manage the lifecycle of requests.
37
- */
38
- this._request$ = new Subject();
39
- /**
40
- * A stream of responses that have been received.
41
- * This property is used internally by the `HttpClient` class to manage the lifecycle of responses.
42
- */
43
- this._response$ = new Subject();
44
- /**
45
- * A stream that is used to signal the abortion of requests.
46
- * This property is used internally by the `HttpClient` class to manage the lifecycle of requests.
47
- */
48
- this._abort$ = new Subject();
49
- this.requestHandler = new HttpRequestHandler(options === null || options === void 0 ? void 0 : options.requestHandler);
50
- this.responseHandler = new HttpResponseHandler(options === null || options === void 0 ? void 0 : options.responseHandler);
50
+ this.requestHandler = new HttpRequestHandler(options?.requestHandler);
51
+ this.responseHandler = new HttpResponseHandler(options?.responseHandler);
51
52
  this._init();
52
53
  }
53
54
  /**
@@ -94,15 +95,17 @@ export class HttpClient {
94
95
  * @returns A stream response containing the fetched data in JSON format.
95
96
  */
96
97
  json$(path, args) {
97
- var _a;
98
- const body = typeof (args === null || args === void 0 ? void 0 : args.body) === 'object' ? JSON.stringify(args === null || args === void 0 ? void 0 : args.body) : args === null || args === void 0 ? void 0 : args.body;
99
- const selector = (_a = args === null || args === void 0 ? void 0 : args.selector) !== null && _a !== void 0 ? _a : jsonSelector;
100
- const headers = new Headers(args === null || args === void 0 ? void 0 : args.headers);
98
+ const body = typeof args?.body === 'object' ? JSON.stringify(args?.body) : args?.body;
99
+ const selector = args?.selector ?? jsonSelector;
100
+ const headers = new Headers(args?.headers);
101
101
  headers.append('Accept', 'application/json');
102
102
  headers.append('Content-Type', 'application/json');
103
- return this.fetch$(path, Object.assign(Object.assign({}, args), { body,
103
+ return this.fetch$(path, {
104
+ ...args,
105
+ body,
104
106
  selector,
105
- headers }));
107
+ headers,
108
+ });
106
109
  }
107
110
  /**
108
111
  * Fetches data from the specified path and returns a Promise containing the fetched data in JSON format.
@@ -125,11 +128,13 @@ export class HttpClient {
125
128
  * @returns A stream response containing the fetched blob data.
126
129
  */
127
130
  blob$(path, args) {
128
- var _a;
129
131
  // Get the selector value from the provided args, or use the default blobSelector
130
- const selector = (_a = args === null || args === void 0 ? void 0 : args.selector) !== null && _a !== void 0 ? _a : blobSelector;
132
+ const selector = args?.selector ?? blobSelector;
131
133
  // Create the FetchRequestInit object with the provided args and the selector
132
- const init = Object.assign(Object.assign({}, args), { selector });
134
+ const init = {
135
+ ...args,
136
+ selector,
137
+ };
133
138
  // Call the fetch$ method with the provided path and the constructed init object
134
139
  return this.fetch$(path, init);
135
140
  }
@@ -143,6 +148,40 @@ export class HttpClient {
143
148
  blob(path, args) {
144
149
  return firstValueFrom(this.blob$(path, args));
145
150
  }
151
+ /**
152
+ * Initiates a Server-Sent Events (SSE) stream request to the specified path and returns a stream of events.
153
+ *
154
+ * @template T - The type of the event data expected from the SSE stream.
155
+ * @param path - The endpoint path to connect to for the SSE stream.
156
+ * @param args - Optional fetch request initialization options, including headers and abort signal.
157
+ * @param options - Optional selector options for customizing the SSE stream, excluding the abort signal.
158
+ *
159
+ * @returns A `StreamResponse` that emits `ServerSentEvent<T>` objects as they are received from the server.
160
+ *
161
+ * @example
162
+ * const sse$ = httpClient.sse(
163
+ * '/events',
164
+ * { method: 'POST', body: JSON.stringify({ prompt: 'tell me a joke' }) },
165
+ * { eventFilter: ['message'] }
166
+ * );
167
+ * sse$.subscribe({
168
+ * next: (event) => console.log(event),
169
+ * error: (err) => console.error(err),
170
+ * complete: () => console.log('Completed'),
171
+ * });
172
+ */
173
+ sse$(path, args, options) {
174
+ // Setup default common headers for SSE
175
+ const headers = new Headers(args?.headers);
176
+ headers.append('Accept', 'text/event-stream');
177
+ headers.append('Content-Type', 'text/event-stream');
178
+ headers.append('Cache-Control', 'no-cache');
179
+ headers.append('Connection', 'keep-alive');
180
+ // Create the selector using the provided options and the abort signal from args
181
+ const selector = createSseSelector({ ...options, abortSignal: args?.signal });
182
+ // Call the fetch$ method with the provided path and the constructed init object
183
+ return this._fetch$(path, { selector, ...args, headers });
184
+ }
146
185
  /** @deprecated */
147
186
  jsonAsync(path, args) {
148
187
  return this.json(path, args);
@@ -182,17 +221,17 @@ export class HttpClient {
182
221
  * 6. Cancels the request if the `_abort$` observable emits.
183
222
  */
184
223
  _fetch$(path, args) {
185
- const _a = args || {}, { selector } = _a, options = __rest(_a, ["selector"]);
186
- const response$ = of(Object.assign(Object.assign({}, options), { uri: this._resolveUrl(path) })).pipe(
224
+ const { selector, ...options } = args || {};
225
+ const response$ = of({
226
+ ...options,
227
+ uri: this._resolveUrl(path),
228
+ }).pipe(
187
229
  /** prepare request, allow extensions to modify request */
188
230
  switchMap((x) => this._prepareRequest(x)),
189
231
  /** push request to event buss */
190
232
  tap((x) => this._request$.next(x)),
191
233
  /** execute request */
192
- switchMap((_a) => {
193
- var { uri, path: _path } = _a, init = __rest(_a, ["uri", "path"]);
194
- return fromFetch(uri, init);
195
- }),
234
+ switchMap(({ uri, path: _path, ...init }) => fromFetch(uri, init)),
196
235
  /** prepare response, allow extensions to modify response */
197
236
  switchMap((x) => this._prepareResponse(x)),
198
237
  /** push response to event buss */
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/client/client.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,YAAY,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Q,CAAC,MAAM,CACjE,CAAC;QACF,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QACpE,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;CACF"}
@@ -6,10 +6,9 @@ import { requestMethodCasing } from './fetch-request.schema';
6
6
  * @returns A new request object with the HTTP method in uppercase.
7
7
  */
8
8
  export const capitalizeRequestMethodOperator = (options) => (request) => {
9
- var _a;
10
9
  const { error, success, data } = requestMethodCasing().safeParse(request.method);
11
- request.method = success ? data : (_a = request.method) === null || _a === void 0 ? void 0 : _a.toUpperCase();
12
- if (error && !(options === null || options === void 0 ? void 0 : options.silent)) {
10
+ request.method = success ? data : request.method?.toUpperCase();
11
+ if (error && !options?.silent) {
13
12
  for (const e of error.errors) {
14
13
  console.warn(e.message);
15
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"capitalize-request-method.operator.js","sourceRoot":"","sources":["../../../../src/lib/operators/capitalize-request-method.operator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,CAAwB,OAA8B,EAAsB,EAAE,CAC9E,CAAC,OAAO,EAAK,EAAE;;IACb,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,mBAAmB,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjF,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAA,OAAO,CAAC,MAAM,0CAAE,WAAW,EAAE,CAAC;IAEhE,IAAI,KAAK,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA,EAAE,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
1
+ {"version":3,"file":"capitalize-request-method.operator.js","sourceRoot":"","sources":["../../../../src/lib/operators/capitalize-request-method.operator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,CAAwB,OAA8B,EAAsB,EAAE,CAC9E,CAAC,OAAO,EAAK,EAAE;IACb,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,mBAAmB,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjF,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC;IAEhE,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}