manifest 6.0.0 → 7.0.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.
- package/CONTRACT.md +2 -2
- package/README.md +28 -51
- package/dist/chunk-DP2C4E42.js +720 -0
- package/dist/index.cjs +311 -26
- package/dist/index.d.cts +2 -6
- package/dist/index.d.ts +2 -6
- package/dist/index.js +4 -439
- package/dist/register.cjs +742 -0
- package/dist/register.d.cts +2 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.js +6 -0
- package/docs/guide.md +36 -19
- package/docs/healing-diagram.svg +549 -0
- package/package.json +17 -3
package/CONTRACT.md
CHANGED
|
@@ -15,13 +15,13 @@ The SDK talks to the configured Manifest API using `Authorization: Bearer <proje
|
|
|
15
15
|
}
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Credential filtering and body limits are described in the README. Capture gates live in `runtime.ts`; the server owns repair policy.
|
|
18
|
+
Any 4xx response is captured except 401, 402, 403 and 429; those and every 5xx pass through untouched, because auth, billing, rate limiting and server faults are not repaired by editing the request. JSON bodies and `application/x-www-form-urlencoded` bodies are sent as structured JSON values. Credential filtering and body limits are described in the README. Capture gates live in `runtime.ts`; the server owns repair policy.
|
|
19
19
|
|
|
20
20
|
A successful heal response may contain `status: patched|unverified`, `healAttemptId`, `operations` and `healedRequest` with `url`, `headers` or `body`. Only these two statuses authorize a retry. No patch, malformed responses and unavailable service return the original error response. HTTP 403 with `{"error":"project_disabled"}` suppresses healing for five minutes.
|
|
21
21
|
|
|
22
22
|
## Apply
|
|
23
23
|
|
|
24
|
-
A healed URL replaces the URL only within the original origin. Headers set or replace case-insensitively; null removes a header. Content length is recalculated. Objects merge using the server's healed body as the authoritative copy of fields sent to the server; withheld local credential fields are restored. Non-object JSON replaces the body. Incomplete request
|
|
24
|
+
A healed URL replaces the URL only within the original origin. Headers set or replace case-insensitively; null removes a header. Content length is recalculated. Objects merge using the server's healed body as the authoritative copy of fields sent to the server; withheld local credential fields are restored. Non-object JSON replaces the body. Form-urlencoded retries use the original encoding and are re-encoded from the parsed structure, so repeated keys return as indexed keys; a non-object healed body is not retried for them. Incomplete or malformed request captures and incomplete error captures are not retried.
|
|
25
25
|
|
|
26
26
|
Each captured failure permits one retry. A retry response, including another failure, is returned to the caller. A transport failure returns the original response. Successful response streams are not eagerly consumed.
|
|
27
27
|
|
package/README.md
CHANGED
|
@@ -1,52 +1,46 @@
|
|
|
1
1
|
# Manifest for Node.js
|
|
2
2
|
|
|
3
3
|
[](https://github.com/mnfst/manifest-node/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/manifest)
|
|
5
|
+
[](https://www.npmjs.com/package/manifest)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
**An API rejects your request. Manifest fixes it and retries. You do nothing.**
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install manifest
|
|
11
|
+
```
|
|
6
12
|
|
|
7
13
|
```js
|
|
8
14
|
import { manifest } from 'manifest';
|
|
9
15
|
|
|
10
|
-
manifest();
|
|
16
|
+
manifest(); // once, at startup
|
|
11
17
|
// Keep making your API calls as usual.
|
|
12
18
|
```
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Setup
|
|
17
|
-
|
|
18
|
-
### 1. Install
|
|
19
|
-
|
|
20
|
-
Requires **Node.js 22+**:
|
|
21
|
-
|
|
22
|
-
```sh
|
|
23
|
-
npm install manifest
|
|
24
|
-
```
|
|
20
|
+
Works with built-in `fetch`, `node:http`, `node:https` and Axios, for JSON and form-urlencoded bodies. Node.js 22+. TypeScript, ESM and CommonJS. Zero dependencies.
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+

