@upsnap/strapi 1.0.8 → 1.0.10

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.
@@ -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-BWxGckE8.js"));
41
+ const { App } = await Promise.resolve().then(() => require("./App-CH5fBeNI.js"));
42
42
  return App;
43
43
  }
44
44
  });
@@ -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-DJivreSE.mjs");
39
+ const { App } = await import("./App-BIxhBt5_.mjs");
40
40
  return App;
41
41
  }
42
42
  });
@@ -45,7 +45,22 @@ const service = ({ strapi }) => ({
45
45
  ...options.headers || {}
46
46
  }
47
47
  });
48
- return response.json();
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 }) => ({
@@ -932,6 +1022,59 @@ const notificationChannels = ({ strapi }) => ({
932
1022
  ctx.body = { deleteResult };
933
1023
  }
934
1024
  });
1025
+ const tags = ({ strapi }) => ({
1026
+ async getTags(ctx) {
1027
+ const tagsData = await service({ strapi }).makeBackendRequest(`/user/tags`, {
1028
+ method: "GET"
1029
+ });
1030
+ ctx.body = { tagsData };
1031
+ },
1032
+ async getTagsByID(ctx) {
1033
+ const id = ctx.params.id;
1034
+ const tagsData = await service({ strapi }).makeBackendRequest(
1035
+ `/user/tags/${id}`,
1036
+ {
1037
+ method: "GET"
1038
+ }
1039
+ );
1040
+ ctx.body = { tagsData };
1041
+ },
1042
+ async createTag(ctx) {
1043
+ const { name, color } = ctx.request.body;
1044
+ const tagsData = await service({ strapi }).makeBackendRequest(`/user/tags`, {
1045
+ method: "POST",
1046
+ body: JSON.stringify({ name, color })
1047
+ });
1048
+ ctx.body = { tagsData };
1049
+ },
1050
+ async updateTags(ctx) {
1051
+ const id = ctx.params.id;
1052
+ const { ...data } = ctx.request.body;
1053
+ if (!id) {
1054
+ ctx.status = 400;
1055
+ ctx.body = { error: "Tag ID is required" };
1056
+ return;
1057
+ }
1058
+ const tagsData = await service({ strapi }).makeBackendRequest(
1059
+ `/user/tags/${id}`,
1060
+ {
1061
+ method: "PUT",
1062
+ body: JSON.stringify(data)
1063
+ }
1064
+ );
1065
+ ctx.body = { tagsData };
1066
+ },
1067
+ async deleteTags(ctx) {
1068
+ const id = ctx.params.id;
1069
+ const tagsData = await service({ strapi }).makeBackendRequest(
1070
+ `/user/tags/${id}`,
1071
+ {
1072
+ method: "DELETE"
1073
+ }
1074
+ );
1075
+ ctx.body = { tagsData };
1076
+ }
1077
+ });
935
1078
  const controllers = {
936
1079
  controller,
937
1080
  settings,
@@ -939,7 +1082,8 @@ const controllers = {
939
1082
  statusPage,
940
1083
  regions,
941
1084
  userDetails,
942
- notificationChannels
1085
+ notificationChannels,
1086
+ tags
943
1087
  };
944
1088
  const middlewares = {};
945
1089
  const policies = {};
@@ -1297,6 +1441,69 @@ const routes = {
1297
1441
  policies: [],
1298
1442
  auth: false
1299
1443
  }
1444
+ },
1445
+ {
1446
+ method: "POST",
1447
+ path: "/monitor/all-incidents",
1448
+ handler: "monitor.getAllIncidents",
1449
+ config: {
1450
+ policies: [],
1451
+ auth: false
1452
+ }
1453
+ },
1454
+ {
1455
+ method: "POST",
1456
+ path: "/monitor/incidents/export",
1457
+ handler: "monitor.exportIncidents",
1458
+ config: {
1459
+ policies: [],
1460
+ auth: false
1461
+ }
1462
+ },
1463
+ {
1464
+ method: "GET",
1465
+ path: "/tags",
1466
+ handler: "tags.getTags",
1467
+ config: {
1468
+ policies: [],
1469
+ auth: false
1470
+ }
1471
+ },
1472
+ {
1473
+ method: "GET",
1474
+ path: "/tags/:id",
1475
+ handler: "tags.getTagsByID",
1476
+ config: {
1477
+ policies: [],
1478
+ auth: false
1479
+ }
1480
+ },
1481
+ {
1482
+ method: "POST",
1483
+ path: "/tags",
1484
+ handler: "tags.createTag",
1485
+ config: {
1486
+ policies: [],
1487
+ auth: false
1488
+ }
1489
+ },
1490
+ {
1491
+ method: "PUT",
1492
+ path: "/tags/:id",
1493
+ handler: "tags.updateTags",
1494
+ config: {
1495
+ policies: [],
1496
+ auth: false
1497
+ }
1498
+ },
1499
+ {
1500
+ method: "DELETE",
1501
+ path: "/tags/:id",
1502
+ handler: "tags.deleteTags",
1503
+ config: {
1504
+ policies: [],
1505
+ auth: false
1506
+ }
1300
1507
  }
1301
1508
  ]
1302
1509
  }
@@ -43,7 +43,22 @@ const service = ({ strapi }) => ({
43
43
  ...options.headers || {}
44
44
  }
45
45
  });
