UNPKG

strapi-plugin-navigation

Version:
1,684 lines 356 kB
import * as y from "zod"; import { z as Hs } from "zod"; import ue, { uniqBy as _u, isNil as Ve, find as Yn, includes as Au, last as Vn, capitalize as Tu, isEmpty as st, once as fi, omit as bn, get as dn, toString as Cu, pick as Us, differenceBy as Ru, upperFirst as yr, isObject as vr, isArray as Ur, isString as oo, zipWith as $u, first as Er, cloneDeep as Fu, isNaN as Iu } from "lodash"; import { curry as Be, isArray as ge, isObject as Ae, isEmpty as ze, cloneDeep as Qn, omit as Gr, isNil as ne, isString as $e, trim as xn, pipe as Ou, split as qr, map as Nu, flatten as Pu, first as Gs, constant as zr, identity as Lu, join as Du, eq as ku, clone as Mu, pick as so, union as ju, getOr as Bu, toPath as qs, isBoolean as Hu, has as ao, get as co } from "lodash/fp"; import uo from "crypto"; import Sn from "child_process"; import _n from "lodash/has"; import zs from "lodash/mapValues"; import lo from "lodash/snakeCase"; import Uu from "lodash/camelCase"; import Gu from "lodash/mapKeys"; import Xn from "os"; import ve from "path"; import Ze from "fs"; import Ks from "assert"; import qu from "events"; import zu from "buffer"; import Zn from "stream"; import dt from "util"; import Ku from "constants"; import "node:stream"; import Wu from "@sindresorhus/slugify"; import fo from "pluralize"; const pi = y.object({ // TODO: Proper message translation name: y.string().refine((e) => !e.includes(" "), { message: "No space allowed" }), label: y.string(), required: y.boolean().optional(), enabled: y.boolean().optional() }), Yu = pi.extend({ type: y.literal("select"), multi: y.boolean(), options: y.array(y.string()) }), Vu = pi.extend({ type: y.enum(["boolean", "string"]), multi: y.literal(!1).optional(), options: y.array(y.string()).max(0).optional() }), Qu = pi.extend({ type: y.literal("media"), multi: y.literal(!1).optional(), options: y.array(y.string()).max(0).optional() }), Xu = y.union([ Vu, Qu, Yu ]), Zu = y.union([ y.literal("audience"), Xu ]), ke = y.object({ additionalFields: y.array(Zu), allowedLevels: y.number(), contentTypes: y.array(y.string()), contentTypesNameFields: y.record(y.string(), y.array(y.string())), contentTypesPopulate: y.record(y.string(), y.array(y.string())), gql: y.object({ navigationItemRelated: y.array(y.string()) }), pathDefaultFields: y.record(y.string(), y.any()), cascadeMenuAttached: y.boolean(), preferCustomContentTypes: y.boolean(), isCacheEnabled: y.boolean().optional() }), Ju = y.enum(["collectionType", "singleType"]), el = y.object({ singularName: y.string(), pluralName: y.string(), displayName: y.string(), description: y.string().optional(), name: y.string().optional() }), Ws = y.object({ required: y.boolean().optional(), max: y.number().optional(), min: y.number().optional(), minLength: y.number().optional(), maxLength: y.number().optional(), private: y.boolean().optional(), configurable: y.boolean().optional(), default: y.any().optional() }), tl = y.enum([ "string", "text", "richtext", "blocks", "email", "password", "date", "time", "datetime", "timestamp", "boolean", "integer", "biginteger", "float", "decimal", "json", "relation", "media" ]), nl = Ws.extend({ type: tl }), rl = Ws.extend({ type: y.literal("enumeration"), enum: y.string().array() }), il = y.object({ type: y.literal("component"), component: y.string(), repeatable: y.boolean().optional() }), ol = y.object({ type: y.literal("dynamiczone"), components: y.string().array() }), sl = y.object({ type: y.literal("uid") }), al = y.object({ type: y.literal("media"), allowedTypes: y.enum(["images", "videos", "audios", "files"]).array(), required: y.boolean().optional() }), cl = y.enum(["oneToOne", "oneToMany", "manyToOne", "manyToMany", "morphToMany", "manyToMorph"]), ul = y.object({ type: y.literal("relation"), relation: cl, target: y.string(), mappedBy: y.string().optional(), inversedBy: y.string().optional() }), ll = y.record( y.string(), y.union([ nl, rl, il, ol, ul, al, sl ]) ), Kr = y.object({ kind: Ju, collectionName: y.string(), info: el, options: y.object({ draftAndPublish: y.boolean().optional(), hidden: y.boolean().optional(), templateName: y.string().optional() }).optional(), attributes: ll, actions: y.record(y.string(), y.any()).optional(), lifecycles: y.record(y.string(), y.any()).optional(), uid: y.string(), apiName: y.string().optional(), // TODO?: remove associations: y.object({ model: y.string(), alias: y.string() }).array().optional(), modelName: y.string().optional(), plugin: y.string().optional(), pluginOptions: y.record(y.string(), y.any()).optional(), isSingle: y.boolean().optional() }); Kr.pick({ info: !0, kind: !0, attributes: !0, options: !0 }); const Ys = y.object({ id: y.number(), documentId: y.string(), name: y.string(), key: y.string() }), fl = y.enum(["INTERNAL", "EXTERNAL", "WRAPPER"]), di = y.object({ id: y.number(), documentId: y.string(), title: y.string(), type: fl, path: y.string().or(y.null()).optional(), slug: y.string().or(y.null()).optional(), externalPath: y.string().or(y.null()).optional(), uiRouterKey: y.string(), menuAttached: y.boolean(), order: y.number().int(), collapsed: y.boolean(), related: y.object({ documentId: y.string().optional(), __type: y.string() }).catchall(y.unknown()).nullish(), additionalFields: y.record(y.string(), y.unknown()).or(y.null()).optional(), audience: y.array(Ys).or(y.null()).optional(), autoSync: y.boolean().or(y.null()).optional() }), pl = di.omit({ related: !0 }).pick({ path: !0, type: !0, uiRouterKey: !0, title: !0, externalPath: !0 }).extend({ related: y.unknown() }), Kt = di.extend({ parent: y.lazy(() => Kt.or(y.null())).optional(), items: y.lazy(() => Kt.array()).optional(), master: y.lazy(() => it(!1)).optional() }), po = y.array(Kt), it = (e) => y.object({ id: y.number(), documentId: y.string(), name: y.string(), slug: y.string(), locale: y.string(), visible: y.boolean(), items: e ? y.array(Kt) : Kt.array().optional() }), dl = it(!1).omit({ items: !0, id: !0, documentId: !0, slug: !0, locale: !0 }).extend({ documentId: y.string().optional(), id: y.undefined().optional() }), hl = di.omit({ id: !0, documentId: !0 }).extend({ id: y.number().optional(), documentId: y.string().optional(), items: y.lazy(() => Vs).or(y.null()).optional(), updated: y.boolean().optional(), removed: y.boolean().optional() }), Vs = y.array(hl), ml = it(!1).extend({ items: Vs }).partial().required({ id: !0, documentId: !0 }), gl = /^(?<type>[a-z0-9-]+)\:{2}(?<api>[a-z0-9-]+)\.{1}(?<contentType>[a-z0-9-]+)$/i, yl = [ "beforeCreate", "beforeCreateMany", "afterCreate", "afterCreateMany", "beforeUpdate", "beforeUpdateMany", "afterUpdate", "afterUpdateMany", "beforeDelete", "beforeDeleteMany", "afterDelete", "afterDeleteMany", "beforeCount", "afterCount", "beforeFindOne", "afterFindOne", "beforeFindMany", "afterFindMany" ], vl = "$", Qs = ["api::", "plugin::"], Xs = [ "admin::", "plugin::content-releases", "plugin::i18n.locale", "plugin::navigation", "plugin::review-workflows", "plugin::users-permissions", "plugin::upload.folder" ], El = ["title", "subject", "name"], ho = { SINGLE: "singleType" }, mo = [ "title", "type", "path", "externalPath", "uiRouterKey", "menuAttached", "order", "collapsed", "related", "parent", "master", "audience", "additionalFields" ], wl = (e) => e.filter((t) => t !== "audience"), Zs = (e) => { const t = wl(e); if (t.length !== _u(t, "name").length) throw new Error("All names of custom fields must be unique."); if (!Ve( Yn( t, (n) => typeof n == "object" && Au(mo, n.name) ) )) throw new Error( `Name of custom field cannot be one of: ${mo.join(", ")}` ); }, Js = (e, t) => { if (e == null) throw t ?? new Error("Non-empty value expected, empty given"); }, bl = (e = "") => { const t = (s) => s.split("-").map((o) => Tu(o)).join(""), [n, r, i] = xl(e); return n === "api" ? t(i) : `${t(r)}${t(i)}`; }, xl = (e = "") => e.split(gl).filter((t) => t && t.length > 0), Sl = (e, t) => (n) => [ n, async (r) => { await ie(t, "common").runLifeCycleHook({ contentTypeName: e, hookName: n, event: r }); } ], ea = (e, t) => Object.fromEntries(yl.map(Sl(e, t))), we = ({ strapi: e }) => { const t = e.plugin("navigation"); return { masterModel: t.contentType("navigation"), itemModel: t.contentType("navigation-item"), relatedModel: t.contentType("navigations-items-related"), audienceModel: t.contentType("audience") }; }; function ie({ strapi: e }, t) { return e.plugin("navigation").service(t); } const rn = (e) => e === "*" ? "*" : typeof e == "string" ? [e] : e === !1 ? [] : e === !0 ? "*" : e, _l = (e = "") => { const t = !!Qs.find((r) => e.includes(r)), n = !Xs.find((r) => e.includes(r) || e === r); return !!e && t && n; }, go = (e = "") => Vn(e) === "s" ? e.substr(0, e.length - 1) : e, ta = async ({ strapi: e, forceDefault: t = !1 }) => { const n = e.store({ type: "plugin", name: "navigation" }), r = await e.plugin("navigation").config, i = t ? {} : { ...Wr.default, ...await n.get({ key: "config" }) ?? Wr.default }; let s = st(i) ? i : ke.parse(i); const o = Al(s, r); return s = { additionalFields: o("additionalFields"), contentTypes: o("contentTypes"), contentTypesNameFields: o("contentTypesNameFields"), contentTypesPopulate: o("contentTypesPopulate"), allowedLevels: o("allowedLevels"), gql: o("gql"), pathDefaultFields: o("pathDefaultFields"), cascadeMenuAttached: o("cascadeMenuAttached"), preferCustomContentTypes: o("preferCustomContentTypes"), isCacheEnabled: o("isCacheEnabled") }, Tl(s, { strapi: e }), Zs(s.additionalFields), await n.set({ key: "config", value: s }), s; }, Al = (e, t) => (n) => { const r = e?.[n] ?? t(n); return Js(r, new Error(`[Navigation] Config "${n}" is undefined`)), r; }, Tl = (e, { strapi: t }) => { const n = e.contentTypes.filter( (i) => !t.contentTypes[i] ); if (n.length === 0) return; const r = n.map(bl); e.contentTypes = e.contentTypes.filter( (i) => !n.includes(i) ), e.contentTypesNameFields = Object.fromEntries( Object.entries(e.contentTypesNameFields).filter( ([i]) => !n.includes(i) ) ), e.gql.navigationItemRelated = e.gql.navigationItemRelated.filter( (i) => !r.includes(i) ); }, Wr = { default: { additionalFields: [], allowedLevels: 2, contentTypes: [], contentTypesNameFields: {}, contentTypesPopulate: {}, gql: { navigationItemRelated: [] }, i18nEnabled: !1, pathDefaultFields: {}, pruneObsoleteI18nNavigations: !1, cascadeMenuAttached: !0, preferCustomContentTypes: !1, isCacheEnabled: !1 } }, Cl = fi((e) => ({ find(t, n) { const { audienceModel: { uid: r } } = we(e); return e.strapi.query(r).findMany({ where: t, limit: n }).then(Ys.array().parse); } })), An = (e, t) => ({ findFirst(n, r, i = {}) { return e.strapi.documents(t).findFirst({ populate: rn(n), status: r, ...i }); }, findById(n, r, i, s = {}) { return e.strapi.documents(t).findOne({ documentId: n, populate: rn(r), status: i, ...s }); }, findManyById(n, r, i) { return e.strapi.documents(t).findMany({ where: { documentId: { $in: n } }, populate: rn(r), status: i }); }, findMany(n, r, i, s) { return e.strapi.documents(t).findMany({ where: n, populate: rn(r), status: i, locale: s }); }, count(n, r) { return e.strapi.documents(t).count({ where: n, status: r }); } }), Le = fi((e) => ({ async save({ item: t, locale: n }) { const { itemModel: r } = we(e), { __type: i, documentId: s } = t?.related ?? {}, o = i ? An(e, i) : void 0, a = i && o ? s ? await o.findById(s, void 0, void 0, { locale: n }) : await o.findFirst(void 0, void 0, { locale: n }) : void 0; if (typeof t.documentId == "string") { const { documentId: c, ...f } = t; return e.strapi.documents(r.uid).update({ documentId: t.documentId, data: { ...f, related: a ? { ...a, __type: i } : void 0 }, locale: n }); } else return e.strapi.documents(r.uid).create({ data: { ...t, related: a ? { ...a, __type: i } : void 0 }, locale: n }); }, find({ filters: t, locale: n, limit: r, order: i, populate: s }) { const { itemModel: o } = we(e); return e.strapi.documents(o.uid).findMany({ filters: t, locale: n, limit: r, populate: s, orderBy: i }).then((a) => a.map(Yr)).then(po.parse).then((a) => a.map(Tn)); }, count(t) { const { itemModel: n } = we(e); return e.strapi.query(n.uid).count({ where: t }); }, remove(t) { const { itemModel: n } = we(e); return e.strapi.query(n.uid).delete({ where: { documentId: t.documentId } }); }, removeForIds(t) { const { itemModel: n } = we(e); return e.strapi.query(n.uid).deleteMany({ where: { documentId: t } }); }, findForMasterIds(t) { const { itemModel: n } = we(e); return e.strapi.query(n.uid).findMany({ where: { $or: t.map((r) => ({ master: r })) }, limit: Number.MAX_SAFE_INTEGER }).then(po.parse); } })), Rl = ["id", "publishedAt", "createdAt", "updatedAt", "locale"], Tn = ({ related: e, items: t = [], ...n }) => ({ ...n, items: t.map(Tn), related: e ? bn(e, Rl) : void 0 }), Yr = ({ related: e, ...t }) => ({ ...t, related: e?.[0] }); class Ft extends Error { constructor(t, n) { super(t), this.additionalInfo = n, this.type = "NavigationError"; } } class wr extends Ft { constructor() { super(...arguments), this.type = "FillNavigationError"; } } class $l extends Ft { constructor() { super(...arguments), this.type = "InvalidParamNavigationError"; } } const yo = (e) => e === !0 ? !0 : Array.isArray(e) ? e.includes("items") : !1, Pe = fi((e) => ({ find({ filters: t, locale: n, limit: r, orderBy: i, populate: s }) { const { masterModel: o } = we(e); return e.strapi.documents(o.uid).findMany({ filters: t, locale: n, limit: r, populate: s, orderBy: i }).then( (a) => a.map(({ items: c, ...f }) => ({ ...f, items: c?.map(Yr) })) ).then( (a) => a.map(({ items: c, ...f }) => ({ ...f, items: c?.map(Tn) })) ).then((a) => it(yo(s)).array().parse(a)); }, findOne({ locale: t, filters: n, populate: r }) { const { masterModel: i } = we(e); return e.strapi.documents(i.uid).findOne({ documentId: n.documentId, locale: t, populate: r }).then((s) => s && { ...s, items: s.items?.map(Yr) }).then((s) => it(yo(r)).parse(s)).then((s) => ({ ...s, items: s.items?.map(Tn) })); }, async save(t) { const { masterModel: n } = we(e), { documentId: r, locale: i, ...s } = t; return r ? e.strapi.documents(n.uid).update({ locale: i, documentId: r, data: bn(s, ["id", "documentId"]), populate: ["items"] }).then(it(!1).parse) : e.strapi.documents(n.uid).create({ locale: i, data: { ...s, populate: ["items"] } }).then(it(!1).parse); }, remove(t) { const { masterModel: n } = we(e); if (!t.documentId && !t.id) throw new Ft("Some kind of id required. None given."); return e.strapi.query(n.uid).deleteMany({ where: t }); } })), Fl = "Navigation", Il = "navigation", Ol = async (e) => { const t = ie(e, "common"), { defaultLocale: n, restLocale: r = [] } = await t.readLocale(), i = Pe(e), s = await i.find({ limit: Number.MAX_SAFE_INTEGER, filters: {}, locale: "*" }); s.length === 0 && s.push( await i.save({ name: Fl, visible: !0, locale: n, slug: Il }) ); const o = s.filter(({ locale: a }) => a === n); for (const a of o) for (const c of r) !s.find( ({ locale: u, documentId: l }) => l === a.documentId && c === u ) && await i.save({ documentId: a.documentId, name: a.name, locale: c, visible: a.visible, slug: a.slug }); }, pe = { render: function(e) { return `plugin::navigation.${e}`; }, navigation: { read: "read", update: "update", settings: "settings" } }, Nl = async ({ strapi: e }) => { const t = [ { section: "plugins", displayName: "Read", uid: pe.navigation.read, pluginName: "navigation" }, { section: "plugins", displayName: "Update", uid: pe.navigation.update, pluginName: "navigation" }, { section: "plugins", displayName: "Settings", uid: pe.navigation.settings, pluginName: "navigation" } ]; await e.admin.services.permission.actionProvider.registerMany(t); }, Pl = ({ nexus: e }) => e.objectType({ name: "ContentTypes", definition(t) { t.nonNull.string("uid"), t.nonNull.string("name"), t.nonNull.boolean("isSingle"), t.nonNull.string("collectionName"), t.nonNull.string("contentTypeName"), t.nonNull.string("label"), t.nonNull.string("relatedField"), t.nonNull.string("labelSingular"), t.nonNull.string("endpoint"), t.nonNull.boolean("available"), t.nonNull.boolean("visible"); } }), Ll = ({ nexus: e, strapi: t }) => e.objectType({ name: "ContentTypesNameFields", async definition(n) { n.nonNull.list.nonNull.string("default"); const i = await ie({ strapi: t }, "common").getPluginStore(), o = ke.parse(await i.get({ key: "config" })).contentTypesNameFields; Object.keys(o || {}).forEach((a) => n.nonNull.list.string(a)); } }), Dl = ({ nexus: e }) => e.inputObjectType({ name: "CreateNavigation", definition(t) { t.nonNull.string("name"), t.nonNull.list.field("items", { type: "CreateNavigationItem" }); } }), kl = ({ nexus: e }) => e.inputObjectType({ name: "CreateNavigationItem", definition(t) { t.nonNull.string("title"), t.nonNull.field("type", { type: "NavigationItemType" }), t.string("path"), t.string("externalPath"), t.nonNull.string("uiRouterKey"), t.nonNull.boolean("menuAttached"), t.nonNull.int("order"), t.string("parent"), t.string("master"), t.list.field("items", { type: "CreateNavigationItem" }), t.list.string("audience"), t.field("related", { type: "CreateNavigationRelated" }); } }), Ml = ({ nexus: e }) => e.inputObjectType({ name: "CreateNavigationRelated", definition(t) { t.nonNull.string("ref"), t.nonNull.string("field"), t.nonNull.string("refId"); } }), jl = ({ nexus: e }) => e.objectType({ name: "Navigation", definition(t) { t.nonNull.string("id"), t.nonNull.string("documentId"), t.nonNull.string("name"), t.nonNull.string("slug"), t.nonNull.boolean("visible"); } }), Bl = ({ nexus: e }) => e.objectType({ name: "NavigationConfig", definition(t) { t.int("allowedLevels"), t.nonNull.list.string("additionalFields"), t.field("contentTypesNameFields", { type: "ContentTypesNameFields" }), t.list.field("contentTypes", { type: "ContentTypes" }); } }), Hl = ({ nexus: e }) => e.objectType({ name: "NavigationDetails", definition(t) { t.nonNull.string("id"), t.nonNull.string("documentId"), t.nonNull.string("name"), t.nonNull.string("slug"), t.nonNull.boolean("visible"), t.nonNull.list.field("items", { type: "NavigationItem" }); } }), Ul = ({ nexus: e, config: t }) => e.objectType({ name: "NavigationItem", definition(n) { n.nonNull.int("id"), n.nonNull.string("documentId"), n.nonNull.string("title"), n.nonNull.field("type", { type: "NavigationItemType" }), n.string("path"), n.string("externalPath"), n.nonNull.string("uiRouterKey"), n.nonNull.boolean("menuAttached"), n.nonNull.int("order"), n.field("parent", { type: "NavigationItem" }), n.string("master"), n.list.field("items", { type: "NavigationItem" }), n.field("related", { type: "NavigationItemRelated" }), t.additionalFields.find((r) => r === "audience") && n.list.string("audience"), n.field("additionalFields", { type: "NavigationItemAdditionalFields" }), n.string("created_at"), n.string("updated_at"), n.string("created_by"), n.string("updated_by"), n.string("createdAt"), n.string("updatedAt"), n.string("createdBy"), n.string("updatedBy"); } }), Gl = ({ nexus: e, config: t }) => e.objectType({ name: "NavigationItemAdditionalFields", definition(n) { t.additionalFields.forEach((r) => { if (r !== "audience" && r.enabled) switch (r.type) { case "media": n.field(r.name, { type: "UploadFile" }); break; case "string": n.string(r.name); break; case "boolean": n.boolean(r.name); break; case "select": r.multi ? n.list.string(r.name) : n.string(r.name); break; default: throw new Error( `Type "${JSON.stringify(r.type)}" is unsupported by custom fields` ); } }); } }), ql = ({ strapi: e, nexus: t, config: n }) => { const r = n.gql?.navigationItemRelated, i = "NavigationItemRelated"; return r?.length ? t.unionType({ name: i, definition(s) { s.members(...r); }, resolveType: (s) => e.contentTypes[s.__type]?.globalId }) : t.objectType({ name: i, definition(s) { s.int("id"), s.string("documentId"), s.string("title"), s.string("name"); } }); }, zl = ({ nexus: e }) => e.enumType({ name: "NavigationItemType", members: ["INTERNAL", "EXTERNAL", "WRAPPER"] }), Kl = ({ nexus: e }) => e.enumType({ name: "NavigationRenderType", members: ["FLAT", "TREE"] }), Wl = [ Gl, ql, Ul, Kl, jl, Hl, Ll, Pl, Bl, Ml, kl, Dl, zl ], Yl = (e) => Wl.map((t) => t(e)), Vl = "I18NLocaleCode", Ql = ({ strapi: e, nexus: t }) => { const { nonNull: n, list: r, stringArg: i, booleanArg: s } = t; return { args: { navigationIdOrSlug: n(i()), type: "NavigationRenderType", menuOnly: s(), path: i(), locale: t.arg({ type: Vl }) }, type: n(r("NavigationItem")), resolve(c, { navigationIdOrSlug: f, type: u, menuOnly: l, path: p, locale: d }) { const h = Hs.string().parse(f); return ie({ strapi: e }, "client").render({ idOrSlug: h, type: u, rootPath: p, locale: d, menuOnly: l, wrapRelated: !0 }); } }; }, Xl = ({ strapi: e, nexus: t }) => { const { nonNull: n, list: r, stringArg: i, booleanArg: s } = t; return { type: n(r("NavigationItem")), args: { documentId: n(i()), childUiKey: n(i()), type: "NavigationRenderType", menuOnly: s() }, resolve(o, a) { const { documentId: c, childUIKey: f, type: u, menuOnly: l } = a, p = Hs.string().parse(c); return ie({ strapi: e }, "client").renderChildren({ idOrSlug: p, childUIKey: f, type: u, menuOnly: l, wrapRelated: !0 }); } }; }, Zl = (e) => { const t = { renderNavigationChild: Xl, renderNavigation: Ql }; return e.nexus.extendType({ type: "Query", definition(n) { for (const [r, i] of Object.entries(t)) { const s = i(e); n.field(r, s); } } }); }, Jl = () => ({ "Query.renderNavigationChild": { auth: !1 }, "Query.renderNavigation": { auth: !1 } }), ef = async ({ strapi: e }) => { const t = e.plugin("graphql").service("extension"); t.shadowCRUD("plugin::navigation.audience").disable(), t.shadowCRUD("plugin::navigation.navigation").disable(), t.shadowCRUD("plugin::navigation.navigation-item").disable(), t.shadowCRUD("plugin::navigation.navigations-items-related").disable(); const r = await ie({ strapi: e }, "common").getPluginStore(), i = ke.parse(await r.get({ key: "config" })); t.use(({ strapi: s, nexus: o }) => { const a = Yl({ strapi: s, nexus: o, config: i }), c = Zl({ strapi: s, nexus: o }), f = Jl(); return { types: [a, c], resolversConfig: f }; }); }, tf = async ({ strapi: e }) => { !!e.plugin("graphql") && await ef({ strapi: e }); }, nf = async (e) => { await ta(e), await Ol(e), await Nl(e), await tf(e); }, rf = ({ strapi: e }) => { }, of = ({ strapi: e }) => { }, sf = { collectionName: "audience", info: { singularName: "audience", pluralName: "audiences", displayName: "Audience", name: "audience" }, options: { increments: !0, comment: "Audience" }, attributes: { name: { type: "string", required: !0 }, key: { type: "uid", targetField: "name" } } }, af = { schema: sf }, cf = ea("navigation", { strapi }), uf = { collectionName: "navigations", info: { singularName: "navigation", pluralName: "navigations", displayName: "Navigation", name: "navigation" }, options: { comment: "" }, pluginOptions: { "content-manager": { visible: !1 }, "content-type-builder": { visible: !1 }, i18n: { localized: !0 } }, attributes: { name: { type: "text", configurable: !1, required: !0 }, slug: { type: "uid", target: "name", configurable: !1, required: !0 }, visible: { type: "boolean", default: !1, configurable: !1 }, items: { type: "relation", relation: "oneToMany", target: "plugin::navigation.navigation-item", configurable: !1, mappedBy: "master" } } }, lf = { schema: uf, lifecycles: cf }, ff = ea("navigation-item", { strapi }), pf = { collectionName: "navigations_items", info: { singularName: "navigation-item", pluralName: "navigation-items", displayName: "Navigation Item", name: "navigation-item" }, options: { increments: !0, timestamps: !0, comment: "Navigation Item" }, pluginOptions: { "content-manager": { visible: !1 }, "content-type-builder": { visible: !1 }, i18n: { localized: !1 } }, attributes: { title: { type: "text", configurable: !1, required: !0, pluginOptions: { i18n: { localized: !1 } } }, type: { type: "enumeration", enum: ["INTERNAL", "EXTERNAL", "WRAPPER"], default: "INTERNAL", configurable: !1 }, path: { type: "text", targetField: "title", configurable: !1 }, externalPath: { type: "text", configurable: !1 }, uiRouterKey: { type: "string", configurable: !1 }, menuAttached: { type: "boolean", default: !1, configurable: !1 }, order: { type: "integer", default: 0, configurable: !1 }, collapsed: { type: "boolean", default: !1, configurable: !1 }, autoSync: { type: "boolean", default: !0, configurable: !1 }, related: { type: "relation", relation: "morphToMany", required: !0, configurable: !1 }, parent: { type: "relation", relation: "oneToOne", target: "plugin::navigation.navigation-item", configurable: !1, default: null }, master: { type: "relation", relation: "manyToOne", target: "plugin::navigation.navigation", configurable: !1, inversedBy: "items" }, audience: { type: "relation", relation: "oneToMany", target: "plugin::navigation.audience" }, additionalFields: { type: "json", require: !1, default: {} } } }, df = { schema: pf, lifecycles: ff }, hf = { audience: af, navigation: lf, "navigation-item": df }, na = y.enum(["true", "false"]), on = y.string(), mf = y.object({ locale: y.string().optional(), orderBy: y.string().optional(), orderDirection: y.enum(["DESC", "ASC"]).optional() }), ra = y.enum(["FLAT", "TREE", "RFR"]), ia = y.union([y.boolean(), y.string(), y.string().array(), y.undefined()]), gf = y.object({ type: ra.optional(), menu: na.optional(), path: y.string().optional(), locale: y.string().optional(), populate: ia.optional() }), yf = y.object({ type: ra.optional(), menu: na.optional(), locale: y.string().optional() }), vf = y.object({ source: y.string().min(1), target: y.string().min(1), documentId: y.string().min(1) }); function Ef(e) { return { getAdminService() { return ie(e, "admin"); }, getCommonService() { return ie(e, "common"); }, async get() { return await this.getAdminService().get({}); }, post(t) { const { auditLog: n } = t; return this.getAdminService().post({ payload: dl.parse(t.request.body), auditLog: n }); }, put(t) { const { params: { documentId: n }, auditLog: r } = t, i = y.record(y.string(), y.unknown()).parse(t.request.body); return this.getAdminService().put({ auditLog: r, payload: ml.parse({ ...i, documentId: n }) }); }, async delete(t) { const { auditLog: n, params: { documentId: r } } = t; return await this.getAdminService().delete({ documentId: on.parse(r), auditLog: n }), {}; }, config() { return this.getAdminService().config({ viaSettingsPage: !1 }); }, async updateConfig(t) { return await this.getAdminService().updateConfig({ config: ke.parse(t.request.body) }), {}; }, async restoreConfig() { return await this.getAdminService().restoreConfig(), {}; }, settingsConfig() { return this.getAdminService().config({ viaSettingsPage: !0 }); }, async settingsRestart() { return await this.getAdminService().restart(), {}; }, getById(t) { const { params: { documentId: n } } = t; return this.getAdminService().getById({ documentId: on.parse(n) }); }, getContentTypeItems(t) { const { params: { model: n }, query: r = {} } = t; return this.getAdminService().getContentTypeItems({ query: y.record(y.string(), y.unknown()).parse(r), uid: y.string().parse(n) }); }, async fillFromOtherLocale(t) { const { params: n, auditLog: r } = t, { source: i, target: s, documentId: o } = vf.parse(n); return await this.getAdminService().fillFromOtherLocale({ source: i, target: s, documentId: o, auditLog: r }); }, readNavigationItemFromLocale(t) { const { params: { source: n, target: r }, query: { path: i } } = t; return this.getAdminService().readNavigationItemFromLocale({ path: y.string().parse(i), source: on.parse(n), target: on.parse(r) }); }, getSlug(t) { const { query: { q: n } } = t; return this.getCommonService().getSlug({ query: y.string().parse(n) }).then((r) => ({ slug: r })); }, settingsLocale() { return this.getCommonService().readLocale(); } }; } const wf = (e) => { if (!(!e || e === !0 || e === "*") && typeof e != "object") return Array.isArray(e), e; }; function bf(e) { return { getService() { return ie(e, "client"); }, async readAll(t) { try { const { query: n = {} } = t, { locale: r, orderBy: i, orderDirection: s } = mf.parse(n); return await this.getService().readAll({ locale: r, orderBy: i, orderDirection: s }); } catch (n) { if (n instanceof Error) return t.badRequest(n.message); throw n; } }, async render(t) { const { params: n, query: r = {} } = t, { type: i, menu: s, path: o, locale: a, populate: c } = gf.parse(r), f = y.string().parse(n.idOrSlug); return await this.getService().render({ idOrSlug: f, type: i, menuOnly: s === "true", rootPath: o, locale: a, populate: wf( ia.parse( c === "true" ? !0 : c === "false" ? !1 : Array.isArray(c) ? c.map((u) => u === "true" ? !0 : u === "false" ? !1 : c) : c ) ) }); }, async renderChild(t) { const { params: n, query: r = {} } = t, { type: i, menu: s, locale: o } = yf.parse(r), a = y.string().parse(n.documentId), c = y.string().parse(n.childUIKey); return await this.getService().renderChildren({ idOrSlug: a, childUIKey: c, type: i, menuOnly: s === "true", locale: o }); } }; } const xf = { admin: Ef, client: bf }, Sf = {}, _f = {}, Af = { type: "admin", routes: [ { method: "GET", path: "/", handler: "admin.get", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("read")] } } ] } }, { method: "POST", path: "/", handler: "admin.post", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("update")] } } ] } }, { method: "GET", path: "/config", handler: "admin.config", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("read")] } } ] } }, { method: "PUT", path: "/config", handler: "admin.updateConfig", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("settings")] } } ] } }, { method: "DELETE", path: "/config", handler: "admin.restoreConfig", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("settings")] } } ] } }, { method: "GET", path: "/slug", handler: "admin.getSlug", config: { policies: ["admin::isAuthenticatedAdmin"] } }, { method: "GET", path: "/:documentId", handler: "admin.getById", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("read")] } } ] } }, { method: "PUT", path: "/:documentId", handler: "admin.put", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("update")] } } ] } }, { method: "DELETE", path: "/:documentId", handler: "admin.delete", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("update")] } } ] } }, { method: "GET", path: "/content-type-items/:model", handler: "admin.getContentTypeItems", config: { policies: ["admin::isAuthenticatedAdmin"] } }, { method: "GET", path: "/settings/locale", handler: "admin.settingsLocale", config: { policies: ["admin::isAuthenticatedAdmin"] } }, { method: "GET", path: "/settings/config", handler: "admin.settingsConfig", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("settings")] } } ] } }, { method: "GET", path: "/settings/restart", handler: "admin.settingsRestart", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("settings")] } } ] } }, { method: "PUT", path: "/i18n/copy/:documentId/:source/:target", handler: "admin.fillFromOtherLocale", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("update")] } } ] } }, { method: "GET", path: "/i18n/item/read/:source/:target", handler: "admin.readNavigationItemFromLocale", config: { policies: [ { name: "admin::hasPermissions", config: { actions: [pe.render("read")] } } ] } } ] }, Tf = { type: "content-api", routes: [ { method: "GET", path: "/render/:idOrSlug", handler: "client.render", config: { policies: [] } }, { method: "GET", path: "/render/:idOrSlug/:childUIKey", handler: "client.renderChild", config: { policies: [] } }, { method: "GET", path: "/", handler: "client.readAll", config: { policies: [] } } ] }, Cf = { admin: Af, "content-api": Tf }; var me = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function oa(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var Rf = { exports: {} }; (function(e, t) { (function(n, r) { e.exports = r(Sn, uo); })(me, function(n, r) { return function(i) { function s(a) { if (o[a]) return o[a].exports; var c = o[a] = { exports: {}, id: a, loaded: !1 }; return i[a].call(c.exports, c, c.exports, s), c.loaded = !0, c.exports; } var o = {}; return s.m = i, s.c = o, s.p = "", s(0); }([function(i, s, o) { i.exports = o(34); }, function(i, s, o) { var a = o(29)("wks"), c = o(33), f = o(2).Symbol, u = typeof f == "function", l = i.exports = function(p) { return a[p] || (a[p] = u && f[p] || (u ? f : c)("Symbol." + p)); }; l.store = a; }, function(i, s) { var o = i.exports = typeof window < "u" && window.Math == Math ? window : typeof self < "u" && self.Math == Math ? self : Function("return this")(); typeof __g == "number" && (__g = o); }, function(i, s, o) { var a = o(9); i.exports = function(c) { if (!a(c)) throw TypeError(c + " is not an object!"); return c; }; }, function(i, s, o) { i.exports = !o(24)(function() { return Object.defineProperty({}, "a", { get: function() { return 7; } }).a != 7; }); }, function(i, s, o) { var a = o(12), c = o(17); i.exports = o(4) ? function(f, u, l) { return a.f(f, u, c(1, l)); } : function(f, u, l) { return f[u] = l, f; }; }, function(i, s) { var o = i.exports = { version: "2.4.0" }; typeof __e == "number" && (__e = o); }, function(i, s, o) { var a = o(14); i.exports = function(c, f, u) { if (a(c), f === void 0) return c; switch (u) { case 1: return function(l) { return c.call(f, l); }; case 2: return function(l, p) { return c.call(f, l, p); }; case 3: return function(l, p, d) { return c.call(f, l, p, d); }; } return function() { return c.apply(f, arguments); }; }; }, function(i, s) { var o = {}.hasOwnProperty; i.exports = function(a, c) { return o.call(a, c); }; }, function(i, s) { i.exports = function(o) { return typeof o == "object" ? o !== null : typeof o == "function"; }; }, function(i, s) { i.exports = {}; }, function(i, s) { var o = {}.toString; i.exports = function(a) { return o.call(a).slice(8, -1); }; }, function(i, s, o) { var a = o(3), c = o(26), f = o(32), u = Object.defineProperty; s.f = o(4) ? Object.defineProperty : function(l, p, d) { if (a(l), p = f(p, !0), a(d), c) try { return u(l, p, d); } catch { } if ("get" in d || "set" in d) throw TypeError("Accessors not supported!"); return "value" in d && (l[p] = d.value), l; }; }, function(i, s, o) { var a = o(42), c = o(15); i.exports = function(f) { return a(c(f)); }; }, function(i, s) { i.exports = function(o) { if (typeof o != "function") throw TypeError(o + " is not a function!"); return o; }; }, function(i, s) { i.exports = function(o) { if (o == null) throw TypeError("Can't call method on " + o); return o; }; }, function(i, s, o) { var a = o(9), c = o(2).document, f = a(c) && a(c.createElement); i.exports = function(u) { return f ? c.createElement(u) : {}; }; }, function(i, s) { i.exports = function(o, a) { return { enumerable: !(1 & o), configurable: !(2 & o), writable: !(4 & o), value: a }; }; }, function(i, s, o) { var a = o(12).f, c = o(8), f = o(1)("toStringTag"); i.exports = function(u, l, p) { u && !c(u = p ? u : u.prototype, f) && a(u, f, { configurable: !0, value: l }); }; }, function(i, s, o) { var a = o(29)("keys"), c = o(33); i.exports = function(f) { return a[f] || (a[f] = c(f)); }; }, function(i, s) { var o = Math.ceil, a = Math.floor; i.exports = function(c) { return isNaN(c = +c) ? 0 : (c > 0 ? a : o)(c); }; }, function(i, s, o) { var a = o(11), c = o(1)("toStringTag"), f = a(/* @__PURE__ */ function() { return arguments; }()) == "Arguments", u = function(l, p) { try { return l[p]; } catch { } }; i.exports = function(l) { var p, d, h; return l === void 0 ? "Undefined" : l === null ? "Null" : typeof (d = u(p = Object(l), c)) == "string" ? d : f ? a(p) : (h = a(p)) == "Object" && typeof p.callee == "function" ? "Arguments" : h; }; }, function(i, s) { i.exports = "constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","); }, function(i, s, o) { var a = o(2), c = o(6), f = o(7), u = o(5), l = "prototype", p = function(d, h, m) { var g, b, S, T = d & p.F, A = d & p.G, C = d & p.S, R = d & p.P, k = d & p.B, x = d & p.W, _ = A ? c : c[h] || (c[h] = {}), I = _[l], E = A ? a : C ? a[h] : (a[h] || {})[l]; A && (m = h); for (g in m) b = !T && E && E[g] !== void 0, b && g in _ || (S = b ? E[g] : m[g], _[g] = A && typeof E[g] != "function" ? m[g] : k && b ? f(S, a) : x && E[g] == S ? function(P) { var j = function(G, w, v) { if (this instanceof P) { switch (arguments.length) { case 0: return new P(); case 1: return new P(G); case 2: return new P(G, w); } return new P(G, w, v); } return P.apply(this, arguments); }; return j[l] = P[l], j; }(S) : R && typeof S == "function" ? f(Function.call, S) : S, R && ((_.virtual || (_.virtual = {}))[g] = S, d & p.R && I && !I[g] && u(I, g, S))); }; p.F = 1, p.G = 2, p.S = 4, p.P = 8, p.B = 16, p.W = 32, p.U = 64, p.R = 128, i.exports = p; }, function(i, s) { i.exports = function(o) { try { return !!o(); } catch { return !0; } }; }, function(i, s, o) { i.exports = o(2).document && document.documentElement; }, function(i, s, o) { i.exports = !o(4) && !o(24)(function() { return Object.defineProperty(o(16)("div"), "a", { get: function() { return 7; } }).a != 7; }); }, function(i, s, o) { var a = o(28), c = o(23), f = o(57), u = o(5), l = o(8), p = o(10), d = o(45), h = o(18), m = o(52), g = o(1)("iterator"), b = !([].keys && "next" in [].keys()), S = "@@iterator", T = "keys", A = "values", C = function() { return this; }; i.exports = function(R, k, x, _, I, E, P) { d(x, k, _); var j, G, w, v = function(D) { if (!b && D in q) return q[D]; switch (D) { case T: return function() { return new x(this, D); }; case A: return function() { return new x(this, D); }; } return function() { return new x(this, D); }; }, M = k + " Iterator", L = I == A, B = !1, q = R.prototype, W = q[g] || q[S] || I && q[I], Z = W || v(I), Ce = I ? L ? v("entries") : Z : void 0, F = k == "Array" && q.entries || W; if (F && (w = m(F.call(new R())), w !== Object.prototype && (h(w, M, !0), a || l(w, g) || u(w, g, C))), L && W && W.name !== A && (B = !0, Z = function() { return W.call(this); }), a && !P || !b && !B && q[g] || u(q, g, Z), p[k] = Z, p[M] = C, I) if (j = { values: L ? Z : v(A), keys: E ? Z : v(T), entries: Ce }, P) for (G in j) G in q || f(q, G, j[G]); else c(c.P + c.F * (b || B), k, j); return j; }; }, function(i, s) { i.exports = !0; }, function(i, s, o) { var a = o(2), c = "__core-js_shared__", f = a[c] || (a[c] = {}); i.exports = function(u) { return f[u] || (f[u] = {}); }; }, function(i, s, o) { var a, c, f, u = o(7), l = o(41), p = o(25), d = o(16), h = o(2), m = h.process, g = h.setImmediate, b = h.clearImmediate, S = h.MessageChannel, T = 0, A = {}, C = "onreadystatechange", R = function() { var x = +this; if (A.hasOwnProperty(x)) { var _ = A[x]; delete A[x], _(); } }, k = function(x) { R.call(x.data); }; g && b || (g = function(x) { for (var _ = [], I = 1; arguments.length > I; ) _.push(arguments[I++]); return A[++T] = function() { l(typeof x == "function" ? x : Function(x), _); }, a(T), T; }, b = function(x) { delete A[x]; }, o(11)(m) == "process" ? a = function(x) { m.nextTick(u(R, x, 1)); } : S ? (c = new S(), f = c.port2, c.port1.onmessage = k, a = u(f.postMessage, f, 1)) : h.addEventListener && typeof postMessage == "function" && !h.importScripts ? (a = function(x) { h.postMessage(x + "", "*"); }, h.addEventListener("message", k, !1)) : a = C in d("script") ? function(x) { p.appendChild(d("script"))[C] = function() { p.removeChild(this), R.call(x); }; } : function(x) { setTimeout(u(R, x, 1), 0); }), i.exports = { set: g, clear: b }; }, function(i, s, o) { var a = o(20), c = Math.min; i.exports = function(f) { return f > 0 ? c(a(f), 9007199254740991) : 0; }; }, function(i, s, o) { var a = o(9); i.exports = function(c, f) { if (!a(c)) return c; var u, l; if (f && typeof (u = c.toString) == "function" && !a(l = u.call(c)) || typeof (u = c.valueOf) == "function" && !a(l = u.call(c)) || !f && typeof (u = c.toString) == "function" && !a(l = u.call(c))) return l; throw TypeError("Can't convert object to primitive value"); }; }, function(i, s) { var o = 0, a = Math.random(); i.exports = function(c) { return "Symbol(".concat(c === void 0 ? "" : c, ")_", (++o + a).toString(36)); }; }, function(i, s, o) { function a(C) { return C && C.__esModule ? C : { default: C }; } function c() { return process.platform !== "win32" ? "" : process.arch === "ia32" && process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432") ? "mixed" : "native"; } function f(C) { return (0, g.createHash)("sha256").update(C).digest("hex"); } function u(C) { switch (S) { case "darwin": return C.split("IOPlatformUUID")[1].split(` `)[0].replace(/\=|\s+|\"/gi, "").toLowerCase(); case "win32": return C.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi, "").toLowerCase(); case "linux": return C.toString().replace(/\r+|\n+|\s+/gi, "").toLowerCase(); case "freebsd": return C.toString().replace(/\r+|\n+|\s+/gi, "").toLowerCase(); default: throw new Error("Unsupported platform: " + process.platform); } } function l(C) { var R = u((0, m.execSync)(A[S]).toString()); return C ? R : f(R); } function p(C) { return new h.default(function(R, k) { return (0, m.exec)(A[S], {}, function(x, _, I) { if (x) return k(new Error("Error while obtaining machine id: " + x.stack)); var E = u(_.toString()); return R(C ? E : f(E)); }); }); } Object.defineProperty(s, "__esModule", { value: !0 }); var d = o(35), h =