strapi-plugin-navigation 3.0.0-beta.2 → 3.0.0-beta.4
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 +7 -7
- package/dist/_chunks/{ca-DIZHA0OL.mjs → ca-Catou0wg.mjs} +4 -0
- package/dist/_chunks/{ca-Bjfh0w36.js → ca-DtaqQvTI.js} +4 -0
- package/dist/admin/index.js +486 -308
- package/dist/admin/index.mjs +487 -309
- package/dist/admin/src/api/client.d.ts +4 -2
- package/dist/admin/src/api/validators.d.ts +10 -10
- package/dist/admin/src/pages/HomePage/components/NavigationItemForm/index.d.ts +1 -1
- package/dist/admin/src/pages/HomePage/components/NavigationItemForm/utils/form.d.ts +78 -0
- package/dist/admin/src/pages/HomePage/components/NavigationItemPopup/index.d.ts +1 -1
- package/dist/admin/src/pages/HomePage/components/NavigationManager/types.d.ts +1 -1
- package/dist/admin/src/pages/HomePage/hooks/index.d.ts +4 -4
- package/dist/admin/src/pages/HomePage/utils/parsers.d.ts +2 -2
- package/dist/admin/src/pages/SettingsPage/hooks/index.d.ts +1 -1
- package/dist/admin/src/translations/ca.d.ts +4 -0
- package/dist/server/index.js +113 -101
- package/dist/server/index.mjs +113 -101
- package/dist/server/src/content-types/index.d.ts +0 -4
- package/dist/server/src/content-types/navigation/index.d.ts +0 -4
- package/dist/server/src/content-types/navigation/schema.d.ts +0 -4
- package/dist/server/src/controllers/admin.d.ts +10 -10
- package/dist/server/src/controllers/client.d.ts +2 -2
- package/dist/server/src/controllers/validators.d.ts +2 -2
- package/dist/server/src/index.d.ts +7 -11
- package/dist/server/src/repositories/navigation-item.d.ts +8 -4
- package/dist/server/src/repositories/navigation.d.ts +12 -8
- package/dist/server/src/schemas/navigation.d.ts +8 -8
- package/dist/server/src/services/admin/admin.d.ts +2 -2
- package/dist/server/src/services/admin/types.d.ts +2 -2
- package/dist/server/src/services/admin/utils.d.ts +1 -1
- package/dist/server/src/services/client/client.d.ts +1 -1
- package/dist/server/src/services/index.d.ts +7 -7
- package/package.json +7 -8
package/dist/server/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { z as z$1 } from "zod";
|
|
3
3
|
import ___default, { uniqBy, isNil, find, includes, last, capitalize, once as once$1, omit, isObject as isObject$5, get as get$1, upperFirst, differenceBy, isEmpty as isEmpty$1, toString as toString$2, pick as pick$1, isArray as isArray$1, isString as isString$1, zipWith, cloneDeep as cloneDeep$1, first as first$1, isNaN as isNaN$1 } from "lodash";
|
|
4
|
-
import { createId } from "@paralleldrive/cuid2";
|
|
5
4
|
import { curry, isArray, isObject as isObject$4, isEmpty, cloneDeep, omit as omit$1, isNil as isNil$1, trim as trim$1, isString, pipe as pipe$1, split as split$1, map as map$2, flatten, first, identity, constant, join, eq, clone as clone$3, get, pick, union, getOr, toPath, has as has$1, isBoolean as isBoolean$1 } from "lodash/fp";
|
|
6
5
|
import require$$1 from "crypto";
|
|
7
6
|
import require$$0$1 from "child_process";
|
|
@@ -222,7 +221,7 @@ const navigationDBSchema = (withItems) => z.object({
|
|
|
222
221
|
documentId: z.string(),
|
|
223
222
|
name: z.string(),
|
|
224
223
|
slug: z.string(),
|
|
225
|
-
|
|
224
|
+
locale: z.string(),
|
|
226
225
|
visible: z.boolean(),
|
|
227
226
|
items: withItems ? z.array(navigationItemDBSchema) : navigationItemDBSchema.array().optional()
|
|
228
227
|
});
|
|
@@ -231,7 +230,7 @@ const createNavigationSchema = navigationDBSchema(false).omit({
|
|
|
231
230
|
id: true,
|
|
232
231
|
documentId: true,
|
|
233
232
|
slug: true,
|
|
234
|
-
|
|
233
|
+
locale: true
|
|
235
234
|
}).extend({
|
|
236
235
|
documentId: z.string().optional(),
|
|
237
236
|
id: z.undefined().optional()
|
|
@@ -489,15 +488,15 @@ const getNavigationItemRepository = once$1((context) => ({
|
|
|
489
488
|
save(item) {
|
|
490
489
|
const { itemModel } = getPluginModels(context);
|
|
491
490
|
if (typeof item.documentId === "string") {
|
|
492
|
-
const { documentId,
|
|
493
|
-
return context.strapi.
|
|
491
|
+
const { documentId, ...rest } = item;
|
|
492
|
+
return context.strapi.documents(itemModel.uid).update({ documentId: item.documentId, data: { ...rest } });
|
|
494
493
|
} else {
|
|
495
|
-
return context.strapi.
|
|
494
|
+
return context.strapi.documents(itemModel.uid).create({ data: item });
|
|
496
495
|
}
|
|
497
496
|
},
|
|
498
|
-
find({
|
|
497
|
+
find({ filters: filters2, locale: locale2, limit, order, populate: populate2 }) {
|
|
499
498
|
const { itemModel } = getPluginModels(context);
|
|
500
|
-
return context.strapi.
|
|
499
|
+
return context.strapi.documents(itemModel.uid).findMany({ filters: filters2, locale: locale2, limit, populate: populate2, orderBy: order }).then(navigationItemsDBSchema.parse);
|
|
501
500
|
},
|
|
502
501
|
count(where) {
|
|
503
502
|
const { itemModel } = getPluginModels(context);
|
|
@@ -546,31 +545,33 @@ const calculateItemsRequirement = (populate2) => {
|
|
|
546
545
|
return populate2 === true ? true : Array.isArray(populate2) ? populate2.includes("items") : false;
|
|
547
546
|
};
|
|
548
547
|
const getNavigationRepository = once$1((context) => ({
|
|
549
|
-
find({
|
|
548
|
+
find({ filters: filters2, locale: locale2, limit, orderBy, populate: populate2 }) {
|
|
550
549
|
const { masterModel } = getPluginModels(context);
|
|
551
|
-
return context.strapi.
|
|
550
|
+
return context.strapi.documents(masterModel.uid).findMany({ filters: filters2, locale: locale2, limit, populate: populate2, orderBy }).then((data) => {
|
|
552
551
|
return navigationDBSchema(calculateItemsRequirement(populate2)).array().parse(data);
|
|
553
552
|
});
|
|
554
553
|
},
|
|
555
|
-
findOne({
|
|
554
|
+
findOne({ locale: locale2, filters: filters2, populate: populate2 }) {
|
|
556
555
|
const { masterModel } = getPluginModels(context);
|
|
557
|
-
return context.strapi.
|
|
556
|
+
return context.strapi.documents(masterModel.uid).findOne({ documentId: filters2.documentId, locale: locale2, populate: populate2 }).then((data) => {
|
|
558
557
|
return navigationDBSchema(calculateItemsRequirement(populate2)).parse(data);
|
|
559
558
|
});
|
|
560
559
|
},
|
|
561
|
-
save(navigation2) {
|
|
560
|
+
async save(navigation2) {
|
|
562
561
|
const { masterModel } = getPluginModels(context);
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
562
|
+
const { documentId, locale: locale2, ...rest } = navigation2;
|
|
563
|
+
if (documentId) {
|
|
564
|
+
return context.strapi.documents(masterModel.uid).update({
|
|
565
|
+
locale: locale2,
|
|
566
|
+
documentId,
|
|
567
|
+
data: omit(rest, ["id", "documentId"]),
|
|
567
568
|
populate: ["items"]
|
|
568
569
|
}).then(navigationDBSchema(false).parse);
|
|
569
570
|
} else {
|
|
570
|
-
return context.strapi.
|
|
571
|
+
return context.strapi.documents(masterModel.uid).create({
|
|
572
|
+
locale: locale2,
|
|
571
573
|
data: {
|
|
572
|
-
...
|
|
573
|
-
documentId: navigation2.documentId ?? createId(),
|
|
574
|
+
...rest,
|
|
574
575
|
populate: ["items"]
|
|
575
576
|
}
|
|
576
577
|
}).then((x) => {
|
|
@@ -594,33 +595,32 @@ const navigationSetup = async (context) => {
|
|
|
594
595
|
const navigationRepository = getNavigationRepository(context);
|
|
595
596
|
const navigations = await navigationRepository.find({
|
|
596
597
|
limit: Number.MAX_SAFE_INTEGER,
|
|
597
|
-
|
|
598
|
+
filters: {},
|
|
599
|
+
locale: "*"
|
|
598
600
|
});
|
|
599
601
|
if (navigations.length === 0) {
|
|
600
602
|
navigations.push(
|
|
601
603
|
await navigationRepository.save({
|
|
602
604
|
name: DEFAULT_NAVIGATION_NAME,
|
|
603
|
-
localeCode: defaultLocale,
|
|
604
605
|
visible: true,
|
|
605
|
-
|
|
606
|
+
locale: defaultLocale,
|
|
607
|
+
slug: DEFAULT_NAVIGATION_SLUG
|
|
606
608
|
})
|
|
607
609
|
);
|
|
608
610
|
}
|
|
609
|
-
const defaultLocaleNavigations = navigations.filter(
|
|
610
|
-
({ localeCode }) => localeCode === defaultLocale
|
|
611
|
-
);
|
|
611
|
+
const defaultLocaleNavigations = navigations.filter(({ locale: locale2 }) => locale2 === defaultLocale);
|
|
612
612
|
for (const defaultLocaleNavigation of defaultLocaleNavigations) {
|
|
613
613
|
for (const otherLocale of restLocale) {
|
|
614
614
|
const otherLocaleMissing = !navigations.find(
|
|
615
|
-
({
|
|
615
|
+
({ locale: locale2, documentId }) => documentId === defaultLocaleNavigation.documentId && otherLocale === locale2
|
|
616
616
|
);
|
|
617
617
|
if (otherLocaleMissing) {
|
|
618
618
|
await navigationRepository.save({
|
|
619
619
|
documentId: defaultLocaleNavigation.documentId,
|
|
620
620
|
name: defaultLocaleNavigation.name,
|
|
621
|
-
|
|
621
|
+
locale: otherLocale,
|
|
622
622
|
visible: defaultLocaleNavigation.visible,
|
|
623
|
-
slug:
|
|
623
|
+
slug: defaultLocaleNavigation.slug
|
|
624
624
|
});
|
|
625
625
|
}
|
|
626
626
|
}
|
|
@@ -1052,10 +1052,6 @@ const schema$2 = {
|
|
|
1052
1052
|
target: "plugin::navigation.navigation-item",
|
|
1053
1053
|
configurable: false,
|
|
1054
1054
|
mappedBy: "master"
|
|
1055
|
-
},
|
|
1056
|
-
localeCode: {
|
|
1057
|
-
type: "string",
|
|
1058
|
-
configurable: false
|
|
1059
1055
|
}
|
|
1060
1056
|
}
|
|
1061
1057
|
};
|
|
@@ -14735,7 +14731,7 @@ const processItems = (context) => async (item) => {
|
|
|
14735
14731
|
const entity = context.entities.get(related);
|
|
14736
14732
|
const localeVersion = await strapi.documents(entity.uid).findOne({
|
|
14737
14733
|
documentId: entity.documentId,
|
|
14738
|
-
locale: context.
|
|
14734
|
+
locale: context.locale,
|
|
14739
14735
|
status: "published"
|
|
14740
14736
|
});
|
|
14741
14737
|
if (localeVersion) {
|
|
@@ -14923,16 +14919,14 @@ const adminService = (context) => ({
|
|
|
14923
14919
|
return acc;
|
|
14924
14920
|
}, []);
|
|
14925
14921
|
},
|
|
14926
|
-
async get({ ids,
|
|
14927
|
-
let
|
|
14922
|
+
async get({ ids, locale: locale2 }) {
|
|
14923
|
+
let filters2 = {};
|
|
14928
14924
|
if (ids && ids.length) {
|
|
14929
|
-
|
|
14930
|
-
}
|
|
14931
|
-
if (localeCode) {
|
|
14932
|
-
where.localeCode = localeCode;
|
|
14925
|
+
filters2.id = { $in: ids };
|
|
14933
14926
|
}
|
|
14934
14927
|
const dbResults = await getNavigationRepository(context).find({
|
|
14935
|
-
|
|
14928
|
+
filters: filters2,
|
|
14929
|
+
locale: locale2 || "*",
|
|
14936
14930
|
limit: Number.MAX_SAFE_INTEGER,
|
|
14937
14931
|
populate: ["items", "items.parent", "items.audience"]
|
|
14938
14932
|
});
|
|
@@ -14941,7 +14935,7 @@ const adminService = (context) => ({
|
|
|
14941
14935
|
item,
|
|
14942
14936
|
parent
|
|
14943
14937
|
}) => {
|
|
14944
|
-
const children = allItems.filter((child) => child.parent?.
|
|
14938
|
+
const children = allItems.filter((child) => child.parent?.documentId === item.documentId);
|
|
14945
14939
|
return {
|
|
14946
14940
|
...item,
|
|
14947
14941
|
parent,
|
|
@@ -14961,22 +14955,22 @@ const adminService = (context) => ({
|
|
|
14961
14955
|
allItems: navigation2.items ?? [],
|
|
14962
14956
|
item
|
|
14963
14957
|
})
|
|
14964
|
-
)
|
|
14958
|
+
).sort((a, b) => a.order - b.order)
|
|
14965
14959
|
}));
|
|
14966
14960
|
},
|
|
14967
|
-
async getById({ documentId,
|
|
14961
|
+
async getById({ documentId, locale: locale2 }) {
|
|
14968
14962
|
const commonService2 = getPluginService(context, "common");
|
|
14969
|
-
const
|
|
14963
|
+
const { defaultLocale } = await commonService2.readLocale();
|
|
14964
|
+
const filters2 = {
|
|
14970
14965
|
documentId
|
|
14971
14966
|
};
|
|
14972
|
-
if (localeCode) {
|
|
14973
|
-
where.localeCode = localeCode;
|
|
14974
|
-
}
|
|
14975
14967
|
const navigation2 = await getNavigationRepository(context).findOne({
|
|
14976
|
-
|
|
14968
|
+
filters: filters2,
|
|
14969
|
+
locale: locale2 || defaultLocale
|
|
14977
14970
|
});
|
|
14978
14971
|
const dbNavigationItems = await getNavigationItemRepository(context).find({
|
|
14979
|
-
|
|
14972
|
+
filters: { master: navigation2.id },
|
|
14973
|
+
locale: locale2 || defaultLocale,
|
|
14980
14974
|
limit: Number.MAX_SAFE_INTEGER,
|
|
14981
14975
|
order: [{ order: "asc" }],
|
|
14982
14976
|
populate: ["parent", "audience"]
|
|
@@ -14999,7 +14993,7 @@ const adminService = (context) => ({
|
|
|
14999
14993
|
const mainNavigation = await repository.save({
|
|
15000
14994
|
name,
|
|
15001
14995
|
visible,
|
|
15002
|
-
|
|
14996
|
+
locale: defaultLocale,
|
|
15003
14997
|
slug
|
|
15004
14998
|
});
|
|
15005
14999
|
navigationSummary.push(await this.getById({ documentId: mainNavigation.documentId }));
|
|
@@ -15007,8 +15001,8 @@ const adminService = (context) => ({
|
|
|
15007
15001
|
const newLocaleNavigation = await repository.save({
|
|
15008
15002
|
name,
|
|
15009
15003
|
visible,
|
|
15010
|
-
localeCode,
|
|
15011
|
-
slug
|
|
15004
|
+
locale: localeCode,
|
|
15005
|
+
slug,
|
|
15012
15006
|
documentId: mainNavigation.documentId
|
|
15013
15007
|
});
|
|
15014
15008
|
navigationSummary.push(await this.getById({ documentId: newLocaleNavigation.documentId }));
|
|
@@ -15033,30 +15027,37 @@ const adminService = (context) => ({
|
|
|
15033
15027
|
async put({ auditLog, payload }) {
|
|
15034
15028
|
const { masterModel } = getPluginModels(context);
|
|
15035
15029
|
const commonService2 = getPluginService(context, "common");
|
|
15036
|
-
const { defaultLocale } = await commonService2.readLocale();
|
|
15030
|
+
const { defaultLocale, restLocale } = await commonService2.readLocale();
|
|
15037
15031
|
const repository = getNavigationRepository(context);
|
|
15038
15032
|
const { name, visible, items } = payload;
|
|
15039
15033
|
const currentNavigation = await repository.findOne({
|
|
15040
|
-
|
|
15041
|
-
|
|
15034
|
+
filters: { documentId: payload.documentId },
|
|
15035
|
+
locale: payload.locale,
|
|
15036
|
+
populate: "*"
|
|
15042
15037
|
});
|
|
15043
15038
|
const currentNavigationAsDTO = await this.getById({
|
|
15044
15039
|
documentId: payload.documentId,
|
|
15045
|
-
|
|
15040
|
+
locale: payload.locale
|
|
15046
15041
|
});
|
|
15047
15042
|
const detailsHaveChanged = currentNavigation.name !== name || currentNavigation.visible !== visible;
|
|
15048
15043
|
if (detailsHaveChanged) {
|
|
15049
|
-
const
|
|
15050
|
-
|
|
15051
|
-
});
|
|
15044
|
+
const newSlug = name ? await commonService2.getSlug({
|
|
15045
|
+
query: name
|
|
15046
|
+
}) : currentNavigation.slug;
|
|
15047
|
+
const allNavigations = await Promise.all(
|
|
15048
|
+
[defaultLocale, ...restLocale].map(
|
|
15049
|
+
(locale2) => repository.findOne({
|
|
15050
|
+
filters: { documentId: currentNavigation.documentId },
|
|
15051
|
+
locale: locale2
|
|
15052
|
+
})
|
|
15053
|
+
)
|
|
15054
|
+
);
|
|
15052
15055
|
for (const navigation2 of allNavigations) {
|
|
15053
|
-
const newSlug = name ? await commonService2.getSlug({
|
|
15054
|
-
query: `${name}${navigation2.localeCode !== defaultLocale ? ` ${navigation2.localeCode}` : ""}`
|
|
15055
|
-
}) : currentNavigation.slug;
|
|
15056
15056
|
await repository.save({
|
|
15057
15057
|
documentId: navigation2.documentId,
|
|
15058
15058
|
id: navigation2.id,
|
|
15059
15059
|
slug: newSlug,
|
|
15060
|
+
locale: navigation2.locale,
|
|
15060
15061
|
name,
|
|
15061
15062
|
visible
|
|
15062
15063
|
});
|
|
@@ -15077,8 +15078,8 @@ const adminService = (context) => ({
|
|
|
15077
15078
|
});
|
|
15078
15079
|
await commonService2.emitEvent({
|
|
15079
15080
|
entity: await repository.findOne({
|
|
15080
|
-
|
|
15081
|
-
populate:
|
|
15081
|
+
filters: { documentId: payload.documentId },
|
|
15082
|
+
populate: "*"
|
|
15082
15083
|
}),
|
|
15083
15084
|
event: "entry.update",
|
|
15084
15085
|
uid: masterModel.uid
|
|
@@ -15105,12 +15106,12 @@ const adminService = (context) => ({
|
|
|
15105
15106
|
);
|
|
15106
15107
|
};
|
|
15107
15108
|
const navigation2 = await navigationRepository.findOne({
|
|
15108
|
-
|
|
15109
|
-
populate:
|
|
15109
|
+
filters: { documentId },
|
|
15110
|
+
populate: "*"
|
|
15110
15111
|
});
|
|
15111
15112
|
const allNavigations = await navigationRepository.find({
|
|
15112
|
-
|
|
15113
|
-
populate:
|
|
15113
|
+
filters: { documentId: navigation2.documentId },
|
|
15114
|
+
populate: "*"
|
|
15114
15115
|
});
|
|
15115
15116
|
await cleanNavigationItems(
|
|
15116
15117
|
allNavigations.map(({ documentId: documentId2 }) => documentId2)
|
|
@@ -15137,7 +15138,6 @@ const adminService = (context) => ({
|
|
|
15137
15138
|
key: "config"
|
|
15138
15139
|
}).then(configSchema.parse);
|
|
15139
15140
|
validateAdditionalFields(newConfig.additionalFields);
|
|
15140
|
-
console.log({ newConfig });
|
|
15141
15141
|
await pluginStore.set({ key: "config", value: newConfig });
|
|
15142
15142
|
const removedFields = differenceBy(
|
|
15143
15143
|
config2.additionalFields,
|
|
@@ -15160,11 +15160,11 @@ const adminService = (context) => ({
|
|
|
15160
15160
|
target,
|
|
15161
15161
|
documentId
|
|
15162
15162
|
}) {
|
|
15163
|
-
const targetEntity = await this.getById({ documentId,
|
|
15163
|
+
const targetEntity = await this.getById({ documentId, locale: target });
|
|
15164
15164
|
return await this.i18nNavigationContentsCopy({
|
|
15165
|
-
source: await this.getById({ documentId,
|
|
15165
|
+
source: await this.getById({ documentId, locale: source }),
|
|
15166
15166
|
target: targetEntity
|
|
15167
|
-
}).then(() => this.getById({ documentId,
|
|
15167
|
+
}).then(() => this.getById({ documentId, locale: target })).then((newEntity) => {
|
|
15168
15168
|
sendAuditLog(auditLog, "onChangeNavigation", {
|
|
15169
15169
|
actionType: "UPDATE",
|
|
15170
15170
|
oldEntity: targetEntity,
|
|
@@ -15183,7 +15183,7 @@ const adminService = (context) => ({
|
|
|
15183
15183
|
if (target.items?.length) {
|
|
15184
15184
|
throw new FillNavigationError("Current navigation is non-empty");
|
|
15185
15185
|
}
|
|
15186
|
-
if (!target.
|
|
15186
|
+
if (!target.locale) {
|
|
15187
15187
|
throw new FillNavigationError("Current navigation does not have specified locale");
|
|
15188
15188
|
}
|
|
15189
15189
|
if (!sourceItems.length) {
|
|
@@ -15192,15 +15192,16 @@ const adminService = (context) => ({
|
|
|
15192
15192
|
const entities = /* @__PURE__ */ new Map();
|
|
15193
15193
|
const itemProcessor = processItems({
|
|
15194
15194
|
master: target,
|
|
15195
|
-
|
|
15195
|
+
locale: target.locale,
|
|
15196
15196
|
strapi,
|
|
15197
15197
|
entities
|
|
15198
15198
|
});
|
|
15199
15199
|
await commonService2.createBranch({
|
|
15200
15200
|
action: { create: true },
|
|
15201
15201
|
masterEntity: await navigationRepository.findOne({
|
|
15202
|
-
|
|
15203
|
-
|
|
15202
|
+
filters: { documentId: target.documentId },
|
|
15203
|
+
locale: target.locale,
|
|
15204
|
+
populate: "*"
|
|
15204
15205
|
}),
|
|
15205
15206
|
navigationItems: await Promise.all(sourceItems.map(itemProcessor)),
|
|
15206
15207
|
parentItem: void 0
|
|
@@ -15273,7 +15274,7 @@ const adminService = (context) => ({
|
|
|
15273
15274
|
},
|
|
15274
15275
|
async purgeNavigationCache(documentId, clearLocalisations) {
|
|
15275
15276
|
const navigationRepository = getNavigationRepository(context);
|
|
15276
|
-
const entity = await navigationRepository.findOne({
|
|
15277
|
+
const entity = await navigationRepository.findOne({ filters: { documentId } });
|
|
15277
15278
|
if (!entity) {
|
|
15278
15279
|
throw new errors.NotFoundError("Navigation is not defined");
|
|
15279
15280
|
}
|
|
@@ -15281,7 +15282,7 @@ const adminService = (context) => ({
|
|
|
15281
15282
|
let regexps = [mapToRegExp(entity.documentId)];
|
|
15282
15283
|
if (clearLocalisations) {
|
|
15283
15284
|
const navigations = await navigationRepository.find({
|
|
15284
|
-
|
|
15285
|
+
filters: {
|
|
15285
15286
|
documentId: entity.documentId
|
|
15286
15287
|
}
|
|
15287
15288
|
});
|
|
@@ -15372,9 +15373,7 @@ const clientService = (context) => ({
|
|
|
15372
15373
|
async readAll({ locale: locale2, orderBy = "createdAt", orderDirection = "DESC" }) {
|
|
15373
15374
|
const repository = getNavigationRepository(context);
|
|
15374
15375
|
const navigations = repository.find({
|
|
15375
|
-
|
|
15376
|
-
localeCode: locale2
|
|
15377
|
-
} : {},
|
|
15376
|
+
locale: locale2,
|
|
15378
15377
|
orderBy: { [orderBy]: orderDirection }
|
|
15379
15378
|
});
|
|
15380
15379
|
return navigations;
|
|
@@ -15386,6 +15385,9 @@ const clientService = (context) => ({
|
|
|
15386
15385
|
type: type2,
|
|
15387
15386
|
audience: audience2?.map(({ key }) => key)
|
|
15388
15387
|
};
|
|
15388
|
+
if (type2 === "WRAPPER") {
|
|
15389
|
+
return { ...itemCommon };
|
|
15390
|
+
}
|
|
15389
15391
|
if (type2 === "EXTERNAL") {
|
|
15390
15392
|
assertNotEmpty(
|
|
15391
15393
|
path2,
|
|
@@ -15551,26 +15553,34 @@ const clientService = (context) => ({
|
|
|
15551
15553
|
};
|
|
15552
15554
|
const navigationRepository = getNavigationRepository(context);
|
|
15553
15555
|
const navigationItemRepository = getNavigationItemRepository(context);
|
|
15554
|
-
let navigation2
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
|
|
15562
|
-
|
|
15556
|
+
let navigation2;
|
|
15557
|
+
if (locale2) {
|
|
15558
|
+
navigation2 = await navigationRepository.find({
|
|
15559
|
+
filters: {
|
|
15560
|
+
...entityWhereClause
|
|
15561
|
+
},
|
|
15562
|
+
locale: locale2,
|
|
15563
|
+
limit: 1
|
|
15564
|
+
});
|
|
15565
|
+
} else {
|
|
15566
|
+
navigation2 = await navigationRepository.find({
|
|
15567
|
+
filters: entityWhereClause,
|
|
15568
|
+
limit: 1
|
|
15563
15569
|
});
|
|
15564
15570
|
}
|
|
15571
|
+
if (isArray$1(navigation2)) {
|
|
15572
|
+
navigation2 = first$1(navigation2);
|
|
15573
|
+
}
|
|
15565
15574
|
if (navigation2 && navigation2.documentId) {
|
|
15566
15575
|
const navigationItems = await navigationItemRepository.find({
|
|
15567
|
-
|
|
15576
|
+
filters: {
|
|
15568
15577
|
master: navigation2,
|
|
15569
15578
|
...itemCriteria
|
|
15570
15579
|
},
|
|
15580
|
+
locale: locale2,
|
|
15571
15581
|
limit: Number.MAX_SAFE_INTEGER,
|
|
15572
15582
|
order: [{ order: "asc" }],
|
|
15573
|
-
populate: ["
|
|
15583
|
+
populate: ["audience", "parent"]
|
|
15574
15584
|
});
|
|
15575
15585
|
const mappedItems = await commonService2.mapToNavigationItemDTO({
|
|
15576
15586
|
navigationItems,
|
|
@@ -15800,7 +15810,7 @@ const commonService = (context) => ({
|
|
|
15800
15810
|
documentId,
|
|
15801
15811
|
isNil(populate2) ? config2.contentTypesPopulate[uid] || [] : parsePopulateQuery(populate2),
|
|
15802
15812
|
"published",
|
|
15803
|
-
{ locale: master?.
|
|
15813
|
+
{ locale: master?.locale }
|
|
15804
15814
|
);
|
|
15805
15815
|
if (relatedItem) {
|
|
15806
15816
|
entities.set(related, {
|
|
@@ -15897,7 +15907,7 @@ const commonService = (context) => ({
|
|
|
15897
15907
|
}) {
|
|
15898
15908
|
const navigationActions = [];
|
|
15899
15909
|
for (const navigationItem2 of navigationItems) {
|
|
15900
|
-
if (!navigationItem2.
|
|
15910
|
+
if (!navigationItem2.documentId) {
|
|
15901
15911
|
continue;
|
|
15902
15912
|
}
|
|
15903
15913
|
action.remove = true;
|
|
@@ -15923,14 +15933,16 @@ const commonService = (context) => ({
|
|
|
15923
15933
|
let navigationActions = [];
|
|
15924
15934
|
for (const navigationItem2 of navigationItems) {
|
|
15925
15935
|
action.create = true;
|
|
15926
|
-
const { parent, master, items, id, ...params } = navigationItem2;
|
|
15927
|
-
const insertDetails = id ? {
|
|
15936
|
+
const { parent, master, items, documentId, id, ...params } = navigationItem2;
|
|
15937
|
+
const insertDetails = documentId && id ? {
|
|
15928
15938
|
...params,
|
|
15939
|
+
documentId,
|
|
15929
15940
|
id,
|
|
15930
15941
|
master: masterEntity ? masterEntity.id : void 0,
|
|
15931
15942
|
parent: parentItem ? parentItem.id : void 0
|
|
15932
15943
|
} : {
|
|
15933
15944
|
...params,
|
|
15945
|
+
documentId: void 0,
|
|
15934
15946
|
id: void 0,
|
|
15935
15947
|
master: masterEntity ? masterEntity.id : void 0,
|
|
15936
15948
|
parent: parentItem ? parentItem.id : void 0
|
|
@@ -15959,11 +15971,11 @@ const commonService = (context) => ({
|
|
|
15959
15971
|
const result = [];
|
|
15960
15972
|
for (const updateDetails of navigationItems) {
|
|
15961
15973
|
action.update = true;
|
|
15962
|
-
const {
|
|
15974
|
+
const { documentId, updated, parent, master, items, ...params } = updateDetails;
|
|
15963
15975
|
let currentItem;
|
|
15964
15976
|
if (updated) {
|
|
15965
15977
|
currentItem = await getNavigationItemRepository(context).save({
|
|
15966
|
-
|
|
15978
|
+
documentId,
|
|
15967
15979
|
...params
|
|
15968
15980
|
});
|
|
15969
15981
|
} else {
|
|
@@ -16008,7 +16020,7 @@ const commonService = (context) => ({
|
|
|
16008
16020
|
const removedFieldsKeys = removedFields.map(({ name }) => `additionalFields.${name}`);
|
|
16009
16021
|
const removedFieldsNames = removedFields.map(({ name }) => name);
|
|
16010
16022
|
const navigationItems = await getNavigationItemRepository(context).find({
|
|
16011
|
-
|
|
16023
|
+
filters: {
|
|
16012
16024
|
additionalFields: {
|
|
16013
16025
|
$contains: [removedFieldsNames]
|
|
16014
16026
|
}
|
|
@@ -16092,7 +16104,7 @@ const migrationService = (context) => ({
|
|
|
16092
16104
|
async migrateRelatedIdToDocumentId() {
|
|
16093
16105
|
console.log("Navigation plugin :: Migrations :: Relared id to document id - START");
|
|
16094
16106
|
const navigationItemRepository = getNavigationItemRepository(context);
|
|
16095
|
-
const all = await navigationItemRepository.find({
|
|
16107
|
+
const all = await navigationItemRepository.find({ filters: {}, limit: Number.MAX_SAFE_INTEGER });
|
|
16096
16108
|
await Promise.all(
|
|
16097
16109
|
all.map(async (item) => {
|
|
16098
16110
|
if (item.related) {
|
|
@@ -71,10 +71,6 @@ declare const _default: {
|
|
|
71
71
|
configurable: boolean;
|
|
72
72
|
mappedBy: string;
|
|
73
73
|
};
|
|
74
|
-
localeCode: {
|
|
75
|
-
type: string;
|
|
76
|
-
configurable: boolean;
|
|
77
|
-
};
|
|
78
74
|
};
|
|
79
75
|
};
|
|
80
76
|
lifecycles: Record<string, import("../types").Effect<import("../types").LifeCycleEvent<import("../types").LifeCycleHookName, unknown, Record<string, unknown>>>>;
|
|
@@ -45,10 +45,6 @@ declare const _default: {
|
|
|
45
45
|
configurable: boolean;
|
|
46
46
|
mappedBy: string;
|
|
47
47
|
};
|
|
48
|
-
localeCode: {
|
|
49
|
-
type: string;
|
|
50
|
-
configurable: boolean;
|
|
51
|
-
};
|
|
52
48
|
};
|
|
53
49
|
};
|
|
54
50
|
lifecycles: Record<string, import("../../types").Effect<import("../../types").LifeCycleEvent<import("../../types").LifeCycleHookName, unknown, Record<string, unknown>>>>;
|
|
@@ -11,21 +11,21 @@ export default function adminController(context: {
|
|
|
11
11
|
getAdminService(): {
|
|
12
12
|
config({ viaSettingsPage }: import("../services/admin/types").ConfigInput): Promise<import("../dtos").NavigationPluginConfigDTO>;
|
|
13
13
|
configContentTypes({ viaSettingsPage, }: import("../services/admin/types").ConfigInput): Promise<import("../dtos").ConfigContentTypeDTO[]>;
|
|
14
|
-
get({ ids,
|
|
14
|
+
get({ ids, locale }: import("../services/admin/types").GetInput): Promise<{
|
|
15
15
|
name: string;
|
|
16
16
|
id: number;
|
|
17
17
|
documentId: string;
|
|
18
18
|
slug: string;
|
|
19
|
-
|
|
19
|
+
locale: string;
|
|
20
20
|
visible: boolean;
|
|
21
21
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
22
22
|
}[]>;
|
|
23
|
-
getById({ documentId,
|
|
23
|
+
getById({ documentId, locale }: import("../services/admin/types").GetByIdInput): Promise<{
|
|
24
24
|
name: string;
|
|
25
25
|
id: number;
|
|
26
26
|
documentId: string;
|
|
27
27
|
slug: string;
|
|
28
|
-
|
|
28
|
+
locale: string;
|
|
29
29
|
visible: boolean;
|
|
30
30
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
31
31
|
}>;
|
|
@@ -35,7 +35,7 @@ export default function adminController(context: {
|
|
|
35
35
|
id: number;
|
|
36
36
|
documentId: string;
|
|
37
37
|
slug: string;
|
|
38
|
-
|
|
38
|
+
locale: string;
|
|
39
39
|
visible: boolean;
|
|
40
40
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
41
41
|
}>;
|
|
@@ -48,7 +48,7 @@ export default function adminController(context: {
|
|
|
48
48
|
id: number;
|
|
49
49
|
documentId: string;
|
|
50
50
|
slug: string;
|
|
51
|
-
|
|
51
|
+
locale: string;
|
|
52
52
|
visible: boolean;
|
|
53
53
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
54
54
|
}>;
|
|
@@ -182,7 +182,7 @@ export default function adminController(context: {
|
|
|
182
182
|
id: number;
|
|
183
183
|
documentId: string;
|
|
184
184
|
slug: string;
|
|
185
|
-
|
|
185
|
+
locale: string;
|
|
186
186
|
visible: boolean;
|
|
187
187
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
188
188
|
}[]>;
|
|
@@ -192,7 +192,7 @@ export default function adminController(context: {
|
|
|
192
192
|
id: number;
|
|
193
193
|
documentId: string;
|
|
194
194
|
slug: string;
|
|
195
|
-
|
|
195
|
+
locale: string;
|
|
196
196
|
visible: boolean;
|
|
197
197
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
198
198
|
}>;
|
|
@@ -207,7 +207,7 @@ export default function adminController(context: {
|
|
|
207
207
|
id: number;
|
|
208
208
|
documentId: string;
|
|
209
209
|
slug: string;
|
|
210
|
-
|
|
210
|
+
locale: string;
|
|
211
211
|
visible: boolean;
|
|
212
212
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
213
213
|
}>;
|
|
@@ -219,7 +219,7 @@ export default function adminController(context: {
|
|
|
219
219
|
id: number;
|
|
220
220
|
documentId: string;
|
|
221
221
|
slug: string;
|
|
222
|
-
|
|
222
|
+
locale: string;
|
|
223
223
|
visible: boolean;
|
|
224
224
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
225
225
|
}>;
|
|
@@ -9,7 +9,7 @@ export default function clientController(context: {
|
|
|
9
9
|
id: number;
|
|
10
10
|
documentId: string;
|
|
11
11
|
slug: string;
|
|
12
|
-
|
|
12
|
+
locale: string;
|
|
13
13
|
visible: boolean;
|
|
14
14
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
15
15
|
}[]>;
|
|
@@ -141,7 +141,7 @@ export default function clientController(context: {
|
|
|
141
141
|
id: number;
|
|
142
142
|
documentId: string;
|
|
143
143
|
slug: string;
|
|
144
|
-
|
|
144
|
+
locale: string;
|
|
145
145
|
visible: boolean;
|
|
146
146
|
items?: import("../schemas").NavigationItemDBSchema[] | undefined;
|
|
147
147
|
}[] | KoaContext>;
|
|
@@ -24,14 +24,14 @@ export declare const renderQuerySchema: z.ZodObject<{
|
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
25
|
path?: string | undefined;
|
|
26
26
|
type?: "FLAT" | "TREE" | "RFR" | undefined;
|
|
27
|
-
populate?: string | boolean | string[] | undefined;
|
|
28
27
|
locale?: string | undefined;
|
|
28
|
+
populate?: string | boolean | string[] | undefined;
|
|
29
29
|
menu?: "true" | "false" | undefined;
|
|
30
30
|
}, {
|
|
31
31
|
path?: string | undefined;
|
|
32
32
|
type?: "FLAT" | "TREE" | "RFR" | undefined;
|
|
33
|
-
populate?: string | boolean | string[] | undefined;
|
|
34
33
|
locale?: string | undefined;
|
|
34
|
+
populate?: string | boolean | string[] | undefined;
|
|
35
35
|
menu?: "true" | "false" | undefined;
|
|
36
36
|
}>;
|
|
37
37
|
export declare const renderChildQueryParams: z.ZodObject<{
|