@mattisvensson/strapi-plugin-webatlas 0.13.0 → 0.14.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.
Files changed (184) hide show
  1. package/dist/admin/{ContentBox-D4PGQ8eh.js → ContentBox-CHwpYMiB.js} +1 -1
  2. package/dist/admin/{ContentBox-KyQN2KGV.mjs → ContentBox-CYnyB_5a.mjs} +1 -1
  3. package/dist/admin/{RoutePicker-CgndSXoF.mjs → RoutePicker-43YnYCpH.mjs} +1 -1
  4. package/dist/admin/{RoutePicker-CwoMMhf_.js → RoutePicker-D9zf-VdN.js} +1 -1
  5. package/dist/admin/{de-Cl0vM1wA.js → de-DolV3m7M.js} +64 -1
  6. package/dist/admin/{de-DWs5ckOd.mjs → de-Dt3jjL3h.mjs} +64 -1
  7. package/dist/admin/{en-CyhISGZi.mjs → en-CCRmKJEV.mjs} +63 -0
  8. package/dist/admin/{en-DSmtmPYk.js → en-jWdO5RMZ.js} +63 -0
  9. package/dist/admin/{index-uOC1Clyv.js → index-7iO5UsYI.js} +2 -2
  10. package/dist/admin/{index-Bv5Ri-ri.mjs → index-B2k8Pikg.mjs} +2 -2
  11. package/dist/admin/{index-Ctm4TBT5.mjs → index-CK4JyItR.mjs} +63 -8
  12. package/dist/admin/{index-BKhrfzjO.mjs → index-CMuhLgfi.mjs} +16 -11
  13. package/dist/admin/{index-BxGPKxr_.js → index-Ciem6YTr.js} +2 -2
  14. package/dist/admin/{index-FvaXwOH0.mjs → index-DGYmrx3f.mjs} +2 -2
  15. package/dist/admin/index-Ddnt9W-v.mjs +1025 -0
  16. package/dist/admin/{index-JBUU7dE6.js → index-DfG_hSMk.js} +60 -5
  17. package/dist/admin/{index-DTrsl_uN.js → index-DmOWQK6g.js} +12 -7
  18. package/dist/admin/index-dB79zyxi.js +1025 -0
  19. package/dist/admin/index.js +1 -1
  20. package/dist/admin/index.mjs +1 -1
  21. package/dist/admin/src/components/CMEditViewAside/NewPathInfo.d.ts +5 -0
  22. package/dist/admin/src/components/CMEditViewAside/OverrideCheckbox.d.ts +7 -0
  23. package/dist/admin/src/components/CMEditViewAside/Panel.d.ts +5 -0
  24. package/dist/admin/src/components/CMEditViewAside/PathInput.d.ts +12 -0
  25. package/dist/admin/src/components/CMEditViewAside/RouteStructure.d.ts +3 -0
  26. package/dist/admin/src/components/CMEditViewAside/UidPathDisplay.d.ts +4 -0
  27. package/dist/admin/src/components/CMEditViewAside/index.d.ts +3 -0
  28. package/dist/admin/src/components/Initializer.d.ts +5 -0
  29. package/dist/admin/src/components/PathInfo.d.ts +8 -0
  30. package/dist/admin/src/components/PluginIcon.d.ts +3 -0
  31. package/dist/admin/src/components/Tooltip.d.ts +3 -0
  32. package/dist/admin/src/components/UI/Center.d.ts +4 -0
  33. package/dist/admin/src/components/UI/EmptyBox.d.ts +5 -0
  34. package/dist/admin/src/components/UI/FullLoader.d.ts +3 -0
  35. package/dist/admin/src/components/UI/WarningBox.d.ts +4 -0
  36. package/dist/admin/src/components/UI/index.d.ts +5 -0
  37. package/dist/admin/src/components/customFields/RoutePicker.d.ts +25 -0
  38. package/dist/admin/src/components/modals/Delete.d.ts +7 -0
  39. package/dist/admin/src/components/modals/DiscardChanges.d.ts +3 -0
  40. package/dist/admin/src/components/modals/NavCreate.d.ts +1 -0
  41. package/dist/admin/src/components/modals/NavEdit.d.ts +7 -0
  42. package/dist/admin/src/components/modals/NavModal.d.ts +16 -0
  43. package/dist/admin/src/components/modals/NavOverview.d.ts +10 -0
  44. package/dist/admin/src/components/modals/SaveConfirm.d.ts +8 -0
  45. package/dist/admin/src/components/modals/externalItem/index.d.ts +15 -0
  46. package/dist/admin/src/components/modals/index.d.ts +14 -0
  47. package/dist/admin/src/components/modals/internalItem/EntrySelection.d.ts +17 -0
  48. package/dist/admin/src/components/modals/internalItem/ItemDetails.d.ts +13 -0
  49. package/dist/admin/src/components/modals/internalItem/MultiItemReview.d.ts +23 -0
  50. package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +2 -0
  51. package/dist/admin/src/components/modals/internalItem/internalItemEdit.d.ts +2 -0
  52. package/dist/admin/src/components/modals/useModalSharedLogic.d.ts +2 -0
  53. package/dist/admin/src/components/modals/withModalSharedLogic.d.ts +3 -0
  54. package/dist/admin/src/components/modals/wrapperItem/index.d.ts +15 -0
  55. package/dist/admin/src/contexts/index.d.ts +17 -0
  56. package/dist/admin/src/hooks/index.d.ts +7 -0
  57. package/dist/admin/src/hooks/useAllContentTypes.d.ts +7 -0
  58. package/dist/admin/src/hooks/useAllEntities.d.ts +7 -0
  59. package/dist/admin/src/hooks/useApi.d.ts +23 -0
  60. package/dist/admin/src/hooks/useEntrySearch.d.ts +13 -0
  61. package/dist/admin/src/hooks/useErrorMessage.d.ts +8 -0
  62. package/dist/admin/src/hooks/usePluginConfig.d.ts +9 -0
  63. package/dist/admin/src/pages/Navigation/Page.d.ts +2 -0
  64. package/dist/admin/src/pages/Navigation/PageWrapper.d.ts +8 -0
  65. package/dist/admin/src/pages/Navigation/RouteItem.d.ts +2 -0
  66. package/dist/admin/src/pages/Navigation/RouteItemBadge.d.ts +4 -0
  67. package/dist/admin/src/pages/Navigation/RouteItemIcon.d.ts +5 -0
  68. package/dist/admin/src/pages/Navigation/RouteItemMenu.d.ts +12 -0
  69. package/dist/admin/src/pages/Navigation/RouteItemStatus.d.ts +5 -0
  70. package/dist/admin/src/pages/Navigation/SortableRouteItem.d.ts +2 -0
  71. package/dist/admin/src/pages/Navigation/UnsavedChangesBlocker.d.ts +8 -0
  72. package/dist/admin/src/pages/Navigation/index.d.ts +2 -0
  73. package/dist/admin/src/pages/Navigation/useCollapsedItems.d.ts +13 -0
  74. package/dist/admin/src/pages/Paths/HealthSummary.d.ts +8 -0
  75. package/dist/admin/src/pages/Paths/IssueBadges.d.ts +4 -0
  76. package/dist/admin/src/pages/Paths/PageWrapper.d.ts +5 -0
  77. package/dist/admin/src/pages/Paths/PathActionsMenu.d.ts +7 -0
  78. package/dist/admin/src/pages/Paths/PathFilters.d.ts +14 -0
  79. package/dist/admin/src/pages/Paths/PathTable.d.ts +18 -0
  80. package/dist/admin/src/pages/Paths/SearchInput.d.ts +5 -0
  81. package/dist/admin/src/pages/Paths/TableHeader.d.ts +6 -0
  82. package/dist/admin/src/pages/Paths/TableRow.d.ts +9 -0
  83. package/dist/admin/src/pages/Paths/compareBy.d.ts +3 -0
  84. package/dist/admin/src/pages/Paths/hasPathDeviation.d.ts +2 -0
  85. package/dist/admin/src/pages/Paths/healthMessages.d.ts +11 -0
  86. package/dist/admin/src/pages/Paths/index.d.ts +2 -0
  87. package/dist/admin/src/pages/Settings/ContentBox.d.ts +4 -0
  88. package/dist/admin/src/pages/Settings/General/ContentTypeAccordion.d.ts +9 -0
  89. package/dist/admin/src/pages/Settings/General/index.d.ts +2 -0
  90. package/dist/admin/src/pages/Settings/Navigation/index.d.ts +2 -0
  91. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +7 -0
  92. package/dist/admin/src/pages/Settings/SettingTitle.d.ts +3 -0
  93. package/dist/admin/src/pages/Settings/index.d.ts +4 -0
  94. package/dist/admin/src/permissions.d.ts +51 -0
  95. package/dist/admin/src/types/index.d.ts +4 -0
  96. package/dist/admin/src/types/modal.d.ts +60 -0
  97. package/dist/admin/src/types/navigation.d.ts +24 -0
  98. package/dist/admin/src/types/panel.d.ts +50 -0
  99. package/dist/admin/src/types/route.d.ts +3 -0
  100. package/dist/admin/src/utils/buildBreadcrumbString.d.ts +16 -0
  101. package/dist/admin/src/utils/createTempNavItemObject.d.ts +22 -0
  102. package/dist/admin/src/utils/debounce.d.ts +1 -0
  103. package/dist/admin/src/utils/dnd.d.ts +13 -0
  104. package/dist/admin/src/utils/duplicateCheck.d.ts +19 -0
  105. package/dist/admin/src/utils/findParentNavItem.d.ts +13 -0
  106. package/dist/admin/src/utils/getRouteSourceFields.d.ts +2 -0
  107. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  108. package/dist/admin/src/utils/index.d.ts +11 -0
  109. package/dist/admin/src/utils/isAbortError.d.ts +5 -0
  110. package/dist/admin/src/utils/navTree.d.ts +39 -0
  111. package/dist/admin/src/utils/syncNavItemPaths.d.ts +12 -0
  112. package/dist/admin/src/utils/typeChecks.d.ts +3 -0
  113. package/dist/server/index.js +270 -2
  114. package/dist/server/index.mjs +270 -2
  115. package/dist/server/src/bootstrap/documentMiddleware.d.ts +18 -0
  116. package/dist/server/src/bootstrap/index.d.ts +5 -0
  117. package/dist/server/src/bootstrap/permissions.d.ts +2 -0
  118. package/dist/server/src/bootstrap/syncConfig.d.ts +3 -0
  119. package/dist/server/src/bootstrap/webatlasMiddleware.d.ts +2 -0
  120. package/dist/server/src/bootstrap.d.ts +5 -0
  121. package/dist/server/src/config/index.d.ts +8 -0
  122. package/dist/server/src/content-types/index.d.ts +208 -0
  123. package/dist/server/src/content-types/navigation/index.d.ts +56 -0
  124. package/dist/server/src/content-types/navigation/schema.d.ts +54 -0
  125. package/dist/server/src/content-types/navitem/index.d.ts +51 -0
  126. package/dist/server/src/content-types/navitem/schema.d.ts +49 -0
  127. package/dist/server/src/content-types/route/index.d.ts +101 -0
  128. package/dist/server/src/content-types/route/schema.d.ts +99 -0
  129. package/dist/server/src/controllers/admin.d.ts +19 -0
  130. package/dist/server/src/controllers/client.d.ts +8 -0
  131. package/dist/server/src/controllers/index.d.ts +27 -0
  132. package/dist/server/src/destroy.d.ts +5 -0
  133. package/dist/server/src/index.d.ts +15 -5
  134. package/dist/server/src/middlewares/addWebatlasField.d.ts +10 -0
  135. package/dist/server/src/middlewares/enrichRoutePicker.d.ts +10 -0
  136. package/dist/server/src/middlewares/index.d.ts +9 -0
  137. package/dist/server/src/migrations/001-canonical-path.d.ts +7 -0
  138. package/dist/server/src/migrations/002-webatlas-json-field.d.ts +7 -0
  139. package/dist/server/src/migrations/003-route-source-field.d.ts +7 -0
  140. package/dist/server/src/migrations/004-navigation-max-depth.d.ts +7 -0
  141. package/dist/server/src/migrations/index.d.ts +3 -0
  142. package/dist/server/src/policies/has-permissions.d.ts +2 -0
  143. package/dist/server/src/policies/index.d.ts +4 -0
  144. package/dist/server/src/register.d.ts +5 -0
  145. package/dist/server/src/routes/admin.d.ts +17 -0
  146. package/dist/server/src/routes/client.d.ts +12 -0
  147. package/dist/server/src/routes/index.d.ts +30 -0
  148. package/dist/server/src/services/admin.d.ts +33 -0
  149. package/dist/server/src/services/client.d.ts +48 -0
  150. package/dist/server/src/services/health.d.ts +5 -0
  151. package/dist/server/src/services/index.d.ts +83 -0
  152. package/dist/server/src/utils/addWebatlasBreadcrumb.d.ts +14 -0
  153. package/dist/server/src/utils/assertDescendantPathsAllowed.d.ts +19 -0
  154. package/dist/server/src/utils/assertPathAllowed.d.ts +2 -0
  155. package/dist/server/src/utils/buildCanonicalPath.d.ts +1 -0
  156. package/dist/server/src/utils/buildNavigationPath.d.ts +5 -0
  157. package/dist/server/src/utils/buildStructuredNavigation.d.ts +12 -0
  158. package/dist/server/src/utils/cascadePathUpdates.d.ts +6 -0
  159. package/dist/server/src/utils/cleanRootKeys.d.ts +1 -0
  160. package/dist/server/src/utils/duplicateCheck.d.ts +1 -0
  161. package/dist/server/src/utils/enrichRoutePickerFields.d.ts +7 -0
  162. package/dist/server/src/utils/enrichWebatlasData.d.ts +6 -0
  163. package/dist/server/src/utils/extractRouteAndItems.d.ts +32 -0
  164. package/dist/server/src/utils/getDocumentStatuses.d.ts +12 -0
  165. package/dist/server/src/utils/getNonInternalRouteIds.d.ts +1 -0
  166. package/dist/server/src/utils/getPublishedDocumentIds.d.ts +11 -0
  167. package/dist/server/src/utils/getRouteAncestors.d.ts +1 -0
  168. package/dist/server/src/utils/getRouteDescendants.d.ts +1 -0
  169. package/dist/server/src/utils/health/checks.d.ts +48 -0
  170. package/dist/server/src/utils/index.d.ts +29 -0
  171. package/dist/server/src/utils/isBlacklistedPath.d.ts +1 -0
  172. package/dist/server/src/utils/navItemHandler.d.ts +5 -0
  173. package/dist/server/src/utils/navigationItemStructure.d.ts +27 -0
  174. package/dist/server/src/utils/normalizeRouteBlacklist.d.ts +5 -0
  175. package/dist/server/src/utils/pluginHelpers.d.ts +4 -0
  176. package/dist/server/src/utils/populateDeep.d.ts +4 -0
  177. package/dist/server/src/utils/reduceDepthOfOrphanedItems.d.ts +2 -0
  178. package/dist/server/src/utils/removeUnpublishedNavItems.d.ts +7 -0
  179. package/dist/server/src/utils/removeWaFields.d.ts +1 -0
  180. package/dist/server/src/utils/routeHandler.d.ts +5 -0
  181. package/dist/server/src/utils/validateRouteDependencies.d.ts +4 -0
  182. package/package.json +5 -5
  183. package/dist/admin/index-D2O7sLKs.mjs +0 -249
  184. package/dist/admin/index-jOCO4_-k.js +0 -249
