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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
declare const controller: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
/**
|
|
6
|
+
* Get plugin configuration for admin UI
|
|
7
|
+
* GET /field-clearer/config
|
|
8
|
+
*/
|
|
9
|
+
getConfig(ctx: any): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Preview what will be deleted (dry run)
|
|
12
|
+
* POST /field-clearer/preview-field
|
|
13
|
+
* Body: { contentType, documentId, fieldPath }
|
|
14
|
+
*/
|
|
15
|
+
previewField(ctx: any): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Clear a field from a document
|
|
18
|
+
* POST /field-clearer/clear-field
|
|
19
|
+
* Body: { contentType, documentId, fieldPath }
|
|
20
|
+
*
|
|
21
|
+
* Examples:
|
|
22
|
+
* - fieldPath: "coupons" → clears all coupons
|
|
23
|
+
* - fieldPath: "coupons.freebies" → clears freebies inside each coupon
|
|
24
|
+
* - fieldPath: "coupons[1].freebies" → clears freebies from 2nd coupon only
|
|
25
|
+
*/
|
|
26
|
+
clearField(ctx: any): Promise<any>;
|
|
27
|
+
};
|
|
28
|
+
export default controller;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
controller: ({ strapi }: {
|
|
3
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
getConfig(ctx: any): Promise<any>;
|
|
6
|
+
previewField(ctx: any): Promise<any>;
|
|
7
|
+
clearField(ctx: any): Promise<any>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
register: ({ strapi }: {
|
|
3
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
4
|
+
}) => void;
|
|
5
|
+
bootstrap: ({ strapi }: {
|
|
6
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
7
|
+
}) => void;
|
|
8
|
+
destroy: ({ strapi }: {
|
|
9
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
10
|
+
}) => void;
|
|
11
|
+
config: {
|
|
12
|
+
default: {
|
|
13
|
+
allowedContentTypes: string[];
|
|
14
|
+
};
|
|
15
|
+
validator(config: {
|
|
16
|
+
allowedContentTypes?: unknown;
|
|
17
|
+
}): void;
|
|
18
|
+
};
|
|
19
|
+
controllers: {
|
|
20
|
+
controller: ({ strapi }: {
|
|
21
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
22
|
+
}) => {
|
|
23
|
+
getConfig(ctx: any): Promise<any>;
|
|
24
|
+
previewField(ctx: any): Promise<any>;
|
|
25
|
+
clearField(ctx: any): Promise<any>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
routes: {
|
|
29
|
+
method: string;
|
|
30
|
+
path: string;
|
|
31
|
+
handler: string;
|
|
32
|
+
config: {
|
|
33
|
+
policies: string[];
|
|
34
|
+
};
|
|
35
|
+
}[];
|
|
36
|
+
services: {
|
|
37
|
+
service: ({ strapi }: {
|
|
38
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
39
|
+
}) => {
|
|
40
|
+
previewField(contentType: string, documentId: string, fieldPath: string): Promise<{
|
|
41
|
+
fieldPath: string;
|
|
42
|
+
fieldType: string;
|
|
43
|
+
isEmpty: boolean;
|
|
44
|
+
itemCount: number;
|
|
45
|
+
items: any[];
|
|
46
|
+
message: string;
|
|
47
|
+
}>;
|
|
48
|
+
previewTopLevelField(contentType: string, documentId: string, fieldName: string): Promise<{
|
|
49
|
+
fieldPath: string;
|
|
50
|
+
fieldType: string;
|
|
51
|
+
isEmpty: boolean;
|
|
52
|
+
itemCount: number;
|
|
53
|
+
items: any[];
|
|
54
|
+
message: string;
|
|
55
|
+
}>;
|
|
56
|
+
previewNestedField(contentType: string, documentId: string, componentField: string, nestedField: string, indices?: number[]): Promise<{
|
|
57
|
+
fieldPath: string;
|
|
58
|
+
fieldType: string;
|
|
59
|
+
isEmpty: boolean;
|
|
60
|
+
itemCount: number;
|
|
61
|
+
items: any[];
|
|
62
|
+
message: string;
|
|
63
|
+
componentCount?: undefined;
|
|
64
|
+
totalComponentCount?: undefined;
|
|
65
|
+
targetIndices?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
fieldPath: string;
|
|
68
|
+
fieldType: string;
|
|
69
|
+
isEmpty: boolean;
|
|
70
|
+
itemCount: number;
|
|
71
|
+
componentCount: number;
|
|
72
|
+
totalComponentCount: number;
|
|
73
|
+
targetIndices: number[];
|
|
74
|
+
items: any[];
|
|
75
|
+
message: string;
|
|
76
|
+
}>;
|
|
77
|
+
getFieldType(value: any): string;
|
|
78
|
+
extractPreviewItems(value: any, fieldName: string): any[];
|
|
79
|
+
clearField(contentType: string, documentId: string, fieldPath: string): Promise<{
|
|
80
|
+
message: string;
|
|
81
|
+
clearedCount: number;
|
|
82
|
+
path?: undefined;
|
|
83
|
+
} | {
|
|
84
|
+
message: string;
|
|
85
|
+
clearedCount: number;
|
|
86
|
+
path: string;
|
|
87
|
+
}>;
|
|
88
|
+
clearTopLevelField(contentType: string, documentId: string, fieldName: string): Promise<{
|
|
89
|
+
message: string;
|
|
90
|
+
clearedCount: number;
|
|
91
|
+
path?: undefined;
|
|
92
|
+
} | {
|
|
93
|
+
message: string;
|
|
94
|
+
clearedCount: number;
|
|
95
|
+
path: string;
|
|
96
|
+
}>;
|
|
97
|
+
clearNestedField(contentType: string, documentId: string, componentField: string, nestedField: string, indices?: number[]): Promise<{
|
|
98
|
+
message: string;
|
|
99
|
+
clearedCount: number;
|
|
100
|
+
path?: undefined;
|
|
101
|
+
} | {
|
|
102
|
+
message: string;
|
|
103
|
+
clearedCount: number;
|
|
104
|
+
path: string;
|
|
105
|
+
}>;
|
|
106
|
+
isFieldEmpty(value: any): boolean;
|
|
107
|
+
countFieldItems(value: any): number;
|
|
108
|
+
getEmptyValue(value: any): any;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
contentTypes: {};
|
|
112
|
+
policies: {};
|
|
113
|
+
middlewares: {};
|
|
114
|
+
};
|
|
115
|
+
export default _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
service: ({ strapi }: {
|
|
3
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
previewField(contentType: string, documentId: string, fieldPath: string): Promise<{
|
|
6
|
+
fieldPath: string;
|
|
7
|
+
fieldType: string;
|
|
8
|
+
isEmpty: boolean;
|
|
9
|
+
itemCount: number;
|
|
10
|
+
items: any[];
|
|
11
|
+
message: string;
|
|
12
|
+
}>;
|
|
13
|
+
previewTopLevelField(contentType: string, documentId: string, fieldName: string): Promise<{
|
|
14
|
+
fieldPath: string;
|
|
15
|
+
fieldType: string;
|
|
16
|
+
isEmpty: boolean;
|
|
17
|
+
itemCount: number;
|
|
18
|
+
items: any[];
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
previewNestedField(contentType: string, documentId: string, componentField: string, nestedField: string, indices?: number[]): Promise<{
|
|
22
|
+
fieldPath: string;
|
|
23
|
+
fieldType: string;
|
|
24
|
+
isEmpty: boolean;
|
|
25
|
+
itemCount: number;
|
|
26
|
+
items: any[];
|
|
27
|
+
message: string;
|
|
28
|
+
componentCount?: undefined;
|
|
29
|
+
totalComponentCount?: undefined;
|
|
30
|
+
targetIndices?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
fieldPath: string;
|
|
33
|
+
fieldType: string;
|
|
34
|
+
isEmpty: boolean;
|
|
35
|
+
itemCount: number;
|
|
36
|
+
componentCount: number;
|
|
37
|
+
totalComponentCount: number;
|
|
38
|
+
targetIndices: number[];
|
|
39
|
+
items: any[];
|
|
40
|
+
message: string;
|
|
41
|
+
}>;
|
|
42
|
+
getFieldType(value: any): string;
|
|
43
|
+
extractPreviewItems(value: any, fieldName: string): any[];
|
|
44
|
+
clearField(contentType: string, documentId: string, fieldPath: string): Promise<{
|
|
45
|
+
message: string;
|
|
46
|
+
clearedCount: number;
|
|
47
|
+
path?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
message: string;
|
|
50
|
+
clearedCount: number;
|
|
51
|
+
path: string;
|
|
52
|
+
}>;
|
|
53
|
+
clearTopLevelField(contentType: string, documentId: string, fieldName: string): Promise<{
|
|
54
|
+
message: string;
|
|
55
|
+
clearedCount: number;
|
|
56
|
+
path?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
message: string;
|
|
59
|
+
clearedCount: number;
|
|
60
|
+
path: string;
|
|
61
|
+
}>;
|
|
62
|
+
clearNestedField(contentType: string, documentId: string, componentField: string, nestedField: string, indices?: number[]): Promise<{
|
|
63
|
+
message: string;
|
|
64
|
+
clearedCount: number;
|
|
65
|
+
path?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
message: string;
|
|
68
|
+
clearedCount: number;
|
|
69
|
+
path: string;
|
|
70
|
+
}>;
|
|
71
|
+
isFieldEmpty(value: any): boolean;
|
|
72
|
+
countFieldItems(value: any): number;
|
|
73
|
+
getEmptyValue(value: any): any;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export default _default;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
declare const service: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
/**
|
|
6
|
+
* Preview what will be deleted (dry run - no actual deletion)
|
|
7
|
+
* Returns field info and items that would be deleted
|
|
8
|
+
*/
|
|
9
|
+
previewField(contentType: string, documentId: string, fieldPath: string): Promise<{
|
|
10
|
+
fieldPath: string;
|
|
11
|
+
fieldType: string;
|
|
12
|
+
isEmpty: boolean;
|
|
13
|
+
itemCount: number;
|
|
14
|
+
items: any[];
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Preview a top-level field deletion
|
|
19
|
+
*/
|
|
20
|
+
previewTopLevelField(contentType: string, documentId: string, fieldName: string): Promise<{
|
|
21
|
+
fieldPath: string;
|
|
22
|
+
fieldType: string;
|
|
23
|
+
isEmpty: boolean;
|
|
24
|
+
itemCount: number;
|
|
25
|
+
items: any[];
|
|
26
|
+
message: string;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Preview a nested field deletion
|
|
30
|
+
* @param indices - Optional array of component indices to target (0-based). If null, targets all components.
|
|
31
|
+
*/
|
|
32
|
+
previewNestedField(contentType: string, documentId: string, componentField: string, nestedField: string, indices?: number[] | null): Promise<{
|
|
33
|
+
fieldPath: string;
|
|
34
|
+
fieldType: string;
|
|
35
|
+
isEmpty: boolean;
|
|
36
|
+
itemCount: number;
|
|
37
|
+
items: any[];
|
|
38
|
+
message: string;
|
|
39
|
+
componentCount?: undefined;
|
|
40
|
+
totalComponentCount?: undefined;
|
|
41
|
+
targetIndices?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
fieldPath: string;
|
|
44
|
+
fieldType: string;
|
|
45
|
+
isEmpty: boolean;
|
|
46
|
+
itemCount: number;
|
|
47
|
+
componentCount: number;
|
|
48
|
+
totalComponentCount: number;
|
|
49
|
+
targetIndices: number[];
|
|
50
|
+
items: any[];
|
|
51
|
+
message: string;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Get a human-readable field type
|
|
55
|
+
*/
|
|
56
|
+
getFieldType(value: any): string;
|
|
57
|
+
/**
|
|
58
|
+
* Extract preview items from a field value
|
|
59
|
+
*/
|
|
60
|
+
extractPreviewItems(value: any, fieldName: string): any[];
|
|
61
|
+
/**
|
|
62
|
+
* Clear a field from a document using a path
|
|
63
|
+
*
|
|
64
|
+
* Supported field types:
|
|
65
|
+
* - string, text, richtext, enumeration
|
|
66
|
+
* - integer, decimal, float
|
|
67
|
+
* - boolean
|
|
68
|
+
* - CKEditor (customField)
|
|
69
|
+
* - media (single/multiple)
|
|
70
|
+
* - relation (oneToOne, oneToMany, manyToOne, manyToMany)
|
|
71
|
+
* - component (single/repeatable)
|
|
72
|
+
*
|
|
73
|
+
* Examples:
|
|
74
|
+
* - "coupons" → clears entire coupons array (sets to [])
|
|
75
|
+
* - "coupons.freebies" → clears freebies field inside each coupon component
|
|
76
|
+
* - "all_offers_unlocked_message" → clears CKEditor field
|
|
77
|
+
*
|
|
78
|
+
* @param contentType - e.g., 'api::cart.cart'
|
|
79
|
+
* @param documentId - the document's documentId
|
|
80
|
+
* @param fieldPath - e.g., 'coupons' or 'coupons.freebies'
|
|
81
|
+
*/
|
|
82
|
+
clearField(contentType: string, documentId: string, fieldPath: string): Promise<{
|
|
83
|
+
message: string;
|
|
84
|
+
clearedCount: number;
|
|
85
|
+
path?: undefined;
|
|
86
|
+
} | {
|
|
87
|
+
message: string;
|
|
88
|
+
clearedCount: number;
|
|
89
|
+
path: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Clear a top-level field (e.g., "coupons" → sets coupons to [] or null)
|
|
93
|
+
* Works for all field types: relations, components, scalars, media, CKEditor
|
|
94
|
+
*/
|
|
95
|
+
clearTopLevelField(contentType: string, documentId: string, fieldName: string): Promise<{
|
|
96
|
+
message: string;
|
|
97
|
+
clearedCount: number;
|
|
98
|
+
path?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
message: string;
|
|
101
|
+
clearedCount: number;
|
|
102
|
+
path: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Clear a nested field inside component(s) (e.g., "coupons.freebies" or "coupons[1].freebies")
|
|
106
|
+
* Works for all field types inside components
|
|
107
|
+
* @param indices - Optional array of component indices to target (0-based). If null, targets all components.
|
|
108
|
+
*/
|
|
109
|
+
clearNestedField(contentType: string, documentId: string, componentField: string, nestedField: string, indices?: number[] | null): Promise<{
|
|
110
|
+
message: string;
|
|
111
|
+
clearedCount: number;
|
|
112
|
+
path?: undefined;
|
|
113
|
+
} | {
|
|
114
|
+
message: string;
|
|
115
|
+
clearedCount: number;
|
|
116
|
+
path: string;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Check if a field value is considered empty
|
|
120
|
+
*/
|
|
121
|
+
isFieldEmpty(value: any): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Count items in a field for reporting
|
|
124
|
+
*/
|
|
125
|
+
countFieldItems(value: any): number;
|
|
126
|
+
/**
|
|
127
|
+
* Get the appropriate empty value based on the original value type
|
|
128
|
+
*/
|
|
129
|
+
getEmptyValue(value: any): any;
|
|
130
|
+
};
|
|
131
|
+
export default service;
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "strapi-plugin-field-clearer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Strapi v5 plugin to clear/delete field data from content types. Supports nested fields, component arrays, relations, and more.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"strapi",
|
|
7
|
+
"strapi-plugin",
|
|
8
|
+
"strapi-v5",
|
|
9
|
+
"field-clearer",
|
|
10
|
+
"data-management",
|
|
11
|
+
"content-management"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Akshay Golakiya",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/akshaygolakiya/strapi-plugin-field-clearer.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/akshaygolakiya/strapi-plugin-field-clearer/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/akshaygolakiya/strapi-plugin-field-clearer#readme",
|
|
23
|
+
"type": "commonjs",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
|
+
"./strapi-admin": {
|
|
27
|
+
"types": "./dist/admin/src/index.d.ts",
|
|
28
|
+
"source": "./admin/src/index.ts",
|
|
29
|
+
"import": "./dist/admin/index.mjs",
|
|
30
|
+
"require": "./dist/admin/index.js",
|
|
31
|
+
"default": "./dist/admin/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./strapi-server": {
|
|
34
|
+
"types": "./dist/server/src/index.d.ts",
|
|
35
|
+
"source": "./server/src/index.ts",
|
|
36
|
+
"import": "./dist/server/index.mjs",
|
|
37
|
+
"require": "./dist/server/index.js",
|
|
38
|
+
"default": "./dist/server/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "strapi-plugin build",
|
|
48
|
+
"watch": "strapi-plugin watch",
|
|
49
|
+
"watch:link": "strapi-plugin watch:link",
|
|
50
|
+
"verify": "strapi-plugin verify",
|
|
51
|
+
"prepublishOnly": "npm run build",
|
|
52
|
+
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
|
|
53
|
+
"test:ts:back": "run -T tsc -p server/tsconfig.json"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@strapi/design-system": "^2.0.0-rc.23",
|
|
57
|
+
"@strapi/icons": "^2.0.0-rc.23"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@strapi/sdk-plugin": "^5.3.2",
|
|
61
|
+
"@strapi/strapi": "^5.0.0",
|
|
62
|
+
"@strapi/typescript-utils": "^5.0.0",
|
|
63
|
+
"@types/react": "^18.0.0",
|
|
64
|
+
"@types/react-dom": "^18.0.0",
|
|
65
|
+
"prettier": "^3.0.0",
|
|
66
|
+
"react": "^18.0.0",
|
|
67
|
+
"react-dom": "^18.0.0",
|
|
68
|
+
"react-router-dom": "^6.0.0",
|
|
69
|
+
"styled-components": "^6.0.0",
|
|
70
|
+
"typescript": "^5.0.0"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@strapi/strapi": "^5.0.0",
|
|
74
|
+
"react": "^18.0.0",
|
|
75
|
+
"react-dom": "^18.0.0"
|
|
76
|
+
},
|
|
77
|
+
"strapi": {
|
|
78
|
+
"kind": "plugin",
|
|
79
|
+
"name": "field-clearer",
|
|
80
|
+
"displayName": "Field Clearer",
|
|
81
|
+
"description": "Clear/delete field data from content types with a simple UI"
|
|
82
|
+
}
|
|
83
|
+
}
|