@nkhang1902/strapi-plugin-export-import-clsx 1.5.3 → 1.5.5
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nkhang1902/strapi-plugin-export-import-clsx",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "A powerful Strapi plugin for exporting and importing data with Excel support and advanced filtering",
|
|
5
5
|
"main": "./strapi-server.js",
|
|
6
6
|
"scripts": {
|
|
@@ -7,23 +7,12 @@ module.exports = ({ strapi }) => ({
|
|
|
7
7
|
.service("export-service");
|
|
8
8
|
|
|
9
9
|
if (format === "excel") {
|
|
10
|
-
const buffer = await exportService.exportData(
|
|
10
|
+
const {buffer, filename} = await exportService.exportData(
|
|
11
11
|
"excel",
|
|
12
12
|
contentType,
|
|
13
13
|
filters,
|
|
14
14
|
mode
|
|
15
15
|
);
|
|
16
|
-
|
|
17
|
-
const filename = `${contentType?.split(".")[1]}-export-${new Date().toISOString().split("T")[0]}.xlsx`;
|
|
18
|
-
|
|
19
|
-
if (mode === "participant") {
|
|
20
|
-
const expName = await strapi.documents(contentType).findOne({
|
|
21
|
-
select: ["name"],
|
|
22
|
-
filters
|
|
23
|
-
})
|
|
24
|
-
filename = `${expName?.name}-participant-export-${new Date().toISOString().split("T")[0]}.xlsx`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
16
|
ctx.set(
|
|
28
17
|
"Content-Type",
|
|
29
18
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
@@ -32,24 +21,16 @@ module.exports = ({ strapi }) => ({
|
|
|
32
21
|
|
|
33
22
|
ctx.body = buffer;
|
|
34
23
|
} else {
|
|
35
|
-
const data = await exportService.exportData(
|
|
24
|
+
const {data, filename} = await exportService.exportData(
|
|
36
25
|
"json",
|
|
37
26
|
contentType,
|
|
38
27
|
filters,
|
|
39
28
|
mode
|
|
40
29
|
);
|
|
41
|
-
|
|
42
|
-
const filename = `${
|
|
43
|
-
contentType?.replace("api::", "") || "strapi"
|
|
44
|
-
}-export-${new Date().toISOString().split("T")[0]}.json`;
|
|
45
|
-
|
|
46
30
|
ctx.set("Content-Type", "application/json");
|
|
47
31
|
ctx.set("Content-Disposition", `attachment; filename="${filename}"`);
|
|
48
32
|
|
|
49
|
-
ctx.body = JSON.stringify(
|
|
50
|
-
filename: filename,
|
|
51
|
-
data: data,
|
|
52
|
-
}, null, 2);
|
|
33
|
+
ctx.body = JSON.stringify(data, null, 2);
|
|
53
34
|
}
|
|
54
35
|
} catch (error) {
|
|
55
36
|
strapi.log.error("Export error:", error);
|
|
@@ -64,7 +45,7 @@ module.exports = ({ strapi }) => ({
|
|
|
64
45
|
.plugin("export-import-clsx")
|
|
65
46
|
.service("export-service");
|
|
66
47
|
|
|
67
|
-
const buffer = await exportService.exportSingleEntry(contentType, id);
|
|
48
|
+
const {buffer, filename} = await exportService.exportSingleEntry(contentType, id);
|
|
68
49
|
|
|
69
50
|
ctx.set(
|
|
70
51
|
"Content-Type",
|
|
@@ -72,9 +53,7 @@ module.exports = ({ strapi }) => ({
|
|
|
72
53
|
);
|
|
73
54
|
ctx.set(
|
|
74
55
|
"Content-Disposition",
|
|
75
|
-
`attachment; filename="
|
|
76
|
-
new Date().toISOString().split("T")[0]
|
|
77
|
-
}.xlsx"`
|
|
56
|
+
`attachment; filename="${filename}"`
|
|
78
57
|
);
|
|
79
58
|
|
|
80
59
|
ctx.body = buffer;
|
|
@@ -136,12 +136,12 @@ module.exports = ({ strapi }) => ({
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
if (format === "excel" && mode === "participant") {
|
|
139
|
-
return this.convertExperienceParticipantsToExcel(entries[0]);
|
|
139
|
+
return { buffer: this.convertExperienceParticipantsToExcel(entries[0]), filename: `${entries[0].name}-participants-export.xlsx` };
|
|
140
140
|
} else if (format === "excel") {
|
|
141
|
-
return this.convertToExcel(exportData.data);
|
|
141
|
+
return { buffer: this.convertToExcel(exportData.data), filename: `${contentType.split(".")[1]}-export${new Date().toISOString().split("T")[0]}.xlsx` };
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
return exportData;
|
|
144
|
+
return { data: exportData, filename: `${contentType.split(".")[1]}-export${new Date().toISOString().split("T")[0]}.json`};
|
|
145
145
|
},
|
|
146
146
|
|
|
147
147
|
getSearchableFields(contentTypeSchema) {
|