@mattisvensson/strapi-plugin-webatlas 0.11.1 → 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/dist/admin/FullLoader-Btjb2W2p.mjs +0 -1
- package/dist/admin/FullLoader-Da2n70bJ.js +0 -1
- package/dist/admin/SettingTitle-B0quw3f8.js +0 -1
- package/dist/admin/SettingTitle-HMfQOJnK.mjs +0 -1
- 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-9_HhKDUC.mjs +0 -1
- package/dist/admin/index-B79ELMEC.mjs +0 -1
- package/dist/admin/index-BEVoxEAm.js +0 -1
- package/dist/admin/index-Bmg-ERct.mjs +0 -1
- package/dist/admin/index-C8YjuuOx.js +0 -1
- package/dist/admin/index-Cx_mktdk.js +0 -1
- package/dist/admin/index-Cz_k_jjp.mjs +0 -1
- package/dist/admin/index-D2hB1vTw.js +0 -1
- package/dist/admin/index-YdWxpvOH.js +0 -1
- package/dist/admin/index-oEJT_mvw.mjs +0 -1
- package/dist/admin/index.js +0 -1
- package/dist/admin/index.mjs +0 -1
- package/dist/admin/src/index.d.ts +12 -0
- package/dist/server/index.js +87 -117
- package/dist/server/index.mjs +87 -117
- package/dist/server/src/index.d.ts +305 -0
- package/package.json +1 -1
- package/dist/admin/FullLoader-Btjb2W2p.mjs.map +0 -1
- package/dist/admin/FullLoader-Da2n70bJ.js.map +0 -1
- package/dist/admin/SettingTitle-B0quw3f8.js.map +0 -1
- package/dist/admin/SettingTitle-HMfQOJnK.mjs.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-9_HhKDUC.mjs.map +0 -1
- package/dist/admin/index-B79ELMEC.mjs.map +0 -1
- package/dist/admin/index-BEVoxEAm.js.map +0 -1
- package/dist/admin/index-Bmg-ERct.mjs.map +0 -1
- package/dist/admin/index-C8YjuuOx.js.map +0 -1
- package/dist/admin/index-Cx_mktdk.js.map +0 -1
- package/dist/admin/index-Cz_k_jjp.mjs.map +0 -1
- package/dist/admin/index-D2hB1vTw.js.map +0 -1
- package/dist/admin/index-YdWxpvOH.js.map +0 -1
- package/dist/admin/index-oEJT_mvw.mjs.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/server/index.mjs
CHANGED
|
@@ -100,16 +100,16 @@ async function deleteNavItem(documentId) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
function getAdminService() {
|
|
103
|
-
|
|
104
|
-
return (_a = strapi.plugin(PLUGIN_ID)) === null || _a === void 0 ? void 0 : _a.service("admin");
|
|
103
|
+
return strapi.plugin(PLUGIN_ID)?.service("admin");
|
|
105
104
|
}
|
|
106
105
|
function getClientService() {
|
|
107
|
-
|
|
108
|
-
return (_a = strapi.plugin(PLUGIN_ID)) === null || _a === void 0 ? void 0 : _a.service("client");
|
|
106
|
+
return strapi.plugin(PLUGIN_ID)?.service("client");
|
|
109
107
|
}
|
|
110
108
|
function reduceDepthOfOrphanedItems(navigationItems, itemId) {
|
|
111
109
|
const navigationItemsCopy = JSON.parse(JSON.stringify(navigationItems));
|
|
112
|
-
const startItemIndex = navigationItemsCopy.findIndex(
|
|
110
|
+
const startItemIndex = navigationItemsCopy.findIndex(
|
|
111
|
+
(item) => item.documentId === itemId
|
|
112
|
+
);
|
|
113
113
|
if (startItemIndex === -1) return;
|
|
114
114
|
const startItem = navigationItemsCopy[startItemIndex];
|
|
115
115
|
for (let i = startItemIndex + 1; i < navigationItemsCopy.length; i++) {
|
|
@@ -168,11 +168,9 @@ async function deleteRoute(documentId) {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
function buildStructuredNavigation(navigation2, variant = "nested") {
|
|
171
|
-
var _a;
|
|
172
171
|
const itemsById = /* @__PURE__ */ new Map();
|
|
173
172
|
const rootItems = [];
|
|
174
|
-
if (!navigation2.items ||
|
|
175
|
-
return navigation2;
|
|
173
|
+
if (!navigation2.items || navigation2.items?.length === 0) return navigation2;
|
|
176
174
|
navigation2.items.forEach((item) => {
|
|
177
175
|
itemsById.set(item.documentId, { ...item, items: [] });
|
|
178
176
|
});
|
|
@@ -246,7 +244,6 @@ const sortItems = (items) => {
|
|
|
246
244
|
};
|
|
247
245
|
function extractRouteAndItems(items) {
|
|
248
246
|
return items.map((item) => {
|
|
249
|
-
var _a;
|
|
250
247
|
const route2 = { ...item.route };
|
|
251
248
|
if (!route2) return null;
|
|
252
249
|
let depth = null;
|
|
@@ -254,7 +251,7 @@ function extractRouteAndItems(items) {
|
|
|
254
251
|
depth = item.depth;
|
|
255
252
|
}
|
|
256
253
|
let children = null;
|
|
257
|
-
if (
|
|
254
|
+
if (item.items?.length > 0) {
|
|
258
255
|
const items2 = extractRouteAndItems(item.items);
|
|
259
256
|
if (items2.length > 0) children = items2;
|
|
260
257
|
}
|
|
@@ -4258,7 +4255,6 @@ const getModelPopulationAttributes = (model) => {
|
|
|
4258
4255
|
return model.attributes;
|
|
4259
4256
|
};
|
|
4260
4257
|
function getFullPopulateObject(modelUid, maxDepth = 5, ignore = []) {
|
|
4261
|
-
var _a;
|
|
4262
4258
|
if (maxDepth <= 1) {
|
|
4263
4259
|
return true;
|
|
4264
4260
|
}
|
|
@@ -4271,12 +4267,12 @@ function getFullPopulateObject(modelUid, maxDepth = 5, ignore = []) {
|
|
|
4271
4267
|
const populate = {};
|
|
4272
4268
|
const model = strapi.getModel(modelUid);
|
|
4273
4269
|
const newIgnore = [...ignore, modelUid];
|
|
4274
|
-
if (
|
|
4270
|
+
if (model.options?.populateCreatorFields) {
|
|
4275
4271
|
populate.createdBy = true;
|
|
4276
4272
|
populate.updatedBy = true;
|
|
4277
4273
|
}
|
|
4278
4274
|
for (const [key, value] of Object.entries(getModelPopulationAttributes(model))) {
|
|
4279
|
-
if (ignore
|
|
4275
|
+
if (ignore?.includes(key)) continue;
|
|
4280
4276
|
if (value) {
|
|
4281
4277
|
if (value.type === "component") {
|
|
4282
4278
|
const componentPopulate = getFullPopulateObject(value.component, maxDepth - 1, newIgnore);
|
|
@@ -4330,7 +4326,7 @@ async function buildCanonicalPath(slug, parentDocumentId) {
|
|
|
4330
4326
|
const parentRoute = await strapi.documents(waRoute).findOne({
|
|
4331
4327
|
documentId: parentDocumentId
|
|
4332
4328
|
});
|
|
4333
|
-
const parentCanonicalPath =
|
|
4329
|
+
const parentCanonicalPath = parentRoute?.canonicalPath || "";
|
|
4334
4330
|
const canonicalPath = `${parentCanonicalPath ? parentCanonicalPath + "/" : ""}${slug}`;
|
|
4335
4331
|
return canonicalPath;
|
|
4336
4332
|
} catch (err) {
|
|
@@ -4420,16 +4416,19 @@ async function getNonInternalRouteIds() {
|
|
|
4420
4416
|
const routeIds = routes2.map((route2) => route2.documentId);
|
|
4421
4417
|
return routeIds;
|
|
4422
4418
|
}
|
|
4423
|
-
async function validateRouteDependencies({
|
|
4419
|
+
async function validateRouteDependencies({
|
|
4420
|
+
routeId,
|
|
4421
|
+
newParentId
|
|
4422
|
+
}) {
|
|
4424
4423
|
if (!newParentId) return true;
|
|
4425
|
-
const normalizedRouteId = routeId
|
|
4424
|
+
const normalizedRouteId = routeId ?? void 0;
|
|
4426
4425
|
const parentRoute = await strapi.documents(waRoute).findOne({
|
|
4427
4426
|
documentId: newParentId
|
|
4428
4427
|
});
|
|
4429
4428
|
if (!parentRoute) {
|
|
4430
4429
|
throw new Error(`Parent route not found: ${newParentId}`);
|
|
4431
4430
|
}
|
|
4432
|
-
if (
|
|
4431
|
+
if (parentRoute?.type === "external") {
|
|
4433
4432
|
throw new Error("External routes cannot have children");
|
|
4434
4433
|
}
|
|
4435
4434
|
if (!normalizedRouteId) return true;
|
|
@@ -4442,8 +4441,11 @@ async function validateRouteDependencies({ routeId, newParentId }) {
|
|
|
4442
4441
|
}
|
|
4443
4442
|
return true;
|
|
4444
4443
|
}
|
|
4445
|
-
async function buildNavigationPath({
|
|
4446
|
-
|
|
4444
|
+
async function buildNavigationPath({
|
|
4445
|
+
slug,
|
|
4446
|
+
routeDocumentId,
|
|
4447
|
+
calculatedParent
|
|
4448
|
+
}) {
|
|
4447
4449
|
let parentDocumentId = calculatedParent;
|
|
4448
4450
|
let parent = null;
|
|
4449
4451
|
if (parentDocumentId) {
|
|
@@ -4453,25 +4455,22 @@ async function buildNavigationPath({ slug, routeDocumentId, calculatedParent })
|
|
|
4453
4455
|
populate: ["route", "parent"]
|
|
4454
4456
|
});
|
|
4455
4457
|
parent = navItem;
|
|
4456
|
-
parentDocumentId =
|
|
4457
|
-
if (
|
|
4458
|
-
break;
|
|
4458
|
+
parentDocumentId = navItem?.parent?.documentId || null;
|
|
4459
|
+
if (parent?.route?.type === "internal") break;
|
|
4459
4460
|
} while (parentDocumentId);
|
|
4460
4461
|
}
|
|
4461
|
-
if (
|
|
4462
|
-
parent = null;
|
|
4462
|
+
if (parent?.route?.type !== "internal") parent = null;
|
|
4463
4463
|
if (slug.startsWith("/")) slug = slug.substring(1);
|
|
4464
|
-
const newPath =
|
|
4464
|
+
const newPath = parent?.route ? `${parent.route.path}/${slug}` : `${slug}`;
|
|
4465
4465
|
const validatedPath = await duplicateCheck(newPath, routeDocumentId);
|
|
4466
4466
|
return validatedPath;
|
|
4467
4467
|
}
|
|
4468
4468
|
async function handleItemDeletion(navigationItems) {
|
|
4469
|
-
var _a;
|
|
4470
4469
|
const errors = [];
|
|
4471
4470
|
let items = [...navigationItems];
|
|
4472
4471
|
for (let i = 0; i < items.length; i++) {
|
|
4473
4472
|
const item = items[i];
|
|
4474
|
-
if (
|
|
4473
|
+
if (item.clientModifications?.type === "delete") {
|
|
4475
4474
|
try {
|
|
4476
4475
|
if (item.documentId) {
|
|
4477
4476
|
await deleteNavItem(item.documentId);
|
|
@@ -4519,10 +4518,9 @@ async function handleItemUpdate({
|
|
|
4519
4518
|
navigationId,
|
|
4520
4519
|
newNavItemsMap
|
|
4521
4520
|
}) {
|
|
4522
|
-
var _a, _b, _c, _d;
|
|
4523
4521
|
const errors = [];
|
|
4524
|
-
const isCreate =
|
|
4525
|
-
const isUpdate =
|
|
4522
|
+
const isCreate = item.clientModifications?.type === "create";
|
|
4523
|
+
const isUpdate = item.clientModifications?.type === "update";
|
|
4526
4524
|
const isInternal = item.route.type === "internal";
|
|
4527
4525
|
if (isCreate && !item.clientModifications.route) {
|
|
4528
4526
|
try {
|
|
@@ -4587,7 +4585,7 @@ async function handleItemUpdate({
|
|
|
4587
4585
|
});
|
|
4588
4586
|
if (!route2)
|
|
4589
4587
|
throw new Error(`Related route not found for navigation item '${item.route.title}'`);
|
|
4590
|
-
const slug =
|
|
4588
|
+
const slug = item.clientModifications?.slug || item.route.slug;
|
|
4591
4589
|
const path = isInternal ? await buildNavigationPath({
|
|
4592
4590
|
slug,
|
|
4593
4591
|
routeDocumentId: route2.documentId,
|
|
@@ -4596,7 +4594,7 @@ async function handleItemUpdate({
|
|
|
4596
4594
|
const isOverride = path !== route2.canonicalPath;
|
|
4597
4595
|
if (needsRouteUpdate) {
|
|
4598
4596
|
await updateRoute(route2.documentId, {
|
|
4599
|
-
title:
|
|
4597
|
+
title: item.clientModifications?.title || item.route.title,
|
|
4600
4598
|
slug,
|
|
4601
4599
|
path,
|
|
4602
4600
|
isOverride
|
|
@@ -4636,7 +4634,6 @@ function calculateParentAndOrder({
|
|
|
4636
4634
|
groupIndices,
|
|
4637
4635
|
newNavItemsMap
|
|
4638
4636
|
}) {
|
|
4639
|
-
var _a;
|
|
4640
4637
|
if (item.depth === 0) {
|
|
4641
4638
|
if (groupIndices[0] !== void 0) {
|
|
4642
4639
|
groupIndices[0] = groupIndices[0] + 1;
|
|
@@ -4649,7 +4646,7 @@ function calculateParentAndOrder({
|
|
|
4649
4646
|
if (previousItem && typeof previousItem.depth === "number") {
|
|
4650
4647
|
if (item.depth === previousItem.depth + 1) {
|
|
4651
4648
|
parentIds.push(
|
|
4652
|
-
previousItem.documentId.startsWith("temp-") ?
|
|
4649
|
+
previousItem.documentId.startsWith("temp-") ? newNavItemsMap.get(previousItem.documentId)?.documentId || previousItem.documentId : previousItem.documentId
|
|
4653
4650
|
);
|
|
4654
4651
|
groupIndices[item.depth] = 0;
|
|
4655
4652
|
} else if (item.depth <= previousItem.depth) {
|
|
@@ -4675,10 +4672,9 @@ const migration_001_canonical_path = {
|
|
|
4675
4672
|
version: "001",
|
|
4676
4673
|
description: "Migrate title field to canonicalPath using transformToUrl",
|
|
4677
4674
|
async up(strapi2) {
|
|
4678
|
-
var _a;
|
|
4679
4675
|
strapi2.log.info("[webatlas] Starting canonical path migration...");
|
|
4680
4676
|
try {
|
|
4681
|
-
const routes2 = await
|
|
4677
|
+
const routes2 = await strapi2.db?.query(waRoute).findMany({
|
|
4682
4678
|
where: {
|
|
4683
4679
|
title: {
|
|
4684
4680
|
$notNull: true,
|
|
@@ -4687,7 +4683,7 @@ const migration_001_canonical_path = {
|
|
|
4687
4683
|
$or: [{ canonicalPath: { $null: true } }, { canonicalPath: "" }]
|
|
4688
4684
|
},
|
|
4689
4685
|
populate: ["parent"]
|
|
4690
|
-
})
|
|
4686
|
+
});
|
|
4691
4687
|
if (!routes2 || routes2.length === 0) {
|
|
4692
4688
|
strapi2.log.info("[webatlas] No routes found that need canonical path migration");
|
|
4693
4689
|
return;
|
|
@@ -4700,15 +4696,14 @@ const migration_001_canonical_path = {
|
|
|
4700
4696
|
const chunk = routes2.slice(i, i + chunkSize);
|
|
4701
4697
|
await Promise.all(
|
|
4702
4698
|
chunk.map(async (route2) => {
|
|
4703
|
-
var _a2, _b;
|
|
4704
4699
|
try {
|
|
4705
4700
|
const transformedTitle = transformToUrl(route2.title);
|
|
4706
|
-
const parentId =
|
|
4701
|
+
const parentId = route2.parent?.id || null;
|
|
4707
4702
|
const canonicalPath = await buildCanonicalPath(transformedTitle, parentId);
|
|
4708
|
-
await
|
|
4703
|
+
await strapi2.db?.query(waRoute).update({
|
|
4709
4704
|
where: { id: route2.id },
|
|
4710
4705
|
data: { canonicalPath }
|
|
4711
|
-
})
|
|
4706
|
+
});
|
|
4712
4707
|
migratedCount++;
|
|
4713
4708
|
if (migratedCount % 25 === 0) {
|
|
4714
4709
|
strapi2.log.info(`[webatlas] Migrated ${migratedCount}/${routes2.length} routes`);
|
|
@@ -4738,14 +4733,12 @@ const migration_002_webatlas_json_field = {
|
|
|
4738
4733
|
version: "002",
|
|
4739
4734
|
description: "Migrate webatlas_path, webatlas_parent and webatlas_override text fields into the webatlas JSON field",
|
|
4740
4735
|
async up(strapi2) {
|
|
4741
|
-
var _a, _b;
|
|
4742
4736
|
const knex = strapi2.db.connection;
|
|
4743
|
-
const enabledContentTypes = Object.values(strapi2.contentTypes).filter(
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
});
|
|
4737
|
+
const enabledContentTypes = Object.values(strapi2.contentTypes).filter(
|
|
4738
|
+
(ct) => ct.pluginOptions?.webatlas?.enabled === true
|
|
4739
|
+
);
|
|
4747
4740
|
for (const contentType of enabledContentTypes) {
|
|
4748
|
-
const tableName =
|
|
4741
|
+
const tableName = strapi2.db.metadata.get(contentType.uid)?.tableName ?? contentType.collectionName;
|
|
4749
4742
|
strapi2.log.info(`[webatlas] Processing table: ${tableName} (${contentType.uid})`);
|
|
4750
4743
|
const [hasPathCol, hasOverrideCol, hasParentCol, hasWebatlasCol] = await Promise.all([
|
|
4751
4744
|
knex.schema.hasColumn(tableName, "webatlas_path"),
|
|
@@ -4876,7 +4869,6 @@ function registerPermissions(strapi2) {
|
|
|
4876
4869
|
strapi2.admin.services.permission.actionProvider.registerMany(actions);
|
|
4877
4870
|
}
|
|
4878
4871
|
async function syncConfig(strapi2, enabledContentTypes) {
|
|
4879
|
-
var _a;
|
|
4880
4872
|
const pluginStore = strapi2.store({ type: "plugin", name: PLUGIN_ID });
|
|
4881
4873
|
const config2 = await pluginStore.get({
|
|
4882
4874
|
key: "config"
|
|
@@ -4885,18 +4877,17 @@ async function syncConfig(strapi2, enabledContentTypes) {
|
|
|
4885
4877
|
...config2,
|
|
4886
4878
|
selectedContentTypes: [],
|
|
4887
4879
|
navigation: {
|
|
4888
|
-
maxDepth:
|
|
4889
|
-
...config2
|
|
4880
|
+
maxDepth: config2?.navigation?.maxDepth || 1,
|
|
4881
|
+
...config2?.navigation
|
|
4890
4882
|
},
|
|
4891
|
-
migrationVersion:
|
|
4883
|
+
migrationVersion: config2?.migrationVersion || "0"
|
|
4892
4884
|
};
|
|
4893
4885
|
enabledContentTypes.forEach((type) => {
|
|
4894
|
-
|
|
4895
|
-
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);
|
|
4886
|
+
const existingConfig = config2?.selectedContentTypes?.find((ct) => ct.uid === type.uid);
|
|
4896
4887
|
newConfig.selectedContentTypes.push({
|
|
4897
4888
|
uid: type.uid,
|
|
4898
4889
|
label: type.info.displayName,
|
|
4899
|
-
default:
|
|
4890
|
+
default: existingConfig?.default || null
|
|
4900
4891
|
});
|
|
4901
4892
|
});
|
|
4902
4893
|
if (JSON.stringify(newConfig) !== JSON.stringify(config2)) {
|
|
@@ -4907,7 +4898,6 @@ async function syncConfig(strapi2, enabledContentTypes) {
|
|
|
4907
4898
|
function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
4908
4899
|
const actions = ["create", "update", "delete"];
|
|
4909
4900
|
strapi2.documents.use(async (context, next) => {
|
|
4910
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4911
4901
|
if (!enabledContentTypes.map((type) => type.uid).includes(context.uid) || !actions.includes(context.action)) {
|
|
4912
4902
|
return next();
|
|
4913
4903
|
}
|
|
@@ -4922,9 +4912,9 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
|
4922
4912
|
}
|
|
4923
4913
|
const result2 = await next();
|
|
4924
4914
|
if (!transformedSlug) return result2;
|
|
4925
|
-
const existing = await
|
|
4915
|
+
const existing = await strapi2.db?.query(waRoute).findOne({
|
|
4926
4916
|
where: { relatedDocumentId: result2.documentId }
|
|
4927
|
-
})
|
|
4917
|
+
});
|
|
4928
4918
|
if (existing) return result2;
|
|
4929
4919
|
let parent = null;
|
|
4930
4920
|
let isValid = false;
|
|
@@ -4944,7 +4934,7 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
|
4944
4934
|
if (!validatedPath)
|
|
4945
4935
|
throw new Error(`Failed to generate a unique path for slug: ${transformedSlug}`);
|
|
4946
4936
|
const singularName = context.contentType.info.singularName;
|
|
4947
|
-
const title =
|
|
4937
|
+
const title = context.params.data[ctSettings?.default]?.trim() || transformedSlug;
|
|
4948
4938
|
const canonicalPath = await buildCanonicalPath(
|
|
4949
4939
|
transformToUrl(title),
|
|
4950
4940
|
isValid ? parent.documentId : null
|
|
@@ -4959,22 +4949,22 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
|
4959
4949
|
uidPath: `${singularName}/${result2.id}`,
|
|
4960
4950
|
isOverride: isOverride || false,
|
|
4961
4951
|
title,
|
|
4962
|
-
parent: isValid ? parent
|
|
4952
|
+
parent: isValid ? parent?.documentId : null,
|
|
4963
4953
|
canonicalPath
|
|
4964
4954
|
}
|
|
4965
4955
|
});
|
|
4966
|
-
await
|
|
4956
|
+
await strapi2.db?.query(context.uid).updateMany({
|
|
4967
4957
|
where: { documentId: result2.documentId },
|
|
4968
4958
|
data: {
|
|
4969
4959
|
webatlas: {
|
|
4970
4960
|
...webatlas,
|
|
4971
4961
|
slug: transformedSlug,
|
|
4972
4962
|
path: validatedPath,
|
|
4973
|
-
parentDocumentId: isValid ? parent
|
|
4963
|
+
parentDocumentId: isValid ? parent?.documentId : null,
|
|
4974
4964
|
isOverride: isOverride || false
|
|
4975
4965
|
}
|
|
4976
4966
|
}
|
|
4977
|
-
})
|
|
4967
|
+
});
|
|
4978
4968
|
return result2;
|
|
4979
4969
|
}
|
|
4980
4970
|
if (context.action === "update") {
|
|
@@ -5004,29 +4994,23 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
|
5004
4994
|
const transformedSlug = transformToUrl(slug);
|
|
5005
4995
|
let rawPath = transformedSlug;
|
|
5006
4996
|
if (!isOverride) rawPath = parent ? `${parent.path}/${transformedSlug}` : transformedSlug;
|
|
5007
|
-
const validatedPath = await duplicateCheck(
|
|
5008
|
-
rawPath,
|
|
5009
|
-
(_d = relatedRoute === null || relatedRoute === void 0 ? void 0 : relatedRoute.documentId) !== null && _d !== void 0 ? _d : null
|
|
5010
|
-
);
|
|
4997
|
+
const validatedPath = await duplicateCheck(rawPath, relatedRoute?.documentId ?? null);
|
|
5011
4998
|
data.webatlas.path = validatedPath;
|
|
5012
4999
|
data.webatlas.slug = transformedSlug;
|
|
5013
5000
|
if (relatedRoute) data.relatedRoute = relatedRoute;
|
|
5014
5001
|
if (!isValid && parentDocumentId) data.webatlas.parent = null;
|
|
5015
5002
|
const result2 = await next();
|
|
5016
|
-
const title =
|
|
5017
|
-
const canonicalPath = isOverride ? relatedRoute.path : await buildCanonicalPath(
|
|
5018
|
-
transformToUrl(title),
|
|
5019
|
-
parent === null || parent === void 0 ? void 0 : parent.documentId
|
|
5020
|
-
);
|
|
5003
|
+
const title = context.params.data[ctSettings?.default]?.trim() || slug;
|
|
5004
|
+
const canonicalPath = isOverride ? relatedRoute.path : await buildCanonicalPath(transformToUrl(title), parent?.documentId);
|
|
5021
5005
|
const routeData = {
|
|
5022
5006
|
title,
|
|
5023
5007
|
path: validatedPath,
|
|
5024
5008
|
slug,
|
|
5025
5009
|
isOverride: isOverride || false,
|
|
5026
|
-
parent:
|
|
5010
|
+
parent: parent?.documentId || null,
|
|
5027
5011
|
canonicalPath
|
|
5028
5012
|
};
|
|
5029
|
-
let routeDocumentId = relatedRoute
|
|
5013
|
+
let routeDocumentId = relatedRoute?.documentId;
|
|
5030
5014
|
if (!relatedRoute) {
|
|
5031
5015
|
const createdRoute = await strapi2.documents(waRoute).create({
|
|
5032
5016
|
data: {
|
|
@@ -5037,7 +5021,7 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
|
5037
5021
|
...routeData
|
|
5038
5022
|
}
|
|
5039
5023
|
});
|
|
5040
|
-
routeDocumentId = createdRoute
|
|
5024
|
+
routeDocumentId = createdRoute?.documentId;
|
|
5041
5025
|
} else {
|
|
5042
5026
|
await strapi2.documents(waRoute).update({
|
|
5043
5027
|
documentId: relatedRoute.documentId,
|
|
@@ -5061,10 +5045,9 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
|
5061
5045
|
where: { relatedDocumentId },
|
|
5062
5046
|
populate: ["navitem"]
|
|
5063
5047
|
});
|
|
5064
|
-
if (!
|
|
5065
|
-
return result2;
|
|
5048
|
+
if (!deletedRoute?.documentId) return result2;
|
|
5066
5049
|
const navItemDocumentIds = Array.from(
|
|
5067
|
-
|
|
5050
|
+
deletedRoute.navitem?.map((item) => item.documentId)
|
|
5068
5051
|
);
|
|
5069
5052
|
for (const navItemDocumentId of navItemDocumentIds) {
|
|
5070
5053
|
await strapi2.documents(waNavItem).delete({ documentId: navItemDocumentId });
|
|
@@ -5080,16 +5063,15 @@ function documentMiddleware(strapi2, enabledContentTypes, config2) {
|
|
|
5080
5063
|
}
|
|
5081
5064
|
function webatlasMiddleware(strapi2) {
|
|
5082
5065
|
strapi2.documents.use(async (context, next) => {
|
|
5083
|
-
var _a, _b;
|
|
5084
5066
|
if (context.uid !== waNavItem) return next();
|
|
5085
5067
|
if (context.action === "delete") {
|
|
5086
5068
|
let externalRouteDocumentId = null;
|
|
5087
5069
|
try {
|
|
5088
|
-
const navItem = await
|
|
5070
|
+
const navItem = await strapi2.db?.query(waNavItem).findOne({
|
|
5089
5071
|
where: { documentId: context.params.documentId },
|
|
5090
5072
|
populate: ["route"]
|
|
5091
|
-
})
|
|
5092
|
-
if (
|
|
5073
|
+
});
|
|
5074
|
+
if (navItem?.route?.type === "external") {
|
|
5093
5075
|
externalRouteDocumentId = navItem.route.documentId;
|
|
5094
5076
|
}
|
|
5095
5077
|
} catch (err) {
|
|
@@ -5147,10 +5129,9 @@ const bootstrap = async ({ strapi: strapi2 }) => {
|
|
|
5147
5129
|
try {
|
|
5148
5130
|
await runMigrations(strapi2);
|
|
5149
5131
|
registerPermissions(strapi2);
|
|
5150
|
-
const enabledContentTypes = Object.values(strapi2.contentTypes).filter(
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
});
|
|
5132
|
+
const enabledContentTypes = Object.values(strapi2.contentTypes).filter(
|
|
5133
|
+
(type) => type.pluginOptions?.webatlas?.enabled === true
|
|
5134
|
+
);
|
|
5154
5135
|
const config2 = await syncConfig(strapi2, enabledContentTypes);
|
|
5155
5136
|
if (!enabledContentTypes.length) return;
|
|
5156
5137
|
documentMiddleware(strapi2, enabledContentTypes, config2);
|
|
@@ -6066,9 +6047,7 @@ var setExports = requireSet();
|
|
|
6066
6047
|
const set = /* @__PURE__ */ getDefaultExportFromCjs(setExports);
|
|
6067
6048
|
const register = ({ strapi: strapi2 }) => {
|
|
6068
6049
|
Object.values(strapi2.contentTypes).forEach((contentType) => {
|
|
6069
|
-
|
|
6070
|
-
if (!((_b = (_a = contentType.pluginOptions) === null || _a === void 0 ? void 0 : _a.webatlas) === null || _b === void 0 ? void 0 : _b.enabled))
|
|
6071
|
-
return;
|
|
6050
|
+
if (!contentType.pluginOptions?.webatlas?.enabled) return;
|
|
6072
6051
|
const { attributes } = contentType;
|
|
6073
6052
|
const fieldSettings = {
|
|
6074
6053
|
writable: true,
|
|
@@ -6726,7 +6705,7 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
6726
6705
|
...config2,
|
|
6727
6706
|
navigation: {
|
|
6728
6707
|
...defaultConfig.navigation,
|
|
6729
|
-
...config2
|
|
6708
|
+
...config2?.navigation
|
|
6730
6709
|
}
|
|
6731
6710
|
};
|
|
6732
6711
|
return config2;
|
|
@@ -6749,14 +6728,13 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
6749
6728
|
}
|
|
6750
6729
|
},
|
|
6751
6730
|
async getRelatedRoute(documentId) {
|
|
6752
|
-
var _a;
|
|
6753
6731
|
try {
|
|
6754
|
-
return await
|
|
6732
|
+
return await strapi2.db?.query(waRoute).findOne({
|
|
6755
6733
|
where: {
|
|
6756
6734
|
relatedDocumentId: documentId
|
|
6757
6735
|
},
|
|
6758
6736
|
populate: ["parent"]
|
|
6759
|
-
})
|
|
6737
|
+
});
|
|
6760
6738
|
} catch (e) {
|
|
6761
6739
|
strapi2.log.error(e);
|
|
6762
6740
|
}
|
|
@@ -6769,10 +6747,10 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
6769
6747
|
documentId
|
|
6770
6748
|
});
|
|
6771
6749
|
}
|
|
6772
|
-
const descendants =
|
|
6750
|
+
const descendants = route2?.documentId ? await getRouteDescendants(route2.documentId) : [];
|
|
6773
6751
|
const nonInternalRouteIds = await getNonInternalRouteIds();
|
|
6774
6752
|
const prohibitedRouteIds = [...descendants, ...nonInternalRouteIds];
|
|
6775
|
-
|
|
6753
|
+
route2?.documentId && prohibitedRouteIds.push(route2.documentId);
|
|
6776
6754
|
return prohibitedRouteIds;
|
|
6777
6755
|
} catch (e) {
|
|
6778
6756
|
strapi2.log.error(e);
|
|
@@ -6805,7 +6783,9 @@ const admin = ({ strapi: strapi2 }) => ({
|
|
|
6805
6783
|
});
|
|
6806
6784
|
if (!navigation2) throw new Error("Navigation not found");
|
|
6807
6785
|
if (variant) {
|
|
6808
|
-
navigation2 = navigation2.map(
|
|
6786
|
+
navigation2 = navigation2.map(
|
|
6787
|
+
(nav) => buildStructuredNavigation(nav, variant)
|
|
6788
|
+
);
|
|
6809
6789
|
}
|
|
6810
6790
|
}
|
|
6811
6791
|
return navigation2;
|
|
@@ -6977,35 +6957,26 @@ const client = ({ strapi: strapi2 }) => ({
|
|
|
6977
6957
|
},
|
|
6978
6958
|
{
|
|
6979
6959
|
condition: slug,
|
|
6980
|
-
lookup: () => {
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
populate: populateObject
|
|
6985
|
-
});
|
|
6986
|
-
},
|
|
6960
|
+
lookup: () => strapi2.db?.query(waNavigation).findOne({
|
|
6961
|
+
where: { slug },
|
|
6962
|
+
populate: populateObject
|
|
6963
|
+
}),
|
|
6987
6964
|
name: "slug"
|
|
6988
6965
|
},
|
|
6989
6966
|
{
|
|
6990
6967
|
condition: name,
|
|
6991
|
-
lookup: () => {
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
populate: populateObject
|
|
6996
|
-
});
|
|
6997
|
-
},
|
|
6968
|
+
lookup: () => strapi2.db?.query(waNavigation).findOne({
|
|
6969
|
+
where: { name },
|
|
6970
|
+
populate: populateObject
|
|
6971
|
+
}),
|
|
6998
6972
|
name: "name"
|
|
6999
6973
|
},
|
|
7000
6974
|
{
|
|
7001
6975
|
condition: id,
|
|
7002
|
-
lookup: () => {
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
populate: populateObject
|
|
7007
|
-
});
|
|
7008
|
-
},
|
|
6976
|
+
lookup: () => strapi2.db?.query(waNavigation).findOne({
|
|
6977
|
+
where: { id },
|
|
6978
|
+
populate: populateObject
|
|
6979
|
+
}),
|
|
7009
6980
|
name: "id"
|
|
7010
6981
|
}
|
|
7011
6982
|
];
|
|
@@ -7048,4 +7019,3 @@ const index = {
|
|
|
7048
7019
|
export {
|
|
7049
7020
|
index as default
|
|
7050
7021
|
};
|
|
7051
|
-
//# sourceMappingURL=index.mjs.map
|