@monarcode/effetch 0.0.0-stage → 0.1.0-alpha.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 +56 -0
- package/LICENSE +21 -0
- package/README.md +613 -2
- package/dist/Client.d.ts +367 -0
- package/dist/Client.js +110 -0
- package/dist/Errors.d.ts +224 -0
- package/dist/Errors.js +151 -0
- package/dist/Options.d.ts +462 -0
- package/dist/Path.d.ts +72 -0
- package/dist/Plugin.d.ts +553 -0
- package/dist/Plugin.js +7 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +5 -0
- package/dist/internal/body.js +70 -0
- package/dist/internal/object.js +6 -0
- package/dist/internal/path.js +23 -0
- package/dist/internal/pipeline.js +29 -0
- package/dist/internal/plugins.js +92 -0
- package/dist/internal/query.js +22 -0
- package/dist/internal/request.js +33 -0
- package/dist/internal/resolve.js +23 -0
- package/dist/internal/response.js +73 -0
- package/dist/internal/url.js +24 -0
- package/dist/plugins/bearer.d.ts +152 -0
- package/dist/plugins/bearer.js +63 -0
- package/dist/plugins/index.d.ts +32 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/logger.d.ts +66 -0
- package/dist/plugins/logger.js +67 -0
- package/dist/plugins/retry.d.ts +94 -0
- package/dist/plugins/retry.js +74 -0
- package/dist/plugins/timeout.d.ts +108 -0
- package/dist/plugins/timeout.js +84 -0
- package/package.json +85 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@monarcode/effetch`, newest first.
|
|
4
|
+
|
|
5
|
+
## 0.1.0-alpha.1
|
|
6
|
+
|
|
7
|
+
First release published from CI with npm provenance. No changes to the
|
|
8
|
+
package since 0.1.0-alpha.0.
|
|
9
|
+
|
|
10
|
+
## 0.1.0-alpha.0
|
|
11
|
+
|
|
12
|
+
First preview of effetch: typed, schema-driven HTTP calls on Effect v4's
|
|
13
|
+
`HttpClient`.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
#### Client
|
|
18
|
+
|
|
19
|
+
- `make` builds a client from any `HttpClient`, with a `baseUrl` (a string, or
|
|
20
|
+
an Effect such as a `Config`, run once), default `headers`, a default
|
|
21
|
+
`error` schema and `plugins`. Calls need no services apart from those of
|
|
22
|
+
their own schemas.
|
|
23
|
+
- `get`, `head` and `options` (no body), `post`, `put`, `patch` and `del`, and
|
|
24
|
+
`request(method, …)` for any method. `httpClient` exposes the configured
|
|
25
|
+
`HttpClient` for anything else, such as streaming.
|
|
26
|
+
- Path parameters are inferred from the path: `"/users/:id"` requires
|
|
27
|
+
`params: { id }`, and values are URI-encoded.
|
|
28
|
+
- `query` takes a plain object: arrays repeat the key, `null` and `undefined`
|
|
29
|
+
are dropped.
|
|
30
|
+
- `body` is sent by its type (`FormData`, `URLSearchParams`, `Blob`, bytes,
|
|
31
|
+
text, or JSON), or encoded with an `input` schema.
|
|
32
|
+
- `output` decodes the 2xx JSON body with a schema and sends
|
|
33
|
+
`Accept: application/json`. Without it, calls return the raw response.
|
|
34
|
+
|
|
35
|
+
#### Errors
|
|
36
|
+
|
|
37
|
+
- `NetworkError`, `HttpError` and `DecodeError`, with `FetchError` and
|
|
38
|
+
`isFetchError`. `HttpError.body` is decoded with the call's or the client's
|
|
39
|
+
`error` schema, and `HttpError.With<B>` types it.
|
|
40
|
+
- Error URLs never include the query string, and response headers such as
|
|
41
|
+
`set-cookie` print as `<redacted>`.
|
|
42
|
+
|
|
43
|
+
#### Plugins
|
|
44
|
+
|
|
45
|
+
- `plugin` defines a plugin with `onRequest`, `onResponse`, `onError` and
|
|
46
|
+
`wrap` hooks. Its errors, services and options are inferred, and calls can
|
|
47
|
+
skip it or override its options with `plugins: { name: … }`.
|
|
48
|
+
- Built-in plugins in `@monarcode/effetch/plugins`: `bearer` (tokens from a
|
|
49
|
+
string, a sync or async function, or an Effect), `logger`, `retry` (network
|
|
50
|
+
errors and transient statuses, idempotent methods only, with jittered
|
|
51
|
+
backoff) and `timeout` (with `TimeoutError`).
|
|
52
|
+
|
|
53
|
+
#### Types and docs
|
|
54
|
+
|
|
55
|
+
- Every export is documented with an example in the shipped `.d.ts`.
|
|
56
|
+
TypeScript 5.4 or newer is required.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MONARCH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|