@jpmorganchase/mosaic-from-http-request 0.1.0-beta.15 → 0.1.0-beta.16

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.
@@ -1,6 +1,2 @@
1
- import * as nodeFetch from 'node-fetch';
2
1
  import { fromFetch } from 'rxjs/fetch';
3
- declare global {
4
- var fetch: typeof nodeFetch.default;
5
- }
6
2
  export { fromFetch };
package/dist/fromFetch.js CHANGED
@@ -1,9 +1,14 @@
1
1
  /* eslint-disable eslint-comments/no-unlimited-disable */
2
2
  import * as nodeFetch from 'node-fetch';
3
3
  import { fromFetch } from 'rxjs/fetch';
4
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
- // @ts-ignore
6
- global.fetch = nodeFetch.default;
4
+ if (!globalThis.fetch) {
5
+ // eslint-disable-next-line
6
+ // @ts-ignore
7
+ globalThis.fetch = nodeFetch.default;
8
+ // eslint-disable-next-line
9
+ // @ts-ignore
10
+ globalThis.Request = nodeFetch.Request;
11
+ }
7
12
  export { fromFetch };
8
13
  /* eslint-enable eslint-comments/no-unlimited-disable */
9
14
  //# sourceMappingURL=fromFetch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fromFetch.js","sourceRoot":"","sources":["../src/fromFetch.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQvC,6DAA6D;AAC7D,aAAa;AACb,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,wDAAwD"}
1
+ {"version":3,"file":"fromFetch.js","sourceRoot":"","sources":["../src/fromFetch.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;IACrB,2BAA2B;IAC3B,aAAa;IACb,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC;IACrC,2BAA2B;IAC3B,aAAa;IACb,UAAU,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;CACxC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,wDAAwD"}
@@ -6,4 +6,9 @@ export declare type ErrorResponse = {
6
6
  message: string;
7
7
  };
8
8
  export declare function isErrorResponse<TData>(response: TData | ErrorResponse): response is ErrorResponse;
9
- export declare function fromHttpRequest<TData>(url: string): Observable<TData | ErrorResponse>;
9
+ /**
10
+ *
11
+ * @param input The resource you would like to fetch. Can be a url or a request object.
12
+ * @returns Observable of JSON or ErrorResponse
13
+ */
14
+ export declare function fromHttpRequest<TData>(input: string | Request): Observable<TData | ErrorResponse>;
@@ -6,8 +6,13 @@ import { fromFetch } from './fromFetch.js';
6
6
  export function isErrorResponse(response) {
7
7
  return response.error !== undefined;
8
8
  }
9
- export function fromHttpRequest(url) {
10
- return fromFetch(url).pipe(switchMap(response => {
9
+ /**
10
+ *
11
+ * @param input The resource you would like to fetch. Can be a url or a request object.
12
+ * @returns Observable of JSON or ErrorResponse
13
+ */
14
+ export function fromHttpRequest(input) {
15
+ return fromFetch(input).pipe(switchMap(response => {
11
16
  if (response.ok) {
12
17
  return response.json();
13
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fromHttpRequest.js","sourceRoot":"","sources":["../src/fromHttpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sCAAsC,CAAC;AAC9C,OAAO,EAAc,EAAE,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,MAAM,UAAU,eAAe,CAAQ,QAA+B;I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C,IAAI,EAAoB,CAAC;SAC1C;QACD,OAAO,EAAE,CAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjF,CAAC,CAAC,EACF,UAAU,CAAC,GAAG,CAAC,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,EAAE,CAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAiB,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpmorganchase/mosaic-from-http-request",
3
- "version": "0.1.0-beta.15",
3
+ "version": "0.1.0-beta.16",
4
4
  "author": "",
5
5
  "description": "Utility package to turn HTTP fetch requests to observables. This package can be deleted when node 18 is used.",
6
6
  "license": "Apache-2.0",
@@ -32,11 +32,11 @@
32
32
  "dependencies": {
33
33
  "event-target-polyfill": "^0.0.3",
34
34
  "rxjs": "^7.5.5",
35
- "node-fetch": "^2.6.1",
35
+ "node-fetch": "^2.6.2",
36
36
  "yet-another-abortcontroller-polyfill": "0.0.4"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/node-fetch": "^2.5.8",
39
+ "@types/node-fetch": "^2.6.2",
40
40
  "msw": "^0.47.4"
41
41
  }
42
42
  }