@mattisvensson/strapi-plugin-webatlas 0.1.6 → 0.2.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/README.md CHANGED
@@ -20,7 +20,8 @@ This plugin is still in the early stages of development. Many features are plann
20
20
  3. [⏳ Installation](#installation)
21
21
  4. [🖐 Requirements](#requirements)
22
22
  5. [🔧 Configuration](#configuration)
23
- 6. [🧩 Roadmap](#roadmap)
23
+ 6. [📖 Usage](#usage)
24
+ 7. [🧩 Roadmap](#roadmap)
24
25
 
25
26
  ## 💎 Versions
26
27
 
@@ -40,12 +41,12 @@ This plugin is still in the early stages of development. Many features are plann
40
41
  Install Webatlas via command line with a package manager of your choice.
41
42
  Using NPM:
42
43
  ```bash
43
- npm install strapi-plugin-webatlas@beta
44
+ npm install @mattisvensson/strapi-plugin-webatlas@beta
44
45
  ```
45
46
 
46
47
  Using Yarn:
47
48
  ```bash
48
- yarn add strapi-plugin-webatlas@beta
49
+ yarn add @mattisvensson/strapi-plugin-webatlas@beta
49
50
  ```
50
51
 
51
52
  As a next step you must configure your the plugin by the way you want to. See [**Configuration**](#🔧-configuration) section.
@@ -56,8 +57,8 @@ All done. Enjoy 🎉
56
57
 
57
58
  **Minimum environment requirements**
58
59
 
60
+ - Strapi `>=5.0.0`
59
61
  - Node.js `>=20.0.0`
60
- - NPM `>=10.x.x`
61
62
 
62
63
  ## 🔧 Configuration
63
64
 
@@ -91,13 +92,39 @@ For each selected content type, you have the following settings:
91
92
  - **URL Alias pattern:** Create a default pattern for the slug. For example, when creating a 'news' content type and you want your url structure to be like '/news/some-title' for all entities, enter 'news' in this setting field. The slug will automatically be appended to this string.
92
93
  - **URL Alias API field:** Allows you to append the current URL (slug) of an entity to a specific field. This is especially useful when working with components like a "teaser"—for example, you can store the slug in a hidden field within the teaser component. This way, you can fetch just the teaser via the API while still having access to its full URL.
93
94
 
95
+ ## 📖 Usage
96
+
97
+ Webatlas provides two API endpoints. One to fetch routes and one to fetch navigations.
98
+
99
+ ### Fetch route
100
+
101
+ `GET /api/webatlas/path`
102
+
103
+ Query parameters:
104
+ - `slug` (string, required): The slug/path to fetch the route for. This can either be the generated path from webatlas, the uId path or the documentId path.
105
+ - `populate` (string, optional): Comma-separated list of relations to populate. Use `deep` to populate all relations in any depth.
106
+ - `populateDeepDepth` (string, optional): Depth for deep population.
107
+ - `fields` (string, optional): Comma-separated list of fields to include in the response.
108
+ - `status` (string, optional): `draft` or `published`. Default is `published`. Returns the draft or published version of the entity.
109
+
110
+ ### Fetch navigation
111
+
112
+ `GET /api/webatlas/navigation`
113
+
114
+ One of these query parameters are mandatory to fetch a navigation. If you provide multiple, `documentId` has the highest priority, followed by `name` and `id`.
115
+ - `documentId` (string, optional): The document ID of the navigation to fetch.
116
+ - `name` (string, optional): The name of the navigation to fetch.
117
+ - `id` (string, optional): The ID of the navigation to fetch.
118
+
119
+ Optional parameters:
120
+ - `variant` (string, optional): `nested` or `flat`.The variant of the navigation to fetch. Default is `nested`.
121
+
94
122
  ## 🧩 Roadmap
95
123
 
96
124
  - RBAC
97
125
  - User action feedback
98
126
  - Internationalization
99
127
  - Plugin translations
100
- - Draft and published
101
128
  - Route page
102
129
  - Filters
103
130
  - Nested url structure
@@ -0,0 +1,16 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { Flex, Box, Typography } from "@strapi/design-system";
3
+ import { EmptyDocuments } from "@strapi/icons/symbols";
4
+ function Center({ height = 400, children }) {
5
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", minHeight: `${height}px`, justifyContent: "center", children });
6
+ }
7
+ function EmptyBox({ msg }) {
8
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
9
+ /* @__PURE__ */ jsx(EmptyDocuments, { width: "10rem", height: "6rem" }),
10
+ /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", textColor: "neutral600", children: msg }) })
11
+ ] });
12
+ }
13
+ export {
14
+ Center as C,
15
+ EmptyBox as E
16
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const designSystem = require("@strapi/design-system");
4
+ const symbols = require("@strapi/icons/symbols");
5
+ function Center({ height = 400, children }) {
6
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", minHeight: `${height}px`, justifyContent: "center", children });
7
+ }
8
+ function EmptyBox({ msg }) {
9
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10
+ /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "10rem", height: "6rem" }),
11
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", textColor: "neutral600", children: msg }) })
12
+ ] });
13
+ }
14
+ exports.Center = Center;
15
+ exports.EmptyBox = EmptyBox;
@@ -6,9 +6,9 @@ const designSystem = require("@strapi/design-system");
6
6
  const admin = require("@strapi/strapi/admin");
7
7
  const React = require("react");
8
8
  const ReactDOM = require("react-dom");
9
- const index = require("./index-DfHrvxDY.js");
9
+ const index = require("./index-C1dDrhfb.js");
10
+ const EmptyBox = require("./EmptyBox-DT6D5gcf.js");
10
11
  const _commonjsHelpers = require("./_commonjsHelpers-Cq6wktVC.js");
11
- const symbols = require("@strapi/icons/symbols");
12
12
  const core = require("@dnd-kit/core");
13
13
  const sortable = require("@dnd-kit/sortable");
14
14
  const utilities = require("@dnd-kit/utilities");
@@ -229,9 +229,6 @@ function NavEdit({ item, fetchNavigations }) {
229
229
  }
230
230
  );
231
231
  }
232
- function Center({ height = 400, children }) {
233
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", minHeight: `${height}px`, justifyContent: "center", children });
234
- }
235
232
  function NavOverview({ navigations, setActionItem }) {
236
233
  const { setModalType } = React.useContext(ModalContext);
237
234
  const { selectedNavigation, setSelectedNavigation } = React.useContext(SelectedNavigationContext);
@@ -272,7 +269,7 @@ function NavOverview({ navigations, setActionItem }) {
272
269
  children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {})
273
270
  }
274
271
  )
275
- ] }, nav.id)) : /* @__PURE__ */ jsxRuntime.jsx(Center, { height: 100, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: "No navigations available." }) })
272
+ ] }, nav.id)) : /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.Center, { height: 100, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: "No navigations available." }) })
276
273
  }
