fx-fetch 1.0.0 → 1.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/dist/Fetch/fetchBlob.d.ts +24 -0
- package/dist/Fetch/fetchBlob.js +24 -0
- package/dist/Fetch/fetchBlob.js.map +1 -1
- package/dist/Fetch/fetchBytes.d.ts +25 -1
- package/dist/Fetch/fetchBytes.js +24 -0
- package/dist/Fetch/fetchBytes.js.map +1 -1
- package/dist/Fetch/fetchFn.d.ts +28 -0
- package/dist/Fetch/fetchFn.js +28 -0
- package/dist/Fetch/fetchFn.js.map +1 -1
- package/dist/Fetch/fetchFormData.d.ts +24 -0
- package/dist/Fetch/fetchFormData.js +24 -0
- package/dist/Fetch/fetchFormData.js.map +1 -1
- package/dist/Fetch/fetchJson.d.ts +24 -0
- package/dist/Fetch/fetchJson.js +24 -0
- package/dist/Fetch/fetchJson.js.map +1 -1
- package/dist/Fetch/fetchJsonWithSchema.d.ts +90 -0
- package/dist/Fetch/fetchJsonWithSchema.js +30 -0
- package/dist/Fetch/fetchJsonWithSchema.js.map +1 -1
- package/dist/Fetch/fetchReadableStream.d.ts +24 -0
- package/dist/Fetch/fetchReadableStream.js +24 -0
- package/dist/Fetch/fetchReadableStream.js.map +1 -1
- package/dist/Fetch/fetchStream.d.ts +120 -2
- package/dist/Fetch/fetchStream.js +36 -1
- package/dist/Fetch/fetchStream.js.map +1 -1
- package/dist/Fetch/fetchText.d.ts +24 -0
- package/dist/Fetch/fetchText.js +24 -0
- package/dist/Fetch/fetchText.js.map +1 -1
- package/dist/Fetch/paginatedFetch.d.ts +137 -0
- package/dist/Fetch/paginatedFetch.js +43 -0
- package/dist/Fetch/paginatedFetch.js.map +1 -1
- package/dist/Fetch/paginatedFetchStream.d.ts +134 -0
- package/dist/Fetch/paginatedFetchStream.js +42 -0
- package/dist/Fetch/paginatedFetchStream.js.map +1 -1
- package/dist/Request/make.d.ts +6 -1
- package/dist/Request/make.js +6 -1
- package/dist/Request/make.js.map +1 -1
- package/dist/Request/readBytes.d.ts +1 -1
- package/dist/Request/unsafeMake.d.ts +6 -1
- package/dist/Request/unsafeMake.js +6 -1
- package/dist/Request/unsafeMake.js.map +1 -1
- package/dist/Response/readBytes.d.ts +1 -1
- package/dist/utils/readBodyAsBytesOrThrow.d.ts +2 -2
- package/dist/utils/readBodyAsBytesOrThrow.js +2 -2
- package/dist/utils/readBodyAsBytesOrThrow.js.map +1 -1
- package/package.json +3 -2
|
@@ -6,5 +6,29 @@ import * as Response from "../Response/index.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readBlob}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedBlobError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── Blob
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchBlob(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export declare const fetchBlob: (request: Request.Request) => Effect.Effect<Blob, import("../Cause").MalformedBlobError | import("./errors").FetchError | import("./errors").AbortError | import("./errors").NotAllowedError | Response.NotOkError, import("./Fetch").Fetch>;
|
package/dist/Fetch/fetchBlob.js
CHANGED
|
@@ -6,6 +6,30 @@ import { fetch } from "./fetchFn.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readBlob}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedBlobError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── Blob
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchBlob(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export const fetchBlob = (request) => fetch(request).pipe(Effect.flatMap(Response.readBlob));
|
|
11
35
|
//# sourceMappingURL=fetchBlob.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchBlob.js","sourceRoot":"","sources":["../../src/Fetch/fetchBlob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC
|
|
1
|
+
{"version":3,"file":"fetchBlob.js","sourceRoot":"","sources":["../../src/Fetch/fetchBlob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAwB,EAAE,EAAE,CACpD,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -6,5 +6,29 @@ import * as Response from "../Response/index.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readBytes}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedBytesError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── Uint8Array<ArrayBuffer>
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchBytes(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
|
-
export declare const fetchBytes: (request: Request.Request) => Effect.Effect<ArrayBuffer
|
|
34
|
+
export declare const fetchBytes: (request: Request.Request) => Effect.Effect<Uint8Array<ArrayBuffer>, import("../Cause").MalformedBytesError | import("./errors").FetchError | import("./errors").AbortError | import("./errors").NotAllowedError | Response.NotOkError, import("./Fetch").Fetch>;
|
package/dist/Fetch/fetchBytes.js
CHANGED
|
@@ -6,6 +6,30 @@ import { fetch } from "./fetchFn.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readBytes}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedBytesError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── Uint8Array<ArrayBuffer>
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchBytes(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export const fetchBytes = (request) => fetch(request).pipe(Effect.flatMap(Response.readBytes));
|
|
11
35
|
//# sourceMappingURL=fetchBytes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchBytes.js","sourceRoot":"","sources":["../../src/Fetch/fetchBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC
|
|
1
|
+
{"version":3,"file":"fetchBytes.js","sourceRoot":"","sources":["../../src/Fetch/fetchBytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CACrD,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
package/dist/Fetch/fetchFn.d.ts
CHANGED
|
@@ -4,5 +4,33 @@ import { Fetch } from "./Fetch.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* @category Functions
|
|
6
6
|
* @since 0.1.0
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Effect } from 'effect';
|
|
10
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
11
|
+
*
|
|
12
|
+
* // ┌─── Effect.Effect<
|
|
13
|
+
* // │ void,
|
|
14
|
+
* // │ | Fetch.FetchError
|
|
15
|
+
* // │ | Fetch.AbortError
|
|
16
|
+
* // │ | Fetch.NotAllowedError
|
|
17
|
+
* // │ | Response.NotOkError,
|
|
18
|
+
* // │ Fetch.Fetch
|
|
19
|
+
* // │ >
|
|
20
|
+
* // ▼
|
|
21
|
+
* const program = Effect.gen(function* () {
|
|
22
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
23
|
+
*
|
|
24
|
+
* // ┌─── Response.Response
|
|
25
|
+
* // ▼
|
|
26
|
+
* const response = yield* Fetch.fetch(request);
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Run the program
|
|
30
|
+
* program.pipe(
|
|
31
|
+
* Effect.provideService(Fetch.Fetch, Fetch.FetchLive),
|
|
32
|
+
* Effect.runFork // or Effect.runPromise etc.
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
7
35
|
*/
|
|
8
36
|
export declare const fetch: (request: Request.Request) => Effect.Effect<import("../Response").Response, import("./errors").FetchError | import("./errors").AbortError | import("./errors").NotAllowedError | import("../Response").NotOkError, Fetch>;
|
package/dist/Fetch/fetchFn.js
CHANGED
|
@@ -3,6 +3,34 @@ import { Fetch } from "./Fetch.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* @category Functions
|
|
5
5
|
* @since 0.1.0
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { Effect } from 'effect';
|
|
9
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
10
|
+
*
|
|
11
|
+
* // ┌─── Effect.Effect<
|
|
12
|
+
* // │ void,
|
|
13
|
+
* // │ | Fetch.FetchError
|
|
14
|
+
* // │ | Fetch.AbortError
|
|
15
|
+
* // │ | Fetch.NotAllowedError
|
|
16
|
+
* // │ | Response.NotOkError,
|
|
17
|
+
* // │ Fetch.Fetch
|
|
18
|
+
* // │ >
|
|
19
|
+
* // ▼
|
|
20
|
+
* const program = Effect.gen(function* () {
|
|
21
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
22
|
+
*
|
|
23
|
+
* // ┌─── Response.Response
|
|
24
|
+
* // ▼
|
|
25
|
+
* const response = yield* Fetch.fetch(request);
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Run the program
|
|
29
|
+
* program.pipe(
|
|
30
|
+
* Effect.provideService(Fetch.Fetch, Fetch.FetchLive),
|
|
31
|
+
* Effect.runFork // or Effect.runPromise etc.
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
6
34
|
*/
|
|
7
35
|
export const fetch = Effect.fnUntraced(function* (request) {
|
|
8
36
|
const fetchFn = yield* Fetch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchFn.js","sourceRoot":"","sources":["../../src/Fetch/fetchFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAEhC
|
|
1
|
+
{"version":3,"file":"fetchFn.js","sourceRoot":"","sources":["../../src/Fetch/fetchFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,mBAAgB;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAwB;IACxE,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC;IAC7B,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC"}
|
|
@@ -6,5 +6,29 @@ import * as Response from "../Response/index.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readFormData}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedFormDataError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── FormData
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchFormData(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export declare const fetchFormData: (request: Request.Request) => Effect.Effect<FormData, import("../Cause").MalformedFormDataError | import("./errors").FetchError | import("./errors").AbortError | import("./errors").NotAllowedError | Response.NotOkError, import("./Fetch").Fetch>;
|
|
@@ -6,6 +6,30 @@ import { fetch } from "./fetchFn.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readFormData}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedFormDataError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── FormData
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchFormData(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export const fetchFormData = (request) => fetch(request).pipe(Effect.flatMap(Response.readFormData));
|
|
11
35
|
//# sourceMappingURL=fetchFormData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchFormData.js","sourceRoot":"","sources":["../../src/Fetch/fetchFormData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC
|
|
1
|
+
{"version":3,"file":"fetchFormData.js","sourceRoot":"","sources":["../../src/Fetch/fetchFormData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAwB,EAAE,EAAE,CACxD,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC"}
|
|
@@ -6,5 +6,29 @@ import * as Response from "../Response/index.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readJson}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedJsonError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── unknown
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchJson(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export declare const fetchJson: (request: Request.Request) => Effect.Effect<unknown, import("../Cause").MalformedJsonError | import("./errors").FetchError | import("./errors").AbortError | import("./errors").NotAllowedError | Response.NotOkError, import("./Fetch").Fetch>;
|
package/dist/Fetch/fetchJson.js
CHANGED
|
@@ -6,6 +6,30 @@ import { fetch } from "./fetchFn.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readJson}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedJsonError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── unknown
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchJson(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export const fetchJson = (request) => fetch(request).pipe(Effect.flatMap(Response.readJson));
|
|
11
35
|
//# sourceMappingURL=fetchJson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchJson.js","sourceRoot":"","sources":["../../src/Fetch/fetchJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC
|
|
1
|
+
{"version":3,"file":"fetchJson.js","sourceRoot":"","sources":["../../src/Fetch/fetchJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAwB,EAAE,EAAE,CACpD,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -9,6 +9,36 @@ import { Fetch } from "./Fetch.js";
|
|
|
9
9
|
*
|
|
10
10
|
* @category Conversions
|
|
11
11
|
* @since 0.1.0
|
|
12
|
+
* @see {@link Response.readJsonWithSchema}
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { Effect, Schema } from 'effect';
|
|
16
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
17
|
+
*
|
|
18
|
+
* const UserSchema = Schema.Struct({
|
|
19
|
+
* id: Schema.Int,
|
|
20
|
+
* name: Schema.String,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // ┌─── Effect.Effect<
|
|
24
|
+
* // │ void,
|
|
25
|
+
* // │ | Fetch.FetchError
|
|
26
|
+
* // │ | Fetch.AbortError
|
|
27
|
+
* // │ | Fetch.NotAllowedError
|
|
28
|
+
* // │ | Response.NotOkError
|
|
29
|
+
* // │ | MalformedJsonError
|
|
30
|
+
* // │ | ParseError,
|
|
31
|
+
* // │ Fetch.Fetch
|
|
32
|
+
* // │ >
|
|
33
|
+
* // ▼
|
|
34
|
+
* const program = Effect.gen(function* () {
|
|
35
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
36
|
+
*
|
|
37
|
+
* // ┌─── typeof UserSchema.Type
|
|
38
|
+
* // ▼
|
|
39
|
+
* const payload = yield* Fetch.fetchJsonWithSchema(request, UserSchema);
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
12
42
|
*/
|
|
13
43
|
export declare const fetchJsonWithSchema: {
|
|
14
44
|
/**
|
|
@@ -16,6 +46,36 @@ export declare const fetchJsonWithSchema: {
|
|
|
16
46
|
*
|
|
17
47
|
* @category Conversions
|
|
18
48
|
* @since 0.1.0
|
|
49
|
+
* @see {@link Response.readJsonWithSchema}
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { Effect, Schema } from 'effect';
|
|
53
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
54
|
+
*
|
|
55
|
+
* const UserSchema = Schema.Struct({
|
|
56
|
+
* id: Schema.Int,
|
|
57
|
+
* name: Schema.String,
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // ┌─── Effect.Effect<
|
|
61
|
+
* // │ void,
|
|
62
|
+
* // │ | Fetch.FetchError
|
|
63
|
+
* // │ | Fetch.AbortError
|
|
64
|
+
* // │ | Fetch.NotAllowedError
|
|
65
|
+
* // │ | Response.NotOkError
|
|
66
|
+
* // │ | MalformedJsonError
|
|
67
|
+
* // │ | ParseError,
|
|
68
|
+
* // │ Fetch.Fetch
|
|
69
|
+
* // │ >
|
|
70
|
+
* // ▼
|
|
71
|
+
* const program = Effect.gen(function* () {
|
|
72
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
73
|
+
*
|
|
74
|
+
* // ┌─── typeof UserSchema.Type
|
|
75
|
+
* // ▼
|
|
76
|
+
* const payload = yield* Fetch.fetchJsonWithSchema(request, UserSchema);
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
19
79
|
*/
|
|
20
80
|
<A, I, R>(request: Request.Request, schema: Schema.Schema<A, I, R>): Effect.Effect<A, AbortError | FetchError | NotAllowedError | Response.NotOkError | Cause.MalformedJsonError | ParseResult.ParseError, R | Fetch>;
|
|
21
81
|
/**
|
|
@@ -23,6 +83,36 @@ export declare const fetchJsonWithSchema: {
|
|
|
23
83
|
*
|
|
24
84
|
* @category Conversions
|
|
25
85
|
* @since 0.1.0
|
|
86
|
+
* @see {@link Response.readJsonWithSchema}
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { Effect, Schema } from 'effect';
|
|
90
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
91
|
+
*
|
|
92
|
+
* const UserSchema = Schema.Struct({
|
|
93
|
+
* id: Schema.Int,
|
|
94
|
+
* name: Schema.String,
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* // ┌─── Effect.Effect<
|
|
98
|
+
* // │ void,
|
|
99
|
+
* // │ | Fetch.FetchError
|
|
100
|
+
* // │ | Fetch.AbortError
|
|
101
|
+
* // │ | Fetch.NotAllowedError
|
|
102
|
+
* // │ | Response.NotOkError
|
|
103
|
+
* // │ | MalformedJsonError
|
|
104
|
+
* // │ | ParseError,
|
|
105
|
+
* // │ Fetch.Fetch
|
|
106
|
+
* // │ >
|
|
107
|
+
* // ▼
|
|
108
|
+
* const program = Effect.gen(function* () {
|
|
109
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
110
|
+
*
|
|
111
|
+
* // ┌─── typeof UserSchema.Type
|
|
112
|
+
* // ▼
|
|
113
|
+
* const payload = yield* Fetch.fetchJsonWithSchema(request, UserSchema);
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
26
116
|
*/
|
|
27
117
|
<A, I, R>(schema: Schema.Schema<A, I, R>): (request: Request.Request) => Effect.Effect<A, AbortError | FetchError | NotAllowedError | Response.NotOkError | Cause.MalformedJsonError | ParseResult.ParseError, R | Fetch>;
|
|
28
118
|
};
|
|
@@ -8,6 +8,36 @@ const fetchJsonWithSchemaFn = (request, schema) => fetch(request).pipe(Effect.fl
|
|
|
8
8
|
*
|
|
9
9
|
* @category Conversions
|
|
10
10
|
* @since 0.1.0
|
|
11
|
+
* @see {@link Response.readJsonWithSchema}
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Effect, Schema } from 'effect';
|
|
15
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
16
|
+
*
|
|
17
|
+
* const UserSchema = Schema.Struct({
|
|
18
|
+
* id: Schema.Int,
|
|
19
|
+
* name: Schema.String,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // ┌─── Effect.Effect<
|
|
23
|
+
* // │ void,
|
|
24
|
+
* // │ | Fetch.FetchError
|
|
25
|
+
* // │ | Fetch.AbortError
|
|
26
|
+
* // │ | Fetch.NotAllowedError
|
|
27
|
+
* // │ | Response.NotOkError
|
|
28
|
+
* // │ | MalformedJsonError
|
|
29
|
+
* // │ | ParseError,
|
|
30
|
+
* // │ Fetch.Fetch
|
|
31
|
+
* // │ >
|
|
32
|
+
* // ▼
|
|
33
|
+
* const program = Effect.gen(function* () {
|
|
34
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
35
|
+
*
|
|
36
|
+
* // ┌─── typeof UserSchema.Type
|
|
37
|
+
* // ▼
|
|
38
|
+
* const payload = yield* Fetch.fetchJsonWithSchema(request, UserSchema);
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
11
41
|
*/
|
|
12
42
|
export const fetchJsonWithSchema = dual(2, fetchJsonWithSchemaFn);
|
|
13
43
|
//# sourceMappingURL=fetchJsonWithSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchJsonWithSchema.js","sourceRoot":"","sources":["../../src/Fetch/fetchJsonWithSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,OAAO,KAAK,QAAQ,6BAAoB;AAGxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC,MAAM,qBAAqB,GAAG,CAAU,OAAwB,EAAE,MAA8B,EAAE,EAAE,CAClG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAE3E
|
|
1
|
+
{"version":3,"file":"fetchJsonWithSchema.js","sourceRoot":"","sources":["../../src/Fetch/fetchJsonWithSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,OAAO,KAAK,QAAQ,6BAAoB;AAGxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC,MAAM,qBAAqB,GAAG,CAAU,OAAwB,EAAE,MAA8B,EAAE,EAAE,CAClG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAqG5B,IAAI,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC"}
|
|
@@ -6,5 +6,29 @@ import * as Response from "../Response/index.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readReadableStream}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedReadableStreamError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── ReadableStream<Uint8Array<ArrayBuffer>>
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchReadableStream(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export declare const fetchReadableStream: (request: Request.Request) => Effect.Effect<ReadableStream<Uint8Array<ArrayBuffer>>, import("../Cause").MalformedReadableStreamError | import("./errors").FetchError | import("./errors").AbortError | import("./errors").NotAllowedError | Response.NotOkError, import("./Fetch").Fetch>;
|
|
@@ -6,6 +6,30 @@ import { fetch } from "./fetchFn.js";
|
|
|
6
6
|
*
|
|
7
7
|
* @category Functions
|
|
8
8
|
* @since 0.1.0
|
|
9
|
+
* @see {@link Response.readReadableStream}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Effect } from 'effect';
|
|
13
|
+
* import { Fetch, Request, Response } from 'fx-fetch';
|
|
14
|
+
*
|
|
15
|
+
* // ┌─── Effect.Effect<
|
|
16
|
+
* // │ void,
|
|
17
|
+
* // │ | Fetch.FetchError
|
|
18
|
+
* // │ | Fetch.AbortError
|
|
19
|
+
* // │ | Fetch.NotAllowedError
|
|
20
|
+
* // │ | Response.NotOkError
|
|
21
|
+
* // │ | MalformedReadableStreamError,
|
|
22
|
+
* // │ Fetch.Fetch
|
|
23
|
+
* // │ >
|
|
24
|
+
* // ▼
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* const request = Request.unsafeMake({ url: './my-endpoint' });
|
|
27
|
+
*
|
|
28
|
+
* // ┌─── ReadableStream<Uint8Array<ArrayBuffer>>
|
|
29
|
+
* // ▼
|
|
30
|
+
* const payload = yield* Fetch.fetchReadableStream(request);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
9
33
|
*/
|
|
10
34
|
export const fetchReadableStream = (request) => fetch(request).pipe(Effect.flatMap(Response.readReadableStream));
|
|
11
35
|
//# sourceMappingURL=fetchReadableStream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchReadableStream.js","sourceRoot":"","sources":["../../src/Fetch/fetchReadableStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC
|
|
1
|
+
{"version":3,"file":"fetchReadableStream.js","sourceRoot":"","sources":["../../src/Fetch/fetchReadableStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,QAAQ,6BAAoB;AACxC,OAAO,EAAE,KAAK,EAAE,qBAAkB;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAwB,EAAE,EAAE,CAC9D,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC"}
|