@webbio/strapi-plugin-page-builder 0.18.1-platform → 1.0.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.
@@ -111,7 +111,7 @@ export const getSearchFilteredEntities = async ({
111
111
  title: result?.[mainFieldName],
112
112
  publicationState: getPublicationState(),
113
113
  publishedAt: result?.publishedAt,
114
- href: `/content-manager/collectionType/${uid}/${result.id}`,
114
+ href: `/content-manager/collection-types/${uid}/${result.id}`,
115
115
  subTitle: typeof subTitle === 'string' || typeof subTitle === 'number' ? String(subTitle) : ''
116
116
  };
117
117
  });
@@ -28,7 +28,7 @@ export const CreatePageButton = ({ selectedPlatform, onCreatedPage }: ICreatePag
28
28
  const { locales } = useSelector((state: any) => state.i18n_locales);
29
29
 
30
30
  const { post, get, put } = useFetchClient();
31
- const url = `/content-manager/collectionType/${PAGE_UID}/create`;
31
+ const url = `/content-manager/collection-types/${PAGE_UID}/create`;
32
32
 
33
33
  const handleCreatePage = async (e: React.MouseEvent<HTMLAnchorElement>) => {
34
34
  e.preventDefault();
@@ -69,8 +69,8 @@ export const CollectionTypeSettings = ({ onlyPlatform }: CollectionTypeSettingsP
69
69
  {!pageTypeExists && !linkedPage && !isLoadingPageTypeExists && (
70
70
  <S.InfoType variant="pi" textColor="neutral800">
71
71
  Er bestaat nog geen{' '}
72
- <Link to="/content-manager/collectionType/api::page-type.page-type">pagina type</Link> voor dit content
73
- type.
72
+ <Link to="/content-manager/collection-types/api::page-type.page-type">pagina type</Link> voor dit
73
+ content type.
74
74
  </S.InfoType>
75
75
  )}
76
76
  {showCreatePageButton && selectedPlatform && (pageTypeExists || linkedPage) && (
@@ -18,7 +18,7 @@ const useRelationLoad = ({ name, attribute }: IRelationLoadProps) => {
18
18
  const { modifiedData, initialData, slug, layout, allLayoutData, isCreatingEntry, relationLoad } =
19
19
  useCMEditViewDataManager() as any;
20
20
  const { params } =
21
- useRouteMatch<{ origin?: string }>('/content-manager/collectionType/:collectionType/create/clone/:origin') ?? {};
21
+ useRouteMatch<{ origin?: string }>('/content-manager/collection-types/:collectionType/create/clone/:origin') ?? {};
22
22
  const { origin } = params ?? {};
23
23
  const isCloningEntry = Boolean(origin);
24
24
  const entityId = origin || modifiedData.id;
@@ -1,5 +1,5 @@
1
1
  import { Entity } from '@strapi/types';
2
2
 
3
3
  export function getRelationLink(targetModel: string, id?: Entity.ID) {
4
- return `/content-manager/collectionType/${targetModel}/${id ?? ''}`;
4
+ return `/content-manager/collection-types/${targetModel}/${id ?? ''}`;
5
5
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.18.1-platform",
3
+ "version": "1.0.0",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -24,11 +24,11 @@
24
24
  "@mantine/hooks": "^7.2.2",
25
25
  "@sindresorhus/slugify": "^2.2.1",
26
26
  "@strapi/design-system": "^1.19.0",
27
- "@strapi/helper-plugin": "^4.25.8",
27
+ "@strapi/helper-plugin": "^4.25.22",
28
28
  "@strapi/icons": "^1.19.0",
29
29
  "@strapi/provider-email-amazon-ses": "^4.16.2",
30
- "@strapi/typescript-utils": "^4.25.8",
31
- "@strapi/utils": "^4.25.8",
30
+ "@strapi/typescript-utils": "^4.25.22",
31
+ "@strapi/utils": "^4.25.22",
32
32
  "add": "^2.0.6",
33
33
  "aws-sdk": "^2.1528.0",
34
34
  "fuse.js": "^7.0.0",
@@ -48,7 +48,7 @@
48
48
  "typescript": "5.1.6"
49
49
  },
50
50
  "peerDependencies": {
51
- "@strapi/strapi": "^4.25.8",
51
+ "@strapi/strapi": "^4.25.22",
52
52
  "@webbio/strapi-plugin-slug": "^3.3.2",
53
53
  "react": "^17.0.0 || ^18.0.0",
54
54
  "react-dom": "^17.0.0 || ^18.0.0",
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const filter_underscore_arguments_1 = require("../utils/filter-underscore-arguments");
4
+ const constants_1 = require("../../shared/utils/constants");
5
+ const getPageBySlug = (strapi) => {
6
+ const typeDefs = () => {
7
+ return `
8
+ extend type Page {
9
+ collectionType: GenericMorph
10
+ }
11
+
12
+ type Query {
13
+ getPageBySlug(path: String, _locale: String, _publicationState: PublicationState): PageEntity
14
+ }
15
+
16
+ `;
17
+ };
18
+ const resolvers = (strapi) => {
19
+ const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
20
+ return {
21
+ Query: {
22
+ getPageBySlug: {
23
+ resolve: async (_parent, args, ctx) => {
24
+ var _a;
25
+ const filteredArgs = {
26
+ ...(0, filter_underscore_arguments_1.filterUnderscoreArguments)(args)
27
+ };
28
+ const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
29
+ const getPage = async () => {
30
+ var _a, _b, _c;
31
+ const transformedArgs = transformArgs(filteredArgs, {
32
+ contentType: strapi.contentTypes[constants_1.PAGE_UID],
33
+ usePagination: false
34
+ });
35
+ const results = await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findMany(constants_1.PAGE_UID, {
36
+ filters: transformedArgs,
37
+ locale: args._locale,
38
+ publicationState: args._publicationState,
39
+ populate: '*'
40
+ }));
41
+ const entityResponse = toEntityResponse((results === null || results === void 0 ? void 0 : results[0]) || {}, {
42
+ args: transformedArgs,
43
+ resourceUID: constants_1.PAGE_UID
44
+ });
45
+ if (!(entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) || Object.keys(entityResponse.value).length === 0) {
46
+ throw new Error(ctx.koaContext.response.message);
47
+ }
48
+ const collectionTypeDataFilter = (_c = (_b = entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) === null || _b === void 0 ? void 0 : _b.collectionTypeData) === null || _c === void 0 ? void 0 : _c.filter(Boolean);
49
+ const collectionType = collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter === null || collectionTypeDataFilter === void 0 ? void 0 : collectionTypeDataFilter[0] : null;
50
+ const addedAttributes = {
51
+ collectionType: collectionType
52
+ };
53
+ const result = {
54
+ ...entityResponse.value,
55
+ ...addedAttributes
56
+ };
57
+ return result;
58
+ };
59
+ const results = await getPage();
60
+ if (((_a = Object.values(results)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
61
+ return results;
62
+ }
63
+ else {
64
+ throw new Error(ctx.koaContext.response.message);
65
+ }
66
+ }
67
+ }
68
+ }
69
+ };
70
+ };
71
+ const resolversConfig = {
72
+ 'Query.getPageBySlug': {
73
+ auth: false
74
+ }
75
+ };
76
+ return {
77
+ typeDefs: typeDefs(),
78
+ resolvers: resolvers(strapi),
79
+ resolversConfig
80
+ };
81
+ };
82
+ exports.default = getPageBySlug;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerGraphQLResolvers = void 0;
4
+ const constants_1 = require("../../shared/utils/constants");
5
+ const findPageByPath = (strapi) => {
6
+ const typeDefs = `
7
+ type Query {
8
+ findPageByPath(path: String, locale: I18NLocaleCode): PageEntityResponse
9
+ }
10
+ `;
11
+ const resolvers = (strapi) => {
12
+ const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
13
+ const { toEntityResponse, toEntityResponseCollection } = strapi.plugin('graphql').service('format').returnTypes;
14
+ return {
15
+ Query: {
16
+ findPageByPath: {
17
+ resolve: async (parent, args, ctx) => {
18
+ const contentType = strapi.getModel(constants_1.PAGE_UID);
19
+ const transformedArgs = transformArgs(args, { contentType });
20
+ const queryResult = await strapi.entityService.findMany(contentType.uid, {
21
+ filters: {
22
+ path: {
23
+ $eq: transformedArgs.path
24
+ }
25
+ },
26
+ locale: transformedArgs.locale
27
+ });
28
+ const result = queryResult === null || queryResult === void 0 ? void 0 : queryResult[0];
29
+ return toEntityResponse(result, {
30
+ args: transformedArgs,
31
+ resourceUID: contentType.uid
32
+ });
33
+ }
34
+ }
35
+ }
36
+ };
37
+ };
38
+ const resolversConfig = {
39
+ 'Query.findPageByPath': {
40
+ auth: false
41
+ }
42
+ };
43
+ return {
44
+ typeDefs,
45
+ resolvers: resolvers(strapi),
46
+ resolversConfig
47
+ };
48
+ };
49
+ const findPagePaths = (strapi) => {
50
+ const typeDefs = `
51
+ type PageByPath {
52
+ id: Int!
53
+ path: String!
54
+ title: String!
55
+ locale: String!
56
+ pageType: ENUM_PAGE_PAGETYPE
57
+ updatedAt: DateTime!
58
+ publishedAt: DateTime!
59
+ }
60
+
61
+ type Query {
62
+ findPagePaths(locale: String, pageType: String = "all"): [PageByPath]
63
+ }
64
+ `;
65
+ const resolvers = (strapi) => {
66
+ const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
67
+ return {
68
+ Query: {
69
+ findPagePaths: {
70
+ resolve: async (parent, args, ctx) => {
71
+ const contentType = strapi.getModel(constants_1.PAGE_UID);
72
+ const transformedArgs = transformArgs(args, { contentType });
73
+ const queryResult = await strapi.entityService.findMany(contentType.uid, {
74
+ populate: '*',
75
+ locale: transformedArgs.locale
76
+ });
77
+ const result = queryResult.filter((page) => page === null || page === void 0 ? void 0 : page.path);
78
+ return result;
79
+ }
80
+ }
81
+ }
82
+ };
83
+ };
84
+ const resolversConfig = {
85
+ 'Query.findPagePaths': {
86
+ auth: false
87
+ }
88
+ };
89
+ return {
90
+ typeDefs,
91
+ resolvers: resolvers(strapi),
92
+ resolversConfig
93
+ };
94
+ };
95
+ const registerGraphQLResolvers = (strapi) => {
96
+ const extensionService = strapi.plugin('graphql').service('extension');
97
+ extensionService.use(findPageByPath(strapi));
98
+ extensionService.use(findPagePaths(strapi));
99
+ };
100
+ exports.registerGraphQLResolvers = registerGraphQLResolvers;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pagination = void 0;
4
+ class Pagination {
5
+ static checkPagination(page, pageSize) {
6
+ const startPage = page === 1 ? 0 : page - 1;
7
+ const start = startPage * pageSize;
8
+ const limit = (startPage + 1) * pageSize;
9
+ return { start, limit };
10
+ }
11
+ static async getPaginationInfo(transformedpageArgs, transformArgs, start, pageSize, entityResponse, uid) {
12
+ var _a;
13
+ const total = await ((_a = strapi === null || strapi === void 0 ? void 0 : strapi.entityService) === null || _a === void 0 ? void 0 : _a.count(uid, {
14
+ filters: {
15
+ ...transformArgs.filters,
16
+ hasPage: { $eq: true },
17
+ page: { ...transformedpageArgs.filters }
18
+ }
19
+ }));
20
+ const pageCount = Math.ceil(total / pageSize);
21
+ const page = Math.floor(start / pageSize) + 1;
22
+ entityResponse.metaInfo = {
23
+ total,
24
+ pageCount,
25
+ page,
26
+ pageSize
27
+ };
28
+ return entityResponse;
29
+ }
30
+ }
31
+ exports.Pagination = Pagination;