@upsnap/strapi 1.0.9 → 1.0.11

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.
@@ -1,29 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const bootstrap = ({ strapi }) => {
4
- };
5
- const destroy = ({ strapi }) => {
6
- };
7
- const register = ({ strapi }) => {
8
- };
9
- const config = {
10
- default: {},
11
- validator() {
12
- }
13
- };
14
- const contentTypes = {};
15
- const controller = ({ strapi }) => ({
16
- index(ctx) {
17
- ctx.body = strapi.plugin("upsnap").service("service").getWelcomeMessage();
18
- }
19
- });
20
3
  const BACKEND_URL = "https://api.upsnap.ai/v1";
21
4
  const LIGHTHOUSE_CHECKS = ["performance", "accessibility", "bestPractices", "seo", "pwa"];
22
- const service = ({ strapi }) => ({
5
+ const version = "1.0.11";
6
+ const repository = { "type": "git", "url": "https://github.com/Appfoster/upsnap-strapi" };
7
+ const keywords = [];
8
+ const type = "commonjs";
9
+ const exports$1 = { "./package.json": "./package.json", "./strapi-admin": { "types": "./dist/admin/src/index.d.ts", "source": "./admin/src/index.ts", "import": "./dist/admin/index.mjs", "require": "./dist/admin/index.js", "default": "./dist/admin/index.js" }, "./strapi-server": { "types": "./dist/server/src/index.d.ts", "source": "./server/src/index.ts", "import": "./dist/server/index.mjs", "require": "./dist/server/index.js", "default": "./dist/server/index.js" } };
10
+ const files = ["dist"];
11
+ const scripts = { "build": "strapi-plugin build", "watch": "strapi-plugin watch", "watch:link": "strapi-plugin watch:link", "verify": "strapi-plugin verify", "test:ts:front": "run -T tsc -p admin/tsconfig.json", "test:ts:back": "run -T tsc -p server/tsconfig.json" };
12
+ const dependencies = { "@strapi/design-system": "^2.0.0-rc.30", "@strapi/icons": "^2.0.0-rc.30", "axios": "^1.13.5", "react-apexcharts": "^2.0.1", "react-intl": "^6.6.0", "react-toastify": "^11.0.5" };
13
+ const devDependencies = { "@strapi/sdk-plugin": "^6.0.1", "@strapi/strapi": "^5.37.1", "@strapi/typescript-utils": "^5.37.1", "@types/react": "^19.2.14", "@types/react-dom": "^19.2.3", "prettier": "^3.8.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router-dom": "^6.30.3", "styled-components": "^6.3.11", "typescript": "^5.9.3" };
14
+ const peerDependencies = { "@strapi/sdk-plugin": "^5.4.0", "@strapi/strapi": "^5.0.0", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router-dom": "^6.30.3", "styled-components": "^6.3.11" };
15
+ const strapi = { "kind": "plugin", "name": "upsnap", "displayName": "Upsnap", "description": "Complete website health monitoring for Strapi, including uptime, SSL certificates, broken links, performance metrics, domain health, and mixed content issues." };
16
+ const name = "@upsnap/strapi";
17
+ const description = "Complete website health monitoring for Strapi, including uptime, SSL certificates, broken links, performance metrics, domain health, and mixed content issues.";
18
+ const license = "MIT";
19
+ const author = "Upsnap <support@upsnap.ai>";
20
+ const packageJson = {
21
+ version,
22
+ repository,
23
+ keywords,
24
+ type,
25
+ exports: exports$1,
26
+ files,
27
+ scripts,
28
+ dependencies,
29
+ devDependencies,
30
+ peerDependencies,
31
+ strapi,
32
+ name,
33
+ description,
34
+ license,
35
+ author
36
+ };
37
+ const service = ({ strapi: strapi2 }) => ({
23
38
  getWelcomeMessage() {
24
39
  return "Welcome to Strapi 🚀";
25
40
  },
26
- settingsStore: strapi.store({
41
+ settingsStore: strapi2.store({
27
42
  type: "plugin",
28
43
  name: "upsnap",
29
44
  key: "settings"
@@ -61,11 +76,65 @@ const service = ({ strapi }) => ({
61
76
  data: await response.arrayBuffer(),
62
77
  headers: response.headers
63
78
  };
79
+ },
80
+ async trackInstallation() {
81
+ try {
82
+ const settings2 = await this.settingsStore.get();
83
+ if (settings2?.installationTracked) {
84
+ return;
85
+ }
86
+ const pluginVersion = packageJson.version;
87
+ const strapiVersion = strapi2.config.get("info.strapi");
88
+ const siteUrl = strapi2.config.get("server.url") || `http://${strapi2.config.get("server.host") || "localhost"}:${strapi2.config.get("server.port") || 1337}`;
89
+ const response = await this.makeBackendRequest(
90
+ "/installation-data",
91
+ {
92
+ method: "POST",
93
+ body: JSON.stringify({
94
+ platform: "strapi",
95
+ details: {
96
+ version: pluginVersion,
97
+ site_url: siteUrl,
98
+ strapi_version: strapiVersion
99
+ }
100
+ })
101
+ },
102
+ true
103
+ );
104
+ if (response?.status === "success") {
105
+ await this.settingsStore.set({
106
+ value: {
107
+ ...settings2,
108
+ installationTracked: true
109
+ }
110
+ });
111
+ }
112
+ } catch (error) {
113
+ console.log("UpSnap: Failed to track installation data ", error);
114
+ }
64
115
  }
65
116
  });
66
- const settings = ({ strapi }) => ({
117
+ const bootstrap = async ({ strapi: strapi2 }) => {
118
+ await service({ strapi: strapi2 }).trackInstallation();
119
+ };
120
+ const destroy = ({ strapi: strapi2 }) => {
121
+ };
122
+ const register = ({ strapi: strapi2 }) => {
123
+ };
124
+ const config = {
125
+ default: {},
126
+ validator() {
127
+ }
128
+ };
129
+ const contentTypes = {};
130
+ const controller = ({ strapi: strapi2 }) => ({
131
+ index(ctx) {
132
+ ctx.body = strapi2.plugin("upsnap").service("service").getWelcomeMessage();
133
+ }
134
+ });
135
+ const settings = ({ strapi: strapi2 }) => ({
67
136
  async get(ctx) {
68
- const settings2 = await service({ strapi }).settingsStore.get();
137
+ const settings2 = await service({ strapi: strapi2 }).settingsStore.get();
69
138
  ctx.body = {
70
139
  token: settings2?.token ?? null,
71
140
  primaryMonitorId: settings2?.primaryMonitorId ?? null
@@ -74,7 +143,7 @@ const settings = ({ strapi }) => ({
74
143
  async set(ctx) {
75
144
  const { token, logOut } = ctx.request.body;
76
145
  if (!logOut) {
77
- const isValidData = await service({ strapi }).makeBackendRequest("/tokens/validate", {
146
+ const isValidData = await service({ strapi: strapi2 }).makeBackendRequest("/tokens/validate", {
78
147
  method: "POST",
79
148
  body: JSON.stringify({ token })
80
149
  }, true);
@@ -83,7 +152,7 @@ const settings = ({ strapi }) => ({
83
152
  return;
84
153
  }
85
154
  }
86
- const store = service({ strapi }).settingsStore;
155
+ const store = service({ strapi: strapi2 }).settingsStore;
87
156
  const current = await store.get() || {};
88
157
  await store.set({
89
158
  value: {
@@ -95,7 +164,7 @@ const settings = ({ strapi }) => ({
95
164
  },
96
165
  async setPrimaryMonitorId(ctx) {
97
166
  const { monitorId } = ctx.request.body;
98
- const store = service({ strapi }).settingsStore;
167
+ const store = service({ strapi: strapi2 }).settingsStore;
99
168
  const current = await store.get() || {};
100
169
  await store.set({
101
170
  value: {
@@ -106,7 +175,7 @@ const settings = ({ strapi }) => ({
106
175
  ctx.body = { ok: true };
107
176
  },
108
177
  async getPrimaryMonitorId(ctx) {
109
- const settings2 = await service({ strapi }).settingsStore.get();
178
+ const settings2 = await service({ strapi: strapi2 }).settingsStore.get();
110
179
  ctx.body = { primaryMonitorId: settings2?.primaryMonitorId };
111
180
  }
112
181
  });
@@ -334,10 +403,10 @@ function buildBrokenLinksErrorResponse(raw) {
334
403
  data: raw
335
404
  };
336
405
  }
337
- const monitor = ({ strapi }) => ({
406
+ const monitor = ({ strapi: strapi2 }) => ({
338
407
  async getById(ctx) {
339
408
  const monitorId = ctx.params.id;
340
- const token = await service({ strapi }).getToken();
409
+ const token = await service({ strapi: strapi2 }).getToken();
341
410
  const monitorResponse = await fetch(`${BACKEND_URL}/user/monitors/${monitorId}`, {
342
411
  method: "GET",
343
412
  headers: {
@@ -349,7 +418,7 @@ const monitor = ({ strapi }) => ({
349
418
  ctx.body = { monitor: monitor2 };
350
419
  },
351
420
  async get(ctx) {
352
- const monitorsData = await service({ strapi }).makeBackendRequest(
421
+ const monitorsData = await service({ strapi: strapi2 }).makeBackendRequest(
353
422
  `/user/monitors`,
354
423
  {
355
424
  method: "GET"
@@ -360,7 +429,7 @@ const monitor = ({ strapi }) => ({
360
429
  async getMonitorUptimeStats(ctx) {
361
430
  const monitorId = ctx.params.id;
362
431
  const { region } = ctx.query;
363
- const uptimeStatsData = await service({ strapi }).makeBackendRequest(
432
+ const uptimeStatsData = await service({ strapi: strapi2 }).makeBackendRequest(
364
433
  `/user/monitors/${monitorId}/uptime-stats?uptime_stats_time_frames=day,week,month&region=${region}`,
365
434
  {
366
435
  method: "GET"
@@ -371,7 +440,7 @@ const monitor = ({ strapi }) => ({
371
440
  async getMonitorHistogram(ctx) {
372
441
  const monitorId = ctx.params.id;
373
442
  const { region } = ctx.query;
374
- const histogramData = await service({ strapi }).makeBackendRequest(
443
+ const histogramData = await service({ strapi: strapi2 }).makeBackendRequest(
375
444
  `/user/monitors/${monitorId}/histogram?region=${region}`,
376
445
  {
377
446
  method: "GET"
@@ -381,7 +450,7 @@ const monitor = ({ strapi }) => ({
381
450
  },
382
451
  async getHealthChecks(ctx) {
383
452
  const { monitorUrl } = ctx.request.body;
384
- const healthCheckData = await service({ strapi }).makeBackendRequest(`/healthcheck`, {
453
+ const healthCheckData = await service({ strapi: strapi2 }).makeBackendRequest(`/healthcheck`, {
385
454
  method: "POST",
386
455
  headers: {
387
456
  "X-Requested-From": "craft"
@@ -397,7 +466,7 @@ const monitor = ({ strapi }) => ({
397
466
  },
398
467
  async getUptimeHealthCheck(ctx) {
399
468
  const { monitorUrl } = ctx.request.body;
400
- const uptimeHealthCheckData = await service({ strapi }).makeBackendRequest(
469
+ const uptimeHealthCheckData = await service({ strapi: strapi2 }).makeBackendRequest(
401
470
  `/healthcheck`,
402
471
  {
403
472
  method: "POST",
@@ -422,7 +491,7 @@ const monitor = ({ strapi }) => ({
422
491
  },
423
492
  async getSslHealthCheck(ctx) {
424
493
  const { monitorUrl } = ctx.request.body;
425
- const sslHealthCheckData = await service({ strapi }).makeBackendRequest(`/healthcheck`, {
494
+ const sslHealthCheckData = await service({ strapi: strapi2 }).makeBackendRequest(`/healthcheck`, {
426
495
  method: "POST",
427
496
  headers: {
428
497
  "X-Requested-From": "craft"
@@ -444,7 +513,7 @@ const monitor = ({ strapi }) => ({
444
513
  },
445
514
  async getDomainHealthCheck(ctx) {
446
515
  const { monitorUrl } = ctx.request.body;
447
- const domainHealthCheckData = await service({ strapi }).makeBackendRequest(
516
+ const domainHealthCheckData = await service({ strapi: strapi2 }).makeBackendRequest(
448
517
  `/healthcheck`,
449
518
  {
450
519
  method: "POST",
@@ -469,7 +538,7 @@ const monitor = ({ strapi }) => ({
469
538
  },
470
539
  async getLighthouseHealthCheck(ctx) {
471
540
  const { monitorUrl, strategy } = ctx.request.body;
472
- const lighthouseHealthCheckData = await service({ strapi }).makeBackendRequest(
541
+ const lighthouseHealthCheckData = await service({ strapi: strapi2 }).makeBackendRequest(
473
542
  `/healthcheck`,
474
543
  {
475
544
  method: "POST",
@@ -499,7 +568,7 @@ const monitor = ({ strapi }) => ({
499
568
  },
500
569
  async getBrokenLinksHealthCheck(ctx) {
501
570
  const { monitorUrl } = ctx.request.body;
502
- const brokenLinksHealthCheckData = await service({ strapi }).makeBackendRequest(
571
+ const brokenLinksHealthCheckData = await service({ strapi: strapi2 }).makeBackendRequest(
503
572
  `/healthcheck`,
504
573
  {
505
574
  method: "POST",
@@ -528,7 +597,7 @@ const monitor = ({ strapi }) => ({
528
597
  },
529
598
  async getMixedContentHealthCheck(ctx) {
530
599
  const { monitorUrl } = ctx.request.body;
531
- const mixedContentHealthCheckData = await service({ strapi }).makeBackendRequest(
600
+ const mixedContentHealthCheckData = await service({ strapi: strapi2 }).makeBackendRequest(
532
601
  `/healthcheck`,
533
602
  {
534
603
  method: "POST",
@@ -547,7 +616,7 @@ const monitor = ({ strapi }) => ({
547
616
  async getMonitorResponseTime(ctx) {
548
617
  const monitorId = ctx.params.id;
549
618
  const { start, end, region } = ctx.query;
550
- const responseTimeData = await service({ strapi }).makeBackendRequest(
619
+ const responseTimeData = await service({ strapi: strapi2 }).makeBackendRequest(
551
620
  `/user/monitors/${monitorId}/response-time?start=${start}&end=${end}&region=${region || "default"}`,
552
621
  {
553
622
  method: "GET"
@@ -557,7 +626,7 @@ const monitor = ({ strapi }) => ({
557
626
  },
558
627
  async getMonitorIncidents(ctx) {
559
628
  const monitorId = ctx.params.id;
560
- const incidentsData = await service({ strapi }).makeBackendRequest(
629
+ const incidentsData = await service({ strapi: strapi2 }).makeBackendRequest(
561
630
  `/user/monitors/incidents?monitorId=${monitorId}&page=1&page_size=20&time_range=7D`,
562
631
  {
563
632
  method: "GET"
@@ -567,7 +636,7 @@ const monitor = ({ strapi }) => ({
567
636
  },
568
637
  async getMonitorSettings(ctx) {
569
638
  const monitorId = ctx.params.id;
570
- const monitorSettingsData = await service({ strapi }).makeBackendRequest(
639
+ const monitorSettingsData = await service({ strapi: strapi2 }).makeBackendRequest(
571
640
  `/user/monitors/settings?id=${monitorId}`,
572
641
  {
573
642
  method: "GET"
@@ -577,7 +646,7 @@ const monitor = ({ strapi }) => ({
577
646
  },
578
647
  async createMonitor(ctx) {
579
648
  const { ...data } = ctx.request.body;
580
- const monitorsData = await service({ strapi }).makeBackendRequest(`/user/monitors`, {
649
+ const monitorsData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/monitors`, {
581
650
  method: "POST",
582
651
  body: JSON.stringify(data)
583
652
  });
@@ -586,7 +655,7 @@ const monitor = ({ strapi }) => ({
586
655
  async updateMonitor(ctx) {
587
656
  const monitorId = ctx.params.id;
588
657
  const { ...data } = ctx.request.body;
589
- const monitorsData = await service({ strapi }).makeBackendRequest(
658
+ const monitorsData = await service({ strapi: strapi2 }).makeBackendRequest(
590
659
  `/user/monitors/${monitorId}`,
591
660
  {
592
661
  method: "PUT",
@@ -597,7 +666,7 @@ const monitor = ({ strapi }) => ({
597
666
  },
598
667
  async deleteMonitor(ctx) {
599
668
  const monitorId = ctx.params.id;
600
- const monitorsData = await service({ strapi }).makeBackendRequest(
669
+ const monitorsData = await service({ strapi: strapi2 }).makeBackendRequest(
601
670
  `/user/monitors/${monitorId}`,
602
671
  {
603
672
  method: "DELETE"
@@ -607,7 +676,7 @@ const monitor = ({ strapi }) => ({
607
676
  },
608
677
  async deleteMonitors(ctx) {
609
678
  const { monitorIds } = ctx.request.body;
610
- const monitorsData = await service({ strapi }).makeBackendRequest(`/user/monitors`, {
679
+ const monitorsData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/monitors`, {
611
680
  method: "PATCH",
612
681
  body: JSON.stringify({ ids: monitorIds, action: "delete" })
613
682
  });
@@ -642,7 +711,7 @@ const monitor = ({ strapi }) => ({
642
711
  if (search) queryParams.set("search", search);
643
712
  if (sortBy) queryParams.set("sort_by", sortBy);
644
713
  if (sortOrder) queryParams.set("sort_order", sortOrder);
645
- const incidentsData = await service({ strapi }).makeBackendRequest(
714
+ const incidentsData = await service({ strapi: strapi2 }).makeBackendRequest(
646
715
  `/user/monitors/incidents?${queryParams.toString()}`,
647
716
  {
648
717
  method: "GET"
@@ -652,20 +721,20 @@ const monitor = ({ strapi }) => ({
652
721
  },
653
722
  async exportIncidents(ctx) {
654
723
  try {
655
- const { monitorId, region, type, start_time, end_time, search, file_type } = ctx.request.body;
724
+ const { monitorId, region, type: type2, start_time, end_time, search, file_type } = ctx.request.body;
656
725
  if (!monitorId) {
657
726
  ctx.status = 400;
658
727
  ctx.body = { error: "monitorId is required" };
659
728
  return;
660
729
  }
661
730
  const queryParams = new URLSearchParams();
662
- if (type) queryParams.set("type", type);
731
+ if (type2) queryParams.set("type", type2);
663
732
  if (start_time) queryParams.set("start_time", start_time);
664
733
  if (end_time) queryParams.set("end_time", end_time);
665
734
  if (search) queryParams.set("search", search);
666
735
  if (file_type) queryParams.set("file_type", file_type);
667
736
  if (region) queryParams.set("region", region);
668
- const response = await service({ strapi }).makeBackendRequest(
737
+ const response = await service({ strapi: strapi2 }).makeBackendRequest(
669
738
  `/user/monitors/${monitorId}/incidents/export?${queryParams.toString()}`,
670
739
  { method: "GET" }
671
740
  );
@@ -689,16 +758,16 @@ const monitor = ({ strapi }) => ({
689
758
  }
690
759
  }
691
760
  });
692
- const statusPage = ({ strapi }) => ({
761
+ const statusPage = ({ strapi: strapi2 }) => ({
693
762
  async getStatusPages(ctx) {
694
- const statusPagesData = await service({ strapi }).makeBackendRequest(`/user/status-pages`, {
763
+ const statusPagesData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/status-pages`, {
695
764
  method: "GET"
696
765
  });
697
766
  ctx.body = { statusPagesData };
698
767
  },
699
768
  async getStatusPagesByID(ctx) {
700
769
  const id = ctx.params.id;
701
- const statusPagesData = await service({ strapi }).makeBackendRequest(
770
+ const statusPagesData = await service({ strapi: strapi2 }).makeBackendRequest(
702
771
  `/user/status-pages/${id}`,
703
772
  {
704
773
  method: "GET"
@@ -707,16 +776,16 @@ const statusPage = ({ strapi }) => ({
707
776
  ctx.body = { statusPagesData };
708
777
  },
709
778
  async saveStatusPages(ctx) {
710
- const { name, monitor_ids, is_published } = ctx.request.body;
711
- const statusPagesData = await service({ strapi }).makeBackendRequest(`/user/status-pages`, {
779
+ const { name: name2, monitor_ids, is_published } = ctx.request.body;
780
+ const statusPagesData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/status-pages`, {
712
781
  method: "POST",
713
- body: JSON.stringify({ name, monitor_ids, is_published })
782
+ body: JSON.stringify({ name: name2, monitor_ids, is_published })
714
783
  });
715
784
  ctx.body = { statusPagesData };
716
785
  },
717
786
  async updateStatusPages(ctx) {
718
787
  const { id, ...data } = ctx.request.body;
719
- const statusPagesData = await service({ strapi }).makeBackendRequest(
788
+ const statusPagesData = await service({ strapi: strapi2 }).makeBackendRequest(
720
789
  `/user/status-pages/${id}`,
721
790
  {
722
791
  method: "PUT",
@@ -727,7 +796,7 @@ const statusPage = ({ strapi }) => ({
727
796
  },
728
797
  async resetLink(ctx) {
729
798
  const { id } = ctx.request.body;
730
- const statusPagesData = await service({ strapi }).makeBackendRequest(
799
+ const statusPagesData = await service({ strapi: strapi2 }).makeBackendRequest(
731
800
  `/user/status-pages/${id}/reset`,
732
801
  {
733
802
  method: "POST"
@@ -737,7 +806,7 @@ const statusPage = ({ strapi }) => ({
737
806
  },
738
807
  async deleteStatusPages(ctx) {
739
808
  const id = ctx.params.id;
740
- const statusPagesData = await service({ strapi }).makeBackendRequest(
809
+ const statusPagesData = await service({ strapi: strapi2 }).makeBackendRequest(
741
810
  `/user/status-pages/${id}`,
742
811
  {
743
812
  method: "DELETE"
@@ -746,17 +815,17 @@ const statusPage = ({ strapi }) => ({
746
815
  ctx.body = { statusPagesData };
747
816
  }
748
817
  });
749
- const regions = ({ strapi }) => ({
818
+ const regions = ({ strapi: strapi2 }) => ({
750
819
  async getRegions(ctx) {
751
- const regionsData = await service({ strapi }).makeBackendRequest(`/regions`, {
820
+ const regionsData = await service({ strapi: strapi2 }).makeBackendRequest(`/regions`, {
752
821
  method: "GET"
753
822
  });
754
823
  ctx.body = { regionsData };
755
824
  }
756
825
  });
757
- const userDetailsService = ({ strapi }) => ({
826
+ const userDetailsService = ({ strapi: strapi2 }) => ({
758
827
  async createUserApiToken(sessionToken) {
759
- const apiTokens = await service({ strapi }).makeBackendRequest(
828
+ const apiTokens = await service({ strapi: strapi2 }).makeBackendRequest(
760
829
  `/tokens/generate`,
761
830
  {
762
831
  method: "POST",
@@ -776,7 +845,7 @@ const userDetailsService = ({ strapi }) => ({
776
845
  return null;
777
846
  },
778
847
  async getUserApiToken(sessionToken) {
779
- const apiTokens = await service({ strapi }).makeBackendRequest(
848
+ const apiTokens = await service({ strapi: strapi2 }).makeBackendRequest(
780
849
  `/tokens`,
781
850
  {
782
851
  method: "GET"
@@ -845,7 +914,7 @@ const userDetailsService = ({ strapi }) => ({
845
914
  }
846
915
  }
847
916
  };
848
- const monitorsData = await service({ strapi }).makeBackendRequest(`/user/monitors`, {
917
+ const monitorsData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/monitors`, {
849
918
  method: "POST",
850
919
  body: JSON.stringify(payload)
851
920
  }, true, apiToken);
@@ -860,9 +929,9 @@ const userDetailsService = ({ strapi }) => ({
860
929
  }
861
930
  }
862
931
  });
863
- const userDetails = ({ strapi }) => ({
932
+ const userDetails = ({ strapi: strapi2 }) => ({
864
933
  async getUserDetails(ctx) {
865
- const userDetailsData = await service({ strapi }).makeBackendRequest(`/user/details`, {
934
+ const userDetailsData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/details`, {
866
935
  method: "GET"
867
936
  });
868
937
  ctx.body = { userDetailsData };
@@ -870,7 +939,7 @@ const userDetails = ({ strapi }) => ({
870
939
  async signUp(ctx) {
871
940
  try {
872
941
  const { email, password, source, site_url, fullName } = ctx.request.body;
873
- const registerData = await service({ strapi }).makeBackendRequest(
942
+ const registerData = await service({ strapi: strapi2 }).makeBackendRequest(
874
943
  `/user/register`,
875
944
  {
876
945
  method: "POST",
@@ -884,13 +953,13 @@ const userDetails = ({ strapi }) => ({
884
953
  true
885
954
  );
886
955
  if (registerData?.data?.token) {
887
- const apiToken = await userDetailsService({ strapi }).getUserApiToken(registerData?.data?.token);
888
- const monitorId = await userDetailsService({ strapi }).createInitialMonitor(site_url, apiToken);
956
+ const apiToken = await userDetailsService({ strapi: strapi2 }).getUserApiToken(registerData?.data?.token);
957
+ const monitorId = await userDetailsService({ strapi: strapi2 }).createInitialMonitor(site_url, apiToken);
889
958
  if (!apiToken || !monitorId) {
890
959
  ctx.body = { ok: false, message: "Error creating API token or Monitor" };
891
960
  return;
892
961
  }
893
- const store = service({ strapi }).settingsStore;
962
+ const store = service({ strapi: strapi2 }).settingsStore;
894
963
  const current = await store.get() || {};
895
964
  await store.set({
896
965
  value: {
@@ -910,7 +979,7 @@ const userDetails = ({ strapi }) => ({
910
979
  async signIn(ctx) {
911
980
  try {
912
981
  const { email, password } = ctx.request.body;
913
- const loginData = await service({ strapi }).makeBackendRequest(
982
+ const loginData = await service({ strapi: strapi2 }).makeBackendRequest(
914
983
  `/user/login`,
915
984
  {
916
985
  method: "POST",
@@ -922,8 +991,8 @@ const userDetails = ({ strapi }) => ({
922
991
  true
923
992
  );
924
993
  if (loginData?.data?.token) {
925
- const apiToken = await userDetailsService({ strapi }).getUserApiToken(loginData?.data?.token);
926
- const store = service({ strapi }).settingsStore;
994
+ const apiToken = await userDetailsService({ strapi: strapi2 }).getUserApiToken(loginData?.data?.token);
995
+ const store = service({ strapi: strapi2 }).settingsStore;
927
996
  const current = await store.get() || {};
928
997
  await store.set({
929
998
  value: {
@@ -942,7 +1011,7 @@ const userDetails = ({ strapi }) => ({
942
1011
  async forgotPassword(ctx) {
943
1012
  try {
944
1013
  const { email } = ctx.request.body;
945
- const forgotPasswordData = await service({ strapi }).makeBackendRequest(
1014
+ const forgotPasswordData = await service({ strapi: strapi2 }).makeBackendRequest(
946
1015
  `/user/forgot-password`,
947
1016
  {
948
1017
  method: "POST",
@@ -962,9 +1031,9 @@ const userDetails = ({ strapi }) => ({
962
1031
  }
963
1032
  }
964
1033
  });
965
- const notificationChannels = ({ strapi }) => ({
1034
+ const notificationChannels = ({ strapi: strapi2 }) => ({
966
1035
  async getNotificationChannels(ctx) {
967
- const notificationChannelsData = await service({ strapi }).makeBackendRequest(
1036
+ const notificationChannelsData = await service({ strapi: strapi2 }).makeBackendRequest(
968
1037
  `/user/integrations`,
969
1038
  {
970
1039
  method: "GET"
@@ -974,7 +1043,7 @@ const notificationChannels = ({ strapi }) => ({
974
1043
  },
975
1044
  async createNotificationChannel(ctx) {
976
1045
  const { ...data } = ctx.request.body;
977
- const notificationChannelsData = await service({ strapi }).makeBackendRequest(
1046
+ const notificationChannelsData = await service({ strapi: strapi2 }).makeBackendRequest(
978
1047
  `/user/integrations`,
979
1048
  {
980
1049
  method: "POST",
@@ -984,7 +1053,7 @@ const notificationChannels = ({ strapi }) => ({
984
1053
  ctx.body = { notificationChannelsData };
985
1054
  },
986
1055
  async getSupportedIntegrations(ctx) {
987
- const supportedIntegrationsData = await service({ strapi }).makeBackendRequest(
1056
+ const supportedIntegrationsData = await service({ strapi: strapi2 }).makeBackendRequest(
988
1057
  `/integrations/supported`,
989
1058
  {
990
1059
  method: "GET"
@@ -994,7 +1063,7 @@ const notificationChannels = ({ strapi }) => ({
994
1063
  },
995
1064
  async testNotificationChannel(ctx) {
996
1065
  const { id } = ctx.params;
997
- const testResult = await service({ strapi }).makeBackendRequest(
1066
+ const testResult = await service({ strapi: strapi2 }).makeBackendRequest(
998
1067
  `/user/integrations/${id}/test`,
999
1068
  {
1000
1069
  method: "POST"
@@ -1005,7 +1074,7 @@ const notificationChannels = ({ strapi }) => ({
1005
1074
  async updateNotificationChannel(ctx) {
1006
1075
  const { id } = ctx.params;
1007
1076
  const { ...data } = ctx.request.body;
1008
- const updatedChannel = await service({ strapi }).makeBackendRequest(
1077
+ const updatedChannel = await service({ strapi: strapi2 }).makeBackendRequest(
1009
1078
  `/user/integrations/${id}`,
1010
1079
  {
1011
1080
  method: "PUT",
@@ -1016,12 +1085,65 @@ const notificationChannels = ({ strapi }) => ({
1016
1085
  },
1017
1086
  async deleteNotificationChannel(ctx) {
1018
1087
  const { id } = ctx.params;
1019
- const deleteResult = await service({ strapi }).makeBackendRequest(`/user/integrations/${id}`, {
1088
+ const deleteResult = await service({ strapi: strapi2 }).makeBackendRequest(`/user/integrations/${id}`, {
1020
1089
  method: "DELETE"
1021
1090
  });
1022
1091
  ctx.body = { deleteResult };
1023
1092
  }
1024
1093
  });
1094
+ const tags = ({ strapi: strapi2 }) => ({
1095
+ async getTags(ctx) {
1096
+ const tagsData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/tags`, {
1097
+ method: "GET"
1098
+ });
1099
+ ctx.body = { tagsData };
1100
+ },
1101
+ async getTagsByID(ctx) {
1102
+ const id = ctx.params.id;
1103
+ const tagsData = await service({ strapi: strapi2 }).makeBackendRequest(
1104
+ `/user/tags/${id}`,
1105
+ {
1106
+ method: "GET"
1107
+ }
1108
+ );
1109
+ ctx.body = { tagsData };
1110
+ },
1111
+ async createTag(ctx) {
1112
+ const { name: name2, color } = ctx.request.body;
1113
+ const tagsData = await service({ strapi: strapi2 }).makeBackendRequest(`/user/tags`, {
1114
+ method: "POST",
1115
+ body: JSON.stringify({ name: name2, color })
1116
+ });
1117
+ ctx.body = { tagsData };
1118
+ },
1119
+ async updateTags(ctx) {
1120
+ const id = ctx.params.id;
1121
+ const { ...data } = ctx.request.body;
1122
+ if (!id) {
1123
+ ctx.status = 400;
1124
+ ctx.body = { error: "Tag ID is required" };
1125
+ return;
1126
+ }
1127
+ const tagsData = await service({ strapi: strapi2 }).makeBackendRequest(
1128
+ `/user/tags/${id}`,
1129
+ {
1130
+ method: "PUT",
1131
+ body: JSON.stringify(data)
1132
+ }
1133
+ );
1134
+ ctx.body = { tagsData };
1135
+ },
1136
+ async deleteTags(ctx) {
1137
+ const id = ctx.params.id;
1138
+ const tagsData = await service({ strapi: strapi2 }).makeBackendRequest(
1139
+ `/user/tags/${id}`,
1140
+ {
1141
+ method: "DELETE"
1142
+ }
1143
+ );
1144
+ ctx.body = { tagsData };
1145
+ }
1146
+ });
1025
1147
  const controllers = {
1026
1148
  controller,
1027
1149
  settings,
@@ -1029,7 +1151,8 @@ const controllers = {
1029
1151
  statusPage,
1030
1152
  regions,
1031
1153
  userDetails,
1032
- notificationChannels
1154
+ notificationChannels,
1155
+ tags
1033
1156
  };
1034
1157
  const middlewares = {};
1035
1158
  const policies = {};
@@ -1405,6 +1528,51 @@ const routes = {
1405
1528
  policies: [],
1406
1529
  auth: false
1407
1530
  }
1531
+ },
1532
+ {
1533
+ method: "GET",
1534
+ path: "/tags",
1535
+ handler: "tags.getTags",
1536
+ config: {
1537
+ policies: [],
1538
+ auth: false
1539
+ }
1540
+ },
1541
+ {
1542
+ method: "GET",
1543
+ path: "/tags/:id",
1544
+ handler: "tags.getTagsByID",
1545
+ config: {
1546
+ policies: [],
1547
+ auth: false
1548
+ }
1549
+ },
1550
+ {
1551
+ method: "POST",
1552
+ path: "/tags",
1553
+ handler: "tags.createTag",
1554
+ config: {
1555
+ policies: [],
1556
+ auth: false
1557
+ }
1558
+ },
1559
+ {
1560
+ method: "PUT",
1561
+ path: "/tags/:id",
1562
+ handler: "tags.updateTags",
1563
+ config: {
1564
+ policies: [],
1565
+ auth: false
1566
+ }
1567
+ },
1568
+ {
1569
+ method: "DELETE",
1570
+ path: "/tags/:id",
1571
+ handler: "tags.deleteTags",
1572
+ config: {
1573
+ policies: [],
1574
+ auth: false
1575
+ }
1408
1576
  }
1409
1577
  ]
1410
1578
  }