@mattisvensson/strapi-plugin-webatlas 0.12.1 → 0.13.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 (32) hide show
  1. package/README.md +59 -2
  2. package/dist/admin/{SettingTitle-Ib_0AvoZ.js → ContentBox-D4PGQ8eh.js} +1 -5
  3. package/dist/admin/{SettingTitle-0mKlA80i.mjs → ContentBox-KyQN2KGV.mjs} +2 -6
  4. package/dist/admin/{RoutePicker-IRZiHKFi.mjs → RoutePicker-CgndSXoF.mjs} +1 -1
  5. package/dist/admin/{RoutePicker-C3_tzz9U.js → RoutePicker-CwoMMhf_.js} +1 -1
  6. package/dist/admin/WarningBox-AyYq0Onj.mjs +18 -0
  7. package/dist/admin/{WarningBox-BZ3BZ5fR.js → WarningBox-FF1yYDXP.js} +0 -24
  8. package/dist/admin/{de-DhwCZE_m.js → de-Cl0vM1wA.js} +52 -4
  9. package/dist/admin/{de-BFjenpyN.mjs → de-DWs5ckOd.mjs} +52 -4
  10. package/dist/admin/{en-CGCh9ld_.mjs → en-CyhISGZi.mjs} +52 -4
  11. package/dist/admin/{en-C-rPCNd2.js → en-DSmtmPYk.js} +52 -4
  12. package/dist/admin/{index-ByxM39aL.mjs → index-BKhrfzjO.mjs} +105 -33
  13. package/dist/admin/{index-Bym1mXg1.mjs → index-Bv5Ri-ri.mjs} +44 -12
  14. package/dist/admin/{index-88JTX1Mj.js → index-BxGPKxr_.js} +50 -18
  15. package/dist/admin/index-Ctm4TBT5.mjs +5308 -0
  16. package/dist/admin/{index-PD3gcnXA.mjs → index-D2O7sLKs.mjs} +1 -1
  17. package/dist/admin/{index-CsKnBzp6.js → index-DTrsl_uN.js} +105 -33
  18. package/dist/admin/index-FvaXwOH0.mjs +174 -0
  19. package/dist/admin/index-JBUU7dE6.js +5308 -0
  20. package/dist/admin/{index-DNBXz42q.js → index-jOCO4_-k.js} +1 -1
  21. package/dist/admin/index-uOC1Clyv.js +174 -0
  22. package/dist/admin/index.js +1 -1
  23. package/dist/admin/index.mjs +1 -1
  24. package/dist/server/index.js +443 -96
  25. package/dist/server/index.mjs +444 -97
  26. package/dist/server/src/index.d.ts +17 -4
  27. package/package.json +3 -3
  28. package/dist/admin/WarningBox-CXEmXfVx.mjs +0 -42
  29. package/dist/admin/index-BPUJTNed.js +0 -9622
  30. package/dist/admin/index-BY6JLZrD.mjs +0 -9622
  31. package/dist/admin/index-CEJBltoJ.js +0 -147
  32. package/dist/admin/index-CNCyng5O.mjs +0 -147
