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