@@ -93,6 +93,9 @@ function getAdminService() {
93
93
  function getClientService() {
94
94
  return strapi.plugin(PLUGIN_ID)?.service("client");
95
95
  }
96
+ function getHealthService() {
97
+ return strapi.plugin(PLUGIN_ID)?.service("health");
98
+ }
96
99
  function reduceDepthOfOrphanedItems(navigationItems, itemId) {
97
100
  const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
98
101
  const startItemIndex = navigationItemsCopy.findIndex(
@@ -5888,6 +5891,9 @@ const admin$2 = () => ({
5888
5891
  async getAllRoutes(ctx) {
5889
5892
  return await getAdminService().getAllRoutes();
5890
5893
  },
5894
+ async getHealthReport(ctx) {
5895
+ return await getHealthService().getHealthReport();
5896
+ },
5891
5897
  async getRelatedRoute(ctx) {
5892
5898
  const { documentId } = ctx.query;
5893
5899
  if (!documentId) throw new utils.errors.ValidationError("Route documentId is required");
@@ -6066,6 +6072,22 @@ const admin$1 = {
6066
6072
  ]
6067
6073
  }
6068
6074
  },
6075
+ {
6076
+ method: "GET",
6077
+ path: "/health",
6078
+ handler: "admin.getHealthReport",
6079
+ config: {
6080
+ policies: [
6081
+ "admin::isAuthenticatedAdmin",
6082
+ {
6083
+ name: `plugin::${PLUGIN_ID}.has-permissions`,
6084
+ config: {
6085
+ actions: [`plugin::${PLUGIN_ID}.page.routes`]
6086
+ }
6087
+ }
6088
+ ]
6089
+ }
6090
+ },
6069
6091
  {
6070
6092
  method: "GET",
6071
6093
  path: "/route/related",
@@ -6350,7 +6372,14 @@ const admin = ({ strapi: strapi2 }) => ({
6350
6372
  });
6351
6373
  },
6352
6374
  async getAllRoutes() {
6353
- return await strapi2.documents(waRoute).findMany();
6375
+ return await strapi2.documents(waRoute).findMany({
6376
+ populate: {
6377
+ navitem: {
6378
+ fields: ["documentId"],
6379
+ populate: { navigation: { fields: ["documentId", "name"] } }
6380
+ }
6381
+ }
6382
+ });
6354
6383
  },
6355
6384
  async getRelatedRoute(documentId) {
6356
6385
  return await strapi2.db?.query(waRoute).findOne({
@@ -6639,9 +6668,248 @@ const client = ({ strapi: strapi2 }) => ({
6639
6668
  return { ...structured, items: entityNavigation };
6640
6669
  }
6641
6670
  });
6671
+ function checkPathConflicts({ routes: routes2 }) {
6672
+ const routesByValue = /* @__PURE__ */ new Map();
6673
+ for (const route2 of routes2) {
6674
+ if (route2.type === "external") continue;
6675
+ for (const value of [route2.path, route2.canonicalPath, route2.uidPath]) {
6676
+ if (!value) continue;
6677
+ const routesWithValue = routesByValue.get(value) ?? /* @__PURE__ */ new Set();
6678
+ routesWithValue.add(route2);
6679
+ routesByValue.set(value, routesWithValue);
6680
+ }
6681
+ }
6682
+ const issues = [];
6683
+ for (const [value, routesWithValue] of routesByValue) {
6684
+ if (routesWithValue.size < 2) continue;
6685
+ for (const route2 of routesWithValue) {
6686
+ issues.push({
6687
+ check: "pathConflict",
6688
+ severity: "error",
6689
+ routeDocumentId: route2.documentId,
6690
+ details: {
6691
+ value,
6692
+ conflictingRoutes: [...routesWithValue].filter((other) => other !== route2).map((other) => ({ documentId: other.documentId, title: other.title }))
6693
+ }
6694
+ });
6695
+ }
6696
+ }
6697
+ return issues;
6698
+ }
6699
+ function checkOrphanedRoutes({
6700
+ routes: routes2,
6701
+ existingContentTypes,
6702
+ enabledContentTypes,
6703
+ existingDocumentIds
6704
+ }) {
6705
+ const issues = [];
6706
+ for (const route2 of routes2) {
6707
+ if (route2.type !== "internal") continue;
6708
+ const reason = !existingContentTypes.has(route2.relatedContentType) ? "missingContentType" : !enabledContentTypes.has(route2.relatedContentType) ? "disabledContentType" : !existingDocumentIds.get(route2.relatedContentType)?.has(route2.relatedDocumentId) ? "missingDocument" : null;
6709
+ if (reason) {
6710
+ issues.push({
6711
+ check: "orphanedRoute",
6712
+ severity: "error",
6713
+ routeDocumentId: route2.documentId,
6714
+ details: { reason }
6715
+ });
6716
+ }
6717
+ }
6718
+ return issues;
6719
+ }
6720
+ function checkBlacklistedPaths({ routes: routes2, routeBlacklist }) {
6721
+ if (routeBlacklist.length === 0) return [];
6722
+ const issues = [];
6723
+ for (const route2 of routes2) {
6724
+ if (route2.type === "external") continue;
6725
+ const value = [route2.path, route2.canonicalPath].find(
6726
+ (path) => isBlacklistedPath(path, routeBlacklist)
6727
+ );
6728
+ if (value) {
6729
+ issues.push({
6730
+ check: "blacklistedPath",
6731
+ severity: "error",
6732
+ routeDocumentId: route2.documentId,
6733
+ details: { value }
6734
+ });
6735
+ }
6736
+ }
6737
+ return issues;
6738
+ }
6739
+ const VALID_EXTERNAL_PROTOCOLS = ["http:", "https:", "mailto:", "tel:"];
6740
+ function checkInvalidExternalUrls({ routes: routes2 }) {
6741
+ const issues = [];
6742
+ for (const route2 of routes2) {
6743
+ if (route2.type !== "external") continue;
6744
+ let isValid = false;
6745
+ try {
6746
+ isValid = VALID_EXTERNAL_PROTOCOLS.includes(new URL(route2.path).protocol);
6747
+ } catch {
6748
+ isValid = false;
6749
+ }
6750
+ if (!isValid) {
6751
+ issues.push({
6752
+ check: "invalidExternalUrl",
6753
+ severity: "warning",
6754
+ routeDocumentId: route2.documentId,
6755
+ details: { value: route2.path }
6756
+ });
6757
+ }
6758
+ }
6759
+ return issues;
6760
+ }
6761
+ function checkUnpublishedInNavigation({
6762
+ routes: routes2,
6763
+ navItems,
6764
+ draftOnlyDocumentIds
6765
+ }) {
6766
+ const navigationsByRoute = /* @__PURE__ */ new Map();
6767
+ for (const navItem of navItems) {
6768
+ const names = navigationsByRoute.get(navItem.routeDocumentId) ?? /* @__PURE__ */ new Set();
6769
+ names.add(navItem.navigationName);
6770
+ navigationsByRoute.set(navItem.routeDocumentId, names);
6771
+ }
6772
+ const issues = [];
6773
+ for (const route2 of routes2) {
6774
+ if (route2.type !== "internal" || !draftOnlyDocumentIds.has(route2.relatedDocumentId)) continue;
6775
+ for (const navigationName of navigationsByRoute.get(route2.documentId) ?? []) {
6776
+ issues.push({
6777
+ check: "unpublishedInNavigation",
6778
+ severity: "warning",
6779
+ routeDocumentId: route2.documentId,
6780
+ details: { navigationName }
6781
+ });
6782
+ }
6783
+ }
6784
+ return issues;
6785
+ }
6786
+ function checkTooDeepItems({ navItems }) {
6787
+ return navItems.filter((navItem) => navItem.depth > navItem.maxDepth).map((navItem) => ({
6788
+ check: "tooDeepItem",
6789
+ severity: "warning",
6790
+ routeDocumentId: navItem.routeDocumentId,
6791
+ details: {
6792
+ navigationName: navItem.navigationName,
6793
+ depth: navItem.depth,
6794
+ maxDepth: navItem.maxDepth
6795
+ }
6796
+ }));
6797
+ }
6798
+ function checkNotInNavigation({ routes: routes2, navItems }) {
6799
+ const routesInNavigation = new Set(navItems.map((navItem) => navItem.routeDocumentId));
6800
+ return routes2.filter((route2) => route2.type === "internal" && !routesInNavigation.has(route2.documentId)).map((route2) => ({
6801
+ check: "notInNavigation",
6802
+ severity: "info",
6803
+ routeDocumentId: route2.documentId
6804
+ }));
6805
+ }
6806
+ function checkEmptyWrappers({ routes: routes2, navItems }) {
6807
+ const wrapperRouteIds = new Set(
6808
+ routes2.filter((route2) => route2.type === "wrapper").map((route2) => route2.documentId)
6809
+ );
6810
+ return navItems.filter((navItem) => wrapperRouteIds.has(navItem.routeDocumentId) && !navItem.hasChildren).map((navItem) => ({
6811
+ check: "emptyWrapper",
6812
+ severity: "info",
6813
+ routeDocumentId: navItem.routeDocumentId,
6814
+ details: { navigationName: navItem.navigationName }
6815
+ }));
6816
+ }
6817
+ function runHealthChecks(data) {
6818
+ return [
6819
+ checkPathConflicts,
6820
+ checkOrphanedRoutes,
6821
+ checkBlacklistedPaths,
6822
+ checkInvalidExternalUrls,
6823
+ checkUnpublishedInNavigation,
6824
+ checkTooDeepItems,
6825
+ checkNotInNavigation,
6826
+ checkEmptyWrappers
6827
+ ].flatMap((check) => check(data));
6828
+ }
6829
+ async function getHealthNavItems() {
6830
+ const navigations = await strapi.documents(waNavigation).findMany({
6831
+ fields: ["name", "maxDepth"],
6832
+ populate: {
6833
+ items: {
6834
+ fields: ["documentId", "order"],
6835
+ populate: {
6836
+ parent: { fields: ["documentId"] },
6837
+ route: { fields: ["documentId"] }
6838
+ }
6839
+ }
6840
+ }
6841
+ });
6842
+ return navigations.flatMap((navigation2) => {
6843
+ const parentIds = new Set(
6844
+ (navigation2.items ?? []).map((item) => item.parent?.documentId).filter(Boolean)
6845
+ );
6846
+ const { items } = buildStructuredNavigation(navigation2, "flat");
6847
+ return (items ?? []).filter((item) => item.route?.documentId).map((item) => ({
6848
+ routeDocumentId: item.route.documentId,
6849
+ navigationName: navigation2.name,
6850
+ depth: item.depth ?? 0,
6851
+ maxDepth: navigation2.maxDepth ?? DEFAULT_NAVIGATION_MAX_DEPTH,
6852
+ hasChildren: parentIds.has(item.documentId)
6853
+ }));
6854
+ });
6855
+ }
6856
+ async function getExistingDocumentIds(routes2, existingContentTypes) {
6857
+ const documentIdsByUid = /* @__PURE__ */ new Map();
6858
+ for (const route2 of routes2) {
6859
+ if (route2.type !== "internal" || !existingContentTypes.has(route2.relatedContentType)) continue;
6860
+ const documentIds = documentIdsByUid.get(route2.relatedContentType) ?? [];
6861
+ documentIds.push(route2.relatedDocumentId);
6862
+ documentIdsByUid.set(route2.relatedContentType, documentIds);
6863
+ }
6864
+ const existing = /* @__PURE__ */ new Map();
6865
+ for (const [uid, documentIds] of documentIdsByUid) {
6866
+ const entries = await strapi.documents(uid).findMany({
6867
+ filters: { documentId: { $in: documentIds } },
6868
+ fields: ["documentId"]
6869
+ });
6870
+ existing.set(uid, new Set(entries.map((entry) => entry.documentId)));
6871
+ }
6872
+ return existing;
6873
+ }
6874
+ const health = () => ({
6875
+ async getHealthReport() {
6876
+ const routes2 = await strapi.documents(waRoute).findMany({
6877
+ fields: [
6878
+ "title",
6879
+ "path",
6880
+ "canonicalPath",
6881
+ "uidPath",
6882
+ "type",
6883
+ "relatedContentType",
6884
+ "relatedDocumentId"
6885
+ ]
6886
+ });
6887
+ const config2 = await getAdminService().getConfig();
6888
+ const existingContentTypes = new Set(Object.keys(strapi.contentTypes));
6889
+ const [navItems, existingDocumentIds, documentStatuses] = await Promise.all([
6890
+ getHealthNavItems(),
6891
+ getExistingDocumentIds(routes2, existingContentTypes),
6892
+ getDocumentStatuses(routes2)
6893
+ ]);
6894
+ const draftOnlyDocumentIds = new Set(
6895
+ [...documentStatuses].filter(([, status]) => status === "draft").map(([id]) => id)
6896
+ );
6897
+ const issues = runHealthChecks({
6898
+ routes: routes2,
6899
+ navItems,
6900
+ existingContentTypes,
6901
+ enabledContentTypes: new Set(config2?.selectedContentTypes?.map((type) => type.uid) ?? []),
6902
+ existingDocumentIds,
6903
+ draftOnlyDocumentIds,
6904
+ routeBlacklist: normalizeRouteBlacklist(config2?.routeBlacklist)
6905
+ });
6906
+ return { issues, checkedAt: (/* @__PURE__ */ new Date()).toISOString() };
6907
+ }
6908
+ });
6642
6909
  const services = {
6643
6910
  admin,
6644
- client
6911
+ client,
6912
+ health
6645
6913
  };
6646
6914
  const index = {
6647
6915
  register,
@@ -91,6 +91,9 @@ function getAdminService() {
91
91
  function getClientService() {
92
92
  return strapi.plugin(PLUGIN_ID)?.service("client");
93
93
  }
94
+ function getHealthService() {
95
+ return strapi.plugin(PLUGIN_ID)?.service("health");
96
+ }
94
97
  function reduceDepthOfOrphanedItems(navigationItems, itemId) {
95
98
  const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
96
99
  const startItemIndex = navigationItemsCopy.findIndex(
@@ -5886,6 +5889,9 @@ const admin$2 = () => ({
5886
5889
  async getAllRoutes(ctx) {
5887
5890
  return await getAdminService().getAllRoutes();
5888
5891
  },
5892
+ async getHealthReport(ctx) {
5893
+ return await getHealthService().getHealthReport();
5894
+ },
5889
5895
  async getRelatedRoute(ctx) {
5890
5896
  const { documentId } = ctx.query;
5891
5897
  if (!documentId) throw new errors.ValidationError("Route documentId is required");
@@ -6064,6 +6070,22 @@ const admin$1 = {
6064
6070
  ]
6065
6071
  }
6066
6072
  },
6073
+ {
6074
+ method: "GET",
6075
+ path: "/health",
6076
+ handler: "admin.getHealthReport",
6077
+ config: {
6078
+ policies: [
6079
+ "admin::isAuthenticatedAdmin",
6080
+ {
6081
+ name: `plugin::${PLUGIN_ID}.has-permissions`,
6082
+ config: {
6083
+ actions: [`plugin::${PLUGIN_ID}.page.routes`]
6084
+ }
6085
+ }
6086
+ ]
6087
+ }
6088
+ },
6067
6089
  {
6068
6090
  method: "GET",
6069
6091
  path: "/route/related",
@@ -6348,7 +6370,14 @@ const admin = ({ strapi: strapi2 }) => ({
6348
6370
  });
6349
6371
  },
6350
6372
  async getAllRoutes() {
6351
- return await strapi2.documents(waRoute).findMany();
6373
+ return await strapi2.documents(waRoute).findMany({
6374
+ populate: {
6375
+ navitem: {
6376
+ fields: ["documentId"],
6377
+ populate: { navigation: { fields: ["documentId", "name"] } }
6378
+ }
6379
+ }
6380
+ });
6352
6381
  },
6353
6382
  async getRelatedRoute(documentId) {
6354
6383
  return await strapi2.db?.query(waRoute).findOne({
@@ -6637,9 +6666,248 @@ const client = ({ strapi: strapi2 }) => ({
6637
6666
  return { ...structured, items: entityNavigation };
6638
6667
  }
6639
6668
  });
6669
+ function checkPathConflicts({ routes: routes2 }) {
6670
+ const routesByValue = /* @__PURE__ */ new Map();
6671
+ for (const route2 of routes2) {
6672
+ if (route2.type === "external") continue;
6673
+ for (const value of [route2.path, route2.canonicalPath, route2.uidPath]) {
6674
+ if (!value) continue;
6675
+ const routesWithValue = routesByValue.get(value) ?? /* @__PURE__ */ new Set();
6676
+ routesWithValue.add(route2);
6677
+ routesByValue.set(value, routesWithValue);
6678
+ }
6679
+ }
6680
+ const issues = [];
6681
+ for (const [value, routesWithValue] of routesByValue) {
6682
+ if (routesWithValue.size < 2) continue;
6683
+ for (const route2 of routesWithValue) {
6684
+ issues.push({
6685
+ check: "pathConflict",
6686
+ severity: "error",
6687
+ routeDocumentId: route2.documentId,
6688
+ details: {
6689
+ value,
6690
+ conflictingRoutes: [...routesWithValue].filter((other) => other !== route2).map((other) => ({ documentId: other.documentId, title: other.title }))
6691
+ }
6692
+ });
6693
+ }
6694
+ }
6695
+ return issues;
6696
+ }
6697
+ function checkOrphanedRoutes({
6698
+ routes: routes2,
6699
+ existingContentTypes,
6700
+ enabledContentTypes,
6701
+ existingDocumentIds
6702
+ }) {
6703
+ const issues = [];
6704
+ for (const route2 of routes2) {
6705
+ if (route2.type !== "internal") continue;
6706
+ const reason = !existingContentTypes.has(route2.relatedContentType) ? "missingContentType" : !enabledContentTypes.has(route2.relatedContentType) ? "disabledContentType" : !existingDocumentIds.get(route2.relatedContentType)?.has(route2.relatedDocumentId) ? "missingDocument" : null;
6707
+ if (reason) {
6708
+ issues.push({
6709
+ check: "orphanedRoute",
6710
+ severity: "error",
6711
+ routeDocumentId: route2.documentId,
6712
+ details: { reason }
6713
+ });
6714
+ }
6715
+ }
6716
+ return issues;
6717
+ }
6718
+ function checkBlacklistedPaths({ routes: routes2, routeBlacklist }) {
6719
+ if (routeBlacklist.length === 0) return [];
6720
+ const issues = [];
6721
+ for (const route2 of routes2) {
6722
+ if (route2.type === "external") continue;
6723
+ const value = [route2.path, route2.canonicalPath].find(
6724
+ (path) => isBlacklistedPath(path, routeBlacklist)
6725
+ );
6726
+ if (value) {
6727
+ issues.push({
6728
+ check: "blacklistedPath",
6729
+ severity: "error",
6730
+ routeDocumentId: route2.documentId,
6731
+ details: { value }
6732
+ });
6733
+ }
6734
+ }
6735
+ return issues;
6736
+ }
6737
+ const VALID_EXTERNAL_PROTOCOLS = ["http:", "https:", "mailto:", "tel:"];
6738
+ function checkInvalidExternalUrls({ routes: routes2 }) {
6739
+ const issues = [];
6740
+ for (const route2 of routes2) {
6741
+ if (route2.type !== "external") continue;
6742
+ let isValid = false;
6743
+ try {
6744
+ isValid = VALID_EXTERNAL_PROTOCOLS.includes(new URL(route2.path).protocol);
6745
+ } catch {
6746
+ isValid = false;
6747
+ }
6748
+ if (!isValid) {
6749
+ issues.push({
6750
+ check: "invalidExternalUrl",
6751
+ severity: "warning",
6752
+ routeDocumentId: route2.documentId,
6753
+ details: { value: route2.path }
6754
+ });
6755
+ }
6756
+ }
6757
+ return issues;
6758
+ }
6759
+ function checkUnpublishedInNavigation({
6760
+ routes: routes2,
6761
+ navItems,
6762
+ draftOnlyDocumentIds
6763
+ }) {
6764
+ const navigationsByRoute = /* @__PURE__ */ new Map();
6765
+ for (const navItem of navItems) {
6766
+ const names = navigationsByRoute.get(navItem.routeDocumentId) ?? /* @__PURE__ */ new Set();
6767
+ names.add(navItem.navigationName);
6768
+ navigationsByRoute.set(navItem.routeDocumentId, names);
6769
+ }
6770
+ const issues = [];
6771
+ for (const route2 of routes2) {
6772
+ if (route2.type !== "internal" || !draftOnlyDocumentIds.has(route2.relatedDocumentId)) continue;
6773
+ for (const navigationName of navigationsByRoute.get(route2.documentId) ?? []) {
6774
+ issues.push({
6775
+ check: "unpublishedInNavigation",
6776
+ severity: "warning",
6777
+ routeDocumentId: route2.documentId,
6778
+ details: { navigationName }
6779
+ });
6780
+ }
6781
+ }
6782
+ return issues;
6783
+ }
6784
+ function checkTooDeepItems({ navItems }) {
6785
+ return navItems.filter((navItem) => navItem.depth > navItem.maxDepth).map((navItem) => ({
6786
+ check: "tooDeepItem",
6787
+ severity: "warning",
6788
+ routeDocumentId: navItem.routeDocumentId,
6789
+ details: {
6790
+ navigationName: navItem.navigationName,
6791
+ depth: navItem.depth,
6792
+ maxDepth: navItem.maxDepth
6793
+ }
6794
+ }));
6795
+ }
6796
+ function checkNotInNavigation({ routes: routes2, navItems }) {
6797
+ const routesInNavigation = new Set(navItems.map((navItem) => navItem.routeDocumentId));
6798
+ return routes2.filter((route2) => route2.type === "internal" && !routesInNavigation.has(route2.documentId)).map((route2) => ({
6799
+ check: "notInNavigation",
6800
+ severity: "info",
6801
+ routeDocumentId: route2.documentId
6802
+ }));
6803
+ }
6804
+ function checkEmptyWrappers({ routes: routes2, navItems }) {
6805
+ const wrapperRouteIds = new Set(
6806
+ routes2.filter((route2) => route2.type === "wrapper").map((route2) => route2.documentId)
6807
+ );
6808
+ return navItems.filter((navItem) => wrapperRouteIds.has(navItem.routeDocumentId) && !navItem.hasChildren).map((navItem) => ({
6809
+ check: "emptyWrapper",
6810
+ severity: "info",
6811
+ routeDocumentId: navItem.routeDocumentId,
6812
+ details: { navigationName: navItem.navigationName }
6813
+ }));
6814
+ }
6815
+ function runHealthChecks(data) {
6816
+ return [
6817
+ checkPathConflicts,
6818
+ checkOrphanedRoutes,
6819
+ checkBlacklistedPaths,
6820
+ checkInvalidExternalUrls,
6821
+ checkUnpublishedInNavigation,
6822
+ checkTooDeepItems,
6823
+ checkNotInNavigation,
6824
+ checkEmptyWrappers
6825
+ ].flatMap((check) => check(data));
6826
+ }
6827
+ async function getHealthNavItems() {
6828
+ const navigations = await strapi.documents(waNavigation).findMany({
6829
+ fields: ["name", "maxDepth"],
6830
+ populate: {
6831
+ items: {
6832
+ fields: ["documentId", "order"],
6833
+ populate: {
6834
+ parent: { fields: ["documentId"] },
6835
+ route: { fields: ["documentId"] }
6836
+ }
6837
+ }
6838
+ }
6839
+ });
6840
+ return navigations.flatMap((navigation2) => {
6841
+ const parentIds = new Set(
6842
+ (navigation2.items ?? []).map((item) => item.parent?.documentId).filter(Boolean)
6843
+ );
6844
+ const { items } = buildStructuredNavigation(navigation2, "flat");
6845
+ return (items ?? []).filter((item) => item.route?.documentId).map((item) => ({
6846
+ routeDocumentId: item.route.documentId,
6847
+ navigationName: navigation2.name,
6848
+ depth: item.depth ?? 0,
6849
+ maxDepth: navigation2.maxDepth ?? DEFAULT_NAVIGATION_MAX_DEPTH,
6850
+ hasChildren: parentIds.has(item.documentId)
6851
+ }));
6852
+ });
6853
+ }
6854
+ async function getExistingDocumentIds(routes2, existingContentTypes) {
6855
+ const documentIdsByUid = /* @__PURE__ */ new Map();
6856
+ for (const route2 of routes2) {
6857
+ if (route2.type !== "internal" || !existingContentTypes.has(route2.relatedContentType)) continue;
6858
+ const documentIds = documentIdsByUid.get(route2.relatedContentType) ?? [];
6859
+ documentIds.push(route2.relatedDocumentId);
6860
+ documentIdsByUid.set(route2.relatedContentType, documentIds);
6861
+ }
6862
+ const existing = /* @__PURE__ */ new Map();
6863
+ for (const [uid, documentIds] of documentIdsByUid) {
6864
+ const entries = await strapi.documents(uid).findMany({
6865
+ filters: { documentId: { $in: documentIds } },
6866
+ fields: ["documentId"]
6867
+ });
6868
+ existing.set(uid, new Set(entries.map((entry) => entry.documentId)));
6869
+ }
6870
+ return existing;
6871
+ }
6872
+ const health = () => ({
6873
+ async getHealthReport() {
6874
+ const routes2 = await strapi.documents(waRoute).findMany({
6875
+ fields: [
6876
+ "title",
6877
+ "path",
6878
+ "canonicalPath",
6879
+ "uidPath",
6880
+ "type",
6881
+ "relatedContentType",
6882
+ "relatedDocumentId"
6883
+ ]
6884
+ });
6885
+ const config2 = await getAdminService().getConfig();
6886
+ const existingContentTypes = new Set(Object.keys(strapi.contentTypes));
6887
+ const [navItems, existingDocumentIds, documentStatuses] = await Promise.all([
6888
+ getHealthNavItems(),
6889
+ getExistingDocumentIds(routes2, existingContentTypes),
6890
+ getDocumentStatuses(routes2)
6891
+ ]);
6892
+ const draftOnlyDocumentIds = new Set(
6893
+ [...documentStatuses].filter(([, status]) => status === "draft").map(([id]) => id)
6894
+ );
6895
+ const issues = runHealthChecks({
6896
+ routes: routes2,
6897
+ navItems,
6898
+ existingContentTypes,
6899
+ enabledContentTypes: new Set(config2?.selectedContentTypes?.map((type) => type.uid) ?? []),
6900
+ existingDocumentIds,
6901
+ draftOnlyDocumentIds,
6902
+ routeBlacklist: normalizeRouteBlacklist(config2?.routeBlacklist)
6903
+ });
6904
+ return { issues, checkedAt: (/* @__PURE__ */ new Date()).toISOString() };
6905
+ }
6906
+ });
6640
6907
  const services = {
6641
6908
  admin,
6642
- client
6909
+ client,
6910
+ health
6643
6911
  };
6644
6912
  const index = {
6645
6913
  register,
@@ -0,0 +1,18 @@
1
+ import { Core } from '@strapi/strapi';
2
+ import { ContentType, PluginConfig } from '../../../types';
3
+ export type WebatlasDocumentData = {
4
+ webatlas?: {
5
+ slug?: string;
6
+ path?: string;
7
+ parentDocumentId?: string | null;
8
+ isOverride?: boolean;
9
+ [key: string]: any;
10
+ };
11
+ [key: string]: any;
12
+ };
13
+ export type DocumentResult = {
14
+ id: number;
15
+ documentId: string;
16
+ [key: string]: any;
17
+ };
18
+ export declare function documentMiddleware(strapi: Core.Strapi, enabledContentTypes: ContentType[], config: PluginConfig): void;
@@ -0,0 +1,5 @@
1
+ import { registerPermissions } from './permissions';
2
+ import { syncConfig } from './syncConfig';
3
+ import { documentMiddleware } from './documentMiddleware';
4
+ import { webatlasMiddleware } from './webatlasMiddleware';
5
+ export { registerPermissions, syncConfig, documentMiddleware, webatlasMiddleware };
@@ -0,0 +1,2 @@
1
+ import { Core } from '@strapi/strapi';
2
+ export declare function registerPermissions(strapi: Core.Strapi): void;
@@ -0,0 +1,3 @@
1
+ import { Core } from '@strapi/strapi';
2
+ import { PluginConfig, ContentType } from '../../../types';
3
+ export declare function syncConfig(strapi: Core.Strapi, enabledContentTypes: ContentType[]): Promise<PluginConfig>;
@@ -0,0 +1,2 @@
1
+ import { Core } from '@strapi/strapi';
2
+ export declare function webatlasMiddleware(strapi: Core.Strapi): void;
@@ -0,0 +1,5 @@
1
+ import { Core } from '@strapi/strapi';
2
+ declare const bootstrap: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => Promise<void>;
5
+ export default bootstrap;
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ default: {
3
+ selectedContentTypes: any[];
4
+ routeBlacklist: any[];
5
+ };
6
+ validator(): void;
7
+ };
8
+ export default _default;