46
- return response.json();
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 }) => ({
@@ -930,6 +1020,59 @@ const notificationChannels = ({ strapi }) => ({
930
1020
  ctx.body = { deleteResult };
931
1021
  }
932
1022
  });
1023
+ const tags = ({ strapi }) => ({
1024
+ async getTags(ctx) {
1025
+ const tagsData = await service({ strapi }).makeBackendRequest(`/user/tags`, {
1026
+ method: "GET"
1027
+ });
1028
+ ctx.body = { tagsData };
1029
+ },
1030
+ async getTagsByID(ctx) {
1031
+ const id = ctx.params.id;
1032
+ const tagsData = await service({ strapi }).makeBackendRequest(
1033
+ `/user/tags/${id}`,
1034
+ {
1035
+ method: "GET"
1036
+ }
1037
+ );
1038
+ ctx.body = { tagsData };
1039
+ },
1040
+ async createTag(ctx) {
1041
+ const { name, color } = ctx.request.body;
1042
+ const tagsData = await service({ strapi }).makeBackendRequest(`/user/tags`, {
1043
+ method: "POST",
1044
+ body: JSON.stringify({ name, color })
1045
+ });
1046
+ ctx.body = { tagsData };
1047
+ },
1048
+ async updateTags(ctx) {
1049
+ const id = ctx.params.id;
1050
+ const { ...data } = ctx.request.body;
1051
+ if (!id) {
1052
+ ctx.status = 400;
1053
+ ctx.body = { error: "Tag ID is required" };
1054
+ return;
1055
+ }
1056
+ const tagsData = await service({ strapi }).makeBackendRequest(
1057
+ `/user/tags/${id}`,
1058
+ {
1059
+ method: "PUT",
1060
+ body: JSON.stringify(data)
1061
+ }
1062
+ );
1063
+ ctx.body = { tagsData };
1064
+ },
1065
+ async deleteTags(ctx) {
1066
+ const id = ctx.params.id;
1067
+ const tagsData = await service({ strapi }).makeBackendRequest(
1068
+ `/user/tags/${id}`,
1069
+ {
1070
+ method: "DELETE"
1071
+ }
1072
+ );
1073
+ ctx.body = { tagsData };
1074
+ }
1075
+ });
933
1076
  const controllers = {
934
1077
  controller,
935
1078
  settings,
@@ -937,7 +1080,8 @@ const controllers = {
937
1080
  statusPage,
938
1081
  regions,
939
1082
  userDetails,
940
- notificationChannels
1083
+ notificationChannels,
1084
+ tags
941
1085
  };
942
1086
  const middlewares = {};
943
1087
  const policies = {};
@@ -1295,6 +1439,69 @@ const routes = {
1295
1439
  policies: [],
1296
1440
  auth: false
1297
1441
  }
1442
+ },
1443
+ {
1444
+ method: "POST",
1445
+ path: "/monitor/all-incidents",
1446
+ handler: "monitor.getAllIncidents",
1447
+ config: {
1448
+ policies: [],
1449
+ auth: false
1450
+ }
1451
+ },
1452
+ {
1453
+ method: "POST",
1454
+ path: "/monitor/incidents/export",
1455
+ handler: "monitor.exportIncidents",
1456
+ config: {
1457
+ policies: [],
1458
+ auth: false
1459
+ }
1460
+ },
1461
+ {
1462
+ method: "GET",
1463
+ path: "/tags",
1464
+ handler: "tags.getTags",
1465
+ config: {
1466
+ policies: [],
1467
+ auth: false
1468
+ }
1469
+ },
1470
+ {
1471
+ method: "GET",
1472
+ path: "/tags/:id",
1473
+ handler: "tags.getTagsByID",
1474
+ config: {
1475
+ policies: [],
1476
+ auth: false
1477
+ }
1478
+ },
1479
+ {
1480
+ method: "POST",
1481
+ path: "/tags",
1482
+ handler: "tags.createTag",
1483
+ config: {
1484
+ policies: [],
1485
+ auth: false
1486
+ }
1487
+ },
1488
+ {
1489
+ method: "PUT",
1490
+ path: "/tags/:id",
1491
+ handler: "tags.updateTags",
1492
+ config: {
1493
+ policies: [],
1494
+ auth: false
1495
+ }
1496
+ },
1497
+ {
1498
+ method: "DELETE",
1499
+ path: "/tags/:id",
1500
+ handler: "tags.deleteTags",
1501
+ config: {
1502
+ policies: [],
1503
+ auth: false
1504
+ }
1298
1505
  }
1299
1506
  ]
1300
1507
  }
@@ -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;
@@ -89,6 +91,15 @@ declare const _default: {
89
91
  updateNotificationChannel(ctx: any): Promise<void>;
90
92
  deleteNotificationChannel(ctx: any): Promise<void>;
91
93
  };
94
+ tags: ({ strapi }: {
95
+ strapi: import('@strapi/types/dist/core').Strapi;
96
+ }) => {
97
+ getTags(ctx: any): Promise<void>;
98
+ getTagsByID(ctx: any): Promise<void>;
99
+ createTag(ctx: any): Promise<void>;
100
+ updateTags(ctx: any): Promise<void>;
101
+ deleteTags(ctx: any): Promise<void>;
102
+ };
92
103
  };
93
104
  routes: {
94
105
  admin: {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.8",
2
+ "version": "1.0.10",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "https://github.com/Appfoster/upsnap-strapi"