@mattisvensson/strapi-plugin-webatlas 0.11.0 → 0.11.2

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 (50) hide show
  1. package/README.md +14 -8
  2. package/dist/admin/{FullLoader-CrPED_dY.mjs → FullLoader-Btjb2W2p.mjs} +4 -2
  3. package/dist/admin/{FullLoader-Cmsf8xS6.js → FullLoader-Da2n70bJ.js} +4 -2
  4. package/dist/admin/{SettingTitle-BjE_2u6R.js → SettingTitle-B0quw3f8.js} +5 -3
  5. package/dist/admin/{SettingTitle-B1IaU3qs.mjs → SettingTitle-HMfQOJnK.mjs} +5 -3
  6. package/dist/admin/de-B5pRvs13.mjs +0 -1
  7. package/dist/admin/de-CqU1FU8C.js +0 -1
  8. package/dist/admin/en-BE-zzIv8.mjs +0 -1
  9. package/dist/admin/en-C7I90FwV.js +0 -1
  10. package/dist/admin/{index-Cf9j0bn2.mjs → index-9_HhKDUC.mjs} +31 -59
  11. package/dist/admin/{index-DCYCtKrj.mjs → index-B79ELMEC.mjs} +220 -215
  12. package/dist/admin/{index-JLpXBQVL.js → index-BEVoxEAm.js} +31 -59
  13. package/dist/admin/index-Bmg-ERct.mjs +243 -0
  14. package/dist/admin/{index-AVI3QJ0R.js → index-C8YjuuOx.js} +496 -354
  15. package/dist/admin/{index-Yq-QR8t0.js → index-Cx_mktdk.js} +220 -215
  16. package/dist/admin/{index-BbnlyBrZ.mjs → index-Cz_k_jjp.mjs} +41 -31
  17. package/dist/admin/{index-D8bG0YFB.js → index-D2hB1vTw.js} +41 -31
  18. package/dist/admin/index-YdWxpvOH.js +243 -0
  19. package/dist/admin/{index-BIEUXWe7.mjs → index-oEJT_mvw.mjs} +496 -354
  20. package/dist/admin/index.js +1 -2
  21. package/dist/admin/index.mjs +1 -2
  22. package/dist/admin/src/index.d.ts +12 -0
  23. package/dist/server/index.js +174 -145
  24. package/dist/server/index.mjs +174 -145
  25. package/dist/server/src/index.d.ts +305 -0
  26. package/package.json +108 -108
  27. package/dist/admin/FullLoader-Cmsf8xS6.js.map +0 -1
  28. package/dist/admin/FullLoader-CrPED_dY.mjs.map +0 -1
  29. package/dist/admin/SettingTitle-B1IaU3qs.mjs.map +0 -1
  30. package/dist/admin/SettingTitle-BjE_2u6R.js.map +0 -1
  31. package/dist/admin/de-B5pRvs13.mjs.map +0 -1
  32. package/dist/admin/de-CqU1FU8C.js.map +0 -1
  33. package/dist/admin/en-BE-zzIv8.mjs.map +0 -1
  34. package/dist/admin/en-C7I90FwV.js.map +0 -1
  35. package/dist/admin/index-AVI3QJ0R.js.map +0 -1
  36. package/dist/admin/index-B90eSO4a.js +0 -219
  37. package/dist/admin/index-B90eSO4a.js.map +0 -1
  38. package/dist/admin/index-BIEUXWe7.mjs.map +0 -1
  39. package/dist/admin/index-BbnlyBrZ.mjs.map +0 -1
  40. package/dist/admin/index-Cf9j0bn2.mjs.map +0 -1
  41. package/dist/admin/index-D8bG0YFB.js.map +0 -1
  42. package/dist/admin/index-DCYCtKrj.mjs.map +0 -1
  43. package/dist/admin/index-JLpXBQVL.js.map +0 -1
  44. package/dist/admin/index-Y_PYIiRA.mjs +0 -219
  45. package/dist/admin/index-Y_PYIiRA.mjs.map +0 -1
  46. package/dist/admin/index-Yq-QR8t0.js.map +0 -1
  47. package/dist/admin/index.js.map +0 -1
  48. package/dist/admin/index.mjs.map +0 -1
  49. package/dist/server/index.js.map +0 -1
  50. package/dist/server/index.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  function transformToUrl(input, replaceSlash = true) {
2
2
  const specialCharMap = {
3
- "ü": "ue",
4
- "ä": "ae",
5
- "ö": "oe",
6
- "ß": "ss"
3
+ ü: "ue",
4
+ ä: "ae",
5
+ ö: "oe",
6
+ ß: "ss"
7
7
  };
8
8
  if (!input || typeof input !== "string") return "";
9
9
  input = input.toLowerCase();
@@ -37,11 +37,7 @@ const waNavItem = `plugin::${PLUGIN_ID}.navitem`;
37
37
  const waRoute = `plugin::${PLUGIN_ID}.route`;
38
38
  async function checkPathExists(path, excludeDocumentId) {
39
39
  const filters = {
40
- $or: [
41
- { path },
42
- { uidPath: path },
43
- { canonicalPath: path }
44
- ]
40
+ $or: [{ path }, { uidPath: path }, { canonicalPath: path }]
45
41
  };
46
42
  if (excludeDocumentId) {
47
43
  filters.documentId = { $ne: excludeDocumentId };
@@ -111,7 +107,9 @@ function getClientService() {
111
107
  }
112
108
  function reduceDepthOfOrphanedItems(navigationItems, itemId) {
113
109
  const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
114
- const startItemIndex = navigationItemsCopy.findIndex((item) => item.documentId === itemId);
110
+ const startItemIndex = navigationItemsCopy.findIndex(
111
+ (item) => item.documentId === itemId
112
+ );
115
113
  if (startItemIndex === -1) return;
116
114
  const startItem = navigationItemsCopy[startItemIndex];
117
115
  for (let i = startItemIndex + 1; i < navigationItemsCopy.length; i++) {
@@ -4269,6 +4267,10 @@ function getFullPopulateObject(modelUid, maxDepth = 5, ignore = []) {
4269
4267
  const populate = {};
4270
4268
  const model = strapi.getModel(modelUid);
4271
4269
  const newIgnore = [...ignore, modelUid];
4270
+ if (model.options?.populateCreatorFields) {
4271
+ populate.createdBy = true;
4272
+ populate.updatedBy = true;
4273
+ }
4272
4274
  for (const [key, value] of Object.entries(getModelPopulationAttributes(model))) {
4273
4275
  if (ignore?.includes(key)) continue;
4274
4276
  if (value) {
@@ -4316,9 +4318,6 @@ function cleanRootKeys(obj) {
4316
4318
  return obj;
4317
4319
  }
4318
4320
  function removeWaFields(obj) {
4319
- delete obj["webatlas_path"];
4320
- delete obj["webatlas_override"];
4321
- delete obj["webatlas_parent"];
4322
4321
  delete obj["webatlas"];
4323
4322
  return obj;
4324
4323
  }
@@ -4436,7 +4435,9 @@ async function validateRouteDependencies({
4436
4435
  const descendants = await getRouteDescendants(normalizedRouteId);
4437
4436
  const nonInternalRouteIds = await getNonInternalRouteIds();
4438
4437
  if (normalizedRouteId === newParentId || descendants.includes(newParentId) || nonInternalRouteIds.includes(newParentId)) {
4439
- throw new Error(`Circular dependency detected: Cannot set route ${newParentId} as parent of ${normalizedRouteId}`);
4438
+ throw new Error(
4439
+ `Circular dependency detected: Cannot set route ${newParentId} as parent of ${normalizedRouteId}`
4440
+ );
4440
4441
  }
4441
4442
  return true;
4442
4443
  }
@@ -4458,8 +4459,7 @@ async function buildNavigationPath({
4458
4459
  if (parent?.route?.type === "internal") break;
4459
4460
  } while (parentDocumentId);
4460
4461
  }
4461
- if (parent?.route?.type !== "internal")
4462
- parent = null;
4462
+ if (parent?.route?.type !== "internal") parent = null;
4463
4463
  if (slug.startsWith("/")) slug = slug.substring(1);
4464
4464
  const newPath = parent?.route ? `${parent.route.path}/${slug}` : `${slug}`;
4465
4465
  const validatedPath = await duplicateCheck(newPath, routeDocumentId);
@@ -4548,7 +4548,8 @@ async function handleItemUpdate({
4548
4548
  const route2 = await strapi.documents(waRoute).findOne({
4549
4549
  documentId: item.clientModifications.route
4550
4550
  });
4551
- if (!route2) throw new Error(`Related route not found for new navigation item '${item.route.title}'`);
4551
+ if (!route2)
4552
+ throw new Error(`Related route not found for new navigation item '${item.route.title}'`);
4552
4553
  const path = await buildNavigationPath({
4553
4554
  slug: item.route.slug,
4554
4555
  routeDocumentId: route2.documentId,
@@ -4569,7 +4570,10 @@ async function handleItemUpdate({
4569
4570
  if (newNavItem) newNavItemsMap.set(item.documentId, newNavItem);
4570
4571
  } catch (err) {
4571
4572
  errors.push(err instanceof Error ? err.message : String(err));
4572
- strapi.log.error(`Error creating navigation item with existing route '${item.route.title}': `, err);
4573
+ strapi.log.error(
4574
+ `Error creating navigation item with existing route '${item.route.title}': `,
4575
+ err
4576
+ );
4573
4577
  }
4574
4578
  return { success: errors.length === 0, errors };
4575
4579
  }
@@ -4579,23 +4583,33 @@ async function handleItemUpdate({
4579
4583
  const route2 = await strapi.documents(waRoute).findOne({
4580
4584
  documentId: item.route.documentId
4581
4585
  });
4582
- if (!route2) throw new Error(`Related route not found for navigation item '${item.route.title}'`);
4586
+ if (!route2)
4587
+ throw new Error(`Related route not found for navigation item '${item.route.title}'`);
4583
4588
  const slug = item.clientModifications?.slug || item.route.slug;
4584
- const path = isInternal ? await buildNavigationPath({ slug, routeDocumentId: route2.documentId, calculatedParent }) : slug;
4589
+ const path = isInternal ? await buildNavigationPath({
4590
+ slug,
4591
+ routeDocumentId: route2.documentId,
4592
+ calculatedParent
4593
+ }) : slug;
4594
+ const isOverride = path !== route2.canonicalPath;
4585
4595
  if (needsRouteUpdate) {
4586
4596
  await updateRoute(route2.documentId, {
4587
4597
  title: item.clientModifications?.title || item.route.title,
4588
4598
  slug,
4589
4599
  path,
4590
- isOverride: path !== route2.canonicalPath
4600
+ isOverride
4591
4601
  });
4592
4602
  }
4593
4603
  if (isInternal) {
4594
- await strapi.entityService.update(item.route.relatedContentType, item.route.relatedDocumentId, {
4595
- data: {
4596
- webatlas_path: path,
4597
- webatlas_override: path !== route2.canonicalPath
4598
- }
4604
+ const webatlasObj = {
4605
+ path,
4606
+ isOverride,
4607
+ parentDocumentId: calculatedParent,
4608
+ slug
4609
+ };
4610
+ await strapi.db.query(item.route.relatedContentType).updateMany({
4611
+ where: { documentId: item.route.relatedDocumentId },
4612
+ data: { webatlas: webatlasObj }
4599
4613
  });
4600
4614
  }
4601
4615
  } catch (err) {
@@ -4631,7 +4645,9 @@ function calculateParentAndOrder({
4631
4645
  const previousItem = navigationItems[index2 - 1];
4632
4646
  if (previousItem && typeof previousItem.depth === "number") {
4633
4647
  if (item.depth === previousItem.depth + 1) {
4634
- parentIds.push(previousItem.documentId.startsWith("temp-") ? newNavItemsMap.get(previousItem.documentId)?.documentId || previousItem.documentId : previousItem.documentId);
4648
+ parentIds.push(
4649
+ previousItem.documentId.startsWith("temp-") ? newNavItemsMap.get(previousItem.documentId)?.documentId || previousItem.documentId : previousItem.documentId
4650
+ );
4635
4651
  groupIndices[item.depth] = 0;
4636
4652
  } else if (item.depth <= previousItem.depth) {
4637
4653
  const diff = previousItem.depth - item.depth;
@@ -4664,10 +4680,7 @@ const migration_001_canonical_path = {
4664
4680
  $notNull: true,
4665
4681
  $ne: ""
4666
4682
  },
4667
- $or: [
4668
- { canonicalPath: { $null: true } },
4669
- { canonicalPath: "" }
4670
- ]
4683
+ $or: [{ canonicalPath: { $null: true } }, { canonicalPath: "" }]
4671
4684
  },
4672
4685
  populate: ["parent"]
4673
4686
  });
@@ -4681,28 +4694,34 @@ const migration_001_canonical_path = {
4681
4694
  const chunkSize = 50;
4682
4695
  for (let i = 0; i < routes2.length; i += chunkSize) {
4683
4696
  const chunk = routes2.slice(i, i + chunkSize);
4684
- await Promise.all(chunk.map(async (route2) => {
4685
- try {
4686
- const transformedTitle = transformToUrl(route2.title);
4687
- const parentId = route2.parent?.id || null;
4688
- const canonicalPath = await buildCanonicalPath(transformedTitle, parentId);
4689
- await strapi2.db?.query(waRoute).update({
4690
- where: { id: route2.id },
4691
- data: { canonicalPath }
4692
- });
4693
- migratedCount++;
4694
- if (migratedCount % 25 === 0) {
4695
- strapi2.log.info(`[webatlas] Migrated ${migratedCount}/${routes2.length} routes`);
4697
+ await Promise.all(
4698
+ chunk.map(async (route2) => {
4699
+ try {
4700
+ const transformedTitle = transformToUrl(route2.title);
4701
+ const parentId = route2.parent?.id || null;
4702
+ const canonicalPath = await buildCanonicalPath(transformedTitle, parentId);
4703
+ await strapi2.db?.query(waRoute).update({
4704
+ where: { id: route2.id },
4705
+ data: { canonicalPath }
4706
+ });
4707
+ migratedCount++;
4708
+ if (migratedCount % 25 === 0) {
4709
+ strapi2.log.info(`[webatlas] Migrated ${migratedCount}/${routes2.length} routes`);
4710
+ }
4711
+ } catch (error) {
4712
+ strapi2.log.error(`[webatlas] Failed to migrate route ${route2.id}:`, error);
4713
+ errorCount++;
4696
4714
  }
4697
- } catch (error) {
4698
- strapi2.log.error(`[webatlas] Failed to migrate route ${route2.id}:`, error);
4699
- errorCount++;
4700
- }
4701
- }));
4715
+ })
4716
+ );
4702
4717
  }
4703
- strapi2.log.info(`[webatlas] Canonical path migration completed. Migrated: ${migratedCount}, Errors: ${errorCount}`);
4718
+ strapi2.log.info(
4719
+ `[webatlas] Canonical path migration completed. Migrated: ${migratedCount}, Errors: ${errorCount}`
4720
+ );
4704
4721
  if (errorCount > 0) {
4705
- strapi2.log.warn(`[webatlas] ${errorCount} routes failed to migrate. Check logs for details.`);
4722
+ strapi2.log.warn(
4723
+ `[webatlas] ${errorCount} routes failed to migrate. Check logs for details.`
4724
+ );
4706
4725
  }
4707
4726
  } catch (error) {
4708
4727
  strapi2.log.error("[webatlas] Canonical path migration failed:", error);
@@ -4731,7 +4750,9 @@ const migration_002_webatlas_json_field = {
4731
4750
  if (!hasAnyOldCol) {
4732
4751
  strapi2.log.info(`[webatlas] No old fields found in ${tableName}, skipping data migration`);
4733
4752
  } else if (!hasWebatlasCol) {
4734
- strapi2.log.warn(`[webatlas] New "webatlas" column not found in ${tableName} — schema may not have synced yet. Skipping data migration, old columns will still be dropped.`);
4753
+ strapi2.log.warn(
4754
+ `[webatlas] New "webatlas" column not found in ${tableName} — schema may not have synced yet. Skipping data migration, old columns will still be dropped.`
4755
+ );
4735
4756
  } else {
4736
4757
  const selectCols = ["id"];
4737
4758
  if (hasPathCol) selectCols.push("webatlas_path");
@@ -4746,11 +4767,18 @@ const migration_002_webatlas_json_field = {
4746
4767
  if (!path && !isOverride && !parentDocumentId) continue;
4747
4768
  const slug = path ? path.split("/").pop() || "" : "";
4748
4769
  await knex(tableName).where({ id: row.id }).update({
4749
- webatlas: JSON.stringify({ path, slug, isOverride, parentDocumentId })
4770
+ webatlas: JSON.stringify({
4771
+ path,
4772
+ slug,
4773
+ isOverride,
4774
+ parentDocumentId
4775
+ })
4750
4776
  });
4751
4777
  migratedCount++;
4752
4778
  }
4753
- strapi2.log.info(`[webatlas] Migrated ${migratedCount} / ${rows.length} rows in ${tableName}`);
4779
+ strapi2.log.info(
4780
+ `[webatlas] Migrated ${migratedCount} / ${rows.length} rows in ${tableName}`
4781
+ );
4754
4782
  }
4755
4783
  const colsToDrop = [
4756
4784
  hasPathCol && "webatlas_path",
@@ -4767,10 +4795,7 @@ const migration_002_webatlas_json_field = {
4767
4795
  strapi2.log.info("[webatlas] webatlas JSON field migration completed");
4768
4796
  }
4769
4797
  };
4770
- const migrations = [
4771
- migration_001_canonical_path,
4772
- migration_002_webatlas_json_field
4773
- ];
4798
+ const migrations = [migration_001_canonical_path, migration_002_webatlas_json_field];
4774
4799
  const runMigrations = async (strapi2) => {
4775
4800
  const pluginStore = strapi2.store({ type: "plugin", name: PLUGIN_ID });
4776
4801
  let config2 = await pluginStore.get({ key: "config" });
@@ -4894,7 +4919,9 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4894
4919
  let parent = null;
4895
4920
  let isValid = false;
4896
4921
  if (parentDocumentId) {
4897
- isValid = await validateRouteDependencies({ newParentId: parentDocumentId });
4922
+ isValid = await validateRouteDependencies({
4923
+ newParentId: parentDocumentId
4924
+ });
4898
4925
  if (isValid) {
4899
4926
  parent = await strapi2.documents(waRoute).findOne({
4900
4927
  documentId: parentDocumentId
@@ -4904,10 +4931,14 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4904
4931
  let rawPath = transformedSlug;
4905
4932
  if (!isOverride) rawPath = parent ? `${parent.path}/${transformedSlug}` : transformedSlug;
4906
4933
  const validatedPath = await duplicateCheck(rawPath);
4907
- if (!validatedPath) throw new Error(`Failed to generate a unique path for slug: ${transformedSlug}`);
4934
+ if (!validatedPath)
4935
+ throw new Error(`Failed to generate a unique path for slug: ${transformedSlug}`);
4908
4936
  const singularName = context.contentType.info.singularName;
4909
4937
  const title = context.params.data[ctSettings?.default]?.trim() || transformedSlug;
4910
- const canonicalPath = await buildCanonicalPath(transformToUrl(title), isValid ? parent.documentId : null);
4938
+ const canonicalPath = await buildCanonicalPath(
4939
+ transformToUrl(title),
4940
+ isValid ? parent.documentId : null
4941
+ );
4911
4942
  await strapi2.documents(waRoute).create({
4912
4943
  data: {
4913
4944
  relatedContentType: context.uid,
@@ -4924,7 +4955,15 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4924
4955
  });
4925
4956
  await strapi2.db?.query(context.uid).updateMany({
4926
4957
  where: { documentId: result2.documentId },
4927
- data: { webatlas: { ...webatlas, slug: transformedSlug, path: validatedPath, parentDocumentId: isValid ? parent?.documentId : null } }
4958
+ data: {
4959
+ webatlas: {
4960
+ ...webatlas,
4961
+ slug: transformedSlug,
4962
+ path: validatedPath,
4963
+ parentDocumentId: isValid ? parent?.documentId : null,
4964
+ isOverride: isOverride || false
4965
+ }
4966
+ }
4928
4967
  });
4929
4968
  return result2;
4930
4969
  }
@@ -5007,7 +5046,9 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
5007
5046
  populate: ["navitem"]
5008
5047
  });
5009
5048
  if (!deletedRoute?.documentId) return result2;
5010
- const navItemDocumentIds = Array.from(deletedRoute.navitem?.map((item) => item.documentId));
5049
+ const navItemDocumentIds = Array.from(
5050
+ deletedRoute.navitem?.map((item) => item.documentId)
5051
+ );
5011
5052
  for (const navItemDocumentId of navItemDocumentIds) {
5012
5053
  await strapi2.documents(waNavItem).delete({ documentId: navItemDocumentId });
5013
5054
  }
@@ -5049,42 +5090,41 @@ function webatlasMiddleware(strapi2) {
5049
5090
  return next();
5050
5091
  });
5051
5092
  }
5052
- function contentTypeMiddleware(strapi2) {
5053
- strapi2.documents.use(async (context, next) => {
5054
- const pluginOptions = context.contentType?.pluginOptions;
5055
- if (!pluginOptions?.webatlas?.enabled) {
5056
- return next();
5093
+ const sanitizeWebatlas = (config2, { strapi: strapi2 }) => {
5094
+ return async (ctx, next) => {
5095
+ await next();
5096
+ if (!ctx.request.url.startsWith("/api/")) {
5097
+ return;
5057
5098
  }
5058
- if (!["findOne", "findMany"].includes(context.action)) {
5059
- return next();
5099
+ if (!ctx.body || ctx.status !== 200) {
5100
+ return;
5060
5101
  }
5061
- const result = await next();
5062
- if (context.action === "findOne") {
5063
- if (!result || typeof result !== "object" || Array.isArray(result)) return result;
5064
- const entry = result;
5065
- const webatlasObj = entry.webatlas || {};
5066
- const newWebatlasObj = {
5067
- path: webatlasObj.path || "",
5068
- slug: webatlasObj.slug || ""
5069
- };
5070
- return { ...entry, webatlas: newWebatlasObj };
5071
- }
5072
- if (context.action === "findMany") {
5073
- if (!Array.isArray(result)) return result;
5074
- return result.map(
5075
- (entry) => {
5076
- const webatlasObj = entry.webatlas || {};
5077
- const newWebatlasObj = {
5078
- path: webatlasObj.path || "",
5079
- slug: webatlasObj.slug || ""
5080
- };
5081
- return { ...entry, webatlas: newWebatlasObj };
5082
- }
5083
- );
5102
+ const sanitizeWebatlasField = (data) => {
5103
+ if (!data || typeof data !== "object") return data;
5104
+ if (data.webatlas && typeof data.webatlas === "object") {
5105
+ data.webatlas = {
5106
+ path: data.webatlas.path || "",
5107
+ slug: data.webatlas.slug || ""
5108
+ };
5109
+ }
5110
+ return data;
5111
+ };
5112
+ if (ctx.body.data) {
5113
+ if (Array.isArray(ctx.body.data)) {
5114
+ ctx.body.data = ctx.body.data.map(sanitizeWebatlasField);
5115
+ } else {
5116
+ ctx.body.data = sanitizeWebatlasField(ctx.body.data);
5117
+ }
5118
+ } else if (Array.isArray(ctx.body)) {
5119
+ ctx.body = ctx.body.map(sanitizeWebatlasField);
5120
+ } else if (typeof ctx.body === "object") {
5121
+ ctx.body = sanitizeWebatlasField(ctx.body);
5084
5122
  }
5085
- return result;
5086
- });
5087
- }
5123
+ };
5124
+ };
5125
+ const middlewares = {
5126
+ sanitizeWebatlas
5127
+ };
5088
5128
  const bootstrap = async ({ strapi: strapi2 }) => {
5089
5129
  try {
5090
5130
  await runMigrations(strapi2);
@@ -5096,7 +5136,7 @@ const bootstrap = async ({ strapi: strapi2 }) => {
5096
5136
  if (!enabledContentTypes.length) return;
5097
5137
  documentMiddleware(strapi2, enabledContentTypes, config2);
5098
5138
  webatlasMiddleware(strapi2);
5099
- contentTypeMiddleware(strapi2);
5139
+ strapi2.server.use(middlewares.sanitizeWebatlas({}, { strapi: strapi2 }));
5100
5140
  } catch (error) {
5101
5141
  strapi2.log.error(`Bootstrap failed. ${String(error)}`);
5102
5142
  }
@@ -6319,7 +6359,8 @@ const admin$2 = () => ({
6319
6359
  async updateNavigationItemStructure(ctx) {
6320
6360
  try {
6321
6361
  const { navigationId, navigationItems } = ctx.request.body;
6322
- if (!navigationId || !navigationItems) return ctx.throw(400, "NavigationId and Navigation items are required");
6362
+ if (!navigationId || !navigationItems)
6363
+ return ctx.throw(400, "NavigationId and Navigation items are required");
6323
6364
  return await getAdminService().updateNavigationItemStructure(navigationId, navigationItems);
6324
6365
  } catch (e) {
6325
6366
  return ctx.throw(500, e);
@@ -6350,7 +6391,13 @@ const client$2 = ({ strapi: strapi2 }) => ({
6350
6391
  try {
6351
6392
  const { slug, populate, populateDeepDepth, fields, status } = ctx.query;
6352
6393
  if (!slug) return ctx.throw(400, "Slug is required");
6353
- const entity = await getClientService().getEntityByPath(slug, populate, populateDeepDepth, fields, status);
6394
+ const entity = await getClientService().getEntityByPath(
6395
+ slug,
6396
+ populate,
6397
+ populateDeepDepth,
6398
+ fields,
6399
+ status
6400
+ );
6354
6401
  if (!entity) return ctx.throw(404, "Entity not found");
6355
6402
  return ctx.send(entity);
6356
6403
  } catch (e) {
@@ -6360,7 +6407,8 @@ const client$2 = ({ strapi: strapi2 }) => ({
6360
6407
  async getNavigation(ctx) {
6361
6408
  try {
6362
6409
  const { id, name, slug, documentId, variant } = ctx.query;
6363
- if (!id && !name && !slug && !documentId) return ctx.throw(400, "Navigation id, name, slug or documentId is required");
6410
+ if (!id && !name && !slug && !documentId)
6411
+ return ctx.throw(400, "Navigation id, name, slug or documentId is required");
6364
6412
  const navigation2 = await getClientService().getNavigation(id, name, slug, documentId, variant);
6365
6413
  if (!navigation2) return ctx.throw(404, "Navigation not found");
6366
6414
  return ctx.send(navigation2);
@@ -6373,7 +6421,6 @@ const controllers = {
6373
6421
  admin: admin$2,
6374
6422
  client: client$2
6375
6423
  };
6376
- const middlewares = {};
6377
6424
  const hasPermissions = (policyContext, config2, { strapi: strapi2 }) => {
6378
6425
  const { userAbility, user } = policyContext.state;
6379
6426
  const { action, actions } = config2;
@@ -6450,10 +6497,7 @@ const admin$1 = {
6450
6497
  {
6451
6498
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6452
6499
  config: {
6453
- actions: [
6454
- `plugin::${PLUGIN_ID}.page.routes`,
6455
- `plugin::${PLUGIN_ID}.cm.aside`
6456
- ]
6500
+ actions: [`plugin::${PLUGIN_ID}.page.routes`, `plugin::${PLUGIN_ID}.cm.aside`]
6457
6501
  }
6458
6502
  }
6459
6503
  ]
@@ -6469,10 +6513,7 @@ const admin$1 = {
6469
6513
  {
6470
6514
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6471
6515
  config: {
6472
- actions: [
6473
- `plugin::${PLUGIN_ID}.cm.aside`,
6474
- `plugin::${PLUGIN_ID}.page.navigation`
6475
- ]
6516
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.page.navigation`]
6476
6517
  }
6477
6518
  }
6478
6519
  ]
@@ -6488,9 +6529,7 @@ const admin$1 = {
6488
6529
  {
6489
6530
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6490
6531
  config: {
6491
- actions: [
6492
- `plugin::${PLUGIN_ID}.cm.aside`
6493
- ]
6532
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`]
6494
6533
  }
6495
6534
  }
6496
6535
  ]
@@ -6506,9 +6545,7 @@ const admin$1 = {
6506
6545
  {
6507
6546
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6508
6547
  config: {
6509
- actions: [
6510
- `plugin::${PLUGIN_ID}.page.navigation`
6511
- ]
6548
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6512
6549
  }
6513
6550
  }
6514
6551
  ]
@@ -6525,9 +6562,7 @@ const admin$1 = {
6525
6562
  {
6526
6563
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6527
6564
  config: {
6528
- actions: [
6529
- `plugin::${PLUGIN_ID}.page.navigation`
6530
- ]
6565
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6531
6566
  }
6532
6567
  }
6533
6568
  ]
@@ -6543,9 +6578,7 @@ const admin$1 = {
6543
6578
  {
6544
6579
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6545
6580
  config: {
6546
- actions: [
6547
- `plugin::${PLUGIN_ID}.page.navigation`
6548
- ]
6581
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6549
6582
  }
6550
6583
  }
6551
6584
  ]
@@ -6561,9 +6594,7 @@ const admin$1 = {
6561
6594
  {
6562
6595
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6563
6596
  config: {
6564
- actions: [
6565
- `plugin::${PLUGIN_ID}.page.navigation`
6566
- ]
6597
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6567
6598
  }
6568
6599
  }
6569
6600
  ]
@@ -6579,9 +6610,7 @@ const admin$1 = {
6579
6610
  {
6580
6611
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6581
6612
  config: {
6582
- actions: [
6583
- `plugin::${PLUGIN_ID}.page.navigation`
6584
- ]
6613
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6585
6614
  }
6586
6615
  }
6587
6616
  ]
@@ -6597,9 +6626,7 @@ const admin$1 = {
6597
6626
  {
6598
6627
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6599
6628
  config: {
6600
- actions: [
6601
- `plugin::${PLUGIN_ID}.page.navigation`
6602
- ]
6629
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6603
6630
  }
6604
6631
  }
6605
6632
  ]
@@ -6616,10 +6643,7 @@ const admin$1 = {
6616
6643
  {
6617
6644
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6618
6645
  config: {
6619
- actions: [
6620
- `plugin::${PLUGIN_ID}.cm.aside`,
6621
- `plugin::${PLUGIN_ID}.page.navigation`
6622
- ]
6646
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.page.navigation`]
6623
6647
  }
6624
6648
  }
6625
6649
  ]
@@ -6657,7 +6681,10 @@ const admin = ({ strapi: strapi2 }) => ({
6657
6681
  if (!newConfig) return;
6658
6682
  let newConfigMerged;
6659
6683
  try {
6660
- const pluginStore = await strapi2.store({ type: "plugin", name: PLUGIN_ID });
6684
+ const pluginStore = await strapi2.store({
6685
+ type: "plugin",
6686
+ name: PLUGIN_ID
6687
+ });
6661
6688
  const config2 = await pluginStore.get({ key: "config" });
6662
6689
  newConfigMerged = { ...config2, ...newConfig };
6663
6690
  await pluginStore.set({ key: "config", value: newConfigMerged });
@@ -6749,15 +6776,16 @@ const admin = ({ strapi: strapi2 }) => ({
6749
6776
  populate: ["items", "items.route", "items.parent"]
6750
6777
  });
6751
6778
  if (!navigation2) throw new Error("Navigation not found");
6752
- if (variant)
6753
- navigation2 = buildStructuredNavigation(navigation2, variant);
6779
+ if (variant) navigation2 = buildStructuredNavigation(navigation2, variant);
6754
6780
  } else {
6755
6781
  navigation2 = await strapi2.documents(waNavigation).findMany({
6756
6782
  populate: ["items", "items.route", "items.parent"]
6757
6783
  });
6758
6784
  if (!navigation2) throw new Error("Navigation not found");
6759
6785
  if (variant) {
6760
- navigation2 = navigation2.map((nav) => buildStructuredNavigation(nav, variant));
6786
+ navigation2 = navigation2.map(
6787
+ (nav) => buildStructuredNavigation(nav, variant)
6788
+ );
6761
6789
  }
6762
6790
  }
6763
6791
  return navigation2;
@@ -6865,22 +6893,24 @@ const client = ({ strapi: strapi2 }) => ({
6865
6893
  try {
6866
6894
  const route2 = await strapi2.documents(waRoute).findFirst({
6867
6895
  filters: {
6868
- $or: [
6869
- { path: slug },
6870
- { canonicalPath: slug },
6871
- { uidPath: slug }
6872
- ]
6896
+ $or: [{ path: slug }, { canonicalPath: slug }, { uidPath: slug }]
6873
6897
  }
6874
6898
  });
6875
6899
  if (!route2) return null;
6876
6900
  let populateObject = populate;
6877
6901
  if (populate === "deep") {
6878
- const modelObject = getFullPopulateObject(route2.relatedContentType, Number(populateDeepDepth), []);
6902
+ const modelObject = getFullPopulateObject(
6903
+ route2.relatedContentType,
6904
+ Number(populateDeepDepth),
6905
+ []
6906
+ );
6879
6907
  if (typeof modelObject === "object" && "populate" in modelObject) {
6880
6908
  populateObject = modelObject.populate;
6881
6909
  }
6882
6910
  }
6883
- const contentTypeObject = Object.entries(strapi2.contentTypes).find(([key, value]) => key === route2.relatedContentType);
6911
+ const contentTypeObject = Object.entries(strapi2.contentTypes).find(
6912
+ ([key, value]) => key === route2.relatedContentType
6913
+ );
6884
6914
  if (!contentTypeObject) {
6885
6915
  return null;
6886
6916
  }
@@ -6989,4 +7019,3 @@ const index = {
6989
7019
  export {
6990
7020
  index as default
6991
7021
  };
6992
- //# sourceMappingURL=index.mjs.map