277
274
  );
278
275
  }
@@ -333,7 +330,7 @@ function useModalSharedLogic() {
333
330
  const [replacement, setReplacement] = React.useState("");
334
331
  const [validationState, setValidationState] = React.useState("initial");
335
332
  const { entities } = useAllEntities();
336
- const { createNavItem, updateRoute, getRouteByRelated, createExternalRoute } = index.useApi();
333
+ const { createNavItem, updateRoute, getRelatedRoute, createExternalRoute } = index.useApi();
337
334
  const initialState = React.useRef({
338
335
  title: "",
339
336
  slug: "",
@@ -374,7 +371,7 @@ function useModalSharedLogic() {
374
371
  createNavItem,
375
372
  createExternalRoute,
376
373
  updateRoute,
377
- getRouteByRelated,
374
+ getRelatedRoute,
378
375
  replacement,
379
376
  setReplacement,
380
377
  validationState,
@@ -498,7 +495,7 @@ function ItemCreateComponent({
498
495
  entities,
499
496
  createNavItem,
500
497
  updateRoute,
501
- getRouteByRelated,
498
+ getRelatedRoute,
502
499
  replacement,
503
500
  validationState,
504
501
  initialState,
@@ -527,7 +524,7 @@ function ItemCreateComponent({
527
524
  async function fetchRoute() {
528
525
  if (selectedContentType?.contentType && selectedEntity?.id) {
529
526
  try {
530
- const route = await getRouteByRelated(selectedEntity.documentId);
527
+ const route = await getRelatedRoute(selectedEntity.documentId);
531
528
  if (!route) return;
532
529
  dispatchPath({ type: "NO_URL_CHECK", payload: route.fullPath });
533
530
  dispatchPath({ type: "SET_UIDPATH", payload: route.uidPath });
@@ -6369,12 +6366,6 @@ function WrapperItemComponent({
6369
6366
  );
6370
6367
  }
6371
6368
  const WrapperItem = withModalSharedLogic(WrapperItemComponent);
6372
- function EmptyNav({ msg }) {
6373
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6374
- /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyDocuments, { width: "10rem", height: "6rem" }),
6375
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", textColor: "neutral600", children: msg }) })
6376
- ] });
6377
- }
6378
6369
  function Header({ navigations }) {
6379
6370
  const { setModalType } = React.useContext(ModalContext);
6380
6371
  const { selectedNavigation, setSelectedNavigation } = React.useContext(SelectedNavigationContext);
@@ -6788,12 +6779,12 @@ const Navigation = () => {
6788
6779
  ] })
6789
6780
  }
6790
6781
  ) }),
6791
- navigations?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(Center, { height: 400, children: [
6792
- /* @__PURE__ */ jsxRuntime.jsx(EmptyNav, { msg: "You have no navigations yet..." }),
6782
+ navigations?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(EmptyBox.Center, { height: 400, children: [
6783
+ /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: "You have no navigations yet..." }),
6793
6784
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "primary", onClick: () => setModalType("NavCreate"), children: "Create new Navigation" })
6794
6785
  ] }),
6795
- navigationItems?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(Center, { height: 400, children: [
6796
- /* @__PURE__ */ jsxRuntime.jsx(EmptyNav, { msg: "Your navigation is empty..." }),
6786
+ navigationItems?.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(EmptyBox.Center, { height: 400, children: [
6787
+ /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: "Your navigation is empty..." }),
6797
6788
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "primary", onClick: () => setModalType("ItemCreate"), children: "Create new item" })
6798
6789
  ] })
6799
6790
  ] })
@@ -40,7 +40,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
40
40
  );
41
41
  });
42
42
  };
43
- const version = "0.1.5";
43
+ const version = "0.2.0";
44
44
  const keywords = [];
45
45
  const type = "commonjs";
46
46
  const exports$1 = {
@@ -207,10 +207,9 @@ function useApi() {
207
207
  throw err;
208
208
  }
209
209
  };
