@mattisvensson/strapi-plugin-webatlas 0.11.0 → 0.11.1

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 (52) hide show
  1. package/README.md +14 -8
  2. package/dist/admin/{FullLoader-CrPED_dY.mjs → FullLoader-Btjb2W2p.mjs} +5 -2
  3. package/dist/admin/FullLoader-Btjb2W2p.mjs.map +1 -0
  4. package/dist/admin/{FullLoader-Cmsf8xS6.js → FullLoader-Da2n70bJ.js} +5 -2
  5. package/dist/admin/FullLoader-Da2n70bJ.js.map +1 -0
  6. package/dist/admin/{SettingTitle-BjE_2u6R.js → SettingTitle-B0quw3f8.js} +6 -3
  7. package/dist/admin/SettingTitle-B0quw3f8.js.map +1 -0
  8. package/dist/admin/{SettingTitle-B1IaU3qs.mjs → SettingTitle-HMfQOJnK.mjs} +6 -3
  9. package/dist/admin/SettingTitle-HMfQOJnK.mjs.map +1 -0
  10. package/dist/admin/{index-Cf9j0bn2.mjs → index-9_HhKDUC.mjs} +32 -59
  11. package/dist/admin/index-9_HhKDUC.mjs.map +1 -0
  12. package/dist/admin/{index-DCYCtKrj.mjs → index-B79ELMEC.mjs} +221 -215
  13. package/dist/admin/index-B79ELMEC.mjs.map +1 -0
  14. package/dist/admin/{index-JLpXBQVL.js → index-BEVoxEAm.js} +32 -59
  15. package/dist/admin/index-BEVoxEAm.js.map +1 -0
  16. package/dist/admin/index-Bmg-ERct.mjs +244 -0
  17. package/dist/admin/index-Bmg-ERct.mjs.map +1 -0
  18. package/dist/admin/{index-AVI3QJ0R.js → index-C8YjuuOx.js} +497 -354
  19. package/dist/admin/index-C8YjuuOx.js.map +1 -0
  20. package/dist/admin/{index-Yq-QR8t0.js → index-Cx_mktdk.js} +221 -215
  21. package/dist/admin/index-Cx_mktdk.js.map +1 -0
  22. package/dist/admin/{index-BbnlyBrZ.mjs → index-Cz_k_jjp.mjs} +42 -31
  23. package/dist/admin/index-Cz_k_jjp.mjs.map +1 -0
  24. package/dist/admin/{index-D8bG0YFB.js → index-D2hB1vTw.js} +42 -31
  25. package/dist/admin/index-D2hB1vTw.js.map +1 -0
  26. package/dist/admin/index-YdWxpvOH.js +244 -0
  27. package/dist/admin/index-YdWxpvOH.js.map +1 -0
  28. package/dist/admin/{index-BIEUXWe7.mjs → index-oEJT_mvw.mjs} +497 -354
  29. package/dist/admin/index-oEJT_mvw.mjs.map +1 -0
  30. package/dist/admin/index.js +1 -1
  31. package/dist/admin/index.mjs +1 -1
  32. package/dist/server/index.js +273 -214
  33. package/dist/server/index.js.map +1 -1
  34. package/dist/server/index.mjs +273 -214
  35. package/dist/server/index.mjs.map +1 -1
  36. package/package.json +108 -108
  37. package/dist/admin/FullLoader-Cmsf8xS6.js.map +0 -1
  38. package/dist/admin/FullLoader-CrPED_dY.mjs.map +0 -1
  39. package/dist/admin/SettingTitle-B1IaU3qs.mjs.map +0 -1
  40. package/dist/admin/SettingTitle-BjE_2u6R.js.map +0 -1
  41. package/dist/admin/index-AVI3QJ0R.js.map +0 -1
  42. package/dist/admin/index-B90eSO4a.js +0 -219
  43. package/dist/admin/index-B90eSO4a.js.map +0 -1
  44. package/dist/admin/index-BIEUXWe7.mjs.map +0 -1
  45. package/dist/admin/index-BbnlyBrZ.mjs.map +0 -1
  46. package/dist/admin/index-Cf9j0bn2.mjs.map +0 -1
  47. package/dist/admin/index-D8bG0YFB.js.map +0 -1
  48. package/dist/admin/index-DCYCtKrj.mjs.map +0 -1
  49. package/dist/admin/index-JLpXBQVL.js.map +0 -1
  50. package/dist/admin/index-Y_PYIiRA.mjs +0 -219
  51. package/dist/admin/index-Y_PYIiRA.mjs.map +0 -1
  52. package/dist/admin/index-Yq-QR8t0.js.map +0 -1