|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
## Setup
|
|
29
25
|
|
|
30
|
-
Create a project in your Manifest dashboard and copy
|
|
26
|
+
1. Create a project in your Manifest dashboard and copy its project key.
|
|
27
|
+
2. Turn on **Autofix** in **Project Settings**.
|
|
28
|
+
3. Set the key:
|
|
31
29
|
|
|
32
30
|
```sh
|
|
33
31
|
export MNFST_KEY='your-project-key'
|
|
34
32
|
```
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
Call `manifest()` before any library grabs its own reference to `fetch` or `node:http`. To install before any of your modules run, preload it instead:
|
|
37
35
|
|
|
38
36
|
```sh
|
|
39
|
-
|
|
37
|
+
node --import manifest/register app.js
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### 3. Initialize before your requests
|
|
45
|
-
|
|
46
|
-
Call `manifest()` once at startup, before other libraries save a reference to `fetch`. Save this as `example.mjs`, replacing the example endpoint and payload with your own:
|
|
40
|
+
## See it work
|
|
47
41
|
|
|
48
42
|
```js
|
|
49
|
-
import { manifest
|
|
43
|
+
import { manifest } from 'manifest';
|
|
50
44
|
|
|
51
45
|
manifest({
|
|
52
46
|
onHeal(event) {
|
|
@@ -54,36 +48,19 @@ manifest({
|
|
|
54
48
|
},
|
|
55
49
|
});
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
console.log(response.status, await response.text());
|
|
64
|
-
} finally {
|
|
65
|
-
await flush({ timeoutMs: 5000 });
|
|
66
|
-
}
|
|
51
|
+
const res = await fetch('https://api.example.com/orders', {
|
|
52
|
+
method: 'POST',
|
|
53
|
+
headers: { 'content-type': 'application/json' },
|
|
54
|
+
body: JSON.stringify({ limit: 500 }), // rejected? Manifest retries with a valid limit
|
|
55
|
+
});
|
|
67
56
|
```
|
|
68
57
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
CommonJS uses `const { manifest, flush } = require('manifest')`.
|
|
72
|
-
|
|
73
|
-
## Check that it works
|
|
74
|
-
|
|
75
|
-
Send a JSON request that your test API rejects with **400, 404 or 422**. Check the failure in your project's dashboard and the `onHeal` callback for the repair result. A successful request alone does not contact Manifest. `flush()` lets a short script wait for outcome reports before exiting.
|
|
76
|
-
|
|
77
|
-
## What to expect
|
|
78
|
-
|
|
79
|
-
- **One retry.** Manifest returns a repair; the SDK sends the corrected request directly to your API.
|
|
80
|
-
- **Original error if healing is unavailable.** A heal call can add up to 60 seconds. If a retry returns an HTTP response, that response reaches your application.
|
|
81
|
-
- **Built-in fetch.** Browser JavaScript, default Axios, `node:http` and separately imported fetch implementations are not intercepted.
|
|
82
|
-
- **Retry semantics still matter.** Use idempotency keys where needed; a repeated request can repeat side effects.
|
|
83
|
-
|
|
84
|
-
## Privacy
|
|
58
|
+
## Good to know
|
|
85
59
|
|
|
86
|
-
|
|
60
|
+
- **Retries repeat side effects.** Use idempotency keys on non-idempotent calls.
|
|
61
|
+
- **A heal adds up to 60 s** to a failed request. Successful requests are untouched.
|
|
62
|
+
- **Not intercepted:** browsers, HTTP/2, and directly imported `undici`.
|
|
63
|
+
- **Privacy.** Failed URLs, headers, JSON or form-urlencoded bodies, and error responses are sent to Manifest. Known credentials are masked, but nested secrets and business data are not. Enable it only for traffic you allow Manifest to process.
|
|
87
64
|
|
|
88
65
|
## More
|
|
89
66
|
|