210
- const getRouteByRelated = async (relatedDocumentId, populate) => {
211
- const { data } = await get(`/content-manager/collection-types/plugin::webatlas.route?filters[relatedDocumentId][$eq]=${relatedDocumentId}${populate ? "&populate" + populate : ""}`);
212
- if (data?.results) return data.results[0];
213
- return null;
210
+ const getRelatedRoute = async (relatedDocumentId) => {
211
+ const { data } = await get(`/webatlas/route/related?documentId=${relatedDocumentId}`);
212
+ return data;
214
213
  };
215
214
  const createExternalRoute = async (body) => {
216
215
  const { data } = await post("/webatlas/route/external", {
@@ -266,7 +265,20 @@ function useApi() {
266
265
  });
267
266
  return data;
268
267
  };
269
- return { fetchAllContentTypes, fetchAllEntities, getRouteByRelated, createExternalRoute, getRoutes, updateRoute, createNavItem, updateNavItem, deleteNavItem, getStructuredNavigation, deleteNavigation, updateNavigation };
268
+ return {
269
+ fetchAllContentTypes,
270
+ fetchAllEntities,
271
+ getRelatedRoute,
272
+ createExternalRoute,
273
+ getRoutes,
274
+ updateRoute,
275
+ createNavItem,
276
+ updateNavItem,
277
+ deleteNavItem,
278
+ getStructuredNavigation,
279
+ deleteNavigation,
280
+ updateNavigation
281
+ };
270
282
  }
271
283
  const useAllContentTypes = () => {
272
284
  const { fetchAllContentTypes } = useApi();
@@ -3721,7 +3733,7 @@ function reducer(state, action) {
3721
3733
  const Alias = ({ config }) => {
3722
3734
  const { layout, form } = admin.unstable_useContentManagerContext();
3723
3735
  const { initialValues, values, onChange } = form;
3724
- const { getRouteByRelated } = useApi();
3736
+ const { getRelatedRoute } = useApi();
3725
3737
  const [routeId, setRouteId] = React.useState();
3726
3738
  const [isOverride, setIsOverride] = React.useState(false);
3727
3739
  const [validationState, setValidationState] = React.useState("initial");
@@ -3788,7 +3800,7 @@ const Alias = ({ config }) => {
3788
3800
  return;
3789
3801
  }
3790
3802
  try {
3791
- const route = await getRouteByRelated(initialValues.documentId);
3803
+ const route = await getRelatedRoute(initialValues.documentId);
3792
3804
  if (!route) return;
3793
3805
  initialPath.current = initialValues.webatlas_path || route.uIdPath;
3794
3806
  setRouteId(route.id);
@@ -3946,24 +3958,23 @@ const CMEditViewAside = () => {
3946
3958
  setIsLoading(false);
3947
3959
  }, [config]);
3948
3960
  React.useEffect(() => {
3949
- const label = Array.from(document.querySelectorAll("label")).find((l) => l.textContent?.startsWith("webatlas_path"));
3950
- if (label) {
3951
- let parentDiv = label.closest("div");
3952
- for (let i = 0; i < 2; i++) {
3953
- if (parentDiv) {
3954
- parentDiv = parentDiv.parentElement;
3955
- }
3956
- }
3957
- if (parentDiv) {
3958
- const grandParentDiv = parentDiv.parentElement;
3959
- if (grandParentDiv && grandParentDiv.children.length === 1) {
3960
- grandParentDiv.parentElement?.remove();
3961
- return;
3962
- } else {
3963
- parentDiv.remove();
3964
- }
3961
+ const isWebatlasLabel = (label) => label.textContent?.startsWith("webatlas_");
3962
+ document.querySelectorAll("label").forEach((label) => {
3963
+ if (!isWebatlasLabel(label)) return;
3964
+ const container = label.parentElement?.parentElement;
3965
+ const parent = container?.parentElement;
3966
+ const greatGrandParent = parent?.parentElement?.parentElement;
3967
+ if (!container || !parent) return;
3968
+ const parentWebatlasCount = Array.from(parent.querySelectorAll("label")).filter(isWebatlasLabel).length;
3969
+ const childrenCount = parent.children.length;
3970
+ if (greatGrandParent && greatGrandParent?.querySelectorAll("label").length === Array.from(greatGrandParent.querySelectorAll("label")).filter(isWebatlasLabel).length) {
3971
+ greatGrandParent.remove();
3972
+ } else if (childrenCount === 1 || childrenCount === 2 && parentWebatlasCount === 2) {
3973
+ parent.remove();
3974
+ } else {
3975
+ container.remove();
3965
3976
  }
3966
- }
3977
+ });
3967
3978
  }, []);
3968
3979
  if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: "Loading..." });
3969
3980
  if (!isAllowedContentType) return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { textColor: "neutral600", children: [
@@ -3990,7 +4001,7 @@ const index = {
3990
4001
  defaultMessage: "Routes"
3991
4002
  },
3992
4003
  Component: async () => {
3993
- const component = await Promise.resolve().then(() => require("./index-DDVtOWSL.js"));
4004
+ const component = await Promise.resolve().then(() => require("./index-CAlXW6_S.js"));
3994
4005
  return { default: component.default };
3995
4006
  },
3996
4007
  permissions: [
@@ -4009,7 +4020,7 @@ const index = {
4009
4020
  defaultMessage: "Navigation"
4010
4021
  },
4011
4022
  Component: async () => {
4012
- const component = await Promise.resolve().then(() => require("./index-B3GOkpFO.js"));
4023
+ const component = await Promise.resolve().then(() => require("./index-BT4o9vnc.js"));
4013
4024
  return { default: component.default };
4014
4025
  },
4015
4026
  permissions: [
@@ -4038,7 +4049,7 @@ const index = {
4038
4049
  Component: async () => {
4039
4050
  return await Promise.resolve().then(() => require(
4040
4051
  /* webpackChunkName: "webatlas-settings-page" */
4041
- "./index-q4x-lnlr.js"
4052
+ "./index-D5cVtbqb.js"
4042
4053
  ));
4043
4054
  },
4044
4055
  permissions: [
@@ -22,7 +22,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
22
22
  );
23
23
  });
24
24
  };
25
- const version = "0.1.5";
25
+ const version = "0.2.0";
26
26
  const keywords = [];
27
27
  const type = "commonjs";
28
28
  const exports = {
@@ -189,10 +189,9 @@ function useApi() {
189
189
  throw err;
190
190
  }
191
191
  };
192
- const getRouteByRelated = async (relatedDocumentId, populate) => {
193
- const { data } = await get(`/content-manager/collection-types/plugin::webatlas.route?filters[relatedDocumentId][$eq]=${relatedDocumentId}${populate ? "&populate" + populate : ""}`);
194
- if (data?.results) return data.results[0];
195
- return null;
192
+ const getRelatedRoute = async (relatedDocumentId) => {
193
+ const { data } = await get(`/webatlas/route/related?documentId=${relatedDocumentId}`);
194
+ return data;
196
195
  };
197
196
  const createExternalRoute = async (body) => {
198
197
  const { data } = await post("/webatlas/route/external", {
@@ -248,7 +247,20 @@ function useApi() {
248
247
  });
249
248
  return data;
250
249
  };
251
- return { fetchAllContentTypes, fetchAllEntities, getRouteByRelated, createExternalRoute, getRoutes, updateRoute, createNavItem, updateNavItem, deleteNavItem, getStructuredNavigation, deleteNavigation, updateNavigation };
250
+ return {
251
+ fetchAllContentTypes,
252
+ fetchAllEntities,
253
+ getRelatedRoute,
254
+ createExternalRoute,
255
+ getRoutes,
256
+ updateRoute,
257
+ createNavItem,
258
+ updateNavItem,
259
+ deleteNavItem,
260
+ getStructuredNavigation,
261
+ deleteNavigation,
262
+ updateNavigation
263
+ };
252
264
  }
253
265
  const useAllContentTypes = () => {
254
266
  const { fetchAllContentTypes } = useApi();
@@ -3703,7 +3715,7 @@ function reducer(state, action) {
3703
3715
  const Alias = ({ config }) => {
3704
3716
  const { layout, form } = unstable_useContentManagerContext();
3705
3717
  const { initialValues, values, onChange } = form;
3706
- const { getRouteByRelated } = useApi();
3718
+ const { getRelatedRoute } = useApi();
3707
3719
  const [routeId, setRouteId] = useState();
3708
3720
  const [isOverride, setIsOverride] = useState(false);
3709
3721
  const [validationState, setValidationState] = useState("initial");
@@ -3770,7 +3782,7 @@ const Alias = ({ config }) => {
3770
3782
  return;
3771
3783
  }
3772
3784
  try {
3773
- const route = await getRouteByRelated(initialValues.documentId);
3785
+ const route = await getRelatedRoute(initialValues.documentId);
3774
3786
  if (!route) return;
3775
3787
  initialPath.current = initialValues.webatlas_path || route.uIdPath;
3776
3788
  setRouteId(route.id);
@@ -3928,24 +3940,23 @@ const CMEditViewAside = () => {
3928
3940
  setIsLoading(false);
3929
3941
  }, [config]);
3930
3942
  useEffect(() => {
3931
- const label = Array.from(document.querySelectorAll("label")).find((l) => l.textContent?.startsWith("webatlas_path"));
3932
- if (label) {
3933
- let parentDiv = label.closest("div");
3934
- for (let i = 0; i < 2; i++) {
3935
- if (parentDiv) {
3936
- parentDiv = parentDiv.parentElement;
3937
- }
3938
- }
3939
- if (parentDiv) {
3940
- const grandParentDiv = parentDiv.parentElement;
3941
- if (grandParentDiv && grandParentDiv.children.length === 1) {
3942
- grandParentDiv.parentElement?.remove();
3943
- return;
3944
- } else {
3945
- parentDiv.remove();
3946
- }
3943
+ const isWebatlasLabel = (label) => label.textContent?.startsWith("webatlas_");
3944
+ document.querySelectorAll("label").forEach((label) => {
3945
+ if (!isWebatlasLabel(label)) return;
3946
+ const container = label.parentElement?.parentElement;
3947
+ const parent = container?.parentElement;
3948
+ const greatGrandParent = parent?.parentElement?.parentElement;
3949
+ if (!container || !parent) return;
3950
+ const parentWebatlasCount = Array.from(parent.querySelectorAll("label")).filter(isWebatlasLabel).length;
3951
+ const childrenCount = parent.children.length;
3952
+ if (greatGrandParent && greatGrandParent?.querySelectorAll("label").length === Array.from(greatGrandParent.querySelectorAll("label")).filter(isWebatlasLabel).length) {
3953
+ greatGrandParent.remove();
3954
+ } else if (childrenCount === 1 || childrenCount === 2 && parentWebatlasCount === 2) {
3955
+ parent.remove();
3956
+ } else {
3957
+ container.remove();
3947
3958
  }
3948
- }
3959
+ });
3949
3960
  }, []);
3950
3961
  if (isLoading) return /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: "Loading..." });
3951
3962
  if (!isAllowedContentType) return /* @__PURE__ */ jsxs(Typography, { textColor: "neutral600", children: [
@@ -3972,7 +3983,7 @@ const index = {
3972
3983
  defaultMessage: "Routes"
3973
3984
  },
3974
3985
  Component: async () => {
3975
- const component = await import("./index-BoTOXEX8.mjs");
3986
+ const component = await import("./index-LJwFh2n8.mjs");
3976
3987
  return { default: component.default };
3977
3988
  },
3978
3989
  permissions: [
@@ -3991,7 +4002,7 @@ const index = {
3991
4002
  defaultMessage: "Navigation"
3992
4003
  },
3993
4004
  Component: async () => {
3994
- const component = await import("./index-DL3LkD8O.mjs");
4005
+ const component = await import("./index-Gjc_lPTF.mjs");
3995
4006
  return { default: component.default };
3996
4007
  },
3997
4008
  permissions: [
@@ -4020,7 +4031,7 @@ const index = {
4020
4031
  Component: async () => {
4021
4032
  return await import(
4022
4033
  /* webpackChunkName: "webatlas-settings-page" */
4023
- "./index-DWbEC3_A.mjs"
4034
+ "./index-DKdReNuu.mjs"
4024
4035
  );
4025
4036
  },
4026
4037
  permissions: [
@@ -5,7 +5,8 @@ const React = require("react");
5
5
  const admin = require("@strapi/strapi/admin");
6
6
  const designSystem = require("@strapi/design-system");
7
7
  const icons = require("@strapi/icons");
8
- const index = require("./index-DfHrvxDY.js");
8
+ const index = require("./index-C1dDrhfb.js");
9
+ const EmptyBox = require("./EmptyBox-DT6D5gcf.js");
9
10
  const Routes = () => {
10
11
  const { getRoutes } = index.useApi();
11
12
  const [routes, setRoutes] = React.useState([]);
@@ -24,22 +25,18 @@ const Routes = () => {
24
25
  subtitle: "Overview of all existing routes"
25
26
  }
26
27
  ),
27
- /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 6, rowCount: routes.length, children: [
28
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: routes.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.Center, { height: 400, children: /* @__PURE__ */ jsxRuntime.jsx(EmptyBox.EmptyBox, { msg: "No routes found" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 4, rowCount: routes.length, children: [
28
29
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
29
30
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "ID" }) }),
30
31
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Title" }) }),
31
32
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Route" }) }),
32
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Internal" }) }),
33
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: "Active" }) }),
34
33
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: "Actions" }) })
35
34
  ] }) }),
36
35
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.map((route) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
37
36
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.id }) }),
38
37
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.title }) }),
39
38
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.fullPath }) }),
40
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.internal ? "Yes" : "No" }) }),
41
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: route.active ? "Yes" : "No" }) }),
42
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}), href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedId}`, children: "Edit" }) }) })
39
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.LinkButton, { variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}), href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`, children: "Edit" }) }) })
43
40
  ] }, route.id)) })