@@ -1,4 +1,4 @@
1
- import { errors } from "@strapi/utils";
1
+ import { errors, contentTypes as contentTypes$1 } from "@strapi/utils";
2
2
  function transformToUrl(input, replaceSlash = true) {
3
3
  const specialCharMap = {
4
4
  ü: "ue",
@@ -36,6 +36,7 @@ const PLUGIN_ID = pluginPkg.strapi.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plug
36
36
  const waNavigation = `plugin::${PLUGIN_ID}.navigation`;
37
37
  const waNavItem = `plugin::${PLUGIN_ID}.navitem`;
38
38
  const waRoute = `plugin::${PLUGIN_ID}.route`;
39
+ const DEFAULT_NAVIGATION_MAX_DEPTH = 1;
39
40
  async function checkPathExists(path, excludeDocumentId) {
40
41
  const filters = {
41
42
  $or: [{ path }, { uidPath: path }, { canonicalPath: path }]
@@ -182,6 +183,7 @@ function buildStructuredNavigation(navigation2, variant = "nested") {
182
183
  itemsById.set(item.documentId, newItem);
183
184
  itemsProcessed.add(item.documentId);
184
185
  });
186
+ if (remainingItems.length === itemsToProcess.length) break;
185
187
  itemsToProcess = remainingItems;
186
188
  }
187
189
  const sortedItems = sortItems(rootItems);
@@ -4437,6 +4439,14 @@ async function buildNavigationPath({
4437
4439
  const validatedPath = await duplicateCheck(newPath, routeDocumentId);
4438
4440
  return validatedPath;
4439
4441
  }
4442
+ async function buildItemPath({
4443
+ slug,
4444
+ routeDocumentId,
4445
+ calculatedParent
4446
+ }) {
4447
+ const path = await buildNavigationPath({ slug, routeDocumentId, calculatedParent });
4448
+ return { path, slug: path.split("/").pop() ?? slug };
4449
+ }
4440
4450
  async function handleItemDeletion(navigationItems) {
4441
4451
  const errors2 = [];
4442
4452
  let items = [...navigationItems];
@@ -4522,15 +4532,15 @@ async function handleItemUpdate({
4522
4532
  });
4523
4533
  if (!route2)
4524
4534
  throw new Error(`Related route not found for new navigation item '${item.route.title}'`);
4525
- const path = await buildNavigationPath({
4526
- slug: item.route.slug,
4535
+ const { path, slug } = await buildItemPath({
4536
+ slug: transformToUrl(item.route.slug),
4527
4537
  routeDocumentId: route2.documentId,
4528
4538
  calculatedParent
4529
4539
  });
4530
4540
  assertPathAllowed(path, await getRouteBlacklist());
4531
4541
  await updateRoute(route2.documentId, {
4532
4542
  title: item.route.title,
4533
- slug: item.route.slug,
4543
+ slug,
4534
4544
  path,
4535
4545
  isOverride: path !== route2.canonicalPath
4536
4546
  });
@@ -4558,12 +4568,13 @@ async function handleItemUpdate({
4558
4568
  });
4559
4569
  if (!route2)
4560
4570
  throw new Error(`Related route not found for navigation item '${item.route.title}'`);
4561
- const slug = item.clientModifications?.slug || item.route.slug;
4562
- const path = isInternal ? await buildNavigationPath({
4563
- slug,
4571
+ const changedSlug = item.clientModifications?.slug;
4572
+ const requestedSlug = changedSlug ? isInternal ? transformToUrl(changedSlug) : changedSlug : item.route.slug;
4573
+ const { path, slug } = isInternal ? await buildItemPath({
4574
+ slug: requestedSlug,
4564
4575
  routeDocumentId: route2.documentId,
4565
4576
  calculatedParent
4566
- }) : slug;
4577
+ }) : { path: requestedSlug, slug: requestedSlug };
4567
4578
  const isOverride = path !== route2.canonicalPath;
4568
4579
  if (needsRouteUpdate) {
4569
4580
  if (isInternal) assertPathAllowed(path, await getRouteBlacklist());
@@ -4669,7 +4680,8 @@ async function enrichWebatlasData(data, contentTypeUid) {
4669
4680
  }
4670
4681
  return ids;
4671
4682
  };
4672
- const documentIds = collectDocumentIds(data, contentTypeUid);
4683
+ const items = Array.isArray(data) ? data : [data];
4684
+ const documentIds = items.flatMap((item) => collectDocumentIds(item, contentTypeUid));
4673
4685
  if (documentIds.length === 0) return data;
4674
4686
  const uniqueDocumentIds = [...new Set(documentIds)];
4675
4687
  const routes2 = await strapi.db?.query(waRoute).findMany({
@@ -4725,7 +4737,7 @@ async function enrichWebatlasData(data, contentTypeUid) {
4725
4737
  }
4726
4738
  return entity;
4727
4739
  };
4728
- return enrichEntity2(data, contentTypeUid);
4740
+ return Array.isArray(data) ? data.map((item) => enrichEntity2(item, contentTypeUid)) : enrichEntity2(data, contentTypeUid);
4729
4741
  }
4730
4742
  function isExternalUrl(value) {
4731
4743
  return !/^[a-z0-9]+$/.test(value);
@@ -4787,6 +4799,8 @@ function enrichEntity(entity, uid, routeMap) {
4787
4799
  `Wrapper route detected in route-picker field '${key}'. Wrapper routes cannot be used as page links. Setting to null.`
4788
4800
  );
4789
4801
  entity[key] = null;
4802
+ } else if (route2.isUnpublished) {
4803
+ entity[key] = null;
4790
4804
  } else {
4791
4805
  entity[key] = route2.canonicalPath || route2.path || value;
4792
4806
  }
@@ -4822,20 +4836,36 @@ function enrichEntity(entity, uid, routeMap) {
4822
4836
  }
4823
4837
  return entity;
4824
4838
  }
4825
- async function enrichRoutePickerFields(data, contentTypeUid) {
4839
+ async function enrichRoutePickerFields(data, contentTypeUid, status = "published") {
4826
4840
  if (!data || typeof data !== "object") return data;
4827
- const documentIds = collectRoutePickerIds(data, contentTypeUid);
4841
+ const items = Array.isArray(data) ? data : [data];
4842
+ const documentIds = items.flatMap((item) => collectRoutePickerIds(item, contentTypeUid));
4828
4843
  if (documentIds.length === 0) return data;
4829
4844
  const uniqueDocumentIds = [...new Set(documentIds)];
4830
4845
  const routes2 = await strapi.db?.query(waRoute).findMany({
4831
4846
  where: {
4832
4847
  documentId: { $in: uniqueDocumentIds }
4833
4848
  },
4834
- select: ["documentId", "path", "canonicalPath", "type"]
4849
+ select: [
4850
+ "documentId",
4851
+ "path",
4852
+ "canonicalPath",
4853
+ "type",
4854
+ "relatedContentType",
4855
+ "relatedDocumentId"
4856
+ ]
4835
4857
  });
4836
- const routeMap = new Map(routes2?.map((route2) => [route2.documentId, route2]) || []);
4837
- const enriched = enrichEntity(data, contentTypeUid, routeMap);
4838
- return enriched;
4858
+ const publishedDocumentIds = status === "published" ? await getPublishedDocumentIds(routes2 || []) : null;
4859
+ const routeMap = new Map(
4860
+ routes2?.map((route2) => [
4861
+ route2.documentId,
4862
+ {
4863
+ ...route2,
4864
+ isUnpublished: publishedDocumentIds && route2.relatedContentType && !publishedDocumentIds.has(route2.relatedDocumentId)
4865
+ }
4866
+ ]) || []
4867
+ );
4868
+ return Array.isArray(data) ? data.map((item) => enrichEntity(item, contentTypeUid, routeMap)) : enrichEntity(data, contentTypeUid, routeMap);
4839
4869
  }
4840
4870
  function isBlacklistedPath(url, routeBlacklist) {
4841
4871
  if (!url) return false;
@@ -4901,18 +4931,99 @@ function toBreadcrumbEntry(route2) {
4901
4931
  title: route2.title
4902
4932
  };
4903
4933
  }
4904
- async function addWebatlasBreadcrumb(data, route2) {
4934
+ async function addWebatlasBreadcrumb(data, route2, status = "published") {
4905
4935
  if (!data?.webatlas || !route2) return data;
4906
4936
  const segments = route2.canonicalPath?.split("/").filter(Boolean) || [];
4907
4937
  const ancestorPaths = segments.slice(0, -1).map((_, i) => segments.slice(0, i + 1).join("/"));
4908
4938
  const ancestors = ancestorPaths.length ? await strapi.db.query(waRoute).findMany({
4909
4939
  where: { canonicalPath: { $in: ancestorPaths } },
4910
- select: ["path", "canonicalPath", "slug", "uidPath", "title"]
4940
+ select: [
4941
+ "path",
4942
+ "canonicalPath",
4943
+ "slug",
4944
+ "uidPath",
4945
+ "title",
4946
+ "relatedContentType",
4947
+ "relatedDocumentId"
4948
+ ]
4911
4949
  }) : [];
4912
- const orderedAncestors = ancestorPaths.map((path) => ancestors.find((ancestor) => ancestor.canonicalPath === path)).filter(Boolean);
4950
+ const publishedDocumentIds = status === "published" ? await getPublishedDocumentIds(ancestors) : null;
4951
+ const isVisible = (ancestor) => !publishedDocumentIds || !ancestor.relatedContentType || publishedDocumentIds.has(ancestor.relatedDocumentId);
4952
+ const orderedAncestors = ancestorPaths.map((path) => ancestors.find((ancestor) => ancestor.canonicalPath === path)).filter((ancestor) => ancestor && isVisible(ancestor));
4913
4953
  data.webatlas.breadcrumb = [...orderedAncestors, route2].map(toBreadcrumbEntry);
4914
4954
  return data;
4915
4955
  }
4956
+ async function removeUnpublishedNavItems(items) {
4957
+ const publishedDocumentIds = await getPublishedDocumentIds(items.map((item) => item.route));
4958
+ const removedItemIds = new Set(
4959
+ items.filter(
4960
+ ({ route: route2 }) => route2?.relatedContentType && !publishedDocumentIds.has(route2.relatedDocumentId)
4961
+ ).map((item) => item.documentId)
4962
+ );
4963
+ let foundDescendant = removedItemIds.size > 0;
4964
+ while (foundDescendant) {
4965
+ foundDescendant = false;
4966
+ for (const item of items) {
4967
+ if (item.parent && removedItemIds.has(item.parent.documentId) && !removedItemIds.has(item.documentId)) {
4968
+ removedItemIds.add(item.documentId);
4969
+ foundDescendant = true;
4970
+ }
4971
+ }
4972
+ }
4973
+ return items.filter((item) => !removedItemIds.has(item.documentId));
4974
+ }
4975
+ async function getPublishedDocumentIds(routes2) {
4976
+ const documentIdsByUid = /* @__PURE__ */ new Map();
4977
+ for (const route2 of routes2) {
4978
+ if (!route2?.relatedContentType) continue;
4979
+ const documentIds = documentIdsByUid.get(route2.relatedContentType) ?? [];
4980
+ documentIds.push(route2.relatedDocumentId);
4981
+ documentIdsByUid.set(route2.relatedContentType, documentIds);
4982
+ }
4983
+ const publishedDocumentIds = /* @__PURE__ */ new Set();
4984
+ for (const [uid, documentIds] of documentIdsByUid) {
4985
+ if (!strapi.contentTypes[uid]) continue;
4986
+ const entries = await strapi.documents(uid).findMany({
4987
+ filters: { documentId: { $in: documentIds } },
4988
+ fields: ["documentId"],
4989
+ status: "published"
4990
+ });
4991
+ entries.forEach((entry) => publishedDocumentIds.add(entry.documentId));
4992
+ }
4993
+ return publishedDocumentIds;
4994
+ }
4995
+ async function getDocumentStatuses(routes2) {
4996
+ const documentIdsByUid = /* @__PURE__ */ new Map();
4997
+ for (const route2 of routes2) {
4998
+ if (!route2?.relatedContentType || !route2.relatedDocumentId) continue;
4999
+ const documentIds = documentIdsByUid.get(route2.relatedContentType) ?? [];
5000
+ documentIds.push(route2.relatedDocumentId);
5001
+ documentIdsByUid.set(route2.relatedContentType, documentIds);
5002
+ }
5003
+ const statuses = /* @__PURE__ */ new Map();
5004
+ for (const [uid, documentIds] of documentIdsByUid) {
5005
+ const contentType = strapi.contentTypes[uid];
5006
+ if (!contentType || !contentTypes$1.hasDraftAndPublish(contentType)) continue;
5007
+ const query = {
5008
+ filters: { documentId: { $in: documentIds } },
5009
+ fields: ["documentId", "updatedAt"]
5010
+ };
5011
+ const [drafts, published] = await Promise.all([
5012
+ strapi.documents(uid).findMany({ ...query, status: "draft" }),
5013
+ strapi.documents(uid).findMany({ ...query, status: "published" })
5014
+ ]);
5015
+ const publishedUpdatedAt = new Map(
5016
+ published.map((entry) => [entry.documentId, new Date(entry.updatedAt).getTime()])
5017
+ );
5018
+ drafts.forEach((draft) => {
5019
+ const publishedAt = publishedUpdatedAt.get(draft.documentId);
5020
+ if (publishedAt === void 0) return statuses.set(draft.documentId, "draft");
5021
+ const isModified = new Date(draft.updatedAt).getTime() > publishedAt;
5022
+ statuses.set(draft.documentId, isModified ? "modified" : "published");
5023
+ });
5024
+ }
5025
+ return statuses;
5026
+ }
4916
5027
  const migration_001_canonical_path = {
4917
5028
  version: "001",
4918
5029
  description: "Migrate title field to canonicalPath using transformToUrl",
@@ -5063,10 +5174,25 @@ const migration_003_route_source_field = {
5063
5174
  );
5064
5175
  }
5065
5176
  };
5177
+ const migration_004_navigation_max_depth = {
5178
+ version: "004",
5179
+ description: "Move the global navigation max depth of the config to every navigation",
5180
+ async up(strapi2) {
5181
+ const pluginStore = strapi2.store({ type: "plugin", name: PLUGIN_ID });
5182
+ const config2 = await pluginStore.get({ key: "config" });
5183
+ const maxDepth = config2?.navigation?.maxDepth ?? DEFAULT_NAVIGATION_MAX_DEPTH;
5184
+ const { count } = await strapi2.db.query(waNavigation).updateMany({
5185
+ where: { maxDepth: { $null: true } },
5186
+ data: { maxDepth }
5187
+ });
5188
+ strapi2.log.info(`[webatlas] Set the max depth ${maxDepth} for ${count} navigation(s)`);
5189
+ }
5190
+ };
5066
5191
  const migrations = [
5067
5192
  migration_001_canonical_path,
5068
5193
  migration_002_webatlas_json_field,
5069
- migration_003_route_source_field
5194
+ migration_003_route_source_field,
5195
+ migration_004_navigation_max_depth
5070
5196
  ];
5071
5197
  const runMigrations = async (strapi2) => {
5072
5198
  const pluginStore = strapi2.store({ type: "plugin", name: PLUGIN_ID });
@@ -5104,9 +5230,37 @@ function registerPermissions(strapi2) {
5104
5230
  const actions = [
5105
5231
  {
5106
5232
  section: "plugins",
5107
- displayName: "Navigation page",
5108
- uid: "page.navigation",
5109
- subCategory: "Pages",
5233
+ displayName: "Read navigations",
5234
+ uid: "navigation.read",
5235
+ subCategory: "Navigation",
5236
+ pluginName: PLUGIN_ID
5237
+ },
5238
+ {
5239
+ section: "plugins",
5240
+ displayName: "Create navigations",
5241
+ uid: "navigation.create",
5242
+ subCategory: "Navigation",
5243
+ pluginName: PLUGIN_ID
5244
+ },
5245
+ {
5246
+ section: "plugins",
5247
+ displayName: "Edit navigations",
5248
+ uid: "navigation.update",
5249
+ subCategory: "Navigation",
5250
+ pluginName: PLUGIN_ID
5251
+ },
5252
+ {
5253
+ section: "plugins",
5254
+ displayName: "Delete navigations",
5255
+ uid: "navigation.delete",
5256
+ subCategory: "Navigation",
5257
+ pluginName: PLUGIN_ID
5258
+ },
5259
+ {
5260
+ section: "plugins",
5261
+ displayName: "Edit navigation items",
5262
+ uid: "navigation.edit-items",
5263
+ subCategory: "Navigation",
5110
5264
  pluginName: PLUGIN_ID
5111
5265
  },
5112
5266
  {
@@ -5118,15 +5272,29 @@ function registerPermissions(strapi2) {
5118
5272
  },
5119
5273
  {
5120
5274
  section: "plugins",
5121
- displayName: "General page",
5122
- uid: "settings.general",
5275
+ displayName: "Read general settings",
5276
+ uid: "settings.general.read",
5123
5277
  subCategory: "Settings",
5124
5278
  pluginName: PLUGIN_ID
5125
5279
  },
5126
5280
  {
5127
5281
  section: "plugins",
5128
- displayName: "Navigation page",
5129
- uid: "settings.navigation",
5282
+ displayName: "Update general settings",
5283
+ uid: "settings.general.update",
5284
+ subCategory: "Settings",
5285
+ pluginName: PLUGIN_ID
5286
+ },
5287
+ {
5288
+ section: "plugins",
5289
+ displayName: "Read navigation settings",
5290
+ uid: "settings.navigation.read",
5291
+ subCategory: "Settings",
5292
+ pluginName: PLUGIN_ID
5293
+ },
5294
+ {
5295
+ section: "plugins",
5296
+ displayName: "Update navigation settings",
5297
+ uid: "settings.navigation.update",
5130
5298
  subCategory: "Settings",
5131
5299
  pluginName: PLUGIN_ID
5132
5300
  },
@@ -5136,6 +5304,13 @@ function registerPermissions(strapi2) {
5136
5304
  uid: "cm.aside",
5137
5305
  subCategory: "Content Manager",
5138
5306
  pluginName: PLUGIN_ID
5307
+ },
5308
+ {
5309
+ section: "plugins",
5310
+ displayName: "Edit path (parent route and override)",
5311
+ uid: "cm.edit-path",
5312
+ subCategory: "Content Manager",
5313
+ pluginName: PLUGIN_ID
5139
5314
  }
5140
5315
  ];
5141
5316
  strapi2.admin.services.permission.actionProvider.registerMany(actions);
@@ -5145,13 +5320,10 @@ async function syncConfig(strapi2, enabledContentTypes) {
5145
5320
  const config2 = await pluginStore.get({
5146
5321
  key: "config"
5147
5322
  });
5323
+ const { navigation: _legacyNavigation, ...currentConfig } = config2 ?? {};
5148
5324
  let newConfig = {
5149
- ...config2,
5325
+ ...currentConfig,
5150
5326
  selectedContentTypes: [],
5151
- navigation: {
5152
- maxDepth: config2?.navigation?.maxDepth || 1,
5153
- ...config2?.navigation
5154
- },
5155
5327
  migrationVersion: config2?.migrationVersion || "0"
5156
5328
  };
5157
5329
  enabledContentTypes.forEach((type) => {
@@ -5168,6 +5340,21 @@ async function syncConfig(strapi2, enabledContentTypes) {
5168
5340
  }
5169
5341
  return newConfig;
5170
5342
  }
5343
+ async function getDefaultRouteData(strapi2, uid, data) {
5344
+ const pluginStore = strapi2.store({ type: "plugin", name: PLUGIN_ID });
5345
+ const currentConfig = await pluginStore.get({ key: "config" });
5346
+ const ctSettings = currentConfig?.selectedContentTypes.find((ct) => ct.uid === uid);
5347
+ const sourceValue = ctSettings?.routeSourceField ? data[ctSettings.routeSourceField] : void 0;
5348
+ if (typeof sourceValue !== "string" || !sourceValue.trim()) return void 0;
5349
+ const defaultParent = ctSettings.defaultParentRoute ? await strapi2.documents(waRoute).findFirst({
5350
+ filters: { relatedDocumentId: ctSettings.defaultParentRoute }
5351
+ }) : null;
5352
+ return {
5353
+ slug: transformToUrl(sourceValue),
5354
+ parentDocumentId: defaultParent?.documentId ?? null,
5355
+ isOverride: false
5356
+ };
5357
+ }
5171
5358
  function documentMiddleware(strapi2, enabledContentTypes, config2) {
5172
5359
  const actions = ["create", "update", "delete"];
5173
5360
  strapi2.documents.use(async (context, next) => {
@@ -5175,11 +5362,20 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
5175
5362
  return next();
5176
5363
  }
5177
5364
  const ctSettings = config2.selectedContentTypes.find((ct) => ct.uid === context.uid);
5365
+ const requestContext = strapi2.requestContext.get();
5366
+ const isRouteDataAllowed = !requestContext || requestContext.state?.route?.info?.type === "admin";
5367
+ const userAbility = requestContext?.state?.userAbility;
5368
+ const canUseAside = !userAbility || userAbility.can(`plugin::${PLUGIN_ID}.cm.aside`);
5369
+ const canEditPath = !userAbility || userAbility.can(`plugin::${PLUGIN_ID}.cm.edit-path`);
5370
+ if ((context.action === "create" || context.action === "update") && (!isRouteDataAllowed || !canUseAside)) {
5371
+ delete context.params.data?.webatlas;
5372
+ }
5178
5373
  if (context.action === "create") {
5179
5374
  const data = context.params.data;
5180
- const { webatlas } = data;
5375
+ const webatlas = data.webatlas && canEditPath ? data.webatlas : await getDefaultRouteData(strapi2, context.uid, data);
5181
5376
  const { slug, parentDocumentId, isOverride } = webatlas || {};
5182
5377
  const transformedSlug = slug ? transformToUrl(slug, !isOverride) : null;
5378
+ if (!transformedSlug) return next();
5183
5379
  let parent = null;
5184
5380
  let isValid = false;
5185
5381
  if (parentDocumentId) {
@@ -5208,7 +5404,6 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
5208
5404
  assertPathAllowed(rawPath, routeBlacklist);
5209
5405
  assertPathAllowed(canonicalPath, routeBlacklist);
5210
5406
  const result2 = await next();
5211
- if (!transformedSlug) return result2;
5212
5407
  const existing = await strapi2.db?.query(waRoute).findOne({
5213
5408
  where: { relatedDocumentId: result2.documentId }
5214
5409
  });
@@ -5233,17 +5428,28 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
5233
5428
  if (context.action === "update") {
5234
5429
  const data = context.params.data;
5235
5430
  const { documentId } = context.params;
5236
- const { webatlas } = data;
5431
+ const relatedRoute = await strapi2.documents(waRoute).findFirst({
5432
+ filters: {
5433
+ relatedDocumentId: documentId
5434
+ },
5435
+ populate: ["parent"]
5436
+ });
5437
+ let webatlas = data.webatlas;
5438
+ if (!relatedRoute && (!webatlas || !canEditPath)) {
5439
+ webatlas = await getDefaultRouteData(strapi2, context.uid, data);
5440
+ } else if (relatedRoute && webatlas && !canEditPath) {
5441
+ const sourceValue2 = ctSettings?.routeSourceField ? data[ctSettings.routeSourceField] : void 0;
5442
+ webatlas = !relatedRoute.isOverride && typeof sourceValue2 === "string" && sourceValue2.trim() ? {
5443
+ slug: transformToUrl(sourceValue2),
5444
+ parentDocumentId: relatedRoute.parent?.documentId ?? null,
5445
+ isOverride: false
5446
+ } : void 0;
5447
+ }
5237
5448
  const { slug, parentDocumentId, isOverride } = webatlas || {};
5238
5449
  if (!slug) {
5239
5450
  const result3 = await next();
5240
5451
  return result3;
5241
5452
  }
5242
- const relatedRoute = await strapi2.documents(waRoute).findFirst({
5243
- filters: {
5244
- relatedDocumentId: documentId
5245
- }
5246
- });
5247
5453
  let parent = null;
5248
5454
  let isValid = false;
5249
5455
  if (parentDocumentId) {
@@ -5381,15 +5587,7 @@ const addWebatlasField = ({ strapi: strapi2 }) => {
5381
5587
  if (!contentTypeEntry) return;
5382
5588
  const [contentTypeUid] = contentTypeEntry;
5383
5589
  if (ctx.body.data) {
5384
- if (Array.isArray(ctx.body.data)) {
5385
- ctx.body.data = await Promise.all(
5386
- ctx.body.data.map((item) => enrichWebatlasData(item, contentTypeUid))
5387
- );
5388
- } else {
5389
- ctx.body.data = await enrichWebatlasData(ctx.body.data, contentTypeUid);
5390
- }
5391
- } else if (Array.isArray(ctx.body)) {
5392
- ctx.body = await Promise.all(ctx.body.map((item) => enrichWebatlasData(item, contentTypeUid)));
5590
+ ctx.body.data = await enrichWebatlasData(ctx.body.data, contentTypeUid);
5393
5591
  } else if (typeof ctx.body === "object") {
5394
5592
  ctx.body = await enrichWebatlasData(ctx.body, contentTypeUid);
5395
5593
  }
@@ -5412,20 +5610,11 @@ const enrichRoutePicker = ({ strapi: strapi2 }) => {
5412
5610
  );
5413
5611
  if (!contentTypeEntry) return;
5414
5612
  const [contentTypeUid] = contentTypeEntry;
5613
+ const status = ctx.query?.status === "draft" ? "draft" : "published";
5415
5614
  if (ctx.body.data) {
5416
- if (Array.isArray(ctx.body.data)) {
5417
- ctx.body.data = await Promise.all(
5418
- ctx.body.data.map((item) => enrichRoutePickerFields(item, contentTypeUid))
5419
- );
5420
- } else {
5421
- ctx.body.data = await enrichRoutePickerFields(ctx.body.data, contentTypeUid);
5422
- }
5423
- } else if (Array.isArray(ctx.body)) {
5424
- ctx.body = await Promise.all(
5425
- ctx.body.map((item) => enrichRoutePickerFields(item, contentTypeUid))
5426
- );
5615
+ ctx.body.data = await enrichRoutePickerFields(ctx.body.data, contentTypeUid, status);
5427
5616
  } else if (typeof ctx.body === "object") {
5428
- ctx.body = await enrichRoutePickerFields(ctx.body, contentTypeUid);
5617
+ ctx.body = await enrichRoutePickerFields(ctx.body, contentTypeUid, status);
5429
5618
  }
5430
5619
  };
5431
5620
  };
@@ -5462,9 +5651,6 @@ const register = ({ strapi: strapi2 }) => {
5462
5651
  const config = {
5463
5652
  default: {
5464
5653
  selectedContentTypes: [],
5465
- navigation: {
5466
- maxDepth: 1
5467
- },
5468
5654
  routeBlacklist: []
5469
5655
  },
5470
5656
  validator() {
@@ -5609,6 +5795,13 @@ const schema$1 = {
5609
5795
  default: false,
5610
5796
  configurable: false
5611
5797
  },
5798
+ // Depth index of the deepest allowed level, 0 = root only. Only changed in the plugin settings
5799
+ maxDepth: {
5800
+ type: "integer",
5801
+ default: DEFAULT_NAVIGATION_MAX_DEPTH,
5802
+ min: 0,
5803
+ configurable: false
5804
+ },
5612
5805
  items: {
5613
5806
  type: "relation",
5614
5807
  configurable: false,
@@ -5698,6 +5891,21 @@ const admin$2 = () => ({
5698
5891
  if (!documentId) throw new errors.ValidationError("Route documentId is required");
5699
5892
  return await getAdminService().getRelatedRoute(documentId);
5700
5893
  },
5894
+ async getRelatedRoutes(ctx) {
5895
+ const documentIds = String(ctx.query.documentIds || "").split(",").filter(Boolean);
5896
+ if (documentIds.length === 0) throw new errors.ValidationError("documentIds are required");
5897
+ if (documentIds.length > 100)
5898
+ throw new errors.ValidationError("At most 100 documentIds are allowed");
5899
+ return await getAdminService().getRelatedRoutes(documentIds);
5900
+ },
5901
+ async getNavigationDepths(ctx) {
5902
+ return await getAdminService().getNavigationDepths();
5903
+ },
5904
+ async updateNavigationDepths(ctx) {
5905
+ const { data } = ctx.request.body;
5906
+ if (!Array.isArray(data)) throw new errors.ValidationError("Navigation depths are required");
5907
+ return await getAdminService().updateNavigationDepths(data);
5908
+ },
5701
5909
  async getProhibitedRouteIds(ctx) {
5702
5910
  const { documentId } = ctx.params;
5703
5911
  return await getAdminService().getProhibitedRouteIds(documentId);
@@ -5738,14 +5946,20 @@ const admin$2 = () => ({
5738
5946
  const client$2 = ({ strapi: strapi2 }) => ({
5739
5947
  async getEntityByPath(ctx) {
5740
5948
  const { slug, populate, populateDeepDepth, fields, status, breadcrumb } = ctx.query;
5741
- if (!slug) throw new errors.ValidationError("Slug is required");
5949
+ if (typeof slug !== "string" || !slug) throw new errors.ValidationError("Slug is required");
5950
+ if (status !== void 0 && status !== "draft" && status !== "published")
5951
+ throw new errors.ValidationError('Status must be "draft" or "published"');
5952
+ const depth = populateDeepDepth === void 0 ? 5 : Number(populateDeepDepth);
5953
+ if (!Number.isInteger(depth) || depth < 1 || depth > 10)
5954
+ throw new errors.ValidationError("populateDeepDepth must be a number between 1 and 10");
5742
5955
  const entity = await getClientService().getEntityByPath(
5743
5956
  slug,
5744
5957
  populate,
5745
- populateDeepDepth,
5958
+ depth,
5746
5959
  fields,
5747
5960
  status,
5748
- breadcrumb !== "false"
5961
+ breadcrumb !== "false",
5962
+ ctx.state.auth
5749
5963
  );
5750
5964
  if (!entity) throw new errors.NotFoundError("Entity not found");
5751
5965
  return ctx.send(entity);
@@ -5754,6 +5968,14 @@ const client$2 = ({ strapi: strapi2 }) => ({
5754
5968
  const { id, name, slug, documentId, variant } = ctx.query;
5755
5969
  if (!id && !name && !slug && !documentId)
5756
5970
  throw new errors.ValidationError("Navigation id, name, slug or documentId is required");
5971
+ for (const [key, value] of Object.entries({ id, name, slug, documentId })) {
5972
+ if (value !== void 0 && typeof value !== "string")
5973
+ throw new errors.ValidationError(`Navigation ${key} must be a string`);
5974
+ }
5975
+ if (id !== void 0 && !/^\d+$/.test(id))
5976
+ throw new errors.ValidationError("Navigation id must be a number");
5977
+ if (variant !== void 0 && variant !== "nested" && variant !== "flat")
5978
+ throw new errors.ValidationError('Variant must be "nested" or "flat"');
5757
5979
  const navigation2 = await getClientService().getNavigation(id, name, slug, documentId, variant);
5758
5980
  if (!navigation2) throw new errors.NotFoundError("Navigation not found");
5759
5981
  return ctx.send(navigation2);
@@ -5799,9 +6021,9 @@ const admin$1 = {
5799
6021
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5800
6022
  config: {
5801
6023
  actions: [
5802
- `plugin::${PLUGIN_ID}.settings.general`,
5803
- `plugin::${PLUGIN_ID}.settings.navigation`,
5804
- `plugin::${PLUGIN_ID}.page.navigation`,
6024
+ `plugin::${PLUGIN_ID}.settings.general.read`,
6025
+ `plugin::${PLUGIN_ID}.settings.navigation.read`,
6026
+ `plugin::${PLUGIN_ID}.navigation.read`,
5805
6027
  `plugin::${PLUGIN_ID}.cm.aside`
5806
6028
  ]
5807
6029
  }
@@ -5819,10 +6041,7 @@ const admin$1 = {
5819
6041
  {
5820
6042
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5821
6043
  config: {
5822
- actions: [
5823
- `plugin::${PLUGIN_ID}.settings.general`,
5824
- `plugin::${PLUGIN_ID}.settings.navigation`
5825
- ]
6044
+ actions: [`plugin::${PLUGIN_ID}.settings.general.update`]
5826
6045
  }
5827
6046
  }
5828
6047
  ]
@@ -5855,7 +6074,56 @@ const admin$1 = {
5855
6074
  {
5856
6075
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5857
6076
  config: {
5858
- actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.page.navigation`]
6077
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.navigation.read`]
6078
+ }
6079
+ }
6080
+ ]
6081
+ }
6082
+ },
6083
+ // The max depth is a structural setting, so it is only changed in the plugin settings
6084
+ {
6085
+ method: "GET",
6086
+ path: "/settings/navigation-depths",
6087
+ handler: "admin.getNavigationDepths",
6088
+ config: {
6089
+ policies: [
6090
+ "admin::isAuthenticatedAdmin",
6091
+ {
6092
+ name: `plugin::${PLUGIN_ID}.has-permissions`,
6093
+ config: {
6094
+ actions: [`plugin::${PLUGIN_ID}.settings.navigation.read`]
6095
+ }
6096
+ }
6097
+ ]
6098
+ }
6099
+ },
6100
+ {
6101
+ method: "PUT",
6102
+ path: "/settings/navigation-depths",
6103
+ handler: "admin.updateNavigationDepths",
6104
+ config: {
6105
+ policies: [
6106
+ "admin::isAuthenticatedAdmin",
6107
+ {
6108
+ name: `plugin::${PLUGIN_ID}.has-permissions`,
6109
+ config: {
6110
+ actions: [`plugin::${PLUGIN_ID}.settings.navigation.update`]
6111
+ }
6112
+ }
6113
+ ]
6114
+ }
6115
+ },
6116
+ {
6117
+ method: "GET",
6118
+ path: "/route/related/batch",
6119
+ handler: "admin.getRelatedRoutes",
6120
+ config: {
6121
+ policies: [
6122
+ "admin::isAuthenticatedAdmin",
6123
+ {
6124
+ name: `plugin::${PLUGIN_ID}.has-permissions`,
6125
+ config: {
6126
+ actions: [`plugin::${PLUGIN_ID}.navigation.read`]
5859
6127
  }
5860
6128
  }
5861
6129
  ]
@@ -5887,7 +6155,7 @@ const admin$1 = {
5887
6155
  {
5888
6156
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5889
6157
  config: {
5890
- actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6158
+ actions: [`plugin::${PLUGIN_ID}.navigation.read`]
5891
6159
  }
5892
6160
  }
5893
6161
  ]
@@ -5904,7 +6172,7 @@ const admin$1 = {
5904
6172
  {
5905
6173
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5906
6174
  config: {
5907
- actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6175
+ actions: [`plugin::${PLUGIN_ID}.navigation.read`]
5908
6176
  }
5909
6177
  }
5910
6178
  ]
@@ -5920,7 +6188,7 @@ const admin$1 = {
5920
6188
  {
5921
6189
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5922
6190
  config: {
5923
- actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6191
+ actions: [`plugin::${PLUGIN_ID}.navigation.create`]
5924
6192
  }
5925
6193
  }
5926
6194
  ]
@@ -5936,7 +6204,7 @@ const admin$1 = {
5936
6204
  {
5937
6205
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5938
6206
  config: {
5939
- actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6207
+ actions: [`plugin::${PLUGIN_ID}.navigation.update`]
5940
6208
  }
5941
6209
  }
5942
6210
  ]
@@ -5952,7 +6220,7 @@ const admin$1 = {
5952
6220
  {
5953
6221
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5954
6222
  config: {
5955
- actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6223
+ actions: [`plugin::${PLUGIN_ID}.navigation.edit-items`]
5956
6224
  }
5957
6225
  }
5958
6226
  ]
@@ -5968,7 +6236,7 @@ const admin$1 = {
5968
6236
  {
5969
6237
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5970
6238
  config: {
5971
- actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6239
+ actions: [`plugin::${PLUGIN_ID}.navigation.delete`]
5972
6240
  }
5973
6241
  }
5974
6242
  ]
@@ -5985,7 +6253,7 @@ const admin$1 = {
5985
6253
  {
5986
6254
  name: `plugin::${PLUGIN_ID}.has-permissions`,
5987
6255
  config: {
5988
- actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.page.navigation`]
6256
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.navigation.read`]
5989
6257
  }
5990
6258
  }
5991
6259
  ]
@@ -6018,6 +6286,36 @@ const routes = {
6018
6286
  admin: admin$1,
6019
6287
  "content-api": client$1
6020
6288
  };
6289
+ async function getNavigationDepths() {
6290
+ const navigations = await strapi.documents(waNavigation).findMany({
6291
+ populate: ["items", "items.parent"]
6292
+ });
6293
+ return navigations.map((navigation2) => {
6294
+ const { items } = buildStructuredNavigation(navigation2, "flat");
6295
+ return {
6296
+ documentId: navigation2.documentId,
6297
+ name: navigation2.name,
6298
+ maxDepth: navigation2.maxDepth ?? DEFAULT_NAVIGATION_MAX_DEPTH,
6299
+ deepestDepth: Math.max(-1, ...(items ?? []).map((item) => item.depth ?? 0))
6300
+ };
6301
+ });
6302
+ }
6303
+ async function assertItemDepths(navigationId, navigationItems) {
6304
+ const navigation2 = await strapi.documents(waNavigation).findOne({
6305
+ documentId: navigationId,
6306
+ fields: ["maxDepth"]
6307
+ });
6308
+ if (!navigation2) throw new errors.NotFoundError("Navigation not found");
6309
+ const maxDepth = navigation2.maxDepth ?? DEFAULT_NAVIGATION_MAX_DEPTH;
6310
+ const tooDeepItem = navigationItems.find(
6311
+ (item) => item.clientModifications?.type !== "delete" && (item.depth ?? 0) > maxDepth
6312
+ );
6313
+ if (tooDeepItem) {
6314
+ throw new errors.ValidationError(
6315
+ `'${tooDeepItem.clientModifications?.title || tooDeepItem.route?.title}' is deeper than the ${maxDepth + 1} level(s) allowed in this navigation`
6316
+ );
6317
+ }
6318
+ }
6021
6319
  const admin = ({ strapi: strapi2 }) => ({
6022
6320
  async updateConfig(newConfig) {
6023
6321
  if (!newConfig) return;
@@ -6040,11 +6338,7 @@ const admin = ({ strapi: strapi2 }) => ({
6040
6338
  const defaultConfig = strapi2.config.get(`plugin::${PLUGIN_ID}`);
6041
6339
  config2 = {
6042
6340
  ...defaultConfig,
6043
- ...config2,
6044
- navigation: {
6045
- ...defaultConfig.navigation,
6046
- ...config2?.navigation
6047
- }
6341
+ ...config2
6048
6342
  };
6049
6343
  return config2;
6050
6344
  },
@@ -6064,6 +6358,13 @@ const admin = ({ strapi: strapi2 }) => ({
6064
6358
  populate: ["parent"]
6065
6359
  });
6066
6360
  },
6361
+ // Path of the routes linked to the given entries, with one query
6362
+ async getRelatedRoutes(documentIds) {
6363
+ return await strapi2.db?.query(waRoute).findMany({
6364
+ where: { relatedDocumentId: { $in: documentIds } },
6365
+ select: ["relatedDocumentId", "path"]
6366
+ });
6367
+ },
6067
6368
  async getProhibitedRouteIds(documentId) {
6068
6369
  let route2 = null;
6069
6370
  if (documentId) {
@@ -6108,6 +6409,16 @@ const admin = ({ strapi: strapi2 }) => ({
6108
6409
  );
6109
6410
  }
6110
6411
  }
6412
+ const navigations = Array.isArray(navigation2) ? navigation2 : [navigation2];
6413
+ const statuses = await getDocumentStatuses(
6414
+ navigations.flatMap((nav) => (nav.items ?? []).map((item) => item.route))
6415
+ );
6416
+ navigations.forEach(
6417
+ (nav) => nav.items?.forEach((item) => {
6418
+ const status = statuses.get(item.route?.relatedDocumentId);
6419
+ if (status) item.status = status;
6420
+ })
6421
+ );
6111
6422
  return navigation2;
6112
6423
  },
6113
6424
  async createNavigation(name, visible) {
@@ -6128,6 +6439,28 @@ const admin = ({ strapi: strapi2 }) => ({
6128
6439
  }
6129
6440
  });
6130
6441
  },
6442
+ async getNavigationDepths() {
6443
+ return await getNavigationDepths();
6444
+ },
6445
+ async updateNavigationDepths(depths) {
6446
+ const currentDepths = await getNavigationDepths();
6447
+ for (const { documentId, maxDepth } of depths) {
6448
+ const current = currentDepths.find((navigation2) => navigation2.documentId === documentId);
6449
+ if (!current) throw new errors.NotFoundError("Navigation not found");
6450
+ if (!Number.isInteger(maxDepth) || maxDepth < 0) {
6451
+ throw new errors.ValidationError(`Invalid max depth for the navigation '${current.name}'`);
6452
+ }
6453
+ if (maxDepth < current.deepestDepth) {
6454
+ throw new errors.ValidationError(
6455
+ `The navigation '${current.name}' already has items on level ${current.deepestDepth + 1}`
6456
+ );
6457
+ }
6458
+ }
6459
+ for (const { documentId, maxDepth } of depths) {
6460
+ await strapi2.documents(waNavigation).update({ documentId, data: { maxDepth } });
6461
+ }
6462
+ return await getNavigationDepths();
6463
+ },
6131
6464
  async deleteNavigation(documentId) {
6132
6465
  const navigation2 = await strapi2.documents(waNavigation).findOne({
6133
6466
  documentId,
@@ -6145,6 +6478,7 @@ const admin = ({ strapi: strapi2 }) => ({
6145
6478
  },
6146
6479
  async updateNavigationItemStructure(navigationId, navigationItems) {
6147
6480
  if (!navigationId || !navigationItems) return;
6481
+ await assertItemDepths(navigationId, navigationItems);
6148
6482
  const errors2 = [];
6149
6483
  let newNavItemsMap = /* @__PURE__ */ new Map();
6150
6484
  const deletionResult = await handleItemDeletion(navigationItems);
@@ -6193,7 +6527,7 @@ const admin = ({ strapi: strapi2 }) => ({
6193
6527
  }
6194
6528
  });
6195
6529
  const client = ({ strapi: strapi2 }) => ({
6196
- async getEntityByPath(slug, populate, populateDeepDepth, fields, status = "published", breadcrumb = true) {
6530
+ async getEntityByPath(slug, populate, populateDeepDepth, fields, status = "published", breadcrumb = true, auth) {
6197
6531
  const route2 = await strapi2.documents(waRoute).findFirst({
6198
6532
  filters: {
6199
6533
  $or: [{ path: slug }, { canonicalPath: slug }, { uidPath: slug }]
@@ -6204,12 +6538,10 @@ const client = ({ strapi: strapi2 }) => ({
6204
6538
  if (populate === "deep") {
6205
6539
  const modelObject = getFullPopulateObject(
6206
6540
  route2.relatedContentType,
6207
- Number(populateDeepDepth),
6541
+ populateDeepDepth,
6208
6542
  []
6209
6543
  );
6210
- if (typeof modelObject === "object" && "populate" in modelObject) {
6211
- populateObject = modelObject.populate;
6212
- }
6544
+ populateObject = typeof modelObject === "object" && "populate" in modelObject ? modelObject.populate : void 0;
6213
6545
  }
6214
6546
  const contentTypeObject = Object.entries(strapi2.contentTypes).find(
6215
6547
  ([key, value]) => key === route2.relatedContentType
@@ -6218,20 +6550,34 @@ const client = ({ strapi: strapi2 }) => ({
6218
6550
  return null;
6219
6551
  }
6220
6552
  const [contentTypeKey, contentType] = contentTypeObject;
6553
+ const action = contentType.kind === "singleType" ? "find" : "findOne";
6554
+ try {
6555
+ await strapi2.auth.verify(auth, { scope: [`${contentTypeKey}.${action}`] });
6556
+ } catch {
6557
+ return null;
6558
+ }
6559
+ await strapi2.contentAPI.validate.query(
6560
+ { populate: populate === "deep" ? void 0 : populate, fields },
6561
+ contentType,
6562
+ { auth }
6563
+ );
6564
+ const sanitizedQuery = await strapi2.contentAPI.sanitize.query({ fields }, contentType, { auth });
6565
+ const sanitizedPopulate = populateObject ? await strapi2.contentAPI.sanitize.populate(populateObject, contentType, { auth }) : void 0;
6221
6566
  const entity = await strapi2.documents(route2.relatedContentType).findOne({
6222
6567
  documentId: route2.relatedDocumentId,
6223
- populate: populateObject,
6224
- fields,
6568
+ populate: sanitizedPopulate,
6569
+ fields: sanitizedQuery.fields,
6225
6570
  status
6226
6571
  });
6227
6572
  if (!entity) return null;
6228
- let cleanEntity = cleanRootKeys(entity);
6573
+ const sanitizedEntity = await strapi2.contentAPI.sanitize.output(entity, contentType, { auth });
6574
+ let cleanEntity = cleanRootKeys(sanitizedEntity);
6229
6575
  cleanEntity = removeWaFields(cleanEntity);
6230
6576
  cleanEntity = await enrichWebatlasData(cleanEntity, route2.relatedContentType);
6231
6577
  if (breadcrumb) {
6232
- cleanEntity = await addWebatlasBreadcrumb(cleanEntity, route2);
6578
+ cleanEntity = await addWebatlasBreadcrumb(cleanEntity, route2, status);
6233
6579
  }
6234
- cleanEntity = await enrichRoutePickerFields(cleanEntity, contentTypeKey);
6580
+ cleanEntity = await enrichRoutePickerFields(cleanEntity, contentTypeKey, status);
6235
6581
  return {
6236
6582
  contentType: contentType.info.singularName,
6237
6583
  ...cleanEntity
@@ -6284,6 +6630,7 @@ const client = ({ strapi: strapi2 }) => ({
6284
6630
  }
6285
6631
  }
6286
6632
  if (!navigation2) return null;
6633
+ if (navigation2.items) navigation2.items = await removeUnpublishedNavItems(navigation2.items);
6287
6634
  const structured = buildStructuredNavigation(navigation2, variant);
6288
6635
  if (!structured) return null;
6289
6636
  const entityNavigation = extractRouteAndItems(structured.items);