datocms-plugin-record-bin 1.9.0 → 3.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/README.md +113 -11
- package/build/assets/index-BnrW9Ts8.js +15 -0
- package/build/assets/index-aWCW2c0n.css +1 -0
- package/build/index.html +13 -1
- package/index.html +12 -0
- package/package.json +24 -18
- package/src/entrypoints/BinOutlet.tsx +262 -37
- package/src/entrypoints/ConfigScreen.tsx +939 -38
- package/src/entrypoints/ErrorModal.tsx +86 -2
- package/src/index.tsx +73 -28
- package/src/react-app-env.d.ts +1 -1
- package/src/types/types.ts +36 -8
- package/src/utils/binCleanup.test.ts +107 -0
- package/src/utils/binCleanup.ts +71 -23
- package/src/utils/debugLogger.ts +27 -0
- package/src/utils/deployProviders.test.ts +33 -0
- package/src/utils/deployProviders.ts +28 -0
- package/src/utils/getDeploymentUrlFromParameters.test.ts +26 -0
- package/src/utils/getDeploymentUrlFromParameters.ts +21 -0
- package/src/utils/getRuntimeMode.test.ts +57 -0
- package/src/utils/getRuntimeMode.ts +23 -0
- package/src/utils/lambdaLessCapture.test.ts +218 -0
- package/src/utils/lambdaLessCapture.ts +160 -0
- package/src/utils/lambdaLessCleanup.test.ts +125 -0
- package/src/utils/lambdaLessCleanup.ts +69 -0
- package/src/utils/lambdaLessRestore.test.ts +248 -0
- package/src/utils/lambdaLessRestore.ts +159 -0
- package/src/utils/recordBinModel.ts +108 -0
- package/src/utils/recordBinPayload.test.ts +103 -0
- package/src/utils/recordBinPayload.ts +136 -0
- package/src/utils/recordBinWebhook.test.ts +253 -0
- package/src/utils/recordBinWebhook.ts +305 -0
- package/src/utils/render.tsx +17 -8
- package/src/utils/restoreError.test.ts +112 -0
- package/src/utils/restoreError.ts +221 -0
- package/src/utils/verifyLambdaHealth.test.ts +248 -0
- package/src/utils/verifyLambdaHealth.ts +422 -0
- package/vite.config.ts +11 -0
- package/build/asset-manifest.json +0 -13
- package/build/static/css/main.10f29737.css +0 -2
- package/build/static/css/main.10f29737.css.map +0 -1
- package/build/static/js/main.53795e3b.js +0 -3
- package/build/static/js/main.53795e3b.js.LICENSE.txt +0 -47
- package/build/static/js/main.53795e3b.js.map +0 -1
- package/src/entrypoints/InstallationModal.tsx +0 -107
- package/src/entrypoints/PreInstallConfig.tsx +0 -28
- package/src/utils/attemptVercelInitialization.ts +0 -16
package/README.md
CHANGED
|
@@ -1,20 +1,122 @@
|
|
|
1
1
|
# 🗑 Record Bin
|
|
2
2
|
|
|
3
|
-
Record Bin
|
|
3
|
+
Record Bin stores deleted records so they can be restored later.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The plugin now supports two runtimes:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
1. `Lambda` runtime (webhook/API capable)
|
|
8
|
+
2. `Lambda-less` runtime (dashboard delete capture only)
|
|
8
9
|
|
|
9
|
-
The
|
|
10
|
-
It follows the following instructions:
|
|
10
|
+
The plugin requires the `currentUserAccessToken` permission.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
2. By clicking the Vercel Deploy button you can start a step by step process that will create that lambda function (You will be asked your projects Full API token!)
|
|
14
|
-
3. After deploying it, copy the Deployed URL and insert it in the modal, and "Finish installation"
|
|
12
|
+
## Runtime modes
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
Runtime is selected with a single toggle in the plugin config screen:
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
- Toggle off (`Also save records deleted from the API` disabled): `Lambda-less` mode.
|
|
17
|
+
- Toggle on (`Also save records deleted from the API` enabled): `Lambda-full` mode.
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
If you are not sure what Lambda is, keep the toggle off.
|
|
20
|
+
|
|
21
|
+
If no explicit runtime has ever been saved yet, the plugin falls back to legacy auto-detection:
|
|
22
|
+
|
|
23
|
+
- Lambda URL present -> `Lambda-full`
|
|
24
|
+
- No Lambda URL -> `Lambda-less`
|
|
25
|
+
|
|
26
|
+
## Capability matrix
|
|
27
|
+
|
|
28
|
+
| Capability | Lambda runtime | Lambda-less runtime |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| Capture dashboard deletions | ✅ | ✅ |
|
|
31
|
+
| Capture API deletions | ✅ | ❌ |
|
|
32
|
+
| Restore from Record Bin | ✅ | ✅ |
|
|
33
|
+
| Daily cleanup of old bin entries | ✅ | ✅ |
|
|
34
|
+
|
|
35
|
+
## Setup
|
|
36
|
+
|
|
37
|
+
### Option 1: Lambda-less (default)
|
|
38
|
+
|
|
39
|
+
1. Open the plugin config screen.
|
|
40
|
+
2. Keep `Also save records deleted from the API` disabled.
|
|
41
|
+
3. Save plugin settings.
|
|
42
|
+
|
|
43
|
+
In this mode, deleted records are captured through `onBeforeItemsDestroy`.
|
|
44
|
+
|
|
45
|
+
### Option 2: Lambda-full (API deletion capture)
|
|
46
|
+
|
|
47
|
+
1. Open the plugin config screen.
|
|
48
|
+
2. Enable `Also save records deleted from the API`.
|
|
49
|
+
3. Lambda setup fields appear. Click `Deploy lambda` and choose one option:
|
|
50
|
+
- Vercel
|
|
51
|
+
- Netlify
|
|
52
|
+
- Cloudflare
|
|
53
|
+
4. Paste your deployed URL into `Lambda URL`.
|
|
54
|
+
- You can paste either `https://your-app.netlify.app` or just `your-app.netlify.app`; the plugin will prepend `https://` when needed.
|
|
55
|
+
5. Click `Connect`.
|
|
56
|
+
6. Confirm status shows `Connected (ping successful)`.
|
|
57
|
+
|
|
58
|
+
When connected, the plugin creates or updates a project webhook named `🗑️ Record Bin` pointing to your lambda root URL.
|
|
59
|
+
The current user role must be allowed to manage webhooks for connect/disconnect operations.
|
|
60
|
+
|
|
61
|
+
## Important limitations and behavior
|
|
62
|
+
|
|
63
|
+
- In Lambda-less mode, API-triggered deletions are not captured. Only dashboard-triggered deletions go to the bin.
|
|
64
|
+
- Lambda-less capture is fail-open: if backup capture fails, deletion still proceeds.
|
|
65
|
+
- Existing webhook-origin `record_body` payloads are still restorable.
|
|
66
|
+
- New Lambda-less payloads are stored in a webhook-compatible envelope (`event_type: to_be_restored`) so records stay restorable after runtime switches.
|
|
67
|
+
|
|
68
|
+
## Lambda health handshake contract (Lambda runtime)
|
|
69
|
+
|
|
70
|
+
The plugin sends this request payload to `POST /api/datocms/plugin-health`:
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"event_type": "plugin_health_ping",
|
|
75
|
+
"mpi": {
|
|
76
|
+
"message": "DATOCMS_RECORD_BIN_PLUGIN_PING",
|
|
77
|
+
"version": "2026-02-25",
|
|
78
|
+
"phase": "config_connect"
|
|
79
|
+
},
|
|
80
|
+
"plugin": {
|
|
81
|
+
"name": "datocms-plugin-record-bin",
|
|
82
|
+
"environment": "main"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`phase` values:
|
|
88
|
+
|
|
89
|
+
- `config_connect` when the user clicks `Connect` on the config screen.
|
|
90
|
+
- `config_mount` every time the config screen is opened.
|
|
91
|
+
- `finish_installation` is legacy and kept for backward compatibility with older saved states.
|
|
92
|
+
|
|
93
|
+
Expected successful response (`HTTP 200`):
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"ok": true,
|
|
98
|
+
"mpi": {
|
|
99
|
+
"message": "DATOCMS_RECORD_BIN_LAMBDA_PONG",
|
|
100
|
+
"version": "2026-02-25"
|
|
101
|
+
},
|
|
102
|
+
"service": "record-bin-lambda-function",
|
|
103
|
+
"status": "ready"
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Any non-200 status, invalid JSON, timeout, network failure, or contract mismatch is treated as a connectivity error.
|
|
108
|
+
|
|
109
|
+
## Record Bin webhook contract (Lambda runtime)
|
|
110
|
+
|
|
111
|
+
On connect, the plugin reconciles a managed project-level webhook (creates if missing, updates if existing):
|
|
112
|
+
|
|
113
|
+
- `name`: `🗑️ Record Bin` (legacy `🗑 Record Bin` is migrated)
|
|
114
|
+
- `url`: connected lambda base URL
|
|
115
|
+
- `events`: `item.delete`
|
|
116
|
+
- `custom_payload`: `null`
|
|
117
|
+
- `headers`: `{}`
|
|
118
|
+
- `http_basic_user`: `null`
|
|
119
|
+
- `http_basic_password`: `null`
|
|
120
|
+
- `enabled`: `true`
|
|
121
|
+
- `payload_api_version`: `3`
|
|
122
|
+
- `nested_items_in_payload`: `true`
|