@upsnap/strapi 1.0.8 → 1.0.9
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/dist/admin/App-CEvUaGYv.js +11887 -0
- package/dist/admin/App-CZcDoGMB.mjs +11882 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +109 -1
- package/dist/server/index.mjs +109 -1
- package/dist/server/src/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/admin/App-BWxGckE8.js +0 -11019
- package/dist/admin/App-DJivreSE.mjs +0 -11014
package/dist/admin/index.js
CHANGED
|
@@ -38,7 +38,7 @@ const index = {
|
|
|
38
38
|
defaultMessage: PLUGIN_ID.slice(0, 1).toUpperCase() + PLUGIN_ID.slice(1)
|
|
39
39
|
},
|
|
40
40
|
Component: async () => {
|
|
41
|
-
const { App } = await Promise.resolve().then(() => require("./App-
|
|
41
|
+
const { App } = await Promise.resolve().then(() => require("./App-CEvUaGYv.js"));
|
|
42
42
|
return App;
|
|
43
43
|
}
|
|
44
44
|
});
|
package/dist/admin/index.mjs
CHANGED
|
@@ -36,7 +36,7 @@ const index = {
|
|
|
36
36
|
defaultMessage: PLUGIN_ID.slice(0, 1).toUpperCase() + PLUGIN_ID.slice(1)
|
|
37
37
|
},
|
|
38
38
|
Component: async () => {
|
|
39
|
-
const { App } = await import("./App-
|
|
39
|
+
const { App } = await import("./App-CZcDoGMB.mjs");
|
|
40
40
|
return App;
|
|
41
41
|
}
|
|
42
42
|
});
|
package/dist/server/index.js
CHANGED
|
@@ -45,7 +45,22 @@ const service = ({ strapi }) => ({
|
|
|
45
45
|
...options.headers || {}
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
|
|
48
|
+
const contentType = response.headers.get("content-type") || "";
|
|
49
|
+
if (contentType.includes("application/json")) {
|
|
50
|
+
return await response.json();
|
|
51
|
+
}
|
|
52
|
+
if (contentType.includes("text/csv")) {
|
|
53
|
+
return {
|
|
54
|
+
type: "csv",
|
|
55
|
+
data: await response.text(),
|
|
56
|
+
headers: response.headers
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
type: "blob",
|
|
61
|
+
data: await response.arrayBuffer(),
|
|
62
|
+
headers: response.headers
|
|
63
|
+
};
|
|
49
64
|
}
|
|
50
65
|
});
|
|
51
66
|
const settings = ({ strapi }) => ({
|
|
@@ -597,6 +612,81 @@ const monitor = ({ strapi }) => ({
|
|
|
597
612
|
body: JSON.stringify({ ids: monitorIds, action: "delete" })
|
|
598
613
|
});
|
|
599
614
|
ctx.body = { monitorsData };
|
|
615
|
+
},
|
|
616
|
+
async getAllIncidents(ctx) {
|
|
617
|
+
const { ...params } = ctx.request.body;
|
|
618
|
+
const {
|
|
619
|
+
monitorId,
|
|
620
|
+
timeRange,
|
|
621
|
+
page,
|
|
622
|
+
pageSize,
|
|
623
|
+
checkType,
|
|
624
|
+
region,
|
|
625
|
+
search,
|
|
626
|
+
sortBy,
|
|
627
|
+
sortOrder
|
|
628
|
+
} = params;
|
|
629
|
+
if (!monitorId) {
|
|
630
|
+
ctx.status = 400;
|
|
631
|
+
ctx.body = { error: "monitorId is required" };
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
const queryParams = new URLSearchParams();
|
|
635
|
+
queryParams.set("monitorId", monitorId);
|
|
636
|
+
if (timeRange) queryParams.set("time_range", timeRange);
|
|
637
|
+
if (page !== void 0) queryParams.set("page", page.toString());
|
|
638
|
+
if (pageSize !== void 0)
|
|
639
|
+
queryParams.set("page_size", pageSize.toString());
|
|
640
|
+
if (checkType) queryParams.set("check_type", checkType);
|
|
641
|
+
if (region) queryParams.set("region", region);
|
|
642
|
+
if (search) queryParams.set("search", search);
|
|
643
|
+
if (sortBy) queryParams.set("sort_by", sortBy);
|
|
644
|
+
if (sortOrder) queryParams.set("sort_order", sortOrder);
|
|
645
|
+
const incidentsData = await service({ strapi }).makeBackendRequest(
|
|
646
|
+
`/user/monitors/incidents?${queryParams.toString()}`,
|
|
647
|
+
{
|
|
648
|
+
method: "GET"
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
ctx.body = { incidentsData };
|
|
652
|
+
},
|
|
653
|
+
async exportIncidents(ctx) {
|
|
654
|
+
try {
|
|
655
|
+
const { monitorId, region, type, start_time, end_time, search, file_type } = ctx.request.body;
|
|
656
|
+
if (!monitorId) {
|
|
657
|
+
ctx.status = 400;
|
|
658
|
+
ctx.body = { error: "monitorId is required" };
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const queryParams = new URLSearchParams();
|
|
662
|
+
if (type) queryParams.set("type", type);
|
|
663
|
+
if (start_time) queryParams.set("start_time", start_time);
|
|
664
|
+
if (end_time) queryParams.set("end_time", end_time);
|
|
665
|
+
if (search) queryParams.set("search", search);
|
|
666
|
+
if (file_type) queryParams.set("file_type", file_type);
|
|
667
|
+
if (region) queryParams.set("region", region);
|
|
668
|
+
const response = await service({ strapi }).makeBackendRequest(
|
|
669
|
+
`/user/monitors/${monitorId}/incidents/export?${queryParams.toString()}`,
|
|
670
|
+
{ method: "GET" }
|
|
671
|
+
);
|
|
672
|
+
if (!response?.type) {
|
|
673
|
+
ctx.body = response;
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const contentType = response.headers.get("content-type") || "application/octet-stream";
|
|
677
|
+
const disposition = response.headers.get("content-disposition") || `attachment; filename=incidents.${file_type === "excel" ? "xlsx" : file_type || "csv"}`;
|
|
678
|
+
ctx.set("Content-Type", contentType);
|
|
679
|
+
ctx.set("Content-Disposition", disposition);
|
|
680
|
+
if (response.type === "csv") {
|
|
681
|
+
ctx.body = response.data;
|
|
682
|
+
} else {
|
|
683
|
+
ctx.body = Buffer.from(response.data);
|
|
684
|
+
}
|
|
685
|
+
} catch (error) {
|
|
686
|
+
console.error("Error exporting incidents: ", error);
|
|
687
|
+
ctx.status = 500;
|
|
688
|
+
ctx.body = { error: "Failed to export incidents" };
|
|
689
|
+
}
|
|
600
690
|
}
|
|
601
691
|
});
|
|
602
692
|
const statusPage = ({ strapi }) => ({
|
|
@@ -1297,6 +1387,24 @@ const routes = {
|
|
|
1297
1387
|
policies: [],
|
|
1298
1388
|
auth: false
|
|
1299
1389
|
}
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
method: "POST",
|
|
1393
|
+
path: "/monitor/all-incidents",
|
|
1394
|
+
handler: "monitor.getAllIncidents",
|
|
1395
|
+
config: {
|
|
1396
|
+
policies: [],
|
|
1397
|
+
auth: false
|
|
1398
|
+
}
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
method: "POST",
|
|
1402
|
+
path: "/monitor/incidents/export",
|
|
1403
|
+
handler: "monitor.exportIncidents",
|
|
1404
|
+
config: {
|
|
1405
|
+
policies: [],
|
|
1406
|
+
auth: false
|
|
1407
|
+
}
|
|
1300
1408
|
}
|
|
1301
1409
|
]
|
|
1302
1410
|
}
|
package/dist/server/index.mjs
CHANGED
|
@@ -43,7 +43,22 @@ const service = ({ strapi }) => ({
|
|
|
43
43
|
...options.headers || {}
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
|
|
46
|
+
const contentType = response.headers.get("content-type") || "";
|
|
47
|
+
if (contentType.includes("application/json")) {
|
|
48
|
+
return await response.json();
|
|
49
|
+
}
|
|
50
|
+
if (contentType.includes("text/csv")) {
|
|
51
|
+
return {
|
|
52
|
+
type: "csv",
|
|
53
|
+
data: await response.text(),
|
|
54
|
+
headers: response.headers
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
type: "blob",
|
|
59
|
+
data: await response.arrayBuffer(),
|
|
60
|
+
headers: response.headers
|
|
61
|
+
};
|
|
47
62
|
}
|
|
48
63
|
});
|
|
49
64
|
const settings = ({ strapi }) => ({
|
|
@@ -595,6 +610,81 @@ const monitor = ({ strapi }) => ({
|
|
|
595
610
|
body: JSON.stringify({ ids: monitorIds, action: "delete" })
|
|
596
611
|
});
|
|
597
612
|
ctx.body = { monitorsData };
|
|
613
|
+
},
|
|
614
|
+
async getAllIncidents(ctx) {
|
|
615
|
+
const { ...params } = ctx.request.body;
|
|
616
|
+
const {
|
|
617
|
+
monitorId,
|
|
618
|
+
timeRange,
|
|
619
|
+
page,
|
|
620
|
+
pageSize,
|
|
621
|
+
checkType,
|
|
622
|
+
region,
|
|
623
|
+
search,
|
|
624
|
+
sortBy,
|
|
625
|
+
sortOrder
|
|
626
|
+
} = params;
|
|
627
|
+
if (!monitorId) {
|
|
628
|
+
ctx.status = 400;
|
|
629
|
+
ctx.body = { error: "monitorId is required" };
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
const queryParams = new URLSearchParams();
|
|
633
|
+
queryParams.set("monitorId", monitorId);
|
|
634
|
+
if (timeRange) queryParams.set("time_range", timeRange);
|
|
635
|
+
if (page !== void 0) queryParams.set("page", page.toString());
|
|
636
|
+
if (pageSize !== void 0)
|
|
637
|
+
queryParams.set("page_size", pageSize.toString());
|
|
638
|
+
if (checkType) queryParams.set("check_type", checkType);
|
|
639
|
+
if (region) queryParams.set("region", region);
|
|
640
|
+
if (search) queryParams.set("search", search);
|
|
641
|
+
if (sortBy) queryParams.set("sort_by", sortBy);
|
|
642
|
+
if (sortOrder) queryParams.set("sort_order", sortOrder);
|
|
643
|
+
const incidentsData = await service({ strapi }).makeBackendRequest(
|
|
644
|
+
`/user/monitors/incidents?${queryParams.toString()}`,
|
|
645
|
+
{
|
|
646
|
+
method: "GET"
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
ctx.body = { incidentsData };
|
|
650
|
+
},
|
|
651
|
+
async exportIncidents(ctx) {
|
|
652
|
+
try {
|
|
653
|
+
const { monitorId, region, type, start_time, end_time, search, file_type } = ctx.request.body;
|
|
654
|
+
if (!monitorId) {
|
|
655
|
+
ctx.status = 400;
|
|
656
|
+
ctx.body = { error: "monitorId is required" };
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
const queryParams = new URLSearchParams();
|
|
660
|
+
if (type) queryParams.set("type", type);
|
|
661
|
+
if (start_time) queryParams.set("start_time", start_time);
|
|
662
|
+
if (end_time) queryParams.set("end_time", end_time);
|
|
663
|
+
if (search) queryParams.set("search", search);
|
|
664
|
+
if (file_type) queryParams.set("file_type", file_type);
|
|
665
|
+
if (region) queryParams.set("region", region);
|
|
666
|
+
const response = await service({ strapi }).makeBackendRequest(
|
|
667
|
+
`/user/monitors/${monitorId}/incidents/export?${queryParams.toString()}`,
|
|
668
|
+
{ method: "GET" }
|
|
669
|
+
);
|
|
670
|
+
if (!response?.type) {
|
|
671
|
+
ctx.body = response;
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
const contentType = response.headers.get("content-type") || "application/octet-stream";
|
|
675
|
+
const disposition = response.headers.get("content-disposition") || `attachment; filename=incidents.${file_type === "excel" ? "xlsx" : file_type || "csv"}`;
|
|
676
|
+
ctx.set("Content-Type", contentType);
|
|
677
|
+
ctx.set("Content-Disposition", disposition);
|
|
678
|
+
if (response.type === "csv") {
|
|
679
|
+
ctx.body = response.data;
|
|
680
|
+
} else {
|
|
681
|
+
ctx.body = Buffer.from(response.data);
|
|
682
|
+
}
|
|
683
|
+
} catch (error) {
|
|
684
|
+
console.error("Error exporting incidents: ", error);
|
|
685
|
+
ctx.status = 500;
|
|
686
|
+
ctx.body = { error: "Failed to export incidents" };
|
|
687
|
+
}
|
|
598
688
|
}
|
|
599
689
|
});
|
|
600
690
|
const statusPage = ({ strapi }) => ({
|
|
@@ -1295,6 +1385,24 @@ const routes = {
|
|
|
1295
1385
|
policies: [],
|
|
1296
1386
|
auth: false
|
|
1297
1387
|
}
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
method: "POST",
|
|
1391
|
+
path: "/monitor/all-incidents",
|
|
1392
|
+
handler: "monitor.getAllIncidents",
|
|
1393
|
+
config: {
|
|
1394
|
+
policies: [],
|
|
1395
|
+
auth: false
|
|
1396
|
+
}
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
method: "POST",
|
|
1400
|
+
path: "/monitor/incidents/export",
|
|
1401
|
+
handler: "monitor.exportIncidents",
|
|
1402
|
+
config: {
|
|
1403
|
+
policies: [],
|
|
1404
|
+
auth: false
|
|
1405
|
+
}
|
|
1298
1406
|
}
|
|
1299
1407
|
]
|
|
1300
1408
|
}
|
|
@@ -47,6 +47,8 @@ declare const _default: {
|
|
|
47
47
|
updateMonitor(ctx: any): Promise<void>;
|
|
48
48
|
deleteMonitor(ctx: any): Promise<void>;
|
|
49
49
|
deleteMonitors(ctx: any): Promise<void>;
|
|
50
|
+
getAllIncidents(ctx: any): Promise<void>;
|
|
51
|
+
exportIncidents(ctx: any): Promise<void>;
|
|
50
52
|
};
|
|
51
53
|
statusPage: ({ strapi }: {
|
|
52
54
|
strapi: import('@strapi/types/dist/core').Strapi;
|
package/package.json
CHANGED