44
41
  ] }) })
45
42
  ] });
@@ -11,7 +11,7 @@ const reactIntl = require("react-intl");
11
11
  require("@strapi/icons/symbols");
12
12
  const ReactDOM = require("react-dom");
13
13
  const styledComponents = require("styled-components");
14
- const index = require("./index-DfHrvxDY.js");
14
+ const index = require("./index-C1dDrhfb.js");
15
15
  const _interopDefault = (e2) => e2 && e2.__esModule ? e2 : { default: e2 };
16
16
  function _interopNamespace(e2) {
17
17
  if (e2 && e2.__esModule) return e2;
@@ -10,7 +10,7 @@ import { useIntl } from "react-intl";
10
10
  import "@strapi/icons/symbols";
11
11
  import ReactDOM__default, { unstable_batchedUpdates as unstable_batchedUpdates$1 } from "react-dom";
12
12
  import { createGlobalStyle, styled } from "styled-components";
13
- import { _ as _extends$4, b as usePluginConfig, c as useAllContentTypes, t as transformToUrl, T as Tooltip } from "./index-lOv9Po4g.mjs";
13
+ import { _ as _extends$4, b as usePluginConfig, c as useAllContentTypes, t as transformToUrl, T as Tooltip } from "./index-C4lB5G1F.mjs";
14
14
  var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
15
15
  var _freeGlobal = freeGlobal$1;
16
16
  var freeGlobal = _freeGlobal;
@@ -4,9 +4,9 @@ import { Dialog, Typography, Button, Modal, Flex, SingleSelect, SingleSelectOpti
4
4
  import { useFetchClient, Layouts } from "@strapi/strapi/admin";
5
5
  import { useState, useEffect, createContext, useRef, useContext, useReducer, useCallback, useMemo, forwardRef } from "react";
6
6
  import { createPortal } from "react-dom";
7
- import { u as useApi, d as debounce, a as duplicateCheck, t as transformToUrl, U as URLInfo } from "./index-lOv9Po4g.mjs";
7
+ import { u as useApi, d as debounce, a as duplicateCheck, t as transformToUrl, U as URLInfo } from "./index-C4lB5G1F.mjs";
8
+ import { C as Center, E as EmptyBox } from "./EmptyBox-7D4LrvdH.mjs";
8
9
  import { c as commonjsGlobal } from "./_commonjsHelpers-BxmBWJD2.mjs";
9
- import { EmptyDocuments } from "@strapi/icons/symbols";
10
10
  import { MeasuringStrategy, DndContext, closestCenter, DragOverlay } from "@dnd-kit/core";
11
11
  import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
12
12
  import { CSS } from "@dnd-kit/utilities";
@@ -227,9 +227,6 @@ function NavEdit({ item, fetchNavigations }) {
227
227
  }
228
228
  );
229
229
  }
