strapi-plugin-field-clearer 1.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/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/_chunks/en-B9h9Fs9u.js +6 -0
- package/dist/_chunks/en-BtKZmRuE.mjs +6 -0
- package/dist/admin/index.js +27903 -0
- package/dist/admin/index.mjs +27906 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/index.d.ts +11 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/server/index.js +710 -0
- package/dist/server/index.mjs +711 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/index.d.ts +9 -0
- package/dist/server/src/content-types/index.d.ts +2 -0
- package/dist/server/src/controllers/controller.d.ts +28 -0
- package/dist/server/src/controllers/index.d.ts +10 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/index.d.ts +115 -0
- package/dist/server/src/middlewares/index.d.ts +2 -0
- package/dist/server/src/policies/index.d.ts +2 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/index.d.ts +9 -0
- package/dist/server/src/services/index.d.ts +76 -0
- package/dist/server/src/services/service.d.ts +131 -0
- package/package.json +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Akshay Golakiya
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Strapi Plugin: Field Clearer
|
|
2
|
+
|
|
3
|
+
A Strapi v5 plugin that provides a convenient UI to clear/delete field data from content types. Perfect for managing test data, clearing relations, or resetting component arrays.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Clear any field type: relations, components, media, text, enumerations, etc.
|
|
8
|
+
- Support for nested fields inside components (e.g., `coupons.freebies`)
|
|
9
|
+
- Target specific component indices (e.g., `coupons[1].freebies` to clear only the 2nd coupon's freebies)
|
|
10
|
+
- Preview before delete - see exactly what will be removed
|
|
11
|
+
- Bulk mode - clear multiple fields at once
|
|
12
|
+
- Favorites - save frequently used field paths
|
|
13
|
+
- Full audit logging
|
|
14
|
+
- Secure - requires admin authentication and configurable content type whitelist
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install strapi-plugin-field-clearer
|
|
20
|
+
# or
|
|
21
|
+
yarn add strapi-plugin-field-clearer
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
Add the plugin configuration to your `config/plugins.js` (or `config/plugins.ts`):
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
module.exports = {
|
|
30
|
+
'field-clearer': {
|
|
31
|
+
enabled: true,
|
|
32
|
+
config: {
|
|
33
|
+
// Specify which content types can use the Field Clearer
|
|
34
|
+
allowedContentTypes: [
|
|
35
|
+
'api::cart.cart',
|
|
36
|
+
'api::collection.collection',
|
|
37
|
+
'api::product.product',
|
|
38
|
+
// Add your content types here
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Configuration Options
|
|
46
|
+
|
|
47
|
+
| Option | Type | Required | Description |
|
|
48
|
+
|--------|------|----------|-------------|
|
|
49
|
+
| `allowedContentTypes` | `string[]` | Yes | Array of content type UIDs that can use the Field Clearer. Format: `api::collection-name.collection-name` |
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
1. Navigate to any configured content type in the Strapi admin panel
|
|
54
|
+
2. Open a document (entry)
|
|
55
|
+
3. Click the "Clear Field" button in the right panel
|
|
56
|
+
4. Enter the field path you want to clear
|
|
57
|
+
|
|
58
|
+
### Field Path Examples
|
|
59
|
+
|
|
60
|
+
| Path | Description |
|
|
61
|
+
|------|-------------|
|
|
62
|
+
| `coupons` | Clear all coupons (entire field) |
|
|
63
|
+
| `coupons.freebies` | Clear freebies from ALL coupons |
|
|
64
|
+
| `coupons[0].freebies` | Clear freebies from the 1st coupon only |
|
|
65
|
+
| `coupons[1].freebies` | Clear freebies from the 2nd coupon only |
|
|
66
|
+
| `coupons[0,2].freebies` | Clear freebies from 1st and 3rd coupons |
|
|
67
|
+
| `image` | Clear a media field |
|
|
68
|
+
| `tags` | Clear a relation field |
|
|
69
|
+
|
|
70
|
+
### Modes
|
|
71
|
+
|
|
72
|
+
#### Single Mode
|
|
73
|
+
- Enter a field path
|
|
74
|
+
- Preview what will be deleted
|
|
75
|
+
- Confirm deletion
|
|
76
|
+
|
|
77
|
+
#### Bulk Mode
|
|
78
|
+
- Add multiple field paths
|
|
79
|
+
- Preview all at once
|
|
80
|
+
- Clear all selected fields in one operation
|
|
81
|
+
|
|
82
|
+
### Favorites
|
|
83
|
+
- Save frequently used field paths
|
|
84
|
+
- Quick access from the favorites section
|
|
85
|
+
- Validated before saving (ensures field exists)
|
|
86
|
+
|
|
87
|
+
## Security
|
|
88
|
+
|
|
89
|
+
- All endpoints require admin authentication
|
|
90
|
+
- Content types must be explicitly whitelisted in configuration
|
|
91
|
+
- Input validation on all field paths
|
|
92
|
+
- Full audit logging of all clear operations
|
|
93
|
+
|
|
94
|
+
## API Endpoints
|
|
95
|
+
|
|
96
|
+
The plugin exposes these endpoints (all require admin authentication):
|
|
97
|
+
|
|
98
|
+
| Method | Endpoint | Description |
|
|
99
|
+
|--------|----------|-------------|
|
|
100
|
+
| `GET` | `/field-clearer/config` | Get plugin configuration |
|
|
101
|
+
| `POST` | `/field-clearer/preview-field` | Preview what will be deleted |
|
|
102
|
+
| `POST` | `/field-clearer/clear-field` | Clear the specified field |
|
|
103
|
+
|
|
104
|
+
## Requirements
|
|
105
|
+
|
|
106
|
+
- Strapi v5.x
|
|
107
|
+
- Node.js 18+
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Build the plugin
|
|
113
|
+
npm run build
|
|
114
|
+
|
|
115
|
+
# Watch for changes during development
|
|
116
|
+
npm run watch
|
|
117
|
+
|
|
118
|
+
# Link for local development
|
|
119
|
+
npm run watch:link
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
125
|
+
|
|
126
|
+
## Author
|
|
127
|
+
|
|
128
|
+
Akshay Golakiya
|