@@ -2,10 +2,10 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  function transformToUrl(input, replaceSlash = true) {
4
4
  const specialCharMap = {
5
- "ü": "ue",
6
- "ä": "ae",
7
- "ö": "oe",
8
- "ß": "ss"
5
+ ü: "ue",
6
+ ä: "ae",
7
+ ö: "oe",
8
+ ß: "ss"
9
9
  };
10
10
  if (!input || typeof input !== "string") return "";
11
11
  input = input.toLowerCase();
@@ -39,11 +39,7 @@ const waNavItem = `plugin::${PLUGIN_ID}.navitem`;
39
39
  const waRoute = `plugin::${PLUGIN_ID}.route`;
40
40
  async function checkPathExists(path, excludeDocumentId) {
41
41
  const filters = {
42
- $or: [
43
- { path },
44
- { uidPath: path },
45
- { canonicalPath: path }
46
- ]
42
+ $or: [{ path }, { uidPath: path }, { canonicalPath: path }]
47
43
  };
48
44
  if (excludeDocumentId) {
49
45
  filters.documentId = { $ne: excludeDocumentId };
@@ -106,10 +102,12 @@ async function deleteNavItem(documentId) {
106
102
  }
107
103
  }
108
104
  function getAdminService() {
109
- return strapi.plugin(PLUGIN_ID)?.service("admin");
105
+ var _a;
106
+ return (_a = strapi.plugin(PLUGIN_ID)) === null || _a === void 0 ? void 0 : _a.service("admin");
110
107
  }
111
108
  function getClientService() {
112
- return strapi.plugin(PLUGIN_ID)?.service("client");
109
+ var _a;
110
+ return (_a = strapi.plugin(PLUGIN_ID)) === null || _a === void 0 ? void 0 : _a.service("client");
113
111
  }
114
112
  function reduceDepthOfOrphanedItems(navigationItems, itemId) {
115
113
  const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
@@ -172,9 +170,11 @@ async function deleteRoute(documentId) {
172
170
  }
173
171
  }
174
172
  function buildStructuredNavigation(navigation2, variant = "nested") {
173
+ var _a;
175
174
  const itemsById = /* @__PURE__ */ new Map();
176
175
  const rootItems = [];
177
- if (!navigation2.items || navigation2.items?.length === 0) return navigation2;
176
+ if (!navigation2.items || ((_a = navigation2.items) === null || _a === void 0 ? void 0 : _a.length) === 0)
177
+ return navigation2;
178
178
  navigation2.items.forEach((item) => {
179
179
  itemsById.set(item.documentId, { ...item, items: [] });
180
180
  });
@@ -248,6 +248,7 @@ const sortItems = (items) => {
248
248
  };
249
249
  function extractRouteAndItems(items) {
250
250
  return items.map((item) => {
251
+ var _a;
251
252
  const route2 = { ...item.route };
252
253
  if (!route2) return null;
253
254
  let depth = null;
@@ -255,7 +256,7 @@ function extractRouteAndItems(items) {
255
256
  depth = item.depth;
256
257
  }
257
258
  let children = null;
258
- if (item.items?.length > 0) {
259
+ if (((_a = item.items) === null || _a === void 0 ? void 0 : _a.length) > 0) {
259
260
  const items2 = extractRouteAndItems(item.items);
260
261
  if (items2.length > 0) children = items2;
261
262
  }
@@ -4259,6 +4260,7 @@ const getModelPopulationAttributes = (model) => {
4259
4260
  return model.attributes;
4260
4261
  };
4261
4262
  function getFullPopulateObject(modelUid, maxDepth = 5, ignore = []) {
4263
+ var _a;
4262
4264
  if (maxDepth <= 1) {
4263
4265
  return true;
4264
4266
  }
@@ -4271,8 +4273,12 @@ function getFullPopulateObject(modelUid, maxDepth = 5, ignore = []) {
4271
4273
  const populate = {};
4272
4274
  const model = strapi.getModel(modelUid);
4273
4275
  const newIgnore = [...ignore, modelUid];
4276
+ if ((_a = model.options) === null || _a === void 0 ? void 0 : _a.populateCreatorFields) {
4277
+ populate.createdBy = true;
4278
+ populate.updatedBy = true;
4279
+ }
4274
4280
  for (const [key, value] of Object.entries(getModelPopulationAttributes(model))) {
4275
- if (ignore?.includes(key)) continue;
4281
+ if (ignore === null || ignore === void 0 ? void 0 : ignore.includes(key)) continue;
4276
4282
  if (value) {
4277
4283
  if (value.type === "component") {
4278
4284
  const componentPopulate = getFullPopulateObject(value.component, maxDepth - 1, newIgnore);
@@ -4318,9 +4324,6 @@ function cleanRootKeys(obj) {
4318
4324
  return obj;
4319
4325
  }
4320
4326
  function removeWaFields(obj) {
4321
- delete obj["webatlas_path"];
4322
- delete obj["webatlas_override"];
4323
- delete obj["webatlas_parent"];
4324
4327
  delete obj["webatlas"];
4325
4328
  return obj;
4326
4329
  }
@@ -4329,7 +4332,7 @@ async function buildCanonicalPath(slug, parentDocumentId) {
4329
4332
  const parentRoute = await strapi.documents(waRoute).findOne({
4330
4333
  documentId: parentDocumentId
4331
4334
  });
4332
- const parentCanonicalPath = parentRoute?.canonicalPath || "";
4335
+ const parentCanonicalPath = (parentRoute === null || parentRoute === void 0 ? void 0 : parentRoute.canonicalPath) || "";
4333
4336
  const canonicalPath = `${parentCanonicalPath ? parentCanonicalPath + "/" : ""}${slug}`;
4334
4337
  return canonicalPath;
4335
4338
  } catch (err) {
@@ -4419,34 +4422,30 @@ async function getNonInternalRouteIds() {
4419
4422
  const routeIds = routes2.map((route2) => route2.documentId);
4420
4423
  return routeIds;
4421
4424
  }
4422
- async function validateRouteDependencies({
4423
- routeId,
4424
- newParentId
4425
- }) {
4425
+ async function validateRouteDependencies({ routeId, newParentId }) {
4426
4426
  if (!newParentId) return true;
4427
- const normalizedRouteId = routeId ?? void 0;
4427
+ const normalizedRouteId = routeId !== null && routeId !== void 0 ? routeId : void 0;
4428
4428
  const parentRoute = await strapi.documents(waRoute).findOne({
4429
4429
  documentId: newParentId
4430
4430
  });
4431
4431
  if (!parentRoute) {
4432
4432
  throw new Error(`Parent route not found: ${newParentId}`);
4433
4433
  }
4434
- if (parentRoute?.type === "external") {
4434
+ if ((parentRoute === null || parentRoute === void 0 ? void 0 : parentRoute.type) === "external") {
4435
4435
  throw new Error("External routes cannot have children");
4436
4436
  }
4437
4437
  if (!normalizedRouteId) return true;
4438
4438
  const descendants = await getRouteDescendants(normalizedRouteId);
4439
4439
  const nonInternalRouteIds = await getNonInternalRouteIds();
4440
4440
  if (normalizedRouteId === newParentId || descendants.includes(newParentId) || nonInternalRouteIds.includes(newParentId)) {
4441
- throw new Error(`Circular dependency detected: Cannot set route ${newParentId} as parent of ${normalizedRouteId}`);
4441
+ throw new Error(
4442
+ `Circular dependency detected: Cannot set route ${newParentId} as parent of ${normalizedRouteId}`
4443
+ );
4442
4444
  }
4443
4445
  return true;
4444
4446
  }
4445
- async function buildNavigationPath({
4446
- slug,
4447
- routeDocumentId,
4448
- calculatedParent
4449
- }) {
4447
+ async function buildNavigationPath({ slug, routeDocumentId, calculatedParent }) {
4448
+ var _a, _b, _c;
4450
4449
  let parentDocumentId = calculatedParent;
4451
4450
  let parent = null;
4452
4451
  if (parentDocumentId) {
@@ -4456,23 +4455,25 @@ async function buildNavigationPath({
4456
4455
  populate: ["route", "parent"]
4457
4456
  });
4458
4457
  parent = navItem;
4459
- parentDocumentId = navItem?.parent?.documentId || null;
4460
- if (parent?.route?.type === "internal") break;
4458
+ parentDocumentId = ((_a = navItem === null || navItem === void 0 ? void 0 : navItem.parent) === null || _a === void 0 ? void 0 : _a.documentId) || null;
4459
+ if (((_b = parent === null || parent === void 0 ? void 0 : parent.route) === null || _b === void 0 ? void 0 : _b.type) === "internal")
4460
+ break;
4461
4461
  } while (parentDocumentId);
4462
4462
  }
4463
- if (parent?.route?.type !== "internal")
4463
+ if (((_c = parent === null || parent === void 0 ? void 0 : parent.route) === null || _c === void 0 ? void 0 : _c.type) !== "internal")
4464
4464
  parent = null;
4465
4465
  if (slug.startsWith("/")) slug = slug.substring(1);
4466
- const newPath = parent?.route ? `${parent.route.path}/${slug}` : `${slug}`;
4466
+ const newPath = (parent === null || parent === void 0 ? void 0 : parent.route) ? `${parent.route.path}/${slug}` : `${slug}`;
4467
4467
  const validatedPath = await duplicateCheck(newPath, routeDocumentId);
4468
4468
  return validatedPath;
4469
4469
  }
4470
4470
  async function handleItemDeletion(navigationItems) {
4471
+ var _a;
4471
4472
  const errors = [];
4472
4473
  let items = [...navigationItems];
4473
4474
  for (let i = 0; i < items.length; i++) {
4474
4475
  const item = items[i];
4475
- if (item.clientModifications?.type === "delete") {
4476
+ if (((_a = item.clientModifications) === null || _a === void 0 ? void 0 : _a.type) === "delete") {
4476
4477
  try {
4477
4478
  if (item.documentId) {
4478
4479
  await deleteNavItem(item.documentId);
@@ -4520,9 +4521,10 @@ async function handleItemUpdate({
4520
4521
  navigationId,
4521
4522
  newNavItemsMap
4522
4523
  }) {
4524
+ var _a, _b, _c, _d;
4523
4525
  const errors = [];
4524
- const isCreate = item.clientModifications?.type === "create";
4525
- const isUpdate = item.clientModifications?.type === "update";
4526
+ const isCreate = ((_a = item.clientModifications) === null || _a === void 0 ? void 0 : _a.type) === "create";
4527
+ const isUpdate = ((_b = item.clientModifications) === null || _b === void 0 ? void 0 : _b.type) === "update";
4526
4528
  const isInternal = item.route.type === "internal";
4527
4529
  if (isCreate && !item.clientModifications.route) {
4528
4530
  try {
@@ -4550,7 +4552,8 @@ async function handleItemUpdate({
4550
4552
  const route2 = await strapi.documents(waRoute).findOne({
4551
4553
  documentId: item.clientModifications.route
4552
4554
  });
4553
- if (!route2) throw new Error(`Related route not found for new navigation item '${item.route.title}'`);
4555
+ if (!route2)
4556
+ throw new Error(`Related route not found for new navigation item '${item.route.title}'`);
4554
4557
  const path = await buildNavigationPath({
4555
4558
  slug: item.route.slug,
4556
4559
  routeDocumentId: route2.documentId,
@@ -4571,7 +4574,10 @@ async function handleItemUpdate({
4571
4574
  if (newNavItem) newNavItemsMap.set(item.documentId, newNavItem);
4572
4575
  } catch (err) {
4573
4576
  errors.push(err instanceof Error ? err.message : String(err));
4574
- strapi.log.error(`Error creating navigation item with existing route '${item.route.title}': `, err);
4577
+ strapi.log.error(
4578
+ `Error creating navigation item with existing route '${item.route.title}': `,
4579
+ err
4580
+ );
4575
4581
  }
4576
4582
  return { success: errors.length === 0, errors };
4577
4583
  }
@@ -4581,23 +4587,33 @@ async function handleItemUpdate({
4581
4587
  const route2 = await strapi.documents(waRoute).findOne({
4582
4588
  documentId: item.route.documentId
4583
4589
  });
4584
- if (!route2) throw new Error(`Related route not found for navigation item '${item.route.title}'`);
4585
- const slug = item.clientModifications?.slug || item.route.slug;
4586
- const path = isInternal ? await buildNavigationPath({ slug, routeDocumentId: route2.documentId, calculatedParent }) : slug;
4590
+ if (!route2)
4591
+ throw new Error(`Related route not found for navigation item '${item.route.title}'`);
4592
+ const slug = ((_c = item.clientModifications) === null || _c === void 0 ? void 0 : _c.slug) || item.route.slug;
4593
+ const path = isInternal ? await buildNavigationPath({
4594
+ slug,
4595
+ routeDocumentId: route2.documentId,
4596
+ calculatedParent
4597
+ }) : slug;
4598
+ const isOverride = path !== route2.canonicalPath;
4587
4599
  if (needsRouteUpdate) {
4588
4600
  await updateRoute(route2.documentId, {
4589
- title: item.clientModifications?.title || item.route.title,
4601
+ title: ((_d = item.clientModifications) === null || _d === void 0 ? void 0 : _d.title) || item.route.title,
4590
4602
  slug,
4591
4603
  path,
4592
- isOverride: path !== route2.canonicalPath
4604
+ isOverride
4593
4605
  });
4594
4606
  }
4595
4607
  if (isInternal) {
4596
- await strapi.entityService.update(item.route.relatedContentType, item.route.relatedDocumentId, {
4597
- data: {
4598
- webatlas_path: path,
4599
- webatlas_override: path !== route2.canonicalPath
4600
- }
4608
+ const webatlasObj = {
4609
+ path,
4610
+ isOverride,
4611
+ parentDocumentId: calculatedParent,
4612
+ slug
4613
+ };
4614
+ await strapi.db.query(item.route.relatedContentType).updateMany({
4615
+ where: { documentId: item.route.relatedDocumentId },
4616
+ data: { webatlas: webatlasObj }
4601
4617
  });
4602
4618
  }
4603
4619
  } catch (err) {
@@ -4622,6 +4638,7 @@ function calculateParentAndOrder({
4622
4638
  groupIndices,
4623
4639
  newNavItemsMap
4624
4640
  }) {
4641
+ var _a;
4625
4642
  if (item.depth === 0) {
4626
4643
  if (groupIndices[0] !== void 0) {
4627
4644
  groupIndices[0] = groupIndices[0] + 1;
@@ -4633,7 +4650,9 @@ function calculateParentAndOrder({
4633
4650
  const previousItem = navigationItems[index2 - 1];
4634
4651
  if (previousItem && typeof previousItem.depth === "number") {
4635
4652
  if (item.depth === previousItem.depth + 1) {
4636
- parentIds.push(previousItem.documentId.startsWith("temp-") ? newNavItemsMap.get(previousItem.documentId)?.documentId || previousItem.documentId : previousItem.documentId);
4653
+ parentIds.push(
4654
+ previousItem.documentId.startsWith("temp-") ? ((_a = newNavItemsMap.get(previousItem.documentId)) === null || _a === void 0 ? void 0 : _a.documentId) || previousItem.documentId : previousItem.documentId
4655
+ );
4637
4656
  groupIndices[item.depth] = 0;
4638
4657
  } else if (item.depth <= previousItem.depth) {
4639
4658
  const diff = previousItem.depth - item.depth;
@@ -4658,21 +4677,19 @@ const migration_001_canonical_path = {
4658
4677
  version: "001",
4659
4678
  description: "Migrate title field to canonicalPath using transformToUrl",
4660
4679
  async up(strapi2) {
4680
+ var _a;
4661
4681
  strapi2.log.info("[webatlas] Starting canonical path migration...");
4662
4682
  try {
4663
- const routes2 = await strapi2.db?.query(waRoute).findMany({
4683
+ const routes2 = await ((_a = strapi2.db) === null || _a === void 0 ? void 0 : _a.query(waRoute).findMany({
4664
4684
  where: {
4665
4685
  title: {
4666
4686
  $notNull: true,
4667
4687
  $ne: ""
4668
4688
  },
4669
- $or: [
4670
- { canonicalPath: { $null: true } },
4671
- { canonicalPath: "" }
4672
- ]
4689
+ $or: [{ canonicalPath: { $null: true } }, { canonicalPath: "" }]
4673
4690
  },
4674
4691
  populate: ["parent"]
4675
- });
4692
+ }));
4676
4693
  if (!routes2 || routes2.length === 0) {
4677
4694
  strapi2.log.info("[webatlas] No routes found that need canonical path migration");
4678
4695
  return;
@@ -4683,28 +4700,35 @@ const migration_001_canonical_path = {
4683
4700
  const chunkSize = 50;
4684
4701
  for (let i = 0; i < routes2.length; i += chunkSize) {
4685
4702
  const chunk = routes2.slice(i, i + chunkSize);
4686
- await Promise.all(chunk.map(async (route2) => {
4687
- try {
4688
- const transformedTitle = transformToUrl(route2.title);
4689
- const parentId = route2.parent?.id || null;
4690
- const canonicalPath = await buildCanonicalPath(transformedTitle, parentId);
4691
- await strapi2.db?.query(waRoute).update({
4692
- where: { id: route2.id },
4693
- data: { canonicalPath }
4694
- });
4695
- migratedCount++;
4696
- if (migratedCount % 25 === 0) {
4697
- strapi2.log.info(`[webatlas] Migrated ${migratedCount}/${routes2.length} routes`);
4703
+ await Promise.all(
4704
+ chunk.map(async (route2) => {
4705
+ var _a2, _b;
4706
+ try {
4707
+ const transformedTitle = transformToUrl(route2.title);
4708
+ const parentId = ((_a2 = route2.parent) === null || _a2 === void 0 ? void 0 : _a2.id) || null;
4709
+ const canonicalPath = await buildCanonicalPath(transformedTitle, parentId);
4710
+ await ((_b = strapi2.db) === null || _b === void 0 ? void 0 : _b.query(waRoute).update({
4711
+ where: { id: route2.id },
4712
+ data: { canonicalPath }
4713
+ }));
4714
+ migratedCount++;
4715
+ if (migratedCount % 25 === 0) {
4716
+ strapi2.log.info(`[webatlas] Migrated ${migratedCount}/${routes2.length} routes`);
4717
+ }
4718
+ } catch (error) {
4719
+ strapi2.log.error(`[webatlas] Failed to migrate route ${route2.id}:`, error);
4720
+ errorCount++;
4698
4721
  }
4699
- } catch (error) {
4700
- strapi2.log.error(`[webatlas] Failed to migrate route ${route2.id}:`, error);
4701
- errorCount++;
4702
- }
4703
- }));
4722
+ })
4723
+ );
4704
4724
  }
4705
- strapi2.log.info(`[webatlas] Canonical path migration completed. Migrated: ${migratedCount}, Errors: ${errorCount}`);
4725
+ strapi2.log.info(
4726
+ `[webatlas] Canonical path migration completed. Migrated: ${migratedCount}, Errors: ${errorCount}`
4727
+ );
4706
4728
  if (errorCount > 0) {
4707
- strapi2.log.warn(`[webatlas] ${errorCount} routes failed to migrate. Check logs for details.`);
4729
+ strapi2.log.warn(
4730
+ `[webatlas] ${errorCount} routes failed to migrate. Check logs for details.`
4731
+ );
4708
4732
  }
4709
4733
  } catch (error) {
4710
4734
  strapi2.log.error("[webatlas] Canonical path migration failed:", error);
@@ -4716,12 +4740,14 @@ const migration_002_webatlas_json_field = {
4716
4740
  version: "002",
4717
4741
  description: "Migrate webatlas_path, webatlas_parent and webatlas_override text fields into the webatlas JSON field",
4718
4742
  async up(strapi2) {
4743
+ var _a, _b;
4719
4744
  const knex = strapi2.db.connection;
4720
- const enabledContentTypes = Object.values(strapi2.contentTypes).filter(
4721
- (ct) => ct.pluginOptions?.webatlas?.enabled === true
4722
- );
4745
+ const enabledContentTypes = Object.values(strapi2.contentTypes).filter((ct) => {
4746
+ var _a2, _b2;
4747
+ return ((_b2 = (_a2 = ct.pluginOptions) === null || _a2 === void 0 ? void 0 : _a2.webatlas) === null || _b2 === void 0 ? void 0 : _b2.enabled) === true;
4748
+ });
4723
4749
  for (const contentType of enabledContentTypes) {
4724
- const tableName = strapi2.db.metadata.get(contentType.uid)?.tableName ?? contentType.collectionName;
4750
+ const tableName = (_b = (_a = strapi2.db.metadata.get(contentType.uid)) === null || _a === void 0 ? void 0 : _a.tableName) !== null && _b !== void 0 ? _b : contentType.collectionName;
4725
4751
  strapi2.log.info(`[webatlas] Processing table: ${tableName} (${contentType.uid})`);
4726
4752
  const [hasPathCol, hasOverrideCol, hasParentCol, hasWebatlasCol] = await Promise.all([
4727
4753
  knex.schema.hasColumn(tableName, "webatlas_path"),
@@ -4733,7 +4759,9 @@ const migration_002_webatlas_json_field = {
4733
4759
  if (!hasAnyOldCol) {
4734
4760
  strapi2.log.info(`[webatlas] No old fields found in ${tableName}, skipping data migration`);
4735
4761
  } else if (!hasWebatlasCol) {
4736
- 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.`);
4762
+ strapi2.log.warn(
4763
+ `[webatlas] New "webatlas" column not found in ${tableName} — schema may not have synced yet. Skipping data migration, old columns will still be dropped.`
4764
+ );
4737
4765
  } else {
4738
4766
  const selectCols = ["id"];
4739
4767
  if (hasPathCol) selectCols.push("webatlas_path");
@@ -4748,11 +4776,18 @@ const migration_002_webatlas_json_field = {
4748
4776
  if (!path && !isOverride && !parentDocumentId) continue;
4749
4777
  const slug = path ? path.split("/").pop() || "" : "";
4750
4778
  await knex(tableName).where({ id: row.id }).update({
4751
- webatlas: JSON.stringify({ path, slug, isOverride, parentDocumentId })
4779
+ webatlas: JSON.stringify({
4780
+ path,
4781
+ slug,
4782
+ isOverride,
4783
+ parentDocumentId
4784
+ })
4752
4785
  });
4753
4786
  migratedCount++;
4754
4787
  }
4755
- strapi2.log.info(`[webatlas] Migrated ${migratedCount} / ${rows.length} rows in ${tableName}`);
4788
+ strapi2.log.info(
4789
+ `[webatlas] Migrated ${migratedCount} / ${rows.length} rows in ${tableName}`
4790
+ );
4756
4791
  }
4757
4792
  const colsToDrop = [
4758
4793
  hasPathCol && "webatlas_path",
@@ -4769,10 +4804,7 @@ const migration_002_webatlas_json_field = {
4769
4804
  strapi2.log.info("[webatlas] webatlas JSON field migration completed");
4770
4805
  }
4771
4806
  };
4772
- const migrations = [
4773
- migration_001_canonical_path,
4774
- migration_002_webatlas_json_field
4775
- ];
4807
+ const migrations = [migration_001_canonical_path, migration_002_webatlas_json_field];
4776
4808
  const runMigrations = async (strapi2) => {
4777
4809
  const pluginStore = strapi2.store({ type: "plugin", name: PLUGIN_ID });
4778
4810
  let config2 = await pluginStore.get({ key: "config" });
@@ -4846,6 +4878,7 @@ function registerPermissions(strapi2) {
4846
4878
  strapi2.admin.services.permission.actionProvider.registerMany(actions);
4847
4879
  }
4848
4880
  async function syncConfig(strapi2, enabledContentTypes) {
4881
+ var _a;
4849
4882
  const pluginStore = strapi2.store({ type: "plugin", name: PLUGIN_ID });
4850
4883
  const config2 = await pluginStore.get({
4851
4884
  key: "config"
@@ -4854,17 +4887,18 @@ async function syncConfig(strapi2, enabledContentTypes) {
4854
4887
  ...config2,
4855
4888
  selectedContentTypes: [],
4856
4889
  navigation: {
4857
- maxDepth: config2?.navigation?.maxDepth || 1,
4858
- ...config2?.navigation
4890
+ maxDepth: ((_a = config2 === null || config2 === void 0 ? void 0 : config2.navigation) === null || _a === void 0 ? void 0 : _a.maxDepth) || 1,
4891
+ ...config2 === null || config2 === void 0 ? void 0 : config2.navigation
4859
4892
  },
4860
- migrationVersion: config2?.migrationVersion || "0"
4893
+ migrationVersion: (config2 === null || config2 === void 0 ? void 0 : config2.migrationVersion) || "0"
4861
4894
  };
4862
4895
  enabledContentTypes.forEach((type) => {
4863
- const existingConfig = config2?.selectedContentTypes?.find((ct) => ct.uid === type.uid);
4896
+ var _a2;
4897
+ const existingConfig = (_a2 = config2 === null || config2 === void 0 ? void 0 : config2.selectedContentTypes) === null || _a2 === void 0 ? void 0 : _a2.find((ct) => ct.uid === type.uid);
4864
4898
  newConfig.selectedContentTypes.push({
4865
4899
  uid: type.uid,
4866
4900
  label: type.info.displayName,
4867
- default: existingConfig?.default || null
4901
+ default: (existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.default) || null
4868
4902
  });
4869
4903
  });
4870
4904
  if (JSON.stringify(newConfig) !== JSON.stringify(config2)) {
@@ -4875,6 +4909,7 @@ async function syncConfig(strapi2, enabledContentTypes) {
4875
4909
  function documentMiddleware(strapi2, enabledContentTypes, config2) {
4876
4910
  const actions = ["create", "update", "delete"];
4877
4911
  strapi2.documents.use(async (context, next) => {
4912
+ var _a, _b, _c, _d, _e, _f;
4878
4913
  if (!enabledContentTypes.map((type) => type.uid).includes(context.uid) || !actions.includes(context.action)) {
4879
4914
  return next();
4880
4915
  }
@@ -4889,14 +4924,16 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4889
4924
  }
4890
4925
  const result2 = await next();
4891
4926
  if (!transformedSlug) return result2;
4892
- const existing = await strapi2.db?.query(waRoute).findOne({
4927
+ const existing = await ((_a = strapi2.db) === null || _a === void 0 ? void 0 : _a.query(waRoute).findOne({
4893
4928
  where: { relatedDocumentId: result2.documentId }
4894
- });
4929
+ }));
4895
4930
  if (existing) return result2;
4896
4931
  let parent = null;
4897
4932
  let isValid = false;
4898
4933
  if (parentDocumentId) {
4899
- isValid = await validateRouteDependencies({ newParentId: parentDocumentId });
4934
+ isValid = await validateRouteDependencies({
4935
+ newParentId: parentDocumentId
4936
+ });
4900
4937
  if (isValid) {
4901
4938
  parent = await strapi2.documents(waRoute).findOne({
4902
4939
  documentId: parentDocumentId
@@ -4906,10 +4943,14 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4906
4943
  let rawPath = transformedSlug;
4907
4944
  if (!isOverride) rawPath = parent ? `${parent.path}/${transformedSlug}` : transformedSlug;
4908
4945
  const validatedPath = await duplicateCheck(rawPath);
4909
- if (!validatedPath) throw new Error(`Failed to generate a unique path for slug: ${transformedSlug}`);
4946
+ if (!validatedPath)
4947
+ throw new Error(`Failed to generate a unique path for slug: ${transformedSlug}`);
4910
4948
  const singularName = context.contentType.info.singularName;
4911
- const title = context.params.data[ctSettings?.default]?.trim() || transformedSlug;
4912
- const canonicalPath = await buildCanonicalPath(transformToUrl(title), isValid ? parent.documentId : null);
4949
+ const title = ((_b = context.params.data[ctSettings === null || ctSettings === void 0 ? void 0 : ctSettings.default]) === null || _b === void 0 ? void 0 : _b.trim()) || transformedSlug;
4950
+ const canonicalPath = await buildCanonicalPath(
4951
+ transformToUrl(title),
4952
+ isValid ? parent.documentId : null
4953
+ );
4913
4954
  await strapi2.documents(waRoute).create({
4914
4955
  data: {
4915
4956
  relatedContentType: context.uid,
@@ -4920,14 +4961,22 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4920
4961
  uidPath: `${singularName}/${result2.id}`,
4921
4962
  isOverride: isOverride || false,
4922
4963
  title,
4923
- parent: isValid ? parent?.documentId : null,
4964
+ parent: isValid ? parent === null || parent === void 0 ? void 0 : parent.documentId : null,
4924
4965
  canonicalPath
4925
4966
  }
4926
4967
  });
4927
- await strapi2.db?.query(context.uid).updateMany({
4968
+ await ((_c = strapi2.db) === null || _c === void 0 ? void 0 : _c.query(context.uid).updateMany({
4928
4969
  where: { documentId: result2.documentId },
4929
- data: { webatlas: { ...webatlas, slug: transformedSlug, path: validatedPath, parentDocumentId: isValid ? parent?.documentId : null } }
4930
- });
4970
+ data: {
4971
+ webatlas: {
4972
+ ...webatlas,
4973
+ slug: transformedSlug,
4974
+ path: validatedPath,
4975
+ parentDocumentId: isValid ? parent === null || parent === void 0 ? void 0 : parent.documentId : "null",
4976
+ isOverride: isOverride || false
4977
+ }
4978
+ }
4979
+ }));
4931
4980
  return result2;
4932
4981
  }
4933
4982
  if (context.action === "update") {
@@ -4957,23 +5006,29 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4957
5006
  const transformedSlug = transformToUrl(slug);
4958
5007
  let rawPath = transformedSlug;
4959
5008
  if (!isOverride) rawPath = parent ? `${parent.path}/${transformedSlug}` : transformedSlug;
4960
- const validatedPath = await duplicateCheck(rawPath, relatedRoute?.documentId ?? null);
5009
+ const validatedPath = await duplicateCheck(
5010
+ rawPath,
5011
+ (_d = relatedRoute === null || relatedRoute === void 0 ? void 0 : relatedRoute.documentId) !== null && _d !== void 0 ? _d : null
5012
+ );
4961
5013
  data.webatlas.path = validatedPath;
4962
5014
  data.webatlas.slug = transformedSlug;
4963
5015
  if (relatedRoute) data.relatedRoute = relatedRoute;
4964
5016
  if (!isValid && parentDocumentId) data.webatlas.parent = null;
4965
5017
  const result2 = await next();
4966
- const title = context.params.data[ctSettings?.default]?.trim() || slug;
4967
- const canonicalPath = isOverride ? relatedRoute.path : await buildCanonicalPath(transformToUrl(title), parent?.documentId);
5018
+ const title = ((_e = context.params.data[ctSettings === null || ctSettings === void 0 ? void 0 : ctSettings.default]) === null || _e === void 0 ? void 0 : _e.trim()) || slug;
5019
+ const canonicalPath = isOverride ? relatedRoute.path : await buildCanonicalPath(
5020
+ transformToUrl(title),
5021
+ parent === null || parent === void 0 ? void 0 : parent.documentId
5022
+ );
4968
5023
  const routeData = {
4969
5024
  title,
4970
5025
  path: validatedPath,
4971
5026
  slug,
4972
5027
  isOverride: isOverride || false,
4973
- parent: parent?.documentId || null,
5028
+ parent: (parent === null || parent === void 0 ? void 0 : parent.documentId) || null,
4974
5029
  canonicalPath
4975
5030
  };
4976
- let routeDocumentId = relatedRoute?.documentId;
5031
+ let routeDocumentId = relatedRoute === null || relatedRoute === void 0 ? void 0 : relatedRoute.documentId;
4977
5032
  if (!relatedRoute) {
4978
5033
  const createdRoute = await strapi2.documents(waRoute).create({
4979
5034
  data: {
@@ -4984,7 +5039,7 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
4984
5039
  ...routeData
4985
5040
  }
4986
5041
  });
4987
- routeDocumentId = createdRoute?.documentId;
5042
+ routeDocumentId = createdRoute === null || createdRoute === void 0 ? void 0 : createdRoute.documentId;
4988
5043
  } else {
4989
5044
  await strapi2.documents(waRoute).update({
4990
5045
  documentId: relatedRoute.documentId,
@@ -5008,8 +5063,11 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
5008
5063
  where: { relatedDocumentId },
5009
5064
  populate: ["navitem"]
5010
5065
  });
5011
- if (!deletedRoute?.documentId) return result2;
5012
- const navItemDocumentIds = Array.from(deletedRoute.navitem?.map((item) => item.documentId));
5066
+ if (!(deletedRoute === null || deletedRoute === void 0 ? void 0 : deletedRoute.documentId))
5067
+ return result2;
5068
+ const navItemDocumentIds = Array.from(
5069
+ (_f = deletedRoute.navitem) === null || _f === void 0 ? void 0 : _f.map((item) => item.documentId)
5070
+ );
5013
5071
  for (const navItemDocumentId of navItemDocumentIds) {
5014
5072
  await strapi2.documents(waNavItem).delete({ documentId: navItemDocumentId });
5015
5073
  }
@@ -5024,15 +5082,16 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
5024
5082
  }
5025
5083
  function webatlasMiddleware(strapi2) {
5026
5084
  strapi2.documents.use(async (context, next) => {
5085
+ var _a, _b;
5027
5086
  if (context.uid !== waNavItem) return next();
5028
5087
  if (context.action === "delete") {
5029
5088
  let externalRouteDocumentId = null;
5030
5089
  try {
5031
- const navItem = await strapi2.db?.query(waNavItem).findOne({
5090
+ const navItem = await ((_a = strapi2.db) === null || _a === void 0 ? void 0 : _a.query(waNavItem).findOne({
5032
5091
  where: { documentId: context.params.documentId },
5033
5092
  populate: ["route"]
5034
- });
5035
- if (navItem?.route?.type === "external") {
5093
+ }));
5094
+ if (((_b = navItem === null || navItem === void 0 ? void 0 : navItem.route) === null || _b === void 0 ? void 0 : _b.type) === "external") {
5036
5095
  externalRouteDocumentId = navItem.route.documentId;
5037
5096
  }
5038
5097
  } catch (err) {
@@ -5051,54 +5110,54 @@ function webatlasMiddleware(strapi2) {
5051
5110
  return next();
5052
5111
  });
5053
5112
  }
5054
- function contentTypeMiddleware(strapi2) {
5055
- strapi2.documents.use(async (context, next) => {
5056
- const pluginOptions = context.contentType?.pluginOptions;
5057
- if (!pluginOptions?.webatlas?.enabled) {
5058
- return next();
5059
- }
5060
- if (!["findOne", "findMany"].includes(context.action)) {
5061
- return next();
5113
+ const sanitizeWebatlas = (config2, { strapi: strapi2 }) => {
5114
+ return async (ctx, next) => {
5115
+ await next();
5116
+ if (!ctx.request.url.startsWith("/api/")) {
5117
+ return;
5062
5118
  }
5063
- const result = await next();
5064
- if (context.action === "findOne") {
5065
- if (!result || typeof result !== "object" || Array.isArray(result)) return result;
5066
- const entry = result;
5067
- const webatlasObj = entry.webatlas || {};
5068
- const newWebatlasObj = {
5069
- path: webatlasObj.path || "",
5070
- slug: webatlasObj.slug || ""
5071
- };
5072
- return { ...entry, webatlas: newWebatlasObj };
5119
+ if (!ctx.body || ctx.status !== 200) {
5120
+ return;
5073
5121
  }
5074
- if (context.action === "findMany") {
5075
- if (!Array.isArray(result)) return result;
5076
- return result.map(
5077
- (entry) => {
5078
- const webatlasObj = entry.webatlas || {};
5079
- const newWebatlasObj = {
5080
- path: webatlasObj.path || "",
5081
- slug: webatlasObj.slug || ""
5082
- };
5083
- return { ...entry, webatlas: newWebatlasObj };
5084
- }
5085
- );
5122
+ const sanitizeWebatlasField = (data) => {
5123
+ if (!data || typeof data !== "object") return data;
5124
+ if (data.webatlas && typeof data.webatlas === "object") {
5125
+ data.webatlas = {
5126
+ path: data.webatlas.path || "",
5127
+ slug: data.webatlas.slug || ""
5128
+ };
5129
+ }
5130
+ return data;
5131
+ };
5132
+ if (ctx.body.data) {
5133
+ if (Array.isArray(ctx.body.data)) {
5134
+ ctx.body.data = ctx.body.data.map(sanitizeWebatlasField);
5135
+ } else {
5136
+ ctx.body.data = sanitizeWebatlasField(ctx.body.data);
5137
+ }
5138
+ } else if (Array.isArray(ctx.body)) {
5139
+ ctx.body = ctx.body.map(sanitizeWebatlasField);
5140
+ } else if (typeof ctx.body === "object") {
5141
+ ctx.body = sanitizeWebatlasField(ctx.body);
5086
5142
  }
5087
- return result;
5088
- });
5089
- }
5143
+ };
5144
+ };
5145
+ const middlewares = {
5146
+ sanitizeWebatlas
5147
+ };
5090
5148
  const bootstrap = async ({ strapi: strapi2 }) => {
5091
5149
  try {
5092
5150
  await runMigrations(strapi2);
5093
5151
  registerPermissions(strapi2);
5094
- const enabledContentTypes = Object.values(strapi2.contentTypes).filter(
5095
- (type) => type.pluginOptions?.webatlas?.enabled === true
5096
- );
5152
+ const enabledContentTypes = Object.values(strapi2.contentTypes).filter((type) => {
5153
+ var _a, _b;
5154
+ return ((_b = (_a = type.pluginOptions) === null || _a === void 0 ? void 0 : _a.webatlas) === null || _b === void 0 ? void 0 : _b.enabled) === true;
5155
+ });
5097
5156
  const config2 = await syncConfig(strapi2, enabledContentTypes);
5098
5157
  if (!enabledContentTypes.length) return;
5099
5158
  documentMiddleware(strapi2, enabledContentTypes, config2);
5100
5159
  webatlasMiddleware(strapi2);
5101
- contentTypeMiddleware(strapi2);
5160
+ strapi2.server.use(middlewares.sanitizeWebatlas({}, { strapi: strapi2 }));
5102
5161
  } catch (error) {
5103
5162
  strapi2.log.error(`Bootstrap failed. ${String(error)}`);
5104
5163
  }
@@ -6009,7 +6068,9 @@ var setExports = requireSet();
6009
6068
  const set = /* @__PURE__ */ getDefaultExportFromCjs(setExports);
6010
6069
  const register = ({ strapi: strapi2 }) => {
6011
6070
  Object.values(strapi2.contentTypes).forEach((contentType) => {
6012
- if (!contentType.pluginOptions?.webatlas?.enabled) return;
6071
+ var _a, _b;
6072
+ if (!((_b = (_a = contentType.pluginOptions) === null || _a === void 0 ? void 0 : _a.webatlas) === null || _b === void 0 ? void 0 : _b.enabled))
6073
+ return;
6013
6074
  const { attributes } = contentType;
6014
6075
  const fieldSettings = {
6015
6076
  writable: true,
@@ -6321,7 +6382,8 @@ const admin$2 = () => ({
6321
6382
  async updateNavigationItemStructure(ctx) {
6322
6383
  try {
6323
6384
  const { navigationId, navigationItems } = ctx.request.body;
6324
- if (!navigationId || !navigationItems) return ctx.throw(400, "NavigationId and Navigation items are required");
6385
+ if (!navigationId || !navigationItems)
6386
+ return ctx.throw(400, "NavigationId and Navigation items are required");
6325
6387
  return await getAdminService().updateNavigationItemStructure(navigationId, navigationItems);
6326
6388
  } catch (e) {
6327
6389
  return ctx.throw(500, e);
@@ -6352,7 +6414,13 @@ const client$2 = ({ strapi: strapi2 }) => ({
6352
6414
  try {
6353
6415
  const { slug, populate, populateDeepDepth, fields, status } = ctx.query;
6354
6416
  if (!slug) return ctx.throw(400, "Slug is required");
6355
- const entity = await getClientService().getEntityByPath(slug, populate, populateDeepDepth, fields, status);
6417
+ const entity = await getClientService().getEntityByPath(
6418
+ slug,
6419
+ populate,
6420
+ populateDeepDepth,
6421
+ fields,
6422
+ status
6423
+ );
6356
6424
  if (!entity) return ctx.throw(404, "Entity not found");
6357
6425
  return ctx.send(entity);
6358
6426
  } catch (e) {
@@ -6362,7 +6430,8 @@ const client$2 = ({ strapi: strapi2 }) => ({
6362
6430
  async getNavigation(ctx) {
6363
6431
  try {
6364
6432
  const { id, name, slug, documentId, variant } = ctx.query;
6365
- if (!id && !name && !slug && !documentId) return ctx.throw(400, "Navigation id, name, slug or documentId is required");
6433
+ if (!id && !name && !slug && !documentId)
6434
+ return ctx.throw(400, "Navigation id, name, slug or documentId is required");
6366
6435
  const navigation2 = await getClientService().getNavigation(id, name, slug, documentId, variant);
6367
6436
  if (!navigation2) return ctx.throw(404, "Navigation not found");
6368
6437
  return ctx.send(navigation2);
@@ -6375,7 +6444,6 @@ const controllers = {
6375
6444
  admin: admin$2,
6376
6445
  client: client$2
6377
6446
  };
6378
- const middlewares = {};
6379
6447
  const hasPermissions = (policyContext, config2, { strapi: strapi2 }) => {
6380
6448
  const { userAbility, user } = policyContext.state;
6381
6449
  const { action, actions } = config2;
@@ -6452,10 +6520,7 @@ const admin$1 = {
6452
6520
  {
6453
6521
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6454
6522
  config: {
6455
- actions: [
6456
- `plugin::${PLUGIN_ID}.page.routes`,
6457
- `plugin::${PLUGIN_ID}.cm.aside`
6458
- ]
6523
+ actions: [`plugin::${PLUGIN_ID}.page.routes`, `plugin::${PLUGIN_ID}.cm.aside`]
6459
6524
  }
6460
6525
  }
6461
6526
  ]
@@ -6471,10 +6536,7 @@ const admin$1 = {
6471
6536
  {
6472
6537
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6473
6538
  config: {
6474
- actions: [
6475
- `plugin::${PLUGIN_ID}.cm.aside`,
6476
- `plugin::${PLUGIN_ID}.page.navigation`
6477
- ]
6539
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.page.navigation`]
6478
6540
  }
6479
6541
  }
6480
6542
  ]
@@ -6490,9 +6552,7 @@ const admin$1 = {
6490
6552
  {
6491
6553
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6492
6554
  config: {
6493
- actions: [
6494
- `plugin::${PLUGIN_ID}.cm.aside`
6495
- ]
6555
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`]
6496
6556
  }
6497
6557
  }
6498
6558
  ]
@@ -6508,9 +6568,7 @@ const admin$1 = {
6508
6568
  {
6509
6569
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6510
6570
  config: {
6511
- actions: [
6512
- `plugin::${PLUGIN_ID}.page.navigation`
6513
- ]
6571
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6514
6572
  }
6515
6573
  }
6516
6574
  ]
@@ -6527,9 +6585,7 @@ const admin$1 = {
6527
6585
  {
6528
6586
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6529
6587
  config: {
6530
- actions: [
6531
- `plugin::${PLUGIN_ID}.page.navigation`
6532
- ]
6588
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6533
6589
  }
6534
6590
  }
6535
6591
  ]
@@ -6545,9 +6601,7 @@ const admin$1 = {
6545
6601
  {
6546
6602
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6547
6603
  config: {
6548
- actions: [
6549
- `plugin::${PLUGIN_ID}.page.navigation`
6550
- ]
6604
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6551
6605
  }
6552
6606
  }
6553
6607
  ]
@@ -6563,9 +6617,7 @@ const admin$1 = {
6563
6617
  {
6564
6618
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6565
6619
  config: {
6566
- actions: [
6567
- `plugin::${PLUGIN_ID}.page.navigation`
6568
- ]
6620
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6569
6621
  }
6570
6622
  }
6571
6623
  ]
@@ -6581,9 +6633,7 @@ const admin$1 = {
6581
6633
  {
6582
6634
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6583
6635
  config: {
6584
- actions: [
6585
- `plugin::${PLUGIN_ID}.page.navigation`
6586
- ]
6636
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6587
6637
  }
6588
6638
  }
6589
6639
  ]
@@ -6599,9 +6649,7 @@ const admin$1 = {
6599
6649
  {
6600
6650
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6601
6651
  config: {
6602
- actions: [
6603
- `plugin::${PLUGIN_ID}.page.navigation`
6604
- ]
6652
+ actions: [`plugin::${PLUGIN_ID}.page.navigation`]
6605
6653
  }
6606
6654
  }
6607
6655
  ]
@@ -6618,10 +6666,7 @@ const admin$1 = {
6618
6666
  {
6619
6667
  name: `plugin::${PLUGIN_ID}.has-permissions`,
6620
6668
  config: {
6621
- actions: [
6622
- `plugin::${PLUGIN_ID}.cm.aside`,
6623
- `plugin::${PLUGIN_ID}.page.navigation`
6624
- ]
6669
+ actions: [`plugin::${PLUGIN_ID}.cm.aside`, `plugin::${PLUGIN_ID}.page.navigation`]
6625
6670
  }
6626
6671
  }
6627
6672
  ]
@@ -6659,7 +6704,10 @@ const admin = ({ strapi: strapi2 }) => ({
6659
6704
  if (!newConfig) return;
6660
6705
  let newConfigMerged;
6661
6706
  try {
6662
- const pluginStore = await strapi2.store({ type: "plugin", name: PLUGIN_ID });
6707
+ const pluginStore = await strapi2.store({
6708
+ type: "plugin",
6709
+ name: PLUGIN_ID
6710
+ });
6663
6711
  const config2 = await pluginStore.get({ key: "config" });
6664
6712
  newConfigMerged = { ...config2, ...newConfig };
6665
6713
  await pluginStore.set({ key: "config", value: newConfigMerged });
@@ -6680,7 +6728,7 @@ const admin = ({ strapi: strapi2 }) => ({
6680
6728
  ...config2,
6681
6729
  navigation: {
6682
6730
  ...defaultConfig.navigation,
6683
- ...config2?.navigation
6731
+ ...config2 === null || config2 === void 0 ? void 0 : config2.navigation
6684
6732
  }
6685
6733
  };
6686
6734
  return config2;
@@ -6703,13 +6751,14 @@ const admin = ({ strapi: strapi2 }) => ({
6703
6751
  }
6704
6752
  },
6705
6753
  async getRelatedRoute(documentId) {
6754
+ var _a;
6706
6755
  try {
6707
- return await strapi2.db?.query(waRoute).findOne({
6756
+ return await ((_a = strapi2.db) === null || _a === void 0 ? void 0 : _a.query(waRoute).findOne({
6708
6757
  where: {
6709
6758
  relatedDocumentId: documentId
6710
6759
  },
6711
6760
  populate: ["parent"]
6712
- });
6761
+ }));
6713
6762
  } catch (e) {
6714
6763
  strapi2.log.error(e);
6715
6764
  }
@@ -6722,10 +6771,10 @@ const admin = ({ strapi: strapi2 }) => ({
6722
6771
  documentId
6723
6772
  });
6724
6773
  }
6725
- const descendants = route2?.documentId ? await getRouteDescendants(route2.documentId) : [];
6774
+ const descendants = (route2 === null || route2 === void 0 ? void 0 : route2.documentId) ? await getRouteDescendants(route2.documentId) : [];
6726
6775
  const nonInternalRouteIds = await getNonInternalRouteIds();
6727
6776
  const prohibitedRouteIds = [...descendants, ...nonInternalRouteIds];
6728
- route2?.documentId && prohibitedRouteIds.push(route2.documentId);
6777
+ (route2 === null || route2 === void 0 ? void 0 : route2.documentId) && prohibitedRouteIds.push(route2.documentId);
6729
6778
  return prohibitedRouteIds;
6730
6779
  } catch (e) {
6731
6780
  strapi2.log.error(e);
@@ -6751,8 +6800,7 @@ const admin = ({ strapi: strapi2 }) => ({
6751
6800
  populate: ["items", "items.route", "items.parent"]
6752
6801
  });
6753
6802
  if (!navigation2) throw new Error("Navigation not found");
6754
- if (variant)
6755
- navigation2 = buildStructuredNavigation(navigation2, variant);
6803
+ if (variant) navigation2 = buildStructuredNavigation(navigation2, variant);
6756
6804
  } else {
6757
6805
  navigation2 = await strapi2.documents(waNavigation).findMany({
6758
6806
  populate: ["items", "items.route", "items.parent"]
@@ -6867,22 +6915,24 @@ const client = ({ strapi: strapi2 }) => ({
6867
6915
  try {
6868
6916
  const route2 = await strapi2.documents(waRoute).findFirst({
6869
6917
  filters: {
6870
- $or: [
6871
- { path: slug },
6872
- { canonicalPath: slug },
6873
- { uidPath: slug }
6874
- ]
6918
+ $or: [{ path: slug }, { canonicalPath: slug }, { uidPath: slug }]
6875
6919
  }
6876
6920
  });
6877
6921
  if (!route2) return null;
6878
6922
  let populateObject = populate;
6879
6923
  if (populate === "deep") {
6880
- const modelObject = getFullPopulateObject(route2.relatedContentType, Number(populateDeepDepth), []);
6924
+ const modelObject = getFullPopulateObject(
6925
+ route2.relatedContentType,
6926
+ Number(populateDeepDepth),
6927
+ []
6928
+ );
6881
6929
  if (typeof modelObject === "object" && "populate" in modelObject) {
6882
6930
  populateObject = modelObject.populate;
6883
6931
  }
6884
6932
  }
6885
- const contentTypeObject = Object.entries(strapi2.contentTypes).find(([key, value]) => key === route2.relatedContentType);
6933
+ const contentTypeObject = Object.entries(strapi2.contentTypes).find(
6934
+ ([key, value]) => key === route2.relatedContentType
6935
+ );
6886
6936
  if (!contentTypeObject) {
6887
6937
  return null;
6888
6938
  }
@@ -6929,26 +6979,35 @@ const client = ({ strapi: strapi2 }) => ({
6929
6979
  },
6930
6980
  {
6931
6981
  condition: slug,
6932
- lookup: () => strapi2.db?.query(waNavigation).findOne({
6933
- where: { slug },
6934
- populate: populateObject
6935
- }),
6982
+ lookup: () => {
6983
+ var _a;
6984
+ return (_a = strapi2.db) === null || _a === void 0 ? void 0 : _a.query(waNavigation).findOne({
6985
+ where: { slug },
6986
+ populate: populateObject
6987
+ });
6988
+ },
6936
6989
  name: "slug"
6937
6990
  },
6938
6991
  {
6939
6992
  condition: name,
6940
- lookup: () => strapi2.db?.query(waNavigation).findOne({
6941
- where: { name },
6942
- populate: populateObject
6943
- }),
6993
+ lookup: () => {
6994
+ var _a;
6995
+ return (_a = strapi2.db) === null || _a === void 0 ? void 0 : _a.query(waNavigation).findOne({
6996
+ where: { name },
6997
+ populate: populateObject
6998
+ });
6999
+ },
6944
7000
  name: "name"
6945
7001
  },
6946
7002
  {
6947
7003
  condition: id,
6948
- lookup: () => strapi2.db?.query(waNavigation).findOne({
6949
- where: { id },
6950
- populate: populateObject
6951
- }),
7004
+ lookup: () => {
7005
+ var _a;
7006
+ return (_a = strapi2.db) === null || _a === void 0 ? void 0 : _a.query(waNavigation).findOne({
7007
+ where: { id },
7008
+ populate: populateObject
7009
+ });
7010
+ },
6952
7011
  name: "id"
6953
7012
  }
6954
7013
  ];