230
- function Center({ height = 400, children }) {
231
- return /* @__PURE__ */ jsx(Flex, { direction: "column", minHeight: `${height}px`, justifyContent: "center", children });
232
- }
233
230
  function NavOverview({ navigations, setActionItem }) {
234
231
  const { setModalType } = useContext(ModalContext);
235
232
  const { selectedNavigation, setSelectedNavigation } = useContext(SelectedNavigationContext);
@@ -331,7 +328,7 @@ function useModalSharedLogic() {
331
328
  const [replacement, setReplacement] = useState("");
332
329
  const [validationState, setValidationState] = useState("initial");
333
330
  const { entities } = useAllEntities();
334
- const { createNavItem, updateRoute, getRouteByRelated, createExternalRoute } = useApi();
331
+ const { createNavItem, updateRoute, getRelatedRoute, createExternalRoute } = useApi();
335
332
  const initialState = useRef({
336
333
  title: "",
337
334
  slug: "",
@@ -372,7 +369,7 @@ function useModalSharedLogic() {
372
369
  createNavItem,
373
370
  createExternalRoute,
374
371
  updateRoute,
375
- getRouteByRelated,
372
+ getRelatedRoute,
376
373
  replacement,
377
374
  setReplacement,
378
375
  validationState,
@@ -496,7 +493,7 @@ function ItemCreateComponent({
496
493
  entities,
497
494
  createNavItem,
498
495
  updateRoute,
499
- getRouteByRelated,
496
+ getRelatedRoute,
500
497
  replacement,
501
498
  validationState,
502
499
  initialState,
@@ -525,7 +522,7 @@ function ItemCreateComponent({
525
522
  async function fetchRoute() {
526
523
  if (selectedContentType?.contentType && selectedEntity?.id) {
527
524
  try {
528
- const route = await getRouteByRelated(selectedEntity.documentId);
525
+ const route = await getRelatedRoute(selectedEntity.documentId);
529
526
  if (!route) return;
530
527
  dispatchPath({ type: "NO_URL_CHECK", payload: route.fullPath });
531
528
  dispatchPath({ type: "SET_UIDPATH", payload: route.uidPath });
@@ -6367,12 +6364,6 @@ function WrapperItemComponent({
6367
6364
  );
6368
6365
  }
6369
6366
  const WrapperItem = withModalSharedLogic(WrapperItemComponent);
6370
- function EmptyNav({ msg }) {
6371
- return /* @__PURE__ */ jsxs(Fragment, { children: [
6372
- /* @__PURE__ */ jsx(EmptyDocuments, { width: "10rem", height: "6rem" }),
6373
- /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", textColor: "neutral600", children: msg }) })
6374
- ] });
6375
- }
6376
6367
  function Header({ navigations }) {
6377
6368
  const { setModalType } = useContext(ModalContext);
6378
6369
  const { selectedNavigation, setSelectedNavigation } = useContext(SelectedNavigationContext);
@@ -6787,11 +6778,11 @@ const Navigation = () => {
6787
6778
  }
6788
6779
  ) }),
6789
6780
  navigations?.length === 0 && /* @__PURE__ */ jsxs(Center, { height: 400, children: [
6790
- /* @__PURE__ */ jsx(EmptyNav, { msg: "You have no navigations yet..." }),
6781
+ /* @__PURE__ */ jsx(EmptyBox, { msg: "You have no navigations yet..." }),
6791
6782
  /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => setModalType("NavCreate"), children: "Create new Navigation" })
6792
6783
  ] }),
6793
6784
  navigationItems?.length === 0 && /* @__PURE__ */ jsxs(Center, { height: 400, children: [
6794
- /* @__PURE__ */ jsx(EmptyNav, { msg: "Your navigation is empty..." }),
6785
+ /* @__PURE__ */ jsx(EmptyBox, { msg: "Your navigation is empty..." }),
6795
6786
  /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => setModalType("ItemCreate"), children: "Create new item" })
6796
6787
  ] })
6797
6788
  ] })
@@ -3,7 +3,8 @@ import { useState, useEffect } from "react";
3
3
  import { Layouts } from "@strapi/strapi/admin";
4
4
  import { Table, Thead, Tr, Th, Typography, VisuallyHidden, Tbody, Td, Flex, LinkButton } from "@strapi/design-system";
5
5
  import { Pencil } from "@strapi/icons";
6
- import { u as useApi } from "./index-lOv9Po4g.mjs";
6
+ import { u as useApi } from "./index-C4lB5G1F.mjs";
7
+ import { C as Center, E as EmptyBox } from "./EmptyBox-7D4LrvdH.mjs";
7
8
  const Routes = () => {
8
9
  const { getRoutes } = useApi();
9
10
  const [routes, setRoutes] = useState([]);
@@ -22,22 +23,18 @@ const Routes = () => {
22
23
  subtitle: "Overview of all existing routes"
23
24
  }
24
25
  ),
25
- /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsxs(Table, { colCount: 6, rowCount: routes.length, children: [
26
+ /* @__PURE__ */ jsx(Layouts.Content, { children: routes.length === 0 ? /* @__PURE__ */ jsx(Center, { height: 400, children: /* @__PURE__ */ jsx(EmptyBox, { msg: "No routes found" }) }) : /* @__PURE__ */ jsxs(Table, { colCount: 4, rowCount: routes.length, children: [
26
27
  /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
27
28
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "ID" }) }),
28
29
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Title" }) }),
29
30
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Route" }) }),
30
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Internal" }) }),
31
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: "Active" }) }),
32
31
  /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: "Actions" }) })
33
32
  ] }) }),
34
33
  /* @__PURE__ */ jsx(Tbody, { children: routes.map((route) => /* @__PURE__ */ jsxs(Tr, { children: [
35
34
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.id }) }),
36
35
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.title }) }),
37
36
  /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.fullPath }) }),
38
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.internal ? "Yes" : "No" }) }),
39
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: route.active ? "Yes" : "No" }) }),
40
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: /* @__PURE__ */ jsx(LinkButton, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(Pencil, {}), href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedId}`, children: "Edit" }) }) })
37
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: /* @__PURE__ */ jsx(LinkButton, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(Pencil, {}), href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`, children: "Edit" }) }) })
41
38
  ] }, route.id)) })
42
39
  ] }) })
