@mattisvensson/strapi-plugin-webatlas 0.1.0
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/LICENSE.md +9 -0
- package/README.md +140 -0
- package/dist/_chunks/_commonjsHelpers-BxmBWJD2.mjs +33 -0
- package/dist/_chunks/_commonjsHelpers-Cq6wktVC.js +32 -0
- package/dist/_chunks/en-B4KWt_jN.js +4 -0
- package/dist/_chunks/en-Byx4XI2L.mjs +4 -0
- package/dist/_chunks/index-B76GOOtR.js +18024 -0
- package/dist/_chunks/index-B8hoZtTR.js +47 -0
- package/dist/_chunks/index-B8i-28Jt.mjs +774 -0
- package/dist/_chunks/index-BFv_JAKx.mjs +6814 -0
- package/dist/_chunks/index-CJUhT0VV.js +773 -0
- package/dist/_chunks/index-D9yK1vNq.js +6814 -0
- package/dist/_chunks/index-DClS2XL-.mjs +47 -0
- package/dist/_chunks/index-DbKqIKw_.mjs +17984 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.mjs +5 -0
- package/dist/admin/src/components/CMEditViewAside/Alias.d.ts +5 -0
- package/dist/admin/src/components/CMEditViewAside/index.d.ts +2 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/components/PluginIcon.d.ts +3 -0
- package/dist/admin/src/components/Tooltip.d.ts +3 -0
- package/dist/admin/src/components/UI/Center.d.ts +5 -0
- package/dist/admin/src/components/URLInfo.d.ts +6 -0
- package/dist/admin/src/components/modals/Delete.d.ts +14 -0
- package/dist/admin/src/components/modals/NavCreate.d.ts +1 -0
- package/dist/admin/src/components/modals/NavEdit.d.ts +7 -0
- package/dist/admin/src/components/modals/NavModal.d.ts +15 -0
- package/dist/admin/src/components/modals/NavOverview.d.ts +8 -0
- package/dist/admin/src/components/modals/externalItem/index.d.ts +9 -0
- package/dist/admin/src/components/modals/index.d.ts +12 -0
- package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +3 -0
- package/dist/admin/src/components/modals/internalItem/internalItemEdit.d.ts +3 -0
- package/dist/admin/src/components/modals/useModalSharedLogic.d.ts +2 -0
- package/dist/admin/src/components/modals/withModalSharedLogic.d.ts +3 -0
- package/dist/admin/src/components/modals/wrapperItem/index.d.ts +9 -0
- package/dist/admin/src/contexts/index.d.ts +13 -0
- package/dist/admin/src/hooks/index.d.ts +6 -0
- package/dist/admin/src/hooks/useAllContentTypes.d.ts +7 -0
- package/dist/admin/src/hooks/useAllEntities.d.ts +7 -0
- package/dist/admin/src/hooks/useApi.d.ts +15 -0
- package/dist/admin/src/hooks/useNavigations.d.ts +5 -0
- package/dist/admin/src/hooks/usePluginConfig.d.ts +9 -0
- package/dist/admin/src/index.d.ts +12 -0
- package/dist/admin/src/pages/Navigation/EmptyNav.d.ts +5 -0
- package/dist/admin/src/pages/Navigation/Header.d.ts +6 -0
- package/dist/admin/src/pages/Navigation/RouteItem.d.ts +15 -0
- package/dist/admin/src/pages/Navigation/SortableRouteItem.d.ts +2 -0
- package/dist/admin/src/pages/Navigation/index.d.ts +2 -0
- package/dist/admin/src/pages/Routes/index.d.ts +2 -0
- package/dist/admin/src/pages/Settings/index.d.ts +2 -0
- package/dist/admin/src/utils/countChildren.d.ts +2 -0
- package/dist/admin/src/utils/debounce.d.ts +1 -0
- package/dist/admin/src/utils/dnd.d.ts +13 -0
- package/dist/admin/src/utils/duplicateCheck.d.ts +8 -0
- package/dist/admin/src/utils/getTranslation.d.ts +2 -0
- package/dist/admin/src/utils/index.d.ts +6 -0
- package/dist/admin/src/utils/typeChecks.d.ts +3 -0
- package/dist/pluginId.d.ts +3 -0
- package/dist/server/index.js +1861 -0
- package/dist/server/index.mjs +1862 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/index.d.ts +5 -0
- package/dist/server/src/content-types/index.d.ts +189 -0
- package/dist/server/src/content-types/navigation/index.d.ts +49 -0
- package/dist/server/src/content-types/navigation/schema.d.ts +47 -0
- package/dist/server/src/content-types/navitem/index.d.ts +50 -0
- package/dist/server/src/content-types/navitem/schema.d.ts +48 -0
- package/dist/server/src/content-types/route/index.d.ts +90 -0
- package/dist/server/src/content-types/route/schema.d.ts +88 -0
- package/dist/server/src/controllers/admin.d.ts +16 -0
- package/dist/server/src/controllers/client.d.ts +8 -0
- package/dist/server/src/controllers/index.d.ts +24 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/index.d.ts +279 -0
- package/dist/server/src/middlewares/index.d.ts +2 -0
- package/dist/server/src/policies/index.d.ts +2 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/admin.d.ts +13 -0
- package/dist/server/src/routes/client.d.ts +12 -0
- package/dist/server/src/routes/index.d.ts +26 -0
- package/dist/server/src/services/admin.d.ts +19 -0
- package/dist/server/src/services/client.d.ts +8 -0
- package/dist/server/src/services/index.d.ts +26 -0
- package/dist/server/src/utils/duplicateCheck.d.ts +1 -0
- package/dist/server/src/utils/pluginHelpers.d.ts +6 -0
- package/dist/utils/buildStructuredNavigation.d.ts +11 -0
- package/dist/utils/cleanRootKeys.d.ts +1 -0
- package/dist/utils/extractRouteAndItems.d.ts +2 -0
- package/dist/utils/getFullPath.d.ts +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/populateDeep.d.ts +4 -0
- package/dist/utils/removeWaFields.d.ts +1 -0
- package/dist/utils/transformToUrl.d.ts +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,1862 @@
|
|
|
1
|
+
function transformToUrl(input) {
|
|
2
|
+
const specialCharMap = {
|
|
3
|
+
"ü": "ue",
|
|
4
|
+
"ä": "ae",
|
|
5
|
+
"ö": "oe"
|
|
6
|
+
};
|
|
7
|
+
if (!input || typeof input !== "string") return "";
|
|
8
|
+
input = input.toLowerCase();
|
|
9
|
+
input = input.replace(/\/+/g, "/");
|
|
10
|
+
input = input.startsWith("/") ? input.slice(1) : input;
|
|
11
|
+
input = input.endsWith("/") ? input.slice(0, -1) : input;
|
|
12
|
+
for (const char in specialCharMap) {
|
|
13
|
+
const regex = new RegExp(char, "g");
|
|
14
|
+
input = input.replace(regex, specialCharMap[char]);
|
|
15
|
+
}
|
|
16
|
+
input = input.trim();
|
|
17
|
+
input = input.replace(/\s+/g, "-");
|
|
18
|
+
input = input.replace(/[^A-Za-z0-9$\-_.+!*'()/]/g, "");
|
|
19
|
+
input = input.replace(/-+/g, "-");
|
|
20
|
+
return input;
|
|
21
|
+
}
|
|
22
|
+
const version = "0.1.0";
|
|
23
|
+
const keywords = [];
|
|
24
|
+
const type = "commonjs";
|
|
25
|
+
const exports = {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
"./strapi-admin": {
|
|
28
|
+
types: "./dist/admin/src/index.d.ts",
|
|
29
|
+
source: "./admin/src/index.tsx",
|
|
30
|
+
"import": "./dist/admin/index.mjs",
|
|
31
|
+
require: "./dist/admin/index.js",
|
|
32
|
+
"default": "./dist/admin/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./strapi-server": {
|
|
35
|
+
types: "./dist/server/src/index.d.ts",
|
|
36
|
+
source: "./server/src/index.ts",
|
|
37
|
+
"import": "./dist/server/index.mjs",
|
|
38
|
+
require: "./dist/server/index.js",
|
|
39
|
+
"default": "./dist/server/index.js"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const files = [
|
|
43
|
+
"dist"
|
|
44
|
+
];
|
|
45
|
+
const scripts = {
|
|
46
|
+
build: "strapi-plugin build && yalc push --publish",
|
|
47
|
+
watch: "strapi-plugin watch",
|
|
48
|
+
"watch:link": "strapi-plugin watch:link",
|
|
49
|
+
verify: "strapi-plugin verify",
|
|
50
|
+
"test:ts:front": "tsc -p admin/tsconfig.json",
|
|
51
|
+
"test:ts:back": "tsc -p server/tsconfig.json",
|
|
52
|
+
"test:jest": "ENV_PATH=./playground/.env jest --verbose --runInBand --forceExit",
|
|
53
|
+
"test:cypress": "cypress run",
|
|
54
|
+
"test:cypress:open": "cypress open",
|
|
55
|
+
"playground:install": "yarn playground:yalc-add-link && cd playground && yarn install",
|
|
56
|
+
"playground:yalc-add": "cd playground && yalc add strapi-plugin-boilerplate",
|
|
57
|
+
"playground:yalc-add-link": "cd playground && yalc add --link strapi-plugin-boilerplate",
|
|
58
|
+
"playground:build": "cd playground && yarn build",
|
|
59
|
+
"playground:develop": "cd playground && yarn develop",
|
|
60
|
+
"playground:start": "cd playground && yarn start"
|
|
61
|
+
};
|
|
62
|
+
const dependencies = {
|
|
63
|
+
"@dnd-kit/core": "^6.3.1",
|
|
64
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
65
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
66
|
+
"@strapi/design-system": "^2.0.0-rc.14",
|
|
67
|
+
"@strapi/icons": "^2.0.0-rc.14",
|
|
68
|
+
"react-intl": "^7.1.0"
|
|
69
|
+
};
|
|
70
|
+
const devDependencies = {
|
|
71
|
+
"@strapi/sdk-plugin": "^5.0.0",
|
|
72
|
+
"@strapi/strapi": "^5.0.0",
|
|
73
|
+
"@strapi/typescript-utils": "^5.0.0",
|
|
74
|
+
"@types/react": "^19.0.0",
|
|
75
|
+
"@types/react-dom": "^19.0.0",
|
|
76
|
+
cypress: "^13.9.0",
|
|
77
|
+
"cypress-terminal-report": "^6.0.2",
|
|
78
|
+
jest: "^29.7.0",
|
|
79
|
+
prettier: "^3.4.2",
|
|
80
|
+
react: "^19.0.0",
|
|
81
|
+
"react-router-dom": "^6.0.0",
|
|
82
|
+
supertest: "^7.0.0",
|
|
83
|
+
typescript: "^5.7.2"
|
|
84
|
+
};
|
|
85
|
+
const peerDependencies = {
|
|
86
|
+
"@strapi/strapi": "^5.0.0",
|
|
87
|
+
react: "^17.0.0 || ^18.0.0",
|
|
88
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
89
|
+
"react-router-dom": "^6.0.0",
|
|
90
|
+
"styled-components": "^6.0.0"
|
|
91
|
+
};
|
|
92
|
+
const description = "A strapi plugin to manage URL routes and navigations.";
|
|
93
|
+
const strapi$1 = {
|
|
94
|
+
name: "webatlas",
|
|
95
|
+
displayName: "Webatlas",
|
|
96
|
+
description: "A strapi plugin to manage URL routes and navigations.",
|
|
97
|
+
kind: "plugin"
|
|
98
|
+
};
|
|
99
|
+
const name = "@mattisvensson/strapi-plugin-webatlas";
|
|
100
|
+
const license = "MIT";
|
|
101
|
+
const repository = {
|
|
102
|
+
type: "git",
|
|
103
|
+
url: "git+ssh://git@github.com:mattisvensson/strapi-plugin-webatlas.git"
|
|
104
|
+
};
|
|
105
|
+
const bugs = {
|
|
106
|
+
url: "https://github.com/mattisvensson/strapi-plugin-webatlas/issues"
|
|
107
|
+
};
|
|
108
|
+
const homepage = "https://github.com/mattisvensson/strapi-plugin-webatlas#readme";
|
|
109
|
+
const author = {
|
|
110
|
+
name: "Matti Svensson",
|
|
111
|
+
email: "mattisvensson@web.de",
|
|
112
|
+
url: "https://mattisvensson.com"
|
|
113
|
+
};
|
|
114
|
+
const maintainers = [
|
|
115
|
+
{
|
|
116
|
+
name: "Matti Svensson",
|
|
117
|
+
email: "mattisvensson@web.de",
|
|
118
|
+
url: "https://mattisvensson.com"
|
|
119
|
+
}
|
|
120
|
+
];
|
|
121
|
+
const packageManager = "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e";
|
|
122
|
+
const pluginPkg = {
|
|
123
|
+
version,
|
|
124
|
+
keywords,
|
|
125
|
+
type,
|
|
126
|
+
exports,
|
|
127
|
+
files,
|
|
128
|
+
scripts,
|
|
129
|
+
dependencies,
|
|
130
|
+
devDependencies,
|
|
131
|
+
peerDependencies,
|
|
132
|
+
description,
|
|
133
|
+
strapi: strapi$1,
|
|
134
|
+
name,
|
|
135
|
+
license,
|
|
136
|
+
repository,
|
|
137
|
+
bugs,
|
|
138
|
+
homepage,
|
|
139
|
+
author,
|
|
140
|
+
maintainers,
|
|
141
|
+
packageManager
|
|
142
|
+
};
|
|
143
|
+
const PLUGIN_NAME = pluginPkg.strapi.displayName;
|
|
144
|
+
const waNavigation = `plugin::${PLUGIN_NAME}.navigation`;
|
|
145
|
+
const waNavItem = `plugin::${PLUGIN_NAME}.navitem`;
|
|
146
|
+
const waRoute = `plugin::${PLUGIN_NAME}.route`;
|
|
147
|
+
function getAdminService() {
|
|
148
|
+
return strapi.plugin(PLUGIN_NAME)?.service("admin");
|
|
149
|
+
}
|
|
150
|
+
function getClientService() {
|
|
151
|
+
return strapi.plugin(PLUGIN_NAME)?.service("client");
|
|
152
|
+
}
|
|
153
|
+
async function checkPathExists(path, targetRoutePath) {
|
|
154
|
+
const entities = await strapi.documents(waRoute).findMany({
|
|
155
|
+
filters: {
|
|
156
|
+
$or: [
|
|
157
|
+
{
|
|
158
|
+
fullPath: path
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
slug: path
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
uidPath: path
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
if (targetRoutePath && entities && entities[0]?.fullPath === targetRoutePath)
|
|
170
|
+
return false;
|
|
171
|
+
return entities?.length > 0;
|
|
172
|
+
}
|
|
173
|
+
async function duplicateCheck(initialPath, targetRouteDocumentId) {
|
|
174
|
+
try {
|
|
175
|
+
let uniquePath = initialPath;
|
|
176
|
+
let targetRoutePath = null;
|
|
177
|
+
let counter = 1;
|
|
178
|
+
if (targetRouteDocumentId) {
|
|
179
|
+
const route2 = await strapi.documents(waRoute).findOne({
|
|
180
|
+
documentId: targetRouteDocumentId
|
|
181
|
+
});
|
|
182
|
+
if (route2) targetRoutePath = route2.fullPath;
|
|
183
|
+
}
|
|
184
|
+
let exists = await checkPathExists(uniquePath, targetRoutePath);
|
|
185
|
+
while (exists) {
|
|
186
|
+
uniquePath = `${initialPath}-${counter}`;
|
|
187
|
+
exists = await checkPathExists(uniquePath);
|
|
188
|
+
counter++;
|
|
189
|
+
}
|
|
190
|
+
return uniquePath;
|
|
191
|
+
} catch (e) {
|
|
192
|
+
console.log(e);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const bootstrap = async ({ strapi: strapi2 }) => {
|
|
196
|
+
if (!strapi2.store) {
|
|
197
|
+
throw new Error("strapi.store is undefined");
|
|
198
|
+
}
|
|
199
|
+
const pluginStore = strapi2.store({ type: "plugin", name: "webatlas" });
|
|
200
|
+
const config2 = await pluginStore.get({
|
|
201
|
+
key: "config"
|
|
202
|
+
});
|
|
203
|
+
if (!config2?.selectedContentTypes) return;
|
|
204
|
+
strapi2.db?.lifecycles.subscribe({
|
|
205
|
+
models: [waNavItem],
|
|
206
|
+
async beforeDelete(event) {
|
|
207
|
+
const id = event.params.where["id"];
|
|
208
|
+
if (!id) return;
|
|
209
|
+
try {
|
|
210
|
+
const navItem = await strapi2.db?.query(waNavItem).findOne({
|
|
211
|
+
where: {
|
|
212
|
+
id
|
|
213
|
+
},
|
|
214
|
+
populate: ["route"]
|
|
215
|
+
});
|
|
216
|
+
event.state = navItem.route.id && !navItem.route.internal ? { id: navItem.route.id } : null;
|
|
217
|
+
} catch (err) {
|
|
218
|
+
console.log(err);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
async afterDelete(event) {
|
|
222
|
+
const { id } = event.state;
|
|
223
|
+
if (!id) return;
|
|
224
|
+
try {
|
|
225
|
+
await strapi2.db?.query(waRoute).delete({
|
|
226
|
+
where: {
|
|
227
|
+
id
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
} catch (err) {
|
|
231
|
+
console.log(err);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
strapi2.db?.lifecycles.subscribe({
|
|
236
|
+
models: config2.selectedContentTypes.map((type2) => type2.uid),
|
|
237
|
+
async beforeCreate() {
|
|
238
|
+
const validContentTypes = config2.selectedContentTypes.filter((type2) => strapi2.contentTypes[type2.uid]);
|
|
239
|
+
await pluginStore.set({ key: "config", value: { selectedContentTypes: validContentTypes } });
|
|
240
|
+
},
|
|
241
|
+
async afterCreate(event) {
|
|
242
|
+
const ctSettings = config2.selectedContentTypes.find((type2) => type2.uid === event.model.uid);
|
|
243
|
+
const {
|
|
244
|
+
webatlas_path,
|
|
245
|
+
webatlas_override
|
|
246
|
+
} = event.params.data;
|
|
247
|
+
if (!webatlas_path) return;
|
|
248
|
+
const title = ctSettings?.default ? event.params.data[ctSettings.default] : "";
|
|
249
|
+
const path = await duplicateCheck(transformToUrl(webatlas_path));
|
|
250
|
+
await strapi2.documents(waRoute).create({
|
|
251
|
+
data: {
|
|
252
|
+
relatedContentType: event.model.uid,
|
|
253
|
+
relatedId: event.result.id,
|
|
254
|
+
relatedDocumentId: event.result.documentId,
|
|
255
|
+
slug: path,
|
|
256
|
+
fullPath: path,
|
|
257
|
+
uidPath: `${event.model.singularName}/${event.result.id}`,
|
|
258
|
+
documentIdPath: event.result.documentId,
|
|
259
|
+
isOverride: webatlas_override || false,
|
|
260
|
+
title
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
async afterUpdate(event) {
|
|
265
|
+
const ctSettings = config2.selectedContentTypes.find((type2) => type2.uid === event.model.uid);
|
|
266
|
+
const {
|
|
267
|
+
webatlas_path,
|
|
268
|
+
webatlas_override,
|
|
269
|
+
documentId
|
|
270
|
+
} = event.params.data;
|
|
271
|
+
if (!webatlas_path) return;
|
|
272
|
+
const relatedRoute = await strapi2.db?.query(waRoute).findOne({
|
|
273
|
+
where: {
|
|
274
|
+
relatedDocumentId: documentId
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
const title = ctSettings?.default ? event.params.data[ctSettings.default] : "";
|
|
278
|
+
const path = await duplicateCheck(transformToUrl(webatlas_path));
|
|
279
|
+
const routeData = {
|
|
280
|
+
title,
|
|
281
|
+
fullPath: path,
|
|
282
|
+
slug: path,
|
|
283
|
+
isOverride: webatlas_override || false
|
|
284
|
+
};
|
|
285
|
+
if (!relatedRoute) {
|
|
286
|
+
await strapi2.documents(waRoute).create({
|
|
287
|
+
data: {
|
|
288
|
+
relatedContentType: event.model.uid,
|
|
289
|
+
relatedId: event.result.id,
|
|
290
|
+
relatedDocumentId: event.result.documentId,
|
|
291
|
+
uidPath: `${event.model.singularName}/${event.result.id}`,
|
|
292
|
+
documentIdPath: event.result.documentId,
|
|
293
|
+
...routeData
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
} else {
|
|
297
|
+
await strapi2.documents(waRoute).update({
|
|
298
|
+
documentId: relatedRoute.documentId,
|
|
299
|
+
data: {
|
|
300
|
+
...routeData
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
async afterDelete(event) {
|
|
306
|
+
try {
|
|
307
|
+
await findAndDeleteNavItem(event.result.id, event.model.uid);
|
|
308
|
+
} catch (err) {
|
|
309
|
+
console.log(err);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
async afterDeleteMany(event) {
|
|
313
|
+
const deletedArr = event.params.where["$and"];
|
|
314
|
+
deletedArr.map((item) => {
|
|
315
|
+
const ids = item.id["$in"];
|
|
316
|
+
ids.map(async (id) => {
|
|
317
|
+
await findAndDeleteNavItem(id, event.model.uid);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
async function findAndDeleteNavItem(relatedId, relatedContentType) {
|
|
324
|
+
if (!relatedId || !relatedContentType) return;
|
|
325
|
+
try {
|
|
326
|
+
const route2 = await strapi.db?.query(waRoute).findOne({
|
|
327
|
+
where: {
|
|
328
|
+
relatedId,
|
|
329
|
+
relatedContentType
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
if (!route2?.documentId) return;
|
|
333
|
+
const navItem = await strapi.db?.query(waNavItem).findOne({
|
|
334
|
+
where: {
|
|
335
|
+
route: {
|
|
336
|
+
documentId: route2.documentId
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
await strapi.documents(waRoute).delete({ documentId: route2.documentId });
|
|
341
|
+
if (navItem?.documentId) await strapi.documents(waNavItem).delete({ documentId: navItem.documentId });
|
|
342
|
+
} catch (err) {
|
|
343
|
+
console.log(err);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const destroy = ({ strapi: strapi2 }) => {
|
|
347
|
+
};
|
|
348
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
349
|
+
function getDefaultExportFromCjs(x) {
|
|
350
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
351
|
+
}
|
|
352
|
+
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
353
|
+
var _freeGlobal = freeGlobal$1;
|
|
354
|
+
var freeGlobal = _freeGlobal;
|
|
355
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
356
|
+
var root$3 = freeGlobal || freeSelf || Function("return this")();
|
|
357
|
+
var _root = root$3;
|
|
358
|
+
var root$2 = _root;
|
|
359
|
+
var Symbol$4 = root$2.Symbol;
|
|
360
|
+
var _Symbol = Symbol$4;
|
|
361
|
+
var Symbol$3 = _Symbol;
|
|
362
|
+
var objectProto$5 = Object.prototype;
|
|
363
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
364
|
+
var nativeObjectToString$1 = objectProto$5.toString;
|
|
365
|
+
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
366
|
+
function getRawTag$1(value) {
|
|
367
|
+
var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
368
|
+
try {
|
|
369
|
+
value[symToStringTag$1] = void 0;
|
|
370
|
+
var unmasked = true;
|
|
371
|
+
} catch (e) {
|
|
372
|
+
}
|
|
373
|
+
var result = nativeObjectToString$1.call(value);
|
|
374
|
+
if (unmasked) {
|
|
375
|
+
if (isOwn) {
|
|
376
|
+
value[symToStringTag$1] = tag;
|
|
377
|
+
} else {
|
|
378
|
+
delete value[symToStringTag$1];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
var _getRawTag = getRawTag$1;
|
|
384
|
+
var objectProto$4 = Object.prototype;
|
|
385
|
+
var nativeObjectToString = objectProto$4.toString;
|
|
386
|
+
function objectToString$1(value) {
|
|
387
|
+
return nativeObjectToString.call(value);
|
|
388
|
+
}
|
|
389
|
+
var _objectToString = objectToString$1;
|
|
390
|
+
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
391
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
392
|
+
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
393
|
+
function baseGetTag$2(value) {
|
|
394
|
+
if (value == null) {
|
|
395
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
396
|
+
}
|
|
397
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
398
|
+
}
|
|
399
|
+
var _baseGetTag = baseGetTag$2;
|
|
400
|
+
function isObject$3(value) {
|
|
401
|
+
var type2 = typeof value;
|
|
402
|
+
return value != null && (type2 == "object" || type2 == "function");
|
|
403
|
+
}
|
|
404
|
+
var isObject_1 = isObject$3;
|
|
405
|
+
var baseGetTag$1 = _baseGetTag, isObject$2 = isObject_1;
|
|
406
|
+
var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
407
|
+
function isFunction$1(value) {
|
|
408
|
+
if (!isObject$2(value)) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
var tag = baseGetTag$1(value);
|
|
412
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
413
|
+
}
|
|
414
|
+
var isFunction_1 = isFunction$1;
|
|
415
|
+
var root$1 = _root;
|
|
416
|
+
var coreJsData$1 = root$1["__core-js_shared__"];
|
|
417
|
+
var _coreJsData = coreJsData$1;
|
|
418
|
+
var coreJsData = _coreJsData;
|
|
419
|
+
var maskSrcKey = function() {
|
|
420
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
|
|
421
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
422
|
+
}();
|
|
423
|
+
function isMasked$1(func) {
|
|
424
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
425
|
+
}
|
|
426
|
+
var _isMasked = isMasked$1;
|
|
427
|
+
var funcProto$1 = Function.prototype;
|
|
428
|
+
var funcToString$1 = funcProto$1.toString;
|
|
429
|
+
function toSource$1(func) {
|
|
430
|
+
if (func != null) {
|
|
431
|
+
try {
|
|
432
|
+
return funcToString$1.call(func);
|
|
433
|
+
} catch (e) {
|
|
434
|
+
}
|
|
435
|
+
try {
|
|
436
|
+
return func + "";
|
|
437
|
+
} catch (e) {
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return "";
|
|
441
|
+
}
|
|
442
|
+
var _toSource = toSource$1;
|
|
443
|
+
var isFunction = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource = _toSource;
|
|
444
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
445
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
446
|
+
var funcProto = Function.prototype, objectProto$3 = Object.prototype;
|
|
447
|
+
var funcToString = funcProto.toString;
|
|
448
|
+
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
|
449
|
+
var reIsNative = RegExp(
|
|
450
|
+
"^" + funcToString.call(hasOwnProperty$3).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
451
|
+
);
|
|
452
|
+
function baseIsNative$1(value) {
|
|
453
|
+
if (!isObject$1(value) || isMasked(value)) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
457
|
+
return pattern.test(toSource(value));
|
|
458
|
+
}
|
|
459
|
+
var _baseIsNative = baseIsNative$1;
|
|
460
|
+
function getValue$1(object, key) {
|
|
461
|
+
return object == null ? void 0 : object[key];
|
|
462
|
+
}
|
|
463
|
+
var _getValue = getValue$1;
|
|
464
|
+
var baseIsNative = _baseIsNative, getValue = _getValue;
|
|
465
|
+
function getNative$3(object, key) {
|
|
466
|
+
var value = getValue(object, key);
|
|
467
|
+
return baseIsNative(value) ? value : void 0;
|
|
468
|
+
}
|
|
469
|
+
var _getNative = getNative$3;
|
|
470
|
+
var getNative$2 = _getNative;
|
|
471
|
+
var defineProperty$1 = function() {
|
|
472
|
+
try {
|
|
473
|
+
var func = getNative$2(Object, "defineProperty");
|
|
474
|
+
func({}, "", {});
|
|
475
|
+
return func;
|
|
476
|
+
} catch (e) {
|
|
477
|
+
}
|
|
478
|
+
}();
|
|
479
|
+
var _defineProperty = defineProperty$1;
|
|
480
|
+
var defineProperty = _defineProperty;
|
|
481
|
+
function baseAssignValue$1(object, key, value) {
|
|
482
|
+
if (key == "__proto__" && defineProperty) {
|
|
483
|
+
defineProperty(object, key, {
|
|
484
|
+
"configurable": true,
|
|
485
|
+
"enumerable": true,
|
|
486
|
+
"value": value,
|
|
487
|
+
"writable": true
|
|
488
|
+
});
|
|
489
|
+
} else {
|
|
490
|
+
object[key] = value;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
var _baseAssignValue = baseAssignValue$1;
|
|
494
|
+
function eq$2(value, other) {
|
|
495
|
+
return value === other || value !== value && other !== other;
|
|
496
|
+
}
|
|
497
|
+
var eq_1 = eq$2;
|
|
498
|
+
var baseAssignValue = _baseAssignValue, eq$1 = eq_1;
|
|
499
|
+
var objectProto$2 = Object.prototype;
|
|
500
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
501
|
+
function assignValue$1(object, key, value) {
|
|
502
|
+
var objValue = object[key];
|
|
503
|
+
if (!(hasOwnProperty$2.call(object, key) && eq$1(objValue, value)) || value === void 0 && !(key in object)) {
|
|
504
|
+
baseAssignValue(object, key, value);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
var _assignValue = assignValue$1;
|
|
508
|
+
var isArray$3 = Array.isArray;
|
|
509
|
+
var isArray_1 = isArray$3;
|
|
510
|
+
function isObjectLike$1(value) {
|
|
511
|
+
return value != null && typeof value == "object";
|
|
512
|
+
}
|
|
513
|
+
var isObjectLike_1 = isObjectLike$1;
|
|
514
|
+
var baseGetTag = _baseGetTag, isObjectLike = isObjectLike_1;
|
|
515
|
+
var symbolTag = "[object Symbol]";
|
|
516
|
+
function isSymbol$3(value) {
|
|
517
|
+
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
|
518
|
+
}
|
|
519
|
+
var isSymbol_1 = isSymbol$3;
|
|
520
|
+
var isArray$2 = isArray_1, isSymbol$2 = isSymbol_1;
|
|
521
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
|
|
522
|
+
function isKey$1(value, object) {
|
|
523
|
+
if (isArray$2(value)) {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
var type2 = typeof value;
|
|
527
|
+
if (type2 == "number" || type2 == "symbol" || type2 == "boolean" || value == null || isSymbol$2(value)) {
|
|
528
|
+
return true;
|
|
529
|
+
}
|
|
530
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
|
531
|
+
}
|
|
532
|
+
var _isKey = isKey$1;
|
|
533
|
+
var getNative$1 = _getNative;
|
|
534
|
+
var nativeCreate$4 = getNative$1(Object, "create");
|
|
535
|
+
var _nativeCreate = nativeCreate$4;
|
|
536
|
+
var nativeCreate$3 = _nativeCreate;
|
|
537
|
+
function hashClear$1() {
|
|
538
|
+
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
539
|
+
this.size = 0;
|
|
540
|
+
}
|
|
541
|
+
var _hashClear = hashClear$1;
|
|
542
|
+
function hashDelete$1(key) {
|
|
543
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
544
|
+
this.size -= result ? 1 : 0;
|
|
545
|
+
return result;
|
|
546
|
+
}
|
|
547
|
+
var _hashDelete = hashDelete$1;
|
|
548
|
+
var nativeCreate$2 = _nativeCreate;
|
|
549
|
+
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
|
|
550
|
+
var objectProto$1 = Object.prototype;
|
|
551
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
552
|
+
function hashGet$1(key) {
|
|
553
|
+
var data = this.__data__;
|
|
554
|
+
if (nativeCreate$2) {
|
|
555
|
+
var result = data[key];
|
|
556
|
+
return result === HASH_UNDEFINED$1 ? void 0 : result;
|
|
557
|
+
}
|
|
558
|
+
return hasOwnProperty$1.call(data, key) ? data[key] : void 0;
|
|
559
|
+
}
|
|
560
|
+
var _hashGet = hashGet$1;
|
|
561
|
+
var nativeCreate$1 = _nativeCreate;
|
|
562
|
+
var objectProto = Object.prototype;
|
|
563
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
564
|
+
function hashHas$1(key) {
|
|
565
|
+
var data = this.__data__;
|
|
566
|
+
return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty.call(data, key);
|
|
567
|
+
}
|
|
568
|
+
var _hashHas = hashHas$1;
|
|
569
|
+
var nativeCreate = _nativeCreate;
|
|
570
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
571
|
+
function hashSet$1(key, value) {
|
|
572
|
+
var data = this.__data__;
|
|
573
|
+
this.size += this.has(key) ? 0 : 1;
|
|
574
|
+
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
575
|
+
return this;
|
|
576
|
+
}
|
|
577
|
+
var _hashSet = hashSet$1;
|
|
578
|
+
var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
|
|
579
|
+
function Hash$1(entries) {
|
|
580
|
+
var index2 = -1, length = entries == null ? 0 : entries.length;
|
|
581
|
+
this.clear();
|
|
582
|
+
while (++index2 < length) {
|
|
583
|
+
var entry = entries[index2];
|
|
584
|
+
this.set(entry[0], entry[1]);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
Hash$1.prototype.clear = hashClear;
|
|
588
|
+
Hash$1.prototype["delete"] = hashDelete;
|
|
589
|
+
Hash$1.prototype.get = hashGet;
|
|
590
|
+
Hash$1.prototype.has = hashHas;
|
|
591
|
+
Hash$1.prototype.set = hashSet;
|
|
592
|
+
var _Hash = Hash$1;
|
|
593
|
+
function listCacheClear$1() {
|
|
594
|
+
this.__data__ = [];
|
|
595
|
+
this.size = 0;
|
|
596
|
+
}
|
|
597
|
+
var _listCacheClear = listCacheClear$1;
|
|
598
|
+
var eq = eq_1;
|
|
599
|
+
function assocIndexOf$4(array, key) {
|
|
600
|
+
var length = array.length;
|
|
601
|
+
while (length--) {
|
|
602
|
+
if (eq(array[length][0], key)) {
|
|
603
|
+
return length;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return -1;
|
|
607
|
+
}
|
|
608
|
+
var _assocIndexOf = assocIndexOf$4;
|
|
609
|
+
var assocIndexOf$3 = _assocIndexOf;
|
|
610
|
+
var arrayProto = Array.prototype;
|
|
611
|
+
var splice = arrayProto.splice;
|
|
612
|
+
function listCacheDelete$1(key) {
|
|
613
|
+
var data = this.__data__, index2 = assocIndexOf$3(data, key);
|
|
614
|
+
if (index2 < 0) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
var lastIndex = data.length - 1;
|
|
618
|
+
if (index2 == lastIndex) {
|
|
619
|
+
data.pop();
|
|
620
|
+
} else {
|
|
621
|
+
splice.call(data, index2, 1);
|
|
622
|
+
}
|
|
623
|
+
--this.size;
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
var _listCacheDelete = listCacheDelete$1;
|
|
627
|
+
var assocIndexOf$2 = _assocIndexOf;
|
|
628
|
+
function listCacheGet$1(key) {
|
|
629
|
+
var data = this.__data__, index2 = assocIndexOf$2(data, key);
|
|
630
|
+
return index2 < 0 ? void 0 : data[index2][1];
|
|
631
|
+
}
|
|
632
|
+
var _listCacheGet = listCacheGet$1;
|
|
633
|
+
var assocIndexOf$1 = _assocIndexOf;
|
|
634
|
+
function listCacheHas$1(key) {
|
|
635
|
+
return assocIndexOf$1(this.__data__, key) > -1;
|
|
636
|
+
}
|
|
637
|
+
var _listCacheHas = listCacheHas$1;
|
|
638
|
+
var assocIndexOf = _assocIndexOf;
|
|
639
|
+
function listCacheSet$1(key, value) {
|
|
640
|
+
var data = this.__data__, index2 = assocIndexOf(data, key);
|
|
641
|
+
if (index2 < 0) {
|
|
642
|
+
++this.size;
|
|
643
|
+
data.push([key, value]);
|
|
644
|
+
} else {
|
|
645
|
+
data[index2][1] = value;
|
|
646
|
+
}
|
|
647
|
+
return this;
|
|
648
|
+
}
|
|
649
|
+
var _listCacheSet = listCacheSet$1;
|
|
650
|
+
var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
|
|
651
|
+
function ListCache$1(entries) {
|
|
652
|
+
var index2 = -1, length = entries == null ? 0 : entries.length;
|
|
653
|
+
this.clear();
|
|
654
|
+
while (++index2 < length) {
|
|
655
|
+
var entry = entries[index2];
|
|
656
|
+
this.set(entry[0], entry[1]);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
ListCache$1.prototype.clear = listCacheClear;
|
|
660
|
+
ListCache$1.prototype["delete"] = listCacheDelete;
|
|
661
|
+
ListCache$1.prototype.get = listCacheGet;
|
|
662
|
+
ListCache$1.prototype.has = listCacheHas;
|
|
663
|
+
ListCache$1.prototype.set = listCacheSet;
|
|
664
|
+
var _ListCache = ListCache$1;
|
|
665
|
+
var getNative = _getNative, root = _root;
|
|
666
|
+
var Map$2 = getNative(root, "Map");
|
|
667
|
+
var _Map = Map$2;
|
|
668
|
+
var Hash = _Hash, ListCache = _ListCache, Map$1 = _Map;
|
|
669
|
+
function mapCacheClear$1() {
|
|
670
|
+
this.size = 0;
|
|
671
|
+
this.__data__ = {
|
|
672
|
+
"hash": new Hash(),
|
|
673
|
+
"map": new (Map$1 || ListCache)(),
|
|
674
|
+
"string": new Hash()
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
var _mapCacheClear = mapCacheClear$1;
|
|
678
|
+
function isKeyable$1(value) {
|
|
679
|
+
var type2 = typeof value;
|
|
680
|
+
return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
|
|
681
|
+
}
|
|
682
|
+
var _isKeyable = isKeyable$1;
|
|
683
|
+
var isKeyable = _isKeyable;
|
|
684
|
+
function getMapData$4(map, key) {
|
|
685
|
+
var data = map.__data__;
|
|
686
|
+
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
687
|
+
}
|
|
688
|
+
var _getMapData = getMapData$4;
|
|
689
|
+
var getMapData$3 = _getMapData;
|
|
690
|
+
function mapCacheDelete$1(key) {
|
|
691
|
+
var result = getMapData$3(this, key)["delete"](key);
|
|
692
|
+
this.size -= result ? 1 : 0;
|
|
693
|
+
return result;
|
|
694
|
+
}
|
|
695
|
+
var _mapCacheDelete = mapCacheDelete$1;
|
|
696
|
+
var getMapData$2 = _getMapData;
|
|
697
|
+
function mapCacheGet$1(key) {
|
|
698
|
+
return getMapData$2(this, key).get(key);
|
|
699
|
+
}
|
|
700
|
+
var _mapCacheGet = mapCacheGet$1;
|
|
701
|
+
var getMapData$1 = _getMapData;
|
|
702
|
+
function mapCacheHas$1(key) {
|
|
703
|
+
return getMapData$1(this, key).has(key);
|
|
704
|
+
}
|
|
705
|
+
var _mapCacheHas = mapCacheHas$1;
|
|
706
|
+
var getMapData = _getMapData;
|
|
707
|
+
function mapCacheSet$1(key, value) {
|
|
708
|
+
var data = getMapData(this, key), size = data.size;
|
|
709
|
+
data.set(key, value);
|
|
710
|
+
this.size += data.size == size ? 0 : 1;
|
|
711
|
+
return this;
|
|
712
|
+
}
|
|
713
|
+
var _mapCacheSet = mapCacheSet$1;
|
|
714
|
+
var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
|
|
715
|
+
function MapCache$1(entries) {
|
|
716
|
+
var index2 = -1, length = entries == null ? 0 : entries.length;
|
|
717
|
+
this.clear();
|
|
718
|
+
while (++index2 < length) {
|
|
719
|
+
var entry = entries[index2];
|
|
720
|
+
this.set(entry[0], entry[1]);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
MapCache$1.prototype.clear = mapCacheClear;
|
|
724
|
+
MapCache$1.prototype["delete"] = mapCacheDelete;
|
|
725
|
+
MapCache$1.prototype.get = mapCacheGet;
|
|
726
|
+
MapCache$1.prototype.has = mapCacheHas;
|
|
727
|
+
MapCache$1.prototype.set = mapCacheSet;
|
|
728
|
+
var _MapCache = MapCache$1;
|
|
729
|
+
var MapCache = _MapCache;
|
|
730
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
731
|
+
function memoize$1(func, resolver) {
|
|
732
|
+
if (typeof func != "function" || resolver != null && typeof resolver != "function") {
|
|
733
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
734
|
+
}
|
|
735
|
+
var memoized = function() {
|
|
736
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
737
|
+
if (cache.has(key)) {
|
|
738
|
+
return cache.get(key);
|
|
739
|
+
}
|
|
740
|
+
var result = func.apply(this, args);
|
|
741
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
742
|
+
return result;
|
|
743
|
+
};
|
|
744
|
+
memoized.cache = new (memoize$1.Cache || MapCache)();
|
|
745
|
+
return memoized;
|
|
746
|
+
}
|
|
747
|
+
memoize$1.Cache = MapCache;
|
|
748
|
+
var memoize_1 = memoize$1;
|
|
749
|
+
var memoize = memoize_1;
|
|
750
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
751
|
+
function memoizeCapped$1(func) {
|
|
752
|
+
var result = memoize(func, function(key) {
|
|
753
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
754
|
+
cache.clear();
|
|
755
|
+
}
|
|
756
|
+
return key;
|
|
757
|
+
});
|
|
758
|
+
var cache = result.cache;
|
|
759
|
+
return result;
|
|
760
|
+
}
|
|
761
|
+
var _memoizeCapped = memoizeCapped$1;
|
|
762
|
+
var memoizeCapped = _memoizeCapped;
|
|
763
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
764
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
765
|
+
var stringToPath$1 = memoizeCapped(function(string) {
|
|
766
|
+
var result = [];
|
|
767
|
+
if (string.charCodeAt(0) === 46) {
|
|
768
|
+
result.push("");
|
|
769
|
+
}
|
|
770
|
+
string.replace(rePropName, function(match, number, quote, subString) {
|
|
771
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
|
|
772
|
+
});
|
|
773
|
+
return result;
|
|
774
|
+
});
|
|
775
|
+
var _stringToPath = stringToPath$1;
|
|
776
|
+
function arrayMap$1(array, iteratee) {
|
|
777
|
+
var index2 = -1, length = array == null ? 0 : array.length, result = Array(length);
|
|
778
|
+
while (++index2 < length) {
|
|
779
|
+
result[index2] = iteratee(array[index2], index2, array);
|
|
780
|
+
}
|
|
781
|
+
return result;
|
|
782
|
+
}
|
|
783
|
+
var _arrayMap = arrayMap$1;
|
|
784
|
+
var Symbol$1 = _Symbol, arrayMap = _arrayMap, isArray$1 = isArray_1, isSymbol$1 = isSymbol_1;
|
|
785
|
+
var INFINITY$1 = 1 / 0;
|
|
786
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
787
|
+
function baseToString$1(value) {
|
|
788
|
+
if (typeof value == "string") {
|
|
789
|
+
return value;
|
|
790
|
+
}
|
|
791
|
+
if (isArray$1(value)) {
|
|
792
|
+
return arrayMap(value, baseToString$1) + "";
|
|
793
|
+
}
|
|
794
|
+
if (isSymbol$1(value)) {
|
|
795
|
+
return symbolToString ? symbolToString.call(value) : "";
|
|
796
|
+
}
|
|
797
|
+
var result = value + "";
|
|
798
|
+
return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
|
|
799
|
+
}
|
|
800
|
+
var _baseToString = baseToString$1;
|
|
801
|
+
var baseToString = _baseToString;
|
|
802
|
+
function toString$1(value) {
|
|
803
|
+
return value == null ? "" : baseToString(value);
|
|
804
|
+
}
|
|
805
|
+
var toString_1 = toString$1;
|
|
806
|
+
var isArray = isArray_1, isKey = _isKey, stringToPath = _stringToPath, toString = toString_1;
|
|
807
|
+
function castPath$1(value, object) {
|
|
808
|
+
if (isArray(value)) {
|
|
809
|
+
return value;
|
|
810
|
+
}
|
|
811
|
+
return isKey(value, object) ? [value] : stringToPath(toString(value));
|
|
812
|
+
}
|
|
813
|
+
var _castPath = castPath$1;
|
|
814
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
815
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
816
|
+
function isIndex$1(value, length) {
|
|
817
|
+
var type2 = typeof value;
|
|
818
|
+
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
819
|
+
return !!length && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
820
|
+
}
|
|
821
|
+
var _isIndex = isIndex$1;
|
|
822
|
+
var isSymbol = isSymbol_1;
|
|
823
|
+
var INFINITY = 1 / 0;
|
|
824
|
+
function toKey$1(value) {
|
|
825
|
+
if (typeof value == "string" || isSymbol(value)) {
|
|
826
|
+
return value;
|
|
827
|
+
}
|
|
828
|
+
var result = value + "";
|
|
829
|
+
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
830
|
+
}
|
|
831
|
+
var _toKey = toKey$1;
|
|
832
|
+
var assignValue = _assignValue, castPath = _castPath, isIndex = _isIndex, isObject = isObject_1, toKey = _toKey;
|
|
833
|
+
function baseSet$1(object, path, value, customizer) {
|
|
834
|
+
if (!isObject(object)) {
|
|
835
|
+
return object;
|
|
836
|
+
}
|
|
837
|
+
path = castPath(path, object);
|
|
838
|
+
var index2 = -1, length = path.length, lastIndex = length - 1, nested = object;
|
|
839
|
+
while (nested != null && ++index2 < length) {
|
|
840
|
+
var key = toKey(path[index2]), newValue = value;
|
|
841
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
842
|
+
return object;
|
|
843
|
+
}
|
|
844
|
+
if (index2 != lastIndex) {
|
|
845
|
+
var objValue = nested[key];
|
|
846
|
+
newValue = customizer ? customizer(objValue, key, nested) : void 0;
|
|
847
|
+
if (newValue === void 0) {
|
|
848
|
+
newValue = isObject(objValue) ? objValue : isIndex(path[index2 + 1]) ? [] : {};
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
assignValue(nested, key, newValue);
|
|
852
|
+
nested = nested[key];
|
|
853
|
+
}
|
|
854
|
+
return object;
|
|
855
|
+
}
|
|
856
|
+
var _baseSet = baseSet$1;
|
|
857
|
+
var baseSet = _baseSet;
|
|
858
|
+
function set(object, path, value) {
|
|
859
|
+
return object == null ? object : baseSet(object, path, value);
|
|
860
|
+
}
|
|
861
|
+
var set_1 = set;
|
|
862
|
+
const set$1 = /* @__PURE__ */ getDefaultExportFromCjs(set_1);
|
|
863
|
+
const register = ({ strapi: strapi2 }) => {
|
|
864
|
+
Object.values(strapi2.contentTypes).forEach((contentType) => {
|
|
865
|
+
if (!contentType.pluginOptions?.webatlas?.active) return;
|
|
866
|
+
const { attributes } = contentType;
|
|
867
|
+
const fieldSettings = {
|
|
868
|
+
writable: true,
|
|
869
|
+
private: true,
|
|
870
|
+
configurable: false,
|
|
871
|
+
editable: false,
|
|
872
|
+
visible: true,
|
|
873
|
+
default: null
|
|
874
|
+
};
|
|
875
|
+
set$1(attributes, "webatlas_path", {
|
|
876
|
+
...fieldSettings,
|
|
877
|
+
type: "string"
|
|
878
|
+
});
|
|
879
|
+
set$1(attributes, "webatlas_override", {
|
|
880
|
+
...fieldSettings,
|
|
881
|
+
type: "boolean"
|
|
882
|
+
});
|
|
883
|
+
});
|
|
884
|
+
};
|
|
885
|
+
const config = {
|
|
886
|
+
default: {},
|
|
887
|
+
validator() {
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
const schema$2 = {
|
|
891
|
+
collectionName: "route",
|
|
892
|
+
info: {
|
|
893
|
+
singularName: "route",
|
|
894
|
+
pluralName: "routes",
|
|
895
|
+
displayName: "Route",
|
|
896
|
+
name: "route"
|
|
897
|
+
},
|
|
898
|
+
options: {
|
|
899
|
+
increments: true,
|
|
900
|
+
timestamps: true,
|
|
901
|
+
comment: "Route"
|
|
902
|
+
},
|
|
903
|
+
pluginOptions: {
|
|
904
|
+
"content-manager": {
|
|
905
|
+
visible: true
|
|
906
|
+
},
|
|
907
|
+
"content-type-builder": {
|
|
908
|
+
visible: false
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
attributes: {
|
|
912
|
+
relatedContentType: {
|
|
913
|
+
type: "string",
|
|
914
|
+
required: true,
|
|
915
|
+
configurable: false
|
|
916
|
+
},
|
|
917
|
+
relatedId: {
|
|
918
|
+
type: "integer",
|
|
919
|
+
required: true,
|
|
920
|
+
configurable: false
|
|
921
|
+
},
|
|
922
|
+
relatedDocumentId: {
|
|
923
|
+
type: "string",
|
|
924
|
+
required: true,
|
|
925
|
+
configurable: false
|
|
926
|
+
},
|
|
927
|
+
title: {
|
|
928
|
+
type: "string",
|
|
929
|
+
required: true,
|
|
930
|
+
configurable: false
|
|
931
|
+
},
|
|
932
|
+
fullPath: {
|
|
933
|
+
type: "string",
|
|
934
|
+
configurable: false
|
|
935
|
+
},
|
|
936
|
+
slug: {
|
|
937
|
+
type: "string",
|
|
938
|
+
configurable: false
|
|
939
|
+
},
|
|
940
|
+
uidPath: {
|
|
941
|
+
type: "string",
|
|
942
|
+
configurable: false
|
|
943
|
+
},
|
|
944
|
+
documentIdPath: {
|
|
945
|
+
type: "string",
|
|
946
|
+
configurable: false
|
|
947
|
+
},
|
|
948
|
+
isOverride: {
|
|
949
|
+
type: "boolean",
|
|
950
|
+
default: false,
|
|
951
|
+
configurable: false
|
|
952
|
+
},
|
|
953
|
+
internal: {
|
|
954
|
+
type: "boolean",
|
|
955
|
+
default: true,
|
|
956
|
+
configurable: false
|
|
957
|
+
},
|
|
958
|
+
active: {
|
|
959
|
+
type: "boolean",
|
|
960
|
+
default: true,
|
|
961
|
+
configurable: false
|
|
962
|
+
},
|
|
963
|
+
navitem: {
|
|
964
|
+
type: "relation",
|
|
965
|
+
relation: "oneToOne",
|
|
966
|
+
target: "plugin::webatlas.navitem",
|
|
967
|
+
mappedBy: "route",
|
|
968
|
+
configurable: false
|
|
969
|
+
},
|
|
970
|
+
wrapper: {
|
|
971
|
+
type: "boolean",
|
|
972
|
+
default: false,
|
|
973
|
+
configurable: false
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
const route = {
|
|
978
|
+
schema: schema$2
|
|
979
|
+
};
|
|
980
|
+
const schema$1 = {
|
|
981
|
+
collectionName: "navigation",
|
|
982
|
+
info: {
|
|
983
|
+
singularName: "navigation",
|
|
984
|
+
pluralName: "navigations",
|
|
985
|
+
displayName: "Navigation",
|
|
986
|
+
name: "navigation"
|
|
987
|
+
},
|
|
988
|
+
options: {
|
|
989
|
+
increments: true,
|
|
990
|
+
comment: ""
|
|
991
|
+
},
|
|
992
|
+
pluginOptions: {
|
|
993
|
+
"content-manager": {
|
|
994
|
+
visible: false
|
|
995
|
+
},
|
|
996
|
+
"content-type-builder": {
|
|
997
|
+
visible: false
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
attributes: {
|
|
1001
|
+
name: {
|
|
1002
|
+
type: "text",
|
|
1003
|
+
configurable: false,
|
|
1004
|
+
required: true
|
|
1005
|
+
},
|
|
1006
|
+
slug: {
|
|
1007
|
+
type: "uid",
|
|
1008
|
+
target: "name",
|
|
1009
|
+
configurable: false,
|
|
1010
|
+
required: true
|
|
1011
|
+
},
|
|
1012
|
+
visible: {
|
|
1013
|
+
type: "boolean",
|
|
1014
|
+
default: false,
|
|
1015
|
+
configurable: false
|
|
1016
|
+
},
|
|
1017
|
+
items: {
|
|
1018
|
+
type: "relation",
|
|
1019
|
+
relation: "oneToMany",
|
|
1020
|
+
target: "plugin::webatlas.navitem",
|
|
1021
|
+
configurable: false,
|
|
1022
|
+
mappedBy: "plugin::webatlas.navigation"
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
const navigation = {
|
|
1027
|
+
schema: schema$1
|
|
1028
|
+
};
|
|
1029
|
+
const schema = {
|
|
1030
|
+
collectionName: "navitem",
|
|
1031
|
+
info: {
|
|
1032
|
+
singularName: "navitem",
|
|
1033
|
+
pluralName: "navitems",
|
|
1034
|
+
displayName: "Navigation Items",
|
|
1035
|
+
name: "navitems"
|
|
1036
|
+
},
|
|
1037
|
+
options: {
|
|
1038
|
+
increments: true,
|
|
1039
|
+
comment: ""
|
|
1040
|
+
},
|
|
1041
|
+
pluginOptions: {
|
|
1042
|
+
"content-manager": {
|
|
1043
|
+
visible: false
|
|
1044
|
+
},
|
|
1045
|
+
"content-type-builder": {
|
|
1046
|
+
visible: false
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
attributes: {
|
|
1050
|
+
navigation: {
|
|
1051
|
+
type: "relation",
|
|
1052
|
+
relation: "manyToOne",
|
|
1053
|
+
target: "plugin::webatlas.navigation",
|
|
1054
|
+
configurable: false,
|
|
1055
|
+
inversedBy: "items"
|
|
1056
|
+
},
|
|
1057
|
+
route: {
|
|
1058
|
+
type: "relation",
|
|
1059
|
+
relation: "oneToOne",
|
|
1060
|
+
target: "plugin::webatlas.route",
|
|
1061
|
+
inversedBy: "navitem",
|
|
1062
|
+
configurable: false
|
|
1063
|
+
},
|
|
1064
|
+
parent: {
|
|
1065
|
+
type: "relation",
|
|
1066
|
+
relation: "oneToOne",
|
|
1067
|
+
target: "plugin::webatlas.navitem",
|
|
1068
|
+
configurable: false
|
|
1069
|
+
},
|
|
1070
|
+
order: {
|
|
1071
|
+
type: "integer",
|
|
1072
|
+
default: 0
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
const navitem = {
|
|
1077
|
+
schema
|
|
1078
|
+
};
|
|
1079
|
+
const contentTypes = {
|
|
1080
|
+
route,
|
|
1081
|
+
navigation,
|
|
1082
|
+
navitem
|
|
1083
|
+
};
|
|
1084
|
+
const admin$2 = () => ({
|
|
1085
|
+
async updateConfig(ctx) {
|
|
1086
|
+
try {
|
|
1087
|
+
await getAdminService().updateConfig(ctx.request.body);
|
|
1088
|
+
} catch (e) {
|
|
1089
|
+
ctx.throw(500, e);
|
|
1090
|
+
}
|
|
1091
|
+
return ctx.send({ status: 200 });
|
|
1092
|
+
},
|
|
1093
|
+
async getConfig(ctx) {
|
|
1094
|
+
try {
|
|
1095
|
+
return await getAdminService().getConfig();
|
|
1096
|
+
} catch (e) {
|
|
1097
|
+
return ctx.throw(500, e);
|
|
1098
|
+
}
|
|
1099
|
+
},
|
|
1100
|
+
async getRoutes(ctx) {
|
|
1101
|
+
try {
|
|
1102
|
+
return await getAdminService().getRoutes();
|
|
1103
|
+
} catch (e) {
|
|
1104
|
+
return ctx.throw(500, e);
|
|
1105
|
+
}
|
|
1106
|
+
},
|
|
1107
|
+
async createExternalRoute(ctx) {
|
|
1108
|
+
try {
|
|
1109
|
+
const { data } = ctx.request.body;
|
|
1110
|
+
return await getAdminService().createExternalRoute(
|
|
1111
|
+
data
|
|
1112
|
+
);
|
|
1113
|
+
} catch (e) {
|
|
1114
|
+
return ctx.throw(500, e);
|
|
1115
|
+
}
|
|
1116
|
+
},
|
|
1117
|
+
async updateRoute(ctx) {
|
|
1118
|
+
try {
|
|
1119
|
+
const { documentId } = ctx.query;
|
|
1120
|
+
if (!documentId) return ctx.throw(400, "Route documentId is required");
|
|
1121
|
+
const { data } = ctx.request.body;
|
|
1122
|
+
return await getAdminService().updateRoute(documentId, data);
|
|
1123
|
+
} catch (e) {
|
|
1124
|
+
return ctx.throw(500, e);
|
|
1125
|
+
}
|
|
1126
|
+
},
|
|
1127
|
+
async getNavigation(ctx) {
|
|
1128
|
+
try {
|
|
1129
|
+
const { documentId, variant } = ctx.query;
|
|
1130
|
+
return await getAdminService().getNavigation(documentId, variant);
|
|
1131
|
+
} catch (e) {
|
|
1132
|
+
return ctx.throw(500, e);
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
async createNavigation(ctx) {
|
|
1136
|
+
try {
|
|
1137
|
+
const data = ctx.request.body;
|
|
1138
|
+
return await getAdminService().createNavigation(data);
|
|
1139
|
+
} catch (e) {
|
|
1140
|
+
return ctx.throw(500, e);
|
|
1141
|
+
}
|
|
1142
|
+
},
|
|
1143
|
+
async updateNavigation(ctx) {
|
|
1144
|
+
try {
|
|
1145
|
+
const { documentId } = ctx.query;
|
|
1146
|
+
if (!documentId) return ctx.throw(400, "Navigation documentId is required");
|
|
1147
|
+
const { data } = ctx.request.body;
|
|
1148
|
+
return await getAdminService().updateNavigation(documentId, data);
|
|
1149
|
+
} catch (e) {
|
|
1150
|
+
return ctx.throw(500, e);
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
async deleteNavigation(ctx) {
|
|
1154
|
+
try {
|
|
1155
|
+
const { documentId } = ctx.query;
|
|
1156
|
+
if (!documentId) return ctx.throw(400, "Navigation documentId is required");
|
|
1157
|
+
return await getAdminService().deleteNavigation(documentId);
|
|
1158
|
+
} catch (e) {
|
|
1159
|
+
return ctx.throw(500, e);
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
async createNavItem(ctx) {
|
|
1163
|
+
try {
|
|
1164
|
+
const { data } = ctx.request.body;
|
|
1165
|
+
return await getAdminService().createNavItem(data);
|
|
1166
|
+
} catch (e) {
|
|
1167
|
+
return ctx.throw(500, e);
|
|
1168
|
+
}
|
|
1169
|
+
},
|
|
1170
|
+
async updateNavItem(ctx) {
|
|
1171
|
+
try {
|
|
1172
|
+
const { documentId } = ctx.query;
|
|
1173
|
+
if (!documentId) return ctx.throw(400, "NavItem documentId is required");
|
|
1174
|
+
const { data } = ctx.request.body;
|
|
1175
|
+
return await getAdminService().updateNavItem(documentId, data);
|
|
1176
|
+
} catch (e) {
|
|
1177
|
+
return ctx.throw(500, e);
|
|
1178
|
+
}
|
|
1179
|
+
},
|
|
1180
|
+
async deleteNavItem(ctx) {
|
|
1181
|
+
try {
|
|
1182
|
+
const { documentId } = ctx.query;
|
|
1183
|
+
if (!documentId) return ctx.throw(400, "NavItem documentId is required");
|
|
1184
|
+
return await getAdminService().deleteNavItem(documentId);
|
|
1185
|
+
} catch (e) {
|
|
1186
|
+
return ctx.throw(500, e);
|
|
1187
|
+
}
|
|
1188
|
+
},
|
|
1189
|
+
async checkUniquePath(ctx) {
|
|
1190
|
+
try {
|
|
1191
|
+
const { path, targetRouteDocumentId } = ctx.query;
|
|
1192
|
+
if (!path) return ctx.throw(400, "Path is required");
|
|
1193
|
+
return await getAdminService().checkUniquePath(path, targetRouteDocumentId || null);
|
|
1194
|
+
} catch (e) {
|
|
1195
|
+
return ctx.throw(500, e);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
const client$2 = ({ strapi: strapi2 }) => ({
|
|
1200
|
+
async getEntityByPath(ctx) {
|
|
1201
|
+
try {
|
|
1202
|
+
const { slug, populate, populateDeepDepth, fields } = ctx.query;
|
|
1203
|
+
if (!slug) return ctx.throw(400, "Slug is required");
|
|
1204
|
+
const entity = await getClientService().getEntityByPath(slug, populate, populateDeepDepth, fields);
|
|
1205
|
+
if (!entity) return ctx.throw(404, "Entity not found");
|
|
1206
|
+
return ctx.send(entity);
|
|
1207
|
+
} catch (e) {
|
|
1208
|
+
ctx.throw(500, e);
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
async getNavigation(ctx) {
|
|
1212
|
+
try {
|
|
1213
|
+
const { id, name: name2, documentId, variant } = ctx.query;
|
|
1214
|
+
if (!id && !name2 && !documentId) return ctx.throw(400, "Navigation id, name or documentId is required");
|
|
1215
|
+
const navigation2 = await getClientService().getNavigation(id, name2, documentId, variant);
|
|
1216
|
+
if (!navigation2) return ctx.throw(404, "Navigation not found");
|
|
1217
|
+
return ctx.send(navigation2);
|
|
1218
|
+
} catch (e) {
|
|
1219
|
+
return ctx.throw(500, e);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
const controllers = {
|
|
1224
|
+
admin: admin$2,
|
|
1225
|
+
client: client$2
|
|
1226
|
+
};
|
|
1227
|
+
const middlewares = {};
|
|
1228
|
+
const policies = {};
|
|
1229
|
+
const admin$1 = {
|
|
1230
|
+
type: "admin",
|
|
1231
|
+
routes: [
|
|
1232
|
+
{
|
|
1233
|
+
method: "GET",
|
|
1234
|
+
path: "/config",
|
|
1235
|
+
handler: "admin.getConfig",
|
|
1236
|
+
config: {
|
|
1237
|
+
policies: [],
|
|
1238
|
+
auth: false
|
|
1239
|
+
}
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
method: "PUT",
|
|
1243
|
+
path: "/config",
|
|
1244
|
+
handler: "admin.updateConfig",
|
|
1245
|
+
config: {
|
|
1246
|
+
policies: [],
|
|
1247
|
+
auth: false
|
|
1248
|
+
}
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
method: "GET",
|
|
1252
|
+
path: "/route",
|
|
1253
|
+
handler: "admin.getRoutes",
|
|
1254
|
+
config: {
|
|
1255
|
+
policies: [],
|
|
1256
|
+
auth: false
|
|
1257
|
+
}
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
method: "POST",
|
|
1261
|
+
path: "/route/external",
|
|
1262
|
+
handler: "admin.createExternalRoute",
|
|
1263
|
+
config: {
|
|
1264
|
+
policies: [],
|
|
1265
|
+
auth: false
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
method: "PUT",
|
|
1270
|
+
path: "/route",
|
|
1271
|
+
handler: "admin.updateRoute",
|
|
1272
|
+
config: {
|
|
1273
|
+
policies: [],
|
|
1274
|
+
auth: false
|
|
1275
|
+
}
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
method: "GET",
|
|
1279
|
+
path: "/navigation",
|
|
1280
|
+
handler: "admin.getNavigation",
|
|
1281
|
+
config: {
|
|
1282
|
+
policies: [],
|
|
1283
|
+
auth: false
|
|
1284
|
+
}
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
method: "POST",
|
|
1288
|
+
path: "/navigation",
|
|
1289
|
+
handler: "admin.createNavigation",
|
|
1290
|
+
config: {
|
|
1291
|
+
policies: [],
|
|
1292
|
+
auth: false
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
method: "PUT",
|
|
1297
|
+
path: "/navigation",
|
|
1298
|
+
handler: "admin.updateNavigation",
|
|
1299
|
+
config: {
|
|
1300
|
+
policies: [],
|
|
1301
|
+
auth: false
|
|
1302
|
+
}
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
method: "DELETE",
|
|
1306
|
+
path: "/navigation",
|
|
1307
|
+
handler: "admin.deleteNavigation",
|
|
1308
|
+
config: {
|
|
1309
|
+
policies: [],
|
|
1310
|
+
auth: false
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
method: "POST",
|
|
1315
|
+
path: "/navitem",
|
|
1316
|
+
handler: "admin.createNavItem",
|
|
1317
|
+
config: {
|
|
1318
|
+
policies: [],
|
|
1319
|
+
auth: false
|
|
1320
|
+
}
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
method: "PUT",
|
|
1324
|
+
path: "/navitem",
|
|
1325
|
+
handler: "admin.updateNavItem",
|
|
1326
|
+
config: {
|
|
1327
|
+
policies: [],
|
|
1328
|
+
auth: false
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
method: "DELETE",
|
|
1333
|
+
path: "/navitem",
|
|
1334
|
+
handler: "admin.deleteNavItem",
|
|
1335
|
+
config: {
|
|
1336
|
+
policies: [],
|
|
1337
|
+
auth: false
|
|
1338
|
+
}
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
method: "GET",
|
|
1342
|
+
path: "/checkUniquePath",
|
|
1343
|
+
handler: "admin.checkUniquePath",
|
|
1344
|
+
config: {
|
|
1345
|
+
policies: [],
|
|
1346
|
+
auth: false
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
]
|
|
1350
|
+
};
|
|
1351
|
+
const client$1 = {
|
|
1352
|
+
type: "content-api",
|
|
1353
|
+
routes: [
|
|
1354
|
+
{
|
|
1355
|
+
method: "GET",
|
|
1356
|
+
path: "/path",
|
|
1357
|
+
handler: "client.getEntityByPath",
|
|
1358
|
+
config: {
|
|
1359
|
+
policies: []
|
|
1360
|
+
}
|
|
1361
|
+
},
|
|
1362
|
+
{
|
|
1363
|
+
method: "GET",
|
|
1364
|
+
path: "/navigation",
|
|
1365
|
+
handler: "client.getNavigation",
|
|
1366
|
+
config: {
|
|
1367
|
+
policies: []
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
]
|
|
1371
|
+
};
|
|
1372
|
+
const routes = {
|
|
1373
|
+
admin: admin$1,
|
|
1374
|
+
"content-api": client$1
|
|
1375
|
+
};
|
|
1376
|
+
function getFullPath(parentPath, slug) {
|
|
1377
|
+
if (!slug) return null;
|
|
1378
|
+
if (!parentPath) return slug;
|
|
1379
|
+
const newPath = parentPath.endsWith("/") ? parentPath : `${parentPath}/`;
|
|
1380
|
+
return `${newPath}${slug}`;
|
|
1381
|
+
}
|
|
1382
|
+
function buildStructuredNavigation(navigation2, variant = "nested") {
|
|
1383
|
+
const itemsById = /* @__PURE__ */ new Map();
|
|
1384
|
+
const rootItems = [];
|
|
1385
|
+
if (!navigation2.items || navigation2.items?.length === 0) return navigation2;
|
|
1386
|
+
navigation2.items.forEach((item) => {
|
|
1387
|
+
itemsById.set(item.id, { ...item, items: [] });
|
|
1388
|
+
});
|
|
1389
|
+
if (variant === "nested") {
|
|
1390
|
+
navigation2.items.forEach((item) => {
|
|
1391
|
+
const newItem = itemsById.get(item.id);
|
|
1392
|
+
if (!newItem) return null;
|
|
1393
|
+
if (item.parent) {
|
|
1394
|
+
const parentItem = itemsById.get(item.parent.id);
|
|
1395
|
+
parentItem && parentItem.items.push(newItem);
|
|
1396
|
+
} else {
|
|
1397
|
+
rootItems.push(newItem);
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
sortItems(rootItems);
|
|
1401
|
+
return { ...navigation2, items: rootItems };
|
|
1402
|
+
} else if (variant === "flat") {
|
|
1403
|
+
let itemsToProcess = [...navigation2.items];
|
|
1404
|
+
let itemsProcessed = /* @__PURE__ */ new Set();
|
|
1405
|
+
while (itemsToProcess.length > 0) {
|
|
1406
|
+
const remainingItems = [];
|
|
1407
|
+
itemsToProcess.forEach((item) => {
|
|
1408
|
+
const newItem = itemsById.get(item.id);
|
|
1409
|
+
if (!newItem) return null;
|
|
1410
|
+
if (item.parent) {
|
|
1411
|
+
const parentItem = itemsById.get(item.parent.id);
|
|
1412
|
+
if (!parentItem || !itemsProcessed.has(item.parent.id)) {
|
|
1413
|
+
remainingItems.push(item);
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
newItem.depth = parentItem.depth !== void 0 ? parentItem.depth + 1 : 0;
|
|
1417
|
+
parentItem.items.push(newItem);
|
|
1418
|
+
} else {
|
|
1419
|
+
newItem.depth = 0;
|
|
1420
|
+
rootItems.push(newItem);
|
|
1421
|
+
}
|
|
1422
|
+
itemsById.set(item.id, newItem);
|
|
1423
|
+
itemsProcessed.add(item.id);
|
|
1424
|
+
});
|
|
1425
|
+
itemsToProcess = remainingItems;
|
|
1426
|
+
}
|
|
1427
|
+
const sortedItems = sortItems(rootItems);
|
|
1428
|
+
const flattenedItems = flattenItems(sortedItems);
|
|
1429
|
+
return { ...navigation2, items: flattenedItems };
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
const flattenItems = (items, result = []) => {
|
|
1433
|
+
items.forEach((item) => {
|
|
1434
|
+
const itemCopy = { ...item };
|
|
1435
|
+
delete itemCopy.items;
|
|
1436
|
+
result.push(itemCopy);
|
|
1437
|
+
if (item.items && item.items.length > 0) {
|
|
1438
|
+
flattenItems(item.items, result);
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1441
|
+
return result;
|
|
1442
|
+
};
|
|
1443
|
+
const sortItems = (items) => {
|
|
1444
|
+
items.sort((a, b) => a.order - b.order);
|
|
1445
|
+
items.forEach((item) => {
|
|
1446
|
+
if (item.items && item.items.length > 0) {
|
|
1447
|
+
sortItems(item.items);
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
return items;
|
|
1451
|
+
};
|
|
1452
|
+
function extractRouteAndItems(items) {
|
|
1453
|
+
return items.map((item) => {
|
|
1454
|
+
const route2 = { ...item.route };
|
|
1455
|
+
if (item.depth) {
|
|
1456
|
+
route2.depth = item.depth;
|
|
1457
|
+
}
|
|
1458
|
+
if (item.items?.length > 0) {
|
|
1459
|
+
const items2 = extractRouteAndItems(item.items);
|
|
1460
|
+
if (items2.length > 0) route2.items = items2;
|
|
1461
|
+
}
|
|
1462
|
+
let type2;
|
|
1463
|
+
if (!route2.internal && route2.wrapper)
|
|
1464
|
+
type2 = "wrapper";
|
|
1465
|
+
else if (!route2.internal && !route2.wrapper)
|
|
1466
|
+
type2 = "external";
|
|
1467
|
+
else
|
|
1468
|
+
type2 = "internal";
|
|
1469
|
+
delete route2.relatedContentType;
|
|
1470
|
+
delete route2.relatedId;
|
|
1471
|
+
delete route2.createdAt;
|
|
1472
|
+
delete route2.updatedAt;
|
|
1473
|
+
delete route2.isOverride;
|
|
1474
|
+
delete route2.internal;
|
|
1475
|
+
delete route2.wrapper;
|
|
1476
|
+
return {
|
|
1477
|
+
__component: type2 === "wrapper" ? `${PLUGIN_NAME}.wrapper` : `${PLUGIN_NAME}.route`,
|
|
1478
|
+
type: type2,
|
|
1479
|
+
...route2
|
|
1480
|
+
};
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
function isEmpty(value) {
|
|
1484
|
+
if (value == null) return true;
|
|
1485
|
+
if (Array.isArray(value) || typeof value === "string") return value.length === 0;
|
|
1486
|
+
if (typeof value === "object") return Object.keys(value).length === 0;
|
|
1487
|
+
return false;
|
|
1488
|
+
}
|
|
1489
|
+
function merge(target, source) {
|
|
1490
|
+
for (const key in source) {
|
|
1491
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
1492
|
+
target[key] = merge(target[key] || {}, source[key]);
|
|
1493
|
+
} else {
|
|
1494
|
+
target[key] = source[key];
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
return target;
|
|
1498
|
+
}
|
|
1499
|
+
const getModelPopulationAttributes = (model) => {
|
|
1500
|
+
if (model.uid === "plugin::upload.file") {
|
|
1501
|
+
const { related, ...attributes } = model.attributes;
|
|
1502
|
+
return attributes;
|
|
1503
|
+
}
|
|
1504
|
+
return model.attributes;
|
|
1505
|
+
};
|
|
1506
|
+
function getFullPopulateObject(modelUid, maxDepth = 20, ignore = []) {
|
|
1507
|
+
if (maxDepth <= 1) {
|
|
1508
|
+
return true;
|
|
1509
|
+
}
|
|
1510
|
+
if (modelUid === "admin::user") {
|
|
1511
|
+
return false;
|
|
1512
|
+
}
|
|
1513
|
+
const populate = {};
|
|
1514
|
+
const model = strapi.getModel(modelUid);
|
|
1515
|
+
if (model.collectionName && !ignore.includes(model.collectionName)) {
|
|
1516
|
+
ignore.push(model.collectionName);
|
|
1517
|
+
} else if (model.collectionName && ignore.includes(model.collectionName)) {
|
|
1518
|
+
return true;
|
|
1519
|
+
}
|
|
1520
|
+
for (const [key, value] of Object.entries(
|
|
1521
|
+
getModelPopulationAttributes(model)
|
|
1522
|
+
)) {
|
|
1523
|
+
if (ignore?.includes(key)) continue;
|
|
1524
|
+
if (value) {
|
|
1525
|
+
if (value.type === "component") {
|
|
1526
|
+
populate[key] = getFullPopulateObject(value.component, maxDepth - 1, ignore);
|
|
1527
|
+
} else if (value.type === "dynamiczone") {
|
|
1528
|
+
const dynamicPopulate = value.components.reduce((prev, cur) => {
|
|
1529
|
+
const curPopulate = getFullPopulateObject(cur, maxDepth - 1, ignore);
|
|
1530
|
+
if (curPopulate === true) {
|
|
1531
|
+
return prev;
|
|
1532
|
+
}
|
|
1533
|
+
return merge(prev, curPopulate);
|
|
1534
|
+
}, {});
|
|
1535
|
+
populate[key] = isEmpty(dynamicPopulate) ? true : dynamicPopulate;
|
|
1536
|
+
} else if (value.type === "relation") {
|
|
1537
|
+
const relationPopulate = getFullPopulateObject(
|
|
1538
|
+
//@ts-ignore
|
|
1539
|
+
value.target,
|
|
1540
|
+
key === "localizations" && maxDepth > 2 ? 1 : maxDepth - 1,
|
|
1541
|
+
ignore
|
|
1542
|
+
);
|
|
1543
|
+
if (relationPopulate) populate[key] = relationPopulate;
|
|
1544
|
+
} else if (value.type === "media") {
|
|
1545
|
+
populate[key] = true;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
return isEmpty(populate) ? true : { populate };
|
|
1550
|
+
}
|
|
1551
|
+
function cleanRootKeys(obj) {
|
|
1552
|
+
for (const key in obj) {
|
|
1553
|
+
if (obj.hasOwnProperty(key)) {
|
|
1554
|
+
const value = obj[key];
|
|
1555
|
+
if (value === null || Array.isArray(value) && value.length === 0 || typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0) {
|
|
1556
|
+
delete obj[key];
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
return obj;
|
|
1561
|
+
}
|
|
1562
|
+
function removeWaFields(obj) {
|
|
1563
|
+
delete obj["webatlas_path"];
|
|
1564
|
+
delete obj["webatlas_override"];
|
|
1565
|
+
return obj;
|
|
1566
|
+
}
|
|
1567
|
+
const admin = ({ strapi: strapi2 }) => ({
|
|
1568
|
+
async updateConfig(newConfig) {
|
|
1569
|
+
if (!newConfig || !newConfig.selectedContentTypes) return;
|
|
1570
|
+
try {
|
|
1571
|
+
const routes2 = await strapi2.documents(waRoute).findMany();
|
|
1572
|
+
const invalidRoutes = routes2.filter((route2) => !newConfig.selectedContentTypes.find((type2) => type2.uid === route2.relatedContentType));
|
|
1573
|
+
invalidRoutes?.map(async (route2) => {
|
|
1574
|
+
await strapi2.documents(waRoute).delete({
|
|
1575
|
+
documentId: route2.documentId
|
|
1576
|
+
});
|
|
1577
|
+
});
|
|
1578
|
+
} catch (err) {
|
|
1579
|
+
console.log(err);
|
|
1580
|
+
return "Error. Couldn't delete invalid routes";
|
|
1581
|
+
}
|
|
1582
|
+
const pluginStore = await strapi2.store({ type: "plugin", name: PLUGIN_NAME });
|
|
1583
|
+
await pluginStore.set({ key: "config", value: newConfig });
|
|
1584
|
+
},
|
|
1585
|
+
async getConfig() {
|
|
1586
|
+
const pluginStore = await strapi2.store({ type: "plugin", name: PLUGIN_NAME });
|
|
1587
|
+
let config2 = await pluginStore.get({
|
|
1588
|
+
key: "config"
|
|
1589
|
+
});
|
|
1590
|
+
if (!config2) {
|
|
1591
|
+
config2 = await pluginStore.set({
|
|
1592
|
+
key: "config",
|
|
1593
|
+
value: {
|
|
1594
|
+
selectedContentTypes: []
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
return config2;
|
|
1599
|
+
},
|
|
1600
|
+
async getRoutes() {
|
|
1601
|
+
try {
|
|
1602
|
+
const entities = await strapi2.documents(waRoute).findMany();
|
|
1603
|
+
return entities;
|
|
1604
|
+
} catch (e) {
|
|
1605
|
+
console.log(e);
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
async createExternalRoute(data) {
|
|
1609
|
+
try {
|
|
1610
|
+
return await strapi2.documents(waRoute).create({
|
|
1611
|
+
data: {
|
|
1612
|
+
title: data.title,
|
|
1613
|
+
slug: data.fullPath,
|
|
1614
|
+
fullPath: data.fullPath,
|
|
1615
|
+
relatedContentType: "",
|
|
1616
|
+
relatedId: 0,
|
|
1617
|
+
relatedDocumentId: "",
|
|
1618
|
+
uidPath: "",
|
|
1619
|
+
internal: false,
|
|
1620
|
+
wrapper: data.wrapper
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
} catch (e) {
|
|
1624
|
+
console.log(e);
|
|
1625
|
+
}
|
|
1626
|
+
},
|
|
1627
|
+
async updateRoute(documentId, data) {
|
|
1628
|
+
try {
|
|
1629
|
+
let checkedPath = data.fullPath;
|
|
1630
|
+
if (data.internal) {
|
|
1631
|
+
const parent = data.parent ? await strapi2.documents(waNavItem).findOne({
|
|
1632
|
+
documentId: data.parent
|
|
1633
|
+
}) : null;
|
|
1634
|
+
const fullPath = data.isOverride ? data.slug : getFullPath(parent?.fullPath, data.slug);
|
|
1635
|
+
checkedPath = await duplicateCheck(fullPath, documentId);
|
|
1636
|
+
}
|
|
1637
|
+
const entity = await strapi2.documents(waRoute).update({
|
|
1638
|
+
documentId,
|
|
1639
|
+
data: {
|
|
1640
|
+
...data,
|
|
1641
|
+
fullPath: checkedPath
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
return entity;
|
|
1645
|
+
} catch (e) {
|
|
1646
|
+
console.log(e);
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
async getNavigation(documentId, variant) {
|
|
1650
|
+
try {
|
|
1651
|
+
let navigation2 = null;
|
|
1652
|
+
if (documentId) {
|
|
1653
|
+
navigation2 = await strapi2.documents(waNavigation).findOne({
|
|
1654
|
+
documentId,
|
|
1655
|
+
populate: ["items", "items.route", "items.parent"]
|
|
1656
|
+
});
|
|
1657
|
+
} else {
|
|
1658
|
+
navigation2 = await strapi2.documents(waNavigation).findMany({
|
|
1659
|
+
populate: ["items", "items.route", "items.parent"]
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
if (!navigation2) throw new Error("Navigation not found");
|
|
1663
|
+
if (variant) {
|
|
1664
|
+
navigation2 = buildStructuredNavigation(navigation2, variant);
|
|
1665
|
+
}
|
|
1666
|
+
return navigation2;
|
|
1667
|
+
} catch (e) {
|
|
1668
|
+
console.log(e);
|
|
1669
|
+
}
|
|
1670
|
+
},
|
|
1671
|
+
async createNavigation(data) {
|
|
1672
|
+
try {
|
|
1673
|
+
const navigation2 = await strapi2.documents(waNavigation).create({
|
|
1674
|
+
data: {
|
|
1675
|
+
name: data.name,
|
|
1676
|
+
slug: transformToUrl(data.name),
|
|
1677
|
+
visible: data.isActive
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
return navigation2;
|
|
1681
|
+
} catch (e) {
|
|
1682
|
+
console.log(e);
|
|
1683
|
+
}
|
|
1684
|
+
},
|
|
1685
|
+
async updateNavigation(documentId, data) {
|
|
1686
|
+
try {
|
|
1687
|
+
const entity = await strapi2.documents(waNavigation).update({
|
|
1688
|
+
documentId,
|
|
1689
|
+
data: {
|
|
1690
|
+
name: data.name,
|
|
1691
|
+
visible: data.visible
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
return entity;
|
|
1695
|
+
} catch (e) {
|
|
1696
|
+
console.log(e);
|
|
1697
|
+
}
|
|
1698
|
+
},
|
|
1699
|
+
async deleteNavigation(documentId) {
|
|
1700
|
+
try {
|
|
1701
|
+
return await strapi2.documents(waNavigation).delete({
|
|
1702
|
+
documentId
|
|
1703
|
+
});
|
|
1704
|
+
} catch (e) {
|
|
1705
|
+
console.log(e);
|
|
1706
|
+
}
|
|
1707
|
+
},
|
|
1708
|
+
async createNavItem(data) {
|
|
1709
|
+
try {
|
|
1710
|
+
if (!data.route || !data.navigation) return false;
|
|
1711
|
+
const parent = data.parent ? await strapi2.documents(waNavItem).findOne({
|
|
1712
|
+
documentId: data.parent,
|
|
1713
|
+
populate: ["route"]
|
|
1714
|
+
}) : null;
|
|
1715
|
+
const route2 = data.route ? await strapi2.documents(waRoute).findOne({
|
|
1716
|
+
documentId: data.route
|
|
1717
|
+
}) : null;
|
|
1718
|
+
let fullPath = route2.slug;
|
|
1719
|
+
if (route2.internal && !route2.isOverride && parent?.route.internal) fullPath = getFullPath(parent?.route?.fullPath, route2.slug);
|
|
1720
|
+
await strapi2.documents(waRoute).update({
|
|
1721
|
+
documentId: data.route,
|
|
1722
|
+
data: {
|
|
1723
|
+
fullPath
|
|
1724
|
+
}
|
|
1725
|
+
});
|
|
1726
|
+
const entity = await strapi2.documents(waNavItem).create({
|
|
1727
|
+
data: {
|
|
1728
|
+
navigation: data.navigation,
|
|
1729
|
+
route: data.route || null,
|
|
1730
|
+
parent: data.parent || null
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
return entity;
|
|
1734
|
+
} catch (e) {
|
|
1735
|
+
console.log(e);
|
|
1736
|
+
}
|
|
1737
|
+
},
|
|
1738
|
+
async updateNavItem(documentId, data) {
|
|
1739
|
+
try {
|
|
1740
|
+
return await strapi2.documents(waNavItem).update({
|
|
1741
|
+
documentId,
|
|
1742
|
+
data: {
|
|
1743
|
+
navigation: data.navigation || null,
|
|
1744
|
+
route: data.route || null,
|
|
1745
|
+
parent: data.parent || null,
|
|
1746
|
+
order: data.order || 0
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
} catch (e) {
|
|
1750
|
+
console.log(e);
|
|
1751
|
+
}
|
|
1752
|
+
},
|
|
1753
|
+
async deleteNavItem(documentId) {
|
|
1754
|
+
try {
|
|
1755
|
+
await strapi2.documents(waNavItem).delete({
|
|
1756
|
+
documentId
|
|
1757
|
+
});
|
|
1758
|
+
return true;
|
|
1759
|
+
} catch (e) {
|
|
1760
|
+
console.log(e);
|
|
1761
|
+
}
|
|
1762
|
+
},
|
|
1763
|
+
async checkUniquePath(initialPath, targetRouteDocumentId = null) {
|
|
1764
|
+
try {
|
|
1765
|
+
return await duplicateCheck(initialPath, targetRouteDocumentId);
|
|
1766
|
+
} catch (e) {
|
|
1767
|
+
console.log(e);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
const client = ({ strapi: strapi2 }) => ({
|
|
1772
|
+
async getEntityByPath(slug, populate, populateDeepDepth, fields) {
|
|
1773
|
+
try {
|
|
1774
|
+
const route2 = await strapi2.db?.query(waRoute).findOne({
|
|
1775
|
+
filters: {
|
|
1776
|
+
$or: [
|
|
1777
|
+
{ fullPath: slug },
|
|
1778
|
+
{ slug },
|
|
1779
|
+
{ uidPath: slug }
|
|
1780
|
+
]
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
if (!route2) return null;
|
|
1784
|
+
let populateObject = populate;
|
|
1785
|
+
if (populate === "deep") {
|
|
1786
|
+
const modelObject = getFullPopulateObject(route2.relatedContentType, Number(populateDeepDepth), []);
|
|
1787
|
+
if (typeof modelObject === "object" && "populate" in modelObject) {
|
|
1788
|
+
populateObject = modelObject.populate;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
const contentTypeObject = Object.entries(strapi2.contentTypes).find(([key, value]) => key === route2.relatedContentType);
|
|
1792
|
+
if (!contentTypeObject) {
|
|
1793
|
+
return null;
|
|
1794
|
+
}
|
|
1795
|
+
const [contentTypeKey, contentType] = contentTypeObject;
|
|
1796
|
+
const entity = await strapi2.documents(route2.relatedContentType).findOne({
|
|
1797
|
+
documentId: route2.documentIdPath,
|
|
1798
|
+
populate: populateObject,
|
|
1799
|
+
fields
|
|
1800
|
+
});
|
|
1801
|
+
if (!entity) return null;
|
|
1802
|
+
let cleanEntity = cleanRootKeys(entity);
|
|
1803
|
+
cleanEntity = removeWaFields(cleanEntity);
|
|
1804
|
+
return { contentType: contentType.info.singularName, ...cleanEntity };
|
|
1805
|
+
} catch (e) {
|
|
1806
|
+
console.log(e);
|
|
1807
|
+
return e;
|
|
1808
|
+
}
|
|
1809
|
+
},
|
|
1810
|
+
async getNavigation(id, name2, documentId, variant = "nested") {
|
|
1811
|
+
try {
|
|
1812
|
+
let navigation2 = null;
|
|
1813
|
+
if (documentId) {
|
|
1814
|
+
navigation2 = await strapi2.documents(waNavigation).findOne({
|
|
1815
|
+
documentId,
|
|
1816
|
+
populate: ["items", "items.parent", "items.route"]
|
|
1817
|
+
});
|
|
1818
|
+
} else if (name2) {
|
|
1819
|
+
navigation2 = await strapi2.db?.query(waNavigation).findOne({
|
|
1820
|
+
where: {
|
|
1821
|
+
name: name2
|
|
1822
|
+
},
|
|
1823
|
+
populate: ["items", "items.parent", "items.route"]
|
|
1824
|
+
});
|
|
1825
|
+
} else if (id) {
|
|
1826
|
+
navigation2 = await strapi2.db?.query(waNavigation).findOne({
|
|
1827
|
+
where: {
|
|
1828
|
+
id
|
|
1829
|
+
},
|
|
1830
|
+
populate: ["items", "items.parent", "items.route"]
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
if (!navigation2) return null;
|
|
1834
|
+
const structured = buildStructuredNavigation(navigation2, variant);
|
|
1835
|
+
if (!structured) return null;
|
|
1836
|
+
const entityNavigation = extractRouteAndItems(structured.items);
|
|
1837
|
+
return { ...structured, items: entityNavigation };
|
|
1838
|
+
} catch (e) {
|
|
1839
|
+
console.log(e);
|
|
1840
|
+
return e;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
const services = {
|
|
1845
|
+
admin,
|
|
1846
|
+
client
|
|
1847
|
+
};
|
|
1848
|
+
const index = {
|
|
1849
|
+
register,
|
|
1850
|
+
bootstrap,
|
|
1851
|
+
destroy,
|
|
1852
|
+
config,
|
|
1853
|
+
controllers,
|
|
1854
|
+
routes,
|
|
1855
|
+
services,
|
|
1856
|
+
contentTypes,
|
|
1857
|
+
policies,
|
|
1858
|
+
middlewares
|
|
1859
|
+
};
|
|
1860
|
+
export {
|
|
1861
|
+
index as default
|
|
1862
|
+
};
|