strapi-plugin-navigation 3.0.0-beta.2 → 3.0.0-beta.3
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 +64 -28
- package/dist/admin/index.mjs +65 -29
- package/dist/admin/src/api/client.d.ts +3 -1
- package/dist/admin/src/api/validators.d.ts +3 -3
- package/dist/admin/src/pages/HomePage/components/NavigationItemForm/index.d.ts +1 -1
- 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 +3 -3
- 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 +98 -92
- package/dist/server/index.mjs +98 -92
- 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 +6 -7
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,31 +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,
|
|
606
|
+
locale: defaultLocale,
|
|
605
607
|
slug: `${DEFAULT_NAVIGATION_SLUG}-${defaultLocale}`
|
|
606
608
|
})
|
|
607
609
|
);
|
|
608
610
|
}
|
|
609
611
|
const defaultLocaleNavigations = navigations.filter(
|
|
610
|
-
({
|
|
612
|
+
({ locale: locale2 }) => locale2 === defaultLocale
|
|
611
613
|
);
|
|
612
614
|
for (const defaultLocaleNavigation of defaultLocaleNavigations) {
|
|
613
615
|
for (const otherLocale of restLocale) {
|
|
614
616
|
const otherLocaleMissing = !navigations.find(
|
|
615
|
-
({
|
|
617
|
+
({ locale: locale2, documentId }) => documentId === defaultLocaleNavigation.documentId && otherLocale === locale2
|
|
616
618
|
);
|
|
617
619
|
if (otherLocaleMissing) {
|
|
618
620
|
await navigationRepository.save({
|
|
619
621
|
documentId: defaultLocaleNavigation.documentId,
|
|
620
622
|
name: defaultLocaleNavigation.name,
|
|
621
|
-
|
|
623
|
+
locale: otherLocale,
|
|
622
624
|
visible: defaultLocaleNavigation.visible,
|
|
623
625
|
slug: `${defaultLocaleNavigation.slug.replace(`-${defaultLocale}`, "")}-${otherLocale}`
|
|
624
626
|
});
|
|
@@ -1052,10 +1054,6 @@ const schema$2 = {
|
|
|
1052
1054
|
target: "plugin::navigation.navigation-item",
|
|
1053
1055
|
configurable: false,
|
|
1054
1056
|
mappedBy: "master"
|
|
1055
|
-
},
|
|
1056
|
-
localeCode: {
|
|
1057
|
-
type: "string",
|
|
1058
|
-
configurable: false
|
|
1059
1057
|
}
|
|
1060
1058
|
}
|
|
1061
1059
|
};
|
|
@@ -14735,7 +14733,7 @@ const processItems = (context) => async (item) => {
|
|
|
14735
14733
|
const entity = context.entities.get(related);
|
|
14736
14734
|
const localeVersion = await strapi.documents(entity.uid).findOne({
|
|
14737
14735
|
documentId: entity.documentId,
|
|
14738
|
-
locale: context.
|
|
14736
|
+
locale: context.locale,
|
|
14739
14737
|
status: "published"
|
|
14740
14738
|
});
|
|
14741
14739
|
if (localeVersion) {
|
|
@@ -14923,16 +14921,14 @@ const adminService = (context) => ({
|
|
|
14923
14921
|
return acc;
|
|
14924
14922
|
}, []);
|
|
14925
14923
|
},
|
|
14926
|
-
async get({ ids,
|
|
14927
|
-
let
|
|
14924
|
+
async get({ ids, locale: locale2 }) {
|
|
14925
|
+
let filters2 = {};
|
|
14928
14926
|
if (ids && ids.length) {
|
|
14929
|
-
|
|
14930
|
-
}
|
|
14931
|
-
if (localeCode) {
|
|
14932
|
-
where.localeCode = localeCode;
|
|
14927
|
+
filters2.id = { $in: ids };
|
|
14933
14928
|
}
|
|
14934
14929
|
const dbResults = await getNavigationRepository(context).find({
|
|
14935
|
-
|
|
14930
|
+
filters: filters2,
|
|
14931
|
+
locale: locale2 || "*",
|
|
14936
14932
|
limit: Number.MAX_SAFE_INTEGER,
|
|
14937
14933
|
populate: ["items", "items.parent", "items.audience"]
|
|
14938
14934
|
});
|
|
@@ -14941,7 +14937,7 @@ const adminService = (context) => ({
|
|
|
14941
14937
|
item,
|
|
14942
14938
|
parent
|
|
14943
14939
|
}) => {
|
|
14944
|
-
const children = allItems.filter((child) => child.parent?.
|
|
14940
|
+
const children = allItems.filter((child) => child.parent?.documentId === item.documentId);
|
|
14945
14941
|
return {
|
|
14946
14942
|
...item,
|
|
14947
14943
|
parent,
|
|
@@ -14961,22 +14957,22 @@ const adminService = (context) => ({
|
|
|
14961
14957
|
allItems: navigation2.items ?? [],
|
|
14962
14958
|
item
|
|
14963
14959
|
})
|
|
14964
|
-
)
|
|
14960
|
+
).sort((a, b) => a.order - b.order)
|
|
14965
14961
|
}));
|
|
14966
14962
|
},
|
|
14967
|
-
async getById({ documentId,
|
|
14963
|
+
async getById({ documentId, locale: locale2 }) {
|
|
14968
14964
|
const commonService2 = getPluginService(context, "common");
|
|
14969
|
-
const
|
|
14965
|
+
const { defaultLocale } = await commonService2.readLocale();
|
|
14966
|
+
const filters2 = {
|
|
14970
14967
|
documentId
|
|
14971
14968
|
};
|
|
14972
|
-
if (localeCode) {
|
|
14973
|
-
where.localeCode = localeCode;
|
|
14974
|
-
}
|
|
14975
14969
|
const navigation2 = await getNavigationRepository(context).findOne({
|
|
14976
|
-
|
|
14970
|
+
filters: filters2,
|
|
14971
|
+
locale: locale2 || defaultLocale
|
|
14977
14972
|
});
|
|
14978
14973
|
const dbNavigationItems = await getNavigationItemRepository(context).find({
|
|
14979
|
-
|
|
14974
|
+
filters: { master: navigation2.id },
|
|
14975
|
+
locale: locale2 || defaultLocale,
|
|
14980
14976
|
limit: Number.MAX_SAFE_INTEGER,
|
|
14981
14977
|
order: [{ order: "asc" }],
|
|
14982
14978
|
populate: ["parent", "audience"]
|
|
@@ -14999,15 +14995,15 @@ const adminService = (context) => ({
|
|
|
14999
14995
|
const mainNavigation = await repository.save({
|
|
15000
14996
|
name,
|
|
15001
14997
|
visible,
|
|
15002
|
-
|
|
15003
|
-
slug
|
|
14998
|
+
locale: defaultLocale,
|
|
14999
|
+
slug: `${slug}-${defaultLocale}`
|
|
15004
15000
|
});
|
|
15005
15001
|
navigationSummary.push(await this.getById({ documentId: mainNavigation.documentId }));
|
|
15006
15002
|
for (const localeCode of restLocale) {
|
|
15007
15003
|
const newLocaleNavigation = await repository.save({
|
|
15008
15004
|
name,
|
|
15009
15005
|
visible,
|
|
15010
|
-
localeCode,
|
|
15006
|
+
locale: localeCode,
|
|
15011
15007
|
slug: `${slug}-${localeCode}`,
|
|
15012
15008
|
documentId: mainNavigation.documentId
|
|
15013
15009
|
});
|
|
@@ -15037,26 +15033,28 @@ const adminService = (context) => ({
|
|
|
15037
15033
|
const repository = getNavigationRepository(context);
|
|
15038
15034
|
const { name, visible, items } = payload;
|
|
15039
15035
|
const currentNavigation = await repository.findOne({
|
|
15040
|
-
|
|
15041
|
-
|
|
15036
|
+
filters: { documentId: payload.documentId },
|
|
15037
|
+
locale: payload.locale,
|
|
15038
|
+
populate: "*"
|
|
15042
15039
|
});
|
|
15043
15040
|
const currentNavigationAsDTO = await this.getById({
|
|
15044
15041
|
documentId: payload.documentId,
|
|
15045
|
-
|
|
15042
|
+
locale: payload.locale
|
|
15046
15043
|
});
|
|
15047
15044
|
const detailsHaveChanged = currentNavigation.name !== name || currentNavigation.visible !== visible;
|
|
15048
15045
|
if (detailsHaveChanged) {
|
|
15049
15046
|
const allNavigations = await repository.find({
|
|
15050
|
-
|
|
15047
|
+
filters: { documentId: currentNavigation.documentId }
|
|
15051
15048
|
});
|
|
15052
15049
|
for (const navigation2 of allNavigations) {
|
|
15053
15050
|
const newSlug = name ? await commonService2.getSlug({
|
|
15054
|
-
query: `${name}${navigation2.
|
|
15051
|
+
query: `${name}${navigation2.locale !== defaultLocale ? ` ${navigation2.locale}` : ""}`
|
|
15055
15052
|
}) : currentNavigation.slug;
|
|
15056
15053
|
await repository.save({
|
|
15057
15054
|
documentId: navigation2.documentId,
|
|
15058
15055
|
id: navigation2.id,
|
|
15059
15056
|
slug: newSlug,
|
|
15057
|
+
locale: navigation2.locale,
|
|
15060
15058
|
name,
|
|
15061
15059
|
visible
|
|
15062
15060
|
});
|
|
@@ -15077,8 +15075,8 @@ const adminService = (context) => ({
|
|
|
15077
15075
|
});
|
|
15078
15076
|
await commonService2.emitEvent({
|
|
15079
15077
|
entity: await repository.findOne({
|
|
15080
|
-
|
|
15081
|
-
populate:
|
|
15078
|
+
filters: { documentId: payload.documentId },
|
|
15079
|
+
populate: "*"
|
|
15082
15080
|
}),
|
|
15083
15081
|
event: "entry.update",
|
|
15084
15082
|
uid: masterModel.uid
|
|
@@ -15105,12 +15103,12 @@ const adminService = (context) => ({
|
|
|
15105
15103
|
);
|
|
15106
15104
|
};
|
|
15107
15105
|
const navigation2 = await navigationRepository.findOne({
|
|
15108
|
-
|
|
15109
|
-
populate:
|
|
15106
|
+
filters: { documentId },
|
|
15107
|
+
populate: "*"
|
|
15110
15108
|
});
|
|
15111
15109
|
const allNavigations = await navigationRepository.find({
|
|
15112
|
-
|
|
15113
|
-
populate:
|
|
15110
|
+
filters: { documentId: navigation2.documentId },
|
|
15111
|
+
populate: "*"
|
|
15114
15112
|
});
|
|
15115
15113
|
await cleanNavigationItems(
|
|
15116
15114
|
allNavigations.map(({ documentId: documentId2 }) => documentId2)
|
|
@@ -15137,7 +15135,6 @@ const adminService = (context) => ({
|
|
|
15137
15135
|
key: "config"
|
|
15138
15136
|
}).then(configSchema.parse);
|
|
15139
15137
|
validateAdditionalFields(newConfig.additionalFields);
|
|
15140
|
-
console.log({ newConfig });
|
|
15141
15138
|
await pluginStore.set({ key: "config", value: newConfig });
|
|
15142
15139
|
const removedFields = differenceBy(
|
|
15143
15140
|
config2.additionalFields,
|
|
@@ -15160,11 +15157,11 @@ const adminService = (context) => ({
|
|
|
15160
15157
|
target,
|
|
15161
15158
|
documentId
|
|
15162
15159
|
}) {
|
|
15163
|
-
const targetEntity = await this.getById({ documentId,
|
|
15160
|
+
const targetEntity = await this.getById({ documentId, locale: target });
|
|
15164
15161
|
return await this.i18nNavigationContentsCopy({
|
|
15165
|
-
source: await this.getById({ documentId,
|
|
15162
|
+
source: await this.getById({ documentId, locale: source }),
|
|
15166
15163
|
target: targetEntity
|
|
15167
|
-
}).then(() => this.getById({ documentId,
|
|
15164
|
+
}).then(() => this.getById({ documentId, locale: target })).then((newEntity) => {
|
|
15168
15165
|
sendAuditLog(auditLog, "onChangeNavigation", {
|
|
15169
15166
|
actionType: "UPDATE",
|
|
15170
15167
|
oldEntity: targetEntity,
|
|
@@ -15183,7 +15180,7 @@ const adminService = (context) => ({
|
|
|
15183
15180
|
if (target.items?.length) {
|
|
15184
15181
|
throw new FillNavigationError("Current navigation is non-empty");
|
|
15185
15182
|
}
|
|
15186
|
-
if (!target.
|
|
15183
|
+
if (!target.locale) {
|
|
15187
15184
|
throw new FillNavigationError("Current navigation does not have specified locale");
|
|
15188
15185
|
}
|
|
15189
15186
|
if (!sourceItems.length) {
|
|
@@ -15192,15 +15189,16 @@ const adminService = (context) => ({
|
|
|
15192
15189
|
const entities = /* @__PURE__ */ new Map();
|
|
15193
15190
|
const itemProcessor = processItems({
|
|
15194
15191
|
master: target,
|
|
15195
|
-
|
|
15192
|
+
locale: target.locale,
|
|
15196
15193
|
strapi,
|
|
15197
15194
|
entities
|
|
15198
15195
|
});
|
|
15199
15196
|
await commonService2.createBranch({
|
|
15200
15197
|
action: { create: true },
|
|
15201
15198
|
masterEntity: await navigationRepository.findOne({
|
|
15202
|
-
|
|
15203
|
-
|
|
15199
|
+
filters: { documentId: target.documentId },
|
|
15200
|
+
locale: target.locale,
|
|
15201
|
+
populate: "*"
|
|
15204
15202
|
}),
|
|
15205
15203
|
navigationItems: await Promise.all(sourceItems.map(itemProcessor)),
|
|
15206
15204
|
parentItem: void 0
|
|
@@ -15273,7 +15271,7 @@ const adminService = (context) => ({
|
|
|
15273
15271
|
},
|
|
15274
15272
|
async purgeNavigationCache(documentId, clearLocalisations) {
|
|
15275
15273
|
const navigationRepository = getNavigationRepository(context);
|
|
15276
|
-
const entity = await navigationRepository.findOne({
|
|
15274
|
+
const entity = await navigationRepository.findOne({ filters: { documentId } });
|
|
15277
15275
|
if (!entity) {
|
|
15278
15276
|
throw new errors.NotFoundError("Navigation is not defined");
|
|
15279
15277
|
}
|
|
@@ -15281,7 +15279,7 @@ const adminService = (context) => ({
|
|
|
15281
15279
|
let regexps = [mapToRegExp(entity.documentId)];
|
|
15282
15280
|
if (clearLocalisations) {
|
|
15283
15281
|
const navigations = await navigationRepository.find({
|
|
15284
|
-
|
|
15282
|
+
filters: {
|
|
15285
15283
|
documentId: entity.documentId
|
|
15286
15284
|
}
|
|
15287
15285
|
});
|
|
@@ -15372,9 +15370,7 @@ const clientService = (context) => ({
|
|
|
15372
15370
|
async readAll({ locale: locale2, orderBy = "createdAt", orderDirection = "DESC" }) {
|
|
15373
15371
|
const repository = getNavigationRepository(context);
|
|
15374
15372
|
const navigations = repository.find({
|
|
15375
|
-
|
|
15376
|
-
localeCode: locale2
|
|
15377
|
-
} : {},
|
|
15373
|
+
locale: locale2,
|
|
15378
15374
|
orderBy: { [orderBy]: orderDirection }
|
|
15379
15375
|
});
|
|
15380
15376
|
return navigations;
|
|
@@ -15551,26 +15547,34 @@ const clientService = (context) => ({
|
|
|
15551
15547
|
};
|
|
15552
15548
|
const navigationRepository = getNavigationRepository(context);
|
|
15553
15549
|
const navigationItemRepository = getNavigationItemRepository(context);
|
|
15554
|
-
let navigation2
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
|
|
15562
|
-
}
|
|
15550
|
+
let navigation2;
|
|
15551
|
+
if (locale2) {
|
|
15552
|
+
navigation2 = await navigationRepository.find({
|
|
15553
|
+
filters: {
|
|
15554
|
+
...entityWhereClause
|
|
15555
|
+
},
|
|
15556
|
+
locale: locale2,
|
|
15557
|
+
limit: 1
|
|
15563
15558
|
});
|
|
15559
|
+
} else {
|
|
15560
|
+
navigation2 = await navigationRepository.find({
|
|
15561
|
+
filters: entityWhereClause,
|
|
15562
|
+
limit: 1
|
|
15563
|
+
});
|
|
15564
|
+
}
|
|
15565
|
+
if (isArray$1(navigation2)) {
|
|
15566
|
+
navigation2 = first$1(navigation2);
|
|
15564
15567
|
}
|
|
15565
15568
|
if (navigation2 && navigation2.documentId) {
|
|
15566
15569
|
const navigationItems = await navigationItemRepository.find({
|
|
15567
|
-
|
|
15570
|
+
filters: {
|
|
15568
15571
|
master: navigation2,
|
|
15569
15572
|
...itemCriteria
|
|
15570
15573
|
},
|
|
15574
|
+
locale: locale2,
|
|
15571
15575
|
limit: Number.MAX_SAFE_INTEGER,
|
|
15572
15576
|
order: [{ order: "asc" }],
|
|
15573
|
-
populate: ["
|
|
15577
|
+
populate: ["audience", "parent"]
|
|
15574
15578
|
});
|
|
15575
15579
|
const mappedItems = await commonService2.mapToNavigationItemDTO({
|
|
15576
15580
|
navigationItems,
|
|
@@ -15800,7 +15804,7 @@ const commonService = (context) => ({
|
|
|
15800
15804
|
documentId,
|
|
15801
15805
|
isNil(populate2) ? config2.contentTypesPopulate[uid] || [] : parsePopulateQuery(populate2),
|
|
15802
15806
|
"published",
|
|
15803
|
-
{ locale: master?.
|
|
15807
|
+
{ locale: master?.locale }
|
|
15804
15808
|
);
|
|
15805
15809
|
if (relatedItem) {
|
|
15806
15810
|
entities.set(related, {
|
|
@@ -15897,7 +15901,7 @@ const commonService = (context) => ({
|
|
|
15897
15901
|
}) {
|
|
15898
15902
|
const navigationActions = [];
|
|
15899
15903
|
for (const navigationItem2 of navigationItems) {
|
|
15900
|
-
if (!navigationItem2.
|
|
15904
|
+
if (!navigationItem2.documentId) {
|
|
15901
15905
|
continue;
|
|
15902
15906
|
}
|
|
15903
15907
|
action.remove = true;
|
|
@@ -15923,14 +15927,16 @@ const commonService = (context) => ({
|
|
|
15923
15927
|
let navigationActions = [];
|
|
15924
15928
|
for (const navigationItem2 of navigationItems) {
|
|
15925
15929
|
action.create = true;
|
|
15926
|
-
const { parent, master, items, id, ...params } = navigationItem2;
|
|
15927
|
-
const insertDetails = id ? {
|
|
15930
|
+
const { parent, master, items, documentId, id, ...params } = navigationItem2;
|
|
15931
|
+
const insertDetails = documentId && id ? {
|
|
15928
15932
|
...params,
|
|
15933
|
+
documentId,
|
|
15929
15934
|
id,
|
|
15930
15935
|
master: masterEntity ? masterEntity.id : void 0,
|
|
15931
15936
|
parent: parentItem ? parentItem.id : void 0
|
|
15932
15937
|
} : {
|
|
15933
15938
|
...params,
|
|
15939
|
+
documentId: void 0,
|
|
15934
15940
|
id: void 0,
|
|
15935
15941
|
master: masterEntity ? masterEntity.id : void 0,
|
|
15936
15942
|
parent: parentItem ? parentItem.id : void 0
|
|
@@ -15959,11 +15965,11 @@ const commonService = (context) => ({
|
|
|
15959
15965
|
const result = [];
|
|
15960
15966
|
for (const updateDetails of navigationItems) {
|
|
15961
15967
|
action.update = true;
|
|
15962
|
-
const {
|
|
15968
|
+
const { documentId, updated, parent, master, items, ...params } = updateDetails;
|
|
15963
15969
|
let currentItem;
|
|
15964
15970
|
if (updated) {
|
|
15965
15971
|
currentItem = await getNavigationItemRepository(context).save({
|
|
15966
|
-
|
|
15972
|
+
documentId,
|
|
15967
15973
|
...params
|
|
15968
15974
|
});
|
|
15969
15975
|
} else {
|
|
@@ -16008,7 +16014,7 @@ const commonService = (context) => ({
|
|
|
16008
16014
|
const removedFieldsKeys = removedFields.map(({ name }) => `additionalFields.${name}`);
|
|
16009
16015
|
const removedFieldsNames = removedFields.map(({ name }) => name);
|
|
16010
16016
|
const navigationItems = await getNavigationItemRepository(context).find({
|
|
16011
|
-
|
|
16017
|
+
filters: {
|
|
16012
16018
|
additionalFields: {
|
|
16013
16019
|
$contains: [removedFieldsNames]
|
|
16014
16020
|
}
|
|
@@ -16092,7 +16098,7 @@ const migrationService = (context) => ({
|
|
|
16092
16098
|
async migrateRelatedIdToDocumentId() {
|
|
16093
16099
|
console.log("Navigation plugin :: Migrations :: Relared id to document id - START");
|
|
16094
16100
|
const navigationItemRepository = getNavigationItemRepository(context);
|
|
16095
|
-
const all = await navigationItemRepository.find({
|
|
16101
|
+
const all = await navigationItemRepository.find({ filters: {}, limit: Number.MAX_SAFE_INTEGER });
|
|
16096
16102
|
await Promise.all(
|
|
16097
16103
|
all.map(async (item) => {
|
|
16098
16104
|
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<{
|