43
40
  ] });
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-DfHrvxDY.js");
2
+ const index = require("../_chunks/index-C1dDrhfb.js");
3
3
  require("react/jsx-runtime");
4
4
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-lOv9Po4g.mjs";
1
+ import { i } from "../_chunks/index-C4lB5G1F.mjs";
2
2
  import "react/jsx-runtime";
3
3
  export {
4
4
  i as default
@@ -1,5 +1,5 @@
1
1
  type EmptyNavProps = {
2
2
  msg: string;
3
3
  };
4
- export default function EmptyNav({ msg }: EmptyNavProps): import("react/jsx-runtime").JSX.Element;
4
+ export default function EmptyBox({ msg }: EmptyNavProps): import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -0,0 +1,3 @@
1
+ import Center from "./Center";
2
+ import EmptyBox from "./EmptyBox";
3
+ export { Center, EmptyBox, };
@@ -2,7 +2,7 @@ import { GroupedEntities, RouteSettings, NavItemSettings, ConfigContentType, Str
2
2
  export default function useApi(): {
3
3
  fetchAllContentTypes: () => Promise<any>;
4
4
  fetchAllEntities: (contentTypes?: ConfigContentType[]) => Promise<GroupedEntities[]>;
5
- getRouteByRelated: (relatedDocumentId: string, populate?: string) => Promise<any>;
5
+ getRelatedRoute: (relatedDocumentId: string) => Promise<any>;
6
6
  createExternalRoute: (body: RouteSettings) => Promise<any>;
7
7
  getRoutes: () => Promise<any>;
8
8
  updateRoute: (body: RouteSettings, documentId: string) => Promise<any>;
@@ -20,7 +20,7 @@ function transformToUrl(input) {
20
20
  input = input.replace(/-+/g, "-");
21
21
  return input;
22
22
  }
23
- const version = "0.1.5";
23
+ const version = "0.2.0";
24
24
  const keywords = [];
25
25
  const type = "commonjs";
26
26
  const exports$1 = {
@@ -1105,6 +1105,16 @@ const admin$2 = () => ({
1105
1105
  return ctx.throw(500, e);
1106
1106
  }
1107
1107
  },
1108
+ async updateRoute(ctx) {
1109
+ try {
1110
+ const { documentId } = ctx.query;
1111
+ if (!documentId) return ctx.throw(400, "Route documentId is required");
1112
+ const { data } = ctx.request.body;
1113
+ return await getAdminService().updateRoute(documentId, data);
1114
+ } catch (e) {
1115
+ return ctx.throw(500, e);
1116
+ }
1117
+ },
1108
1118
  async createExternalRoute(ctx) {
1109
1119
  try {
1110
1120
  const { data } = ctx.request.body;
@@ -1115,12 +1125,11 @@ const admin$2 = () => ({
1115
1125
  return ctx.throw(500, e);
1116
1126
  }
1117
1127
  },
1118
- async updateRoute(ctx) {
1128
+ async getRelatedRoute(ctx) {
1119
1129
  try {
1120
1130
  const { documentId } = ctx.query;
1121
1131
  if (!documentId) return ctx.throw(400, "Route documentId is required");
1122
- const { data } = ctx.request.body;
1123
- return await getAdminService().updateRoute(documentId, data);
1132
+ return await getAdminService().getRelatedRoute(documentId);
1124
1133
  } catch (e) {
1125
1134
  return ctx.throw(500, e);
1126
1135
  }
@@ -1200,9 +1209,9 @@ const admin$2 = () => ({
1200
1209
  const client$2 = ({ strapi: strapi2 }) => ({
1201
1210
  async getEntityByPath(ctx) {
1202
1211
  try {
1203
- const { slug, populate, populateDeepDepth, fields } = ctx.query;
1212
+ const { slug, populate, populateDeepDepth, fields, status } = ctx.query;
1204
1213
  if (!slug) return ctx.throw(400, "Slug is required");
1205
- const entity = await getClientService().getEntityByPath(slug, populate, populateDeepDepth, fields);
1214
+ const entity = await getClientService().getEntityByPath(slug, populate, populateDeepDepth, fields, status);
1206
1215
  if (!entity) return ctx.throw(404, "Entity not found");
1207
1216
  return ctx.send(entity);
1208
1217
  } catch (e) {
@@ -1257,6 +1266,15 @@ const admin$1 = {
1257
1266
  auth: false
1258
1267
  }
1259
1268
  },
1269
+ {
1270
+ method: "PUT",
1271
+ path: "/route",
1272
+ handler: "admin.updateRoute",
1273
+ config: {
1274
+ policies: [],
1275
+ auth: false
1276
+ }
1277
+ },
1260
1278
  {
1261
1279
  method: "POST",
1262
1280
  path: "/route/external",
@@ -1267,9 +1285,9 @@ const admin$1 = {
1267
1285
  }
1268
1286
  },
1269
1287
  {
1270
- method: "PUT",
1271
- path: "/route",
1272
- handler: "admin.updateRoute",
1288
+ method: "GET",
1289
+ path: "/route/related",
1290
+ handler: "admin.getRelatedRoute",
1273
1291
  config: {
1274
1292
  policies: [],
1275
1293
  auth: false
@@ -1606,6 +1624,28 @@ const admin = ({ strapi: strapi2 }) => ({
1606
1624
  console.log(e);
1607
1625
  }
1608
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
+ },
1609
1649
  async createExternalRoute(data) {
1610
1650
  try {
1611
1651
  return await strapi2.documents(waRoute).create({
@@ -1625,24 +1665,13 @@ const admin = ({ strapi: strapi2 }) => ({
1625
1665
  console.log(e);
1626
1666
  }
1627
1667
  },
1628
- async updateRoute(documentId, data) {
1668
+ async getRelatedRoute(documentId) {
1629
1669
  try {
1630
- let checkedPath = data.fullPath;
1631
- if (data.internal) {
1632
- const parent = data.parent ? await strapi2.documents(waNavItem).findOne({
1633
- documentId: data.parent
1634
- }) : null;
1635
- const fullPath = data.isOverride ? data.slug : getFullPath(parent?.fullPath, data.slug);
1636
- checkedPath = await duplicateCheck(fullPath, documentId);
1637
- }
1638
- const entity = await strapi2.documents(waRoute).update({
1639
- documentId,
1640
- data: {
1641
- ...data,
1642
- fullPath: checkedPath
1670
+ return await strapi2.db?.query(waRoute).findOne({
1671
+ where: {
1672
+ relatedDocumentId: documentId
1643
1673
  }
1644
1674
  });
1645
- return entity;
1646
1675
  } catch (e) {
1647
1676
  console.log(e);
1648
1677
  }
@@ -1770,14 +1799,14 @@ const admin = ({ strapi: strapi2 }) => ({
1770
1799
  }
1771
1800
  });
1772
1801
  const client = ({ strapi: strapi2 }) => ({
1773
- async getEntityByPath(slug, populate, populateDeepDepth, fields) {
1802
+ async getEntityByPath(slug, populate, populateDeepDepth, fields, status = "published") {
1774
1803
  try {
1775
- const route2 = await strapi2.db?.query(waRoute).findOne({
1804
+ const route2 = await strapi2.documents(waRoute).findFirst({
1776
1805
  filters: {
1777
1806
  $or: [
1778
1807
  { fullPath: slug },
1779
- { slug },
1780
- { uidPath: slug }
1808
+ { uidPath: slug },
1809
+ { documentIdPath: slug }
1781
1810
  ]
1782
1811
  }
1783
1812
  });
@@ -1797,7 +1826,8 @@ const client = ({ strapi: strapi2 }) => ({
1797
1826
  const entity = await strapi2.documents(route2.relatedContentType).findOne({
1798
1827
  documentId: route2.documentIdPath,
1799
1828
  populate: populateObject,
1800
- fields
1829
+ fields,
1830
+ status
1801
1831
  });
1802
1832
  if (!entity) return null;
1803
1833
  let cleanEntity = cleanRootKeys(entity);
@@ -19,7 +19,7 @@ function transformToUrl(input) {
19
19
  input = input.replace(/-+/g, "-");
20
20
  return input;
21
21
  }
22
- const version = "0.1.5";
22
+ const version = "0.2.0";
23
23
  const keywords = [];
24
24
  const type = "commonjs";
25
25
  const exports = {
@@ -1104,6 +1104,16 @@ const admin$2 = () => ({
1104
1104
  return ctx.throw(500, e);
1105
1105
  }
1106
1106
  },
1107
+ async updateRoute(ctx) {
1108
+ try {
1109
+ const { documentId } = ctx.query;
1110
+ if (!documentId) return ctx.throw(400, "Route documentId is required");
1111
+ const { data } = ctx.request.body;
1112
+ return await getAdminService().updateRoute(documentId, data);
1113
+ } catch (e) {
1114
+ return ctx.throw(500, e);
1115
+ }
1116
+ },
1107
1117
  async createExternalRoute(ctx) {
1108
1118
  try {
1109
1119
  const { data } = ctx.request.body;
@@ -1114,12 +1124,11 @@ const admin$2 = () => ({
1114
1124
  return ctx.throw(500, e);
1115
1125
  }
1116
1126
  },
1117
- async updateRoute(ctx) {
1127
+ async getRelatedRoute(ctx) {
1118
1128
  try {
1119
1129
  const { documentId } = ctx.query;
1120
1130
  if (!documentId) return ctx.throw(400, "Route documentId is required");
1121
- const { data } = ctx.request.body;
1122
- return await getAdminService().updateRoute(documentId, data);
1131
+ return await getAdminService().getRelatedRoute(documentId);
1123
1132
  } catch (e) {
1124
1133
  return ctx.throw(500, e);
1125
1134
  }
@@ -1199,9 +1208,9 @@ const admin$2 = () => ({
1199
1208
  const client$2 = ({ strapi: strapi2 }) => ({
1200
1209
  async getEntityByPath(ctx) {
1201
1210
  try {
1202
- const { slug, populate, populateDeepDepth, fields } = ctx.query;
1211
+ const { slug, populate, populateDeepDepth, fields, status } = ctx.query;
1203
1212
  if (!slug) return ctx.throw(400, "Slug is required");
1204
- const entity = await getClientService().getEntityByPath(slug, populate, populateDeepDepth, fields);
1213
+ const entity = await getClientService().getEntityByPath(slug, populate, populateDeepDepth, fields, status);
1205
1214
  if (!entity) return ctx.throw(404, "Entity not found");
1206
1215
  return ctx.send(entity);
1207
1216
  } catch (e) {
@@ -1256,6 +1265,15 @@ const admin$1 = {
1256
1265
  auth: false
1257
1266
  }
1258
1267
  },
1268
+ {
1269
+ method: "PUT",
1270
+ path: "/route",
1271
+ handler: "admin.updateRoute",
1272
+ config: {
1273
+ policies: [],
1274
+ auth: false
1275
+ }
1276
+ },
1259
1277
  {
1260
1278
  method: "POST",
1261
1279
  path: "/route/external",
@@ -1266,9 +1284,9 @@ const admin$1 = {
1266
1284
  }
1267
1285
  },
1268
1286
  {
1269
- method: "PUT",
1270
- path: "/route",
1271
- handler: "admin.updateRoute",
1287
+ method: "GET",
1288
+ path: "/route/related",
1289
+ handler: "admin.getRelatedRoute",
1272
1290
  config: {
1273
1291
  policies: [],
1274
1292
  auth: false
@@ -1605,6 +1623,28 @@ const admin = ({ strapi: strapi2 }) => ({
1605
1623
  console.log(e);
1606
1624
  }
1607
1625
  },
1626
+ async updateRoute(documentId, data) {
1627
+ try {
1628
+ let checkedPath = data.fullPath;
1629
+ if (data.internal) {
1630
+ const parent = data.parent ? await strapi2.documents(waNavItem).findOne({
1631
+ documentId: data.parent
1632
+ }) : null;
1633
+ const fullPath = data.isOverride ? data.slug : getFullPath(parent?.fullPath, data.slug);
1634
+ checkedPath = await duplicateCheck(fullPath, documentId);
1635
+ }
1636
+ const entity = await strapi2.documents(waRoute).update({
1637
+ documentId,
1638
+ data: {
1639
+ ...data,
1640
+ fullPath: checkedPath
1641
+ }
1642
+ });
1643
+ return entity;
1644
+ } catch (e) {
1645
+ console.log(e);
1646
+ }
1647
+ },
1608
1648
  async createExternalRoute(data) {
1609
1649
  try {
1610
1650
  return await strapi2.documents(waRoute).create({
@@ -1624,24 +1664,13 @@ const admin = ({ strapi: strapi2 }) => ({
1624
1664
  console.log(e);
1625
1665
  }
1626
1666
  },
1627
- async updateRoute(documentId, data) {
1667
+ async getRelatedRoute(documentId) {
1628
1668
  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
1669
+ return await strapi2.db?.query(waRoute).findOne({
1670
+ where: {
1671
+ relatedDocumentId: documentId
1642
1672
  }
1643
1673
  });
1644
- return entity;
1645
1674
  } catch (e) {
1646
1675
  console.log(e);
1647
1676
  }
@@ -1769,14 +1798,14 @@ const admin = ({ strapi: strapi2 }) => ({
1769
1798
  }
1770
1799
  });
1771
1800
  const client = ({ strapi: strapi2 }) => ({
1772
- async getEntityByPath(slug, populate, populateDeepDepth, fields) {
1801
+ async getEntityByPath(slug, populate, populateDeepDepth, fields, status = "published") {
1773
1802
  try {
1774
- const route2 = await strapi2.db?.query(waRoute).findOne({
1803
+ const route2 = await strapi2.documents(waRoute).findFirst({
1775
1804
  filters: {
1776
1805
  $or: [
1777
1806
  { fullPath: slug },
1778
- { slug },
1779
- { uidPath: slug }
1807
+ { uidPath: slug },
1808
+ { documentIdPath: slug }
1780
1809
  ]
1781
1810
  }
1782
1811
  });
@@ -1796,7 +1825,8 @@ const client = ({ strapi: strapi2 }) => ({
1796
1825
  const entity = await strapi2.documents(route2.relatedContentType).findOne({
1797
1826
  documentId: route2.documentIdPath,
1798
1827
  populate: populateObject,
1799
- fields
1828
+ fields,
1829
+ status
1800
1830
  });
1801
1831
  if (!entity) return null;
1802
1832
  let cleanEntity = cleanRootKeys(entity);
@@ -2,8 +2,9 @@ declare const admin: () => {
2
2
  updateConfig(ctx: any): Promise<any>;
3
3
  getConfig(ctx: any): Promise<any>;
4
4
  getRoutes(ctx: any): Promise<any>;
5
- createExternalRoute(ctx: any): Promise<any>;
6
5
  updateRoute(ctx: any): Promise<any>;
6
+ createExternalRoute(ctx: any): Promise<any>;
7
+ getRelatedRoute(ctx: any): Promise<any>;
7
8
  getNavigation(ctx: any): Promise<any>;
8
9
  createNavigation(ctx: any): Promise<any>;
9
10
  updateNavigation(ctx: any): Promise<any>;
@@ -3,8 +3,9 @@ declare const _default: {
3
3
  updateConfig(ctx: any): Promise<any>;
4
4
  getConfig(ctx: any): Promise<any>;
5
5
  getRoutes(ctx: any): Promise<any>;
6
- createExternalRoute(ctx: any): Promise<any>;
7
6
  updateRoute(ctx: any): Promise<any>;
7
+ createExternalRoute(ctx: any): Promise<any>;
8
+ getRelatedRoute(ctx: any): Promise<any>;
8
9
  getNavigation(ctx: any): Promise<any>;
9
10
  createNavigation(ctx: any): Promise<any>;
10
11
  updateNavigation(ctx: any): Promise<any>;
@@ -17,8 +17,9 @@ declare const _default: {
17
17
  updateConfig(ctx: any): Promise<any>;
18
18
  getConfig(ctx: any): Promise<any>;
19
19
  getRoutes(ctx: any): Promise<any>;
20
- createExternalRoute(ctx: any): Promise<any>;
21
20
  updateRoute(ctx: any): Promise<any>;
21
+ createExternalRoute(ctx: any): Promise<any>;
22
+ getRelatedRoute(ctx: any): Promise<any>;
22
23
  getNavigation(ctx: any): Promise<any>;
23
24
  createNavigation(ctx: any): Promise<any>;
24
25
  updateNavigation(ctx: any): Promise<any>;
@@ -67,8 +68,9 @@ declare const _default: {
67
68
  updateConfig(newConfig: any): Promise<string>;
68
69
  getConfig(): Promise<any>;
69
70
  getRoutes(): Promise<any>;
70
- createExternalRoute(data: any): Promise<any>;
71
71
  updateRoute(documentId: string, data: any): Promise<any>;
72
+ createExternalRoute(data: any): Promise<any>;
73
+ getRelatedRoute(documentId: string): Promise<any>;
72
74
  getNavigation(documentId?: string, variant?: import("../../types").StructuredNavigationVariant): Promise<any>;
73
75
  createNavigation(data: any): Promise<any>;
74
76
  updateNavigation(documentId: string, data: import("../../types").NavigationInput): Promise<any>;
@@ -81,7 +83,7 @@ declare const _default: {
81
83
  client: ({ strapi }: {
82
84
  strapi: any;
83
85
  }) => {
84
- getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any): Promise<any>;
86
+ getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any, status?: "draft" | "published"): Promise<any>;
85
87
  getNavigation(id: string, name: string, documentId: string, variant?: import("../../types").StructuredNavigationVariant): Promise<any>;
86
88
  };
87
89
  };
@@ -5,8 +5,9 @@ declare const _default: ({ strapi }: {
5
5
  updateConfig(newConfig: any): Promise<string>;
6
6
  getConfig(): Promise<any>;
7
7
  getRoutes(): Promise<any>;
8
- createExternalRoute(data: any): Promise<any>;
9
8
  updateRoute(documentId: string, data: any): Promise<any>;
9
+ createExternalRoute(data: any): Promise<any>;
10
+ getRelatedRoute(documentId: string): Promise<any>;
10
11
  getNavigation(documentId?: string, variant?: StructuredNavigationVariant): Promise<any>;
11
12
  createNavigation(data: any): Promise<any>;
12
13
  updateNavigation(documentId: string, data: NavigationInput): Promise<any>;
@@ -2,7 +2,7 @@ import { StructuredNavigationVariant } from "../../../types";
2
2
  declare const _default: ({ strapi }: {
3
3
  strapi: any;
4
4
  }) => {
5
- getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any): Promise<any>;
5
+ getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any, status?: 'draft' | 'published'): Promise<any>;
6
6
  getNavigation(id: string, name: string, documentId: string, variant?: StructuredNavigationVariant): Promise<any>;
7
7
  };
8
8
  export default _default;
@@ -5,8 +5,9 @@ declare const _default: {
5
5
  updateConfig(newConfig: any): Promise<string>;
6
6
  getConfig(): Promise<any>;
7
7
  getRoutes(): Promise<any>;
8
- createExternalRoute(data: any): Promise<any>;
9
8
  updateRoute(documentId: string, data: any): Promise<any>;
9
+ createExternalRoute(data: any): Promise<any>;
10
+ getRelatedRoute(documentId: string): Promise<any>;
10
11
  getNavigation(documentId?: string, variant?: import("../../../types").StructuredNavigationVariant): Promise<any>;
11
12
  createNavigation(data: any): Promise<any>;
12
13
  updateNavigation(documentId: string, data: import("../../../types").NavigationInput): Promise<any>;
@@ -19,7 +20,7 @@ declare const _default: {
19
20
  client: ({ strapi }: {
20
21
  strapi: any;
21
22
  }) => {
22
- getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any): Promise<any>;
23
+ getEntityByPath(slug: string, populate: string, populateDeepDepth: string, fields: any, status?: "draft" | "published"): Promise<any>;
23
24
  getNavigation(id: string, name: string, documentId: string, variant?: import("../../../types").StructuredNavigationVariant): Promise<any>;
24
25
  };
25
26
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.6",
2
+ "version": "0.2.0",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {