@webbio/strapi-plugin-page-builder 0.3.8-platform → 0.3.9-legacy

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.
Files changed (67) hide show
  1. package/README.md +35 -11
  2. package/admin/src/api/collection-type.ts +1 -7
  3. package/admin/src/api/page-type.ts +4 -5
  4. package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +12 -15
  5. package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +41 -34
  6. package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +39 -80
  7. package/admin/src/components/EditView/Details/index.tsx +2 -13
  8. package/admin/src/components/EditView/PageSettings/index.tsx +5 -61
  9. package/admin/src/components/EditView/index.tsx +2 -8
  10. package/admin/src/components/PageTypeFilter/index.tsx +17 -0
  11. package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -0
  12. package/admin/src/index.tsx +2 -2
  13. package/admin/src/utils/sanitizeModules.ts +92 -9
  14. package/dist/package.json +12 -10
  15. package/dist/server/bootstrap/permissions.js +10 -68
  16. package/dist/server/bootstrap.js +33 -46
  17. package/dist/server/controllers/collection-types.js +0 -5
  18. package/dist/server/controllers/index.js +1 -3
  19. package/dist/server/controllers/page.js +19 -0
  20. package/dist/server/graphql/index.js +2 -2
  21. package/dist/server/graphql/page-by-slug.js +50 -44
  22. package/dist/server/graphql/pages-by-uid.js +9 -11
  23. package/dist/server/register.js +2 -2
  24. package/dist/server/routes/index.js +5 -26
  25. package/dist/server/schema/page-end.json +0 -5
  26. package/dist/server/services/builder.js +5 -15
  27. package/dist/server/services/collection-types.js +0 -7
  28. package/dist/server/services/index.js +1 -3
  29. package/dist/server/services/template.js +1 -2
  30. package/dist/server/utils/strapi.js +1 -4
  31. package/dist/shared/utils/constants.js +1 -3
  32. package/dist/tsconfig.server.tsbuildinfo +1 -1
  33. package/package.json +12 -10
  34. package/server/bootstrap/collection-type-lifecycles.ts +1 -1
  35. package/server/bootstrap/permissions.ts +10 -75
  36. package/server/bootstrap.ts +35 -49
  37. package/server/controllers/collection-types.ts +0 -5
  38. package/server/controllers/index.ts +1 -3
  39. package/server/controllers/page.ts +23 -0
  40. package/server/graphql/index.ts +2 -2
  41. package/server/graphql/page-by-slug.ts +113 -0
  42. package/server/graphql/pages-by-uid.ts +9 -11
  43. package/server/register.ts +2 -2
  44. package/server/routes/index.ts +5 -26
  45. package/server/schema/page-end.json +0 -5
  46. package/server/services/builder.ts +6 -18
  47. package/server/services/collection-types.ts +1 -8
  48. package/server/services/index.ts +1 -3
  49. package/server/services/template.ts +1 -2
  50. package/server/utils/strapi.ts +1 -5
  51. package/shared/utils/constants.ts +0 -2
  52. package/admin/src/api/has-platform-relation.ts +0 -37
  53. package/admin/src/api/platform-page-types.ts +0 -40
  54. package/admin/src/api/platform.ts +0 -34
  55. package/admin/src/components/EditView/Platform/platform-select.tsx +0 -31
  56. package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +0 -39
  57. package/admin/src/components/PageFilters/PlatformFilter/index.tsx +0 -28
  58. package/admin/src/components/PageFilters/filters.tsx +0 -180
  59. package/admin/src/components/PageFilters/index.tsx +0 -30
  60. package/dist/server/controllers/platform.js +0 -20
  61. package/dist/server/graphql/page-by-path.js +0 -89
  62. package/dist/server/schema/platform-start.json +0 -31
  63. package/dist/server/services/platform.js +0 -36
  64. package/server/controllers/platform.ts +0 -21
  65. package/server/graphql/page-by-path.ts +0 -105
  66. package/server/schema/platform-start.json +0 -31
  67. package/server/services/platform.ts +0 -36
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.3.8-platform",
3
+ "version": "0.3.9-legacy",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -20,14 +20,16 @@
20
20
  "url": "https://github.com/webbio/strapi-plugin-page-builder.git"
21
21
  },
22
22
  "dependencies": {
23
- "@strapi/design-system": "^1.11.0",
24
- "@strapi/helper-plugin": "^4.15.0",
25
- "@strapi/icons": "^1.11.0",
26
- "@strapi/typescript-utils": "^4.15.0",
27
- "@strapi/utils": "^4.15.0",
28
- "react-select": "^5.7.4"
23
+ "@strapi/design-system": "^1.19.0",
24
+ "@strapi/helper-plugin": "^4.25.22",
25
+ "@strapi/icons": "^1.19.0",
26
+ "@strapi/typescript-utils": "^4.25.22",
27
+ "@strapi/utils": "^4.25.22",
28
+ "react-select": "^5.7.4",
29
+ "slugify": "^1.6.6"
29
30
  },
30
31
  "devDependencies": {
32
+ "@strapi/typescript-utils": "^4.25.22",
31
33
  "@types/react": "^18.2.21",
32
34
  "@types/react-dom": "^18.2.7",
33
35
  "@types/react-router-dom": "^5.3.3",
@@ -39,8 +41,8 @@
39
41
  "typescript": "5.1.6"
40
42
  },
41
43
  "peerDependencies": {
42
- "@strapi/strapi": "^4.15.0",
43
- "@webbio/strapi-plugin-slug": "^2.0.5",
44
+ "@strapi/strapi": "^4.25.22",
45
+ "@webbio/strapi-plugin-slug": "^4.0.10",
44
46
  "react": "^17.0.0 || ^18.0.0",
45
47
  "react-dom": "^17.0.0 || ^18.0.0",
46
48
  "react-router-dom": "^5.3.4",
@@ -59,7 +61,7 @@
59
61
  }
60
62
  ],
61
63
  "engines": {
62
- "node": ">=14.19.1 <=18.x.x",
64
+ "node": ">=14.19.1 <=20.x.x",
63
65
  "npm": ">=6.0.0"
64
66
  },
65
67
  "license": "MIT",
@@ -37,7 +37,7 @@ export default async ({ strapi }: { strapi: Strapi }) => {
37
37
  data: {
38
38
  updatedAt: data.updatedAt
39
39
  }
40
- } as Record<string, any>);
40
+ } as any);
41
41
  }
42
42
  } catch (error) {
43
43
  console.log('[PAGEBUILDER PLUGIN] collection type lifecycle error: ', error);
@@ -1,5 +1,5 @@
1
1
  import { Strapi } from '@strapi/strapi';
2
- import { PAGE_TYPE_UID, PLATFORM_UID } from '../../shared/utils/constants';
2
+ import { PAGE_TYPE_UID } from '../../shared/utils/constants';
3
3
 
4
4
  export default async ({ strapi }: { strapi: Strapi }) => {
5
5
  try {
@@ -7,84 +7,26 @@ export default async ({ strapi }: { strapi: Strapi }) => {
7
7
  limit: -1
8
8
  })) as Record<string, any>[];
9
9
 
10
- const platforms = (await strapi.entityService?.findMany(PLATFORM_UID, {
11
- limit: -1
12
- })) as Record<string, any>[];
13
-
14
- const platformPagePermissions = platforms.map((platform) => {
15
- return pageTypes.map((pageType) => {
16
- const name = `platform-is-${platform.title}-${pageType.uid}`;
17
- const displayName = `${platform.title}-${pageType.title}`;
18
-
19
- return {
20
- plugin: 'page-builder',
21
- name,
22
- displayName,
23
- category: `${platform.title} Page roles`,
24
- handler: async () => {
25
- return {
26
- $and: [
27
- {
28
- 'platform.id': {
29
- $eq: platform.id
30
- }
31
- },
32
- {
33
- 'pageType.uid': {
34
- $eq: pageType.uid
35
- }
36
- },
37
- {
38
- uid: {
39
- $eq: pageType.uid
40
- }
41
- }
42
- ]
43
- };
44
- }
45
- };
46
- });
47
- });
48
-
49
- const pageTypePermissions = pageTypes.map((pageType) => {
50
- const name = `pageType-permission-${pageType.uid}`;
51
- const displayName = `pageType ${pageType.title}`;
10
+ const pagePermissions = pageTypes.map((pageType) => {
11
+ const name = `page-type-is-${pageType.uid}`;
12
+ const displayName = pageType.title;
52
13
 
53
14
  return {
54
15
  plugin: 'page-builder',
55
16
  name,
56
17
  displayName,
57
- category: `Platform pageType roles`,
58
- handler: async () => {
59
- return {
60
- uid: {
61
- $eq: pageType.uid
62
- }
63
- };
64
- }
65
- };
66
- });
67
-
68
- const platformCollectiontypePermissions = platforms.map((platform) => {
69
- const name = `platform-is-${platform.title}`;
70
- const displayName = platform.title;
71
-
72
- return {
73
- plugin: 'page-builder',
74
- name,
75
- displayName,
76
- category: 'Platform CollectionType roles',
18
+ category: 'Page type',
77
19
  handler: async () => {
78
20
  return {
79
21
  $or: [
80
22
  {
81
- 'platform.id': {
82
- $eq: platform.id
23
+ 'pageType.uid': {
24
+ $eq: pageType.uid
83
25
  }
84
26
  },
85
27
  {
86
- id: {
87
- $eq: platform.id
28
+ uid: {
29
+ $eq: pageType.uid
88
30
  }
89
31
  }
90
32
  ]
@@ -92,15 +34,8 @@ export default async ({ strapi }: { strapi: Strapi }) => {
92
34
  }
93
35
  };
94
36
  });
95
-
96
- const allPermissions = [
97
- ...platformPagePermissions.flat(),
98
- ...pageTypePermissions.flat(),
99
- ...platformCollectiontypePermissions
100
- ];
101
-
102
37
  // @ts-ignore shitty types
103
- await strapi.admin.services.permission.conditionProvider.registerMany(allPermissions);
38
+ await strapi.admin.services.permission.conditionProvider.registerMany(pagePermissions);
104
39
  } catch {
105
40
  console.log('Cannot set page permissions');
106
41
  }
@@ -1,6 +1,6 @@
1
1
  import { Common, Strapi } from '@strapi/strapi';
2
2
  import { errors } from '@strapi/utils';
3
- import { PAGE_TYPE_UID, PAGE_UID, PLATFORM_UID } from '../shared/utils/constants';
3
+ import { PAGE_TYPE_UID, PAGE_UID } from '../shared/utils/constants';
4
4
  import permissions from './bootstrap/permissions';
5
5
  import collectionTypeLifecycles from './bootstrap/collection-type-lifecycles';
6
6
 
@@ -26,8 +26,7 @@ export default async ({ strapi }: { strapi: Strapi }) => {
26
26
  async beforeCreate(event) {
27
27
  let { data } = event.params;
28
28
  const collectionTypeId = data?.collectionTypeId;
29
- const pageTypeId = data?.pageType.connect?.[0]?.id || data.initialPageType;
30
- const platformId = data?.platform.connect?.[0]?.id;
29
+ const pageTypeId = data?.pageType?.connect?.[0]?.id || data.initialPageType;
31
30
 
32
31
  if (collectionTypeId && pageTypeId) {
33
32
  const pageType: Record<string, any> | undefined | null = await strapi.entityService?.findOne(
@@ -40,24 +39,10 @@ export default async ({ strapi }: { strapi: Strapi }) => {
40
39
 
41
40
  const page: Record<string, any>[] = collectionToConnect?.page as any;
42
41
 
43
- const foundPlatforms: Record<string, any> | undefined | null = await strapi.entityService?.findMany(
44
- PLATFORM_UID,
45
- {
46
- populate: '*',
47
- filters: {
48
- pagetype: {
49
- uid: pageType?.uid
50
- }
51
- }
52
- }
53
- );
54
-
55
- if (page && page.length > 0) {
56
- throw new errors.ValidationError('You can only link one CollectionType to one page');
57
- }
58
-
59
- if (platformId && !foundPlatforms?.some((platform) => platform.id === platformId)) {
60
- throw new errors.ValidationError('Platform not found');
42
+ // Only block if a page with the same locale already exists
43
+ const existingPageWithSameLocale = page?.find((p: any) => p.locale === data.locale);
44
+ if (existingPageWithSameLocale) {
45
+ throw new errors.ValidationError('A page with this locale is already linked to this collection type');
61
46
  }
62
47
 
63
48
  data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
@@ -89,7 +74,7 @@ export default async ({ strapi }: { strapi: Strapi }) => {
89
74
  originalEntity.collectionTypeData[0].id,
90
75
  {
91
76
  data: {
92
- id: originalEntity.collectionTypeData.id,
77
+ id: originalEntity.collectionTypeData[0].id,
93
78
  hasPage: false
94
79
  }
95
80
  }
@@ -108,13 +93,18 @@ export default async ({ strapi }: { strapi: Strapi }) => {
108
93
 
109
94
  const page: Record<string, any>[] = collectionToConnect?.page as any;
110
95
 
111
- if (page && page?.length > 0 && !page.some((p) => p.id === data.id)) {
112
- throw new errors.ValidationError('You can only link one CollectionType to one page');
96
+ const existingPageWithSameLocale = page?.find(
97
+ (p: any) => p.locale === data.locale && p.id !== data.id && p.id !== where?.id
98
+ );
99
+ if (existingPageWithSameLocale) {
100
+ throw new errors.ValidationError('A page with this locale is already linked to this collection type');
113
101
  }
114
102
 
115
103
  data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
116
104
  }
117
105
 
106
+ // needs to check if the collectionTypeData is already connected to another page
107
+ // if so, remove the hasPage for filtering
118
108
  if (
119
109
  data.collectionTypeData &&
120
110
  originalEntity?.collectionTypeData?.[0]?.__type &&
@@ -137,32 +127,28 @@ export default async ({ strapi }: { strapi: Strapi }) => {
137
127
  }
138
128
  },
139
129
  async afterUpdate(event) {
140
- const data = event?.params?.data;
141
-
142
- if (data.collectionTypeData?.__type && data.collectionTypeData.id) {
143
- await strapi.entityService?.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
144
- data: {
145
- id: data.collectionTypeData.id,
146
- hasPage: true,
147
- lifecycleState: {
148
- exit: true
149
- }
150
- }
151
- });
152
- }
153
- },
154
- async afterCreate(event) {
155
- const data = event?.params?.data;
156
- if (data.collectionTypeData?.__type && data.collectionTypeData.id) {
157
- await strapi.entityService?.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
158
- data: {
159
- id: data.collectionTypeData.id,
160
- hasPage: true,
161
- lifecycleState: {
162
- exit: true
130
+ try {
131
+ // Result not correctly typed within Strapi
132
+ const data = event?.['result'];
133
+ const hasCollectionTypeRelation =
134
+ data && data?.collectionTypeData?.[0] && data?.collectionTypeData[0].__type && data?.collectionTypeData[0].id;
135
+
136
+ if (hasCollectionTypeRelation) {
137
+ const isPublished = data.publishedAt !== undefined;
138
+ const pageData = isPublished ? { hasPage: !!data.publishedAt } : {};
139
+
140
+ await strapi.entityService?.update(data.collectionTypeData[0].__type, data.collectionTypeData[0].id, {
141
+ data: {
142
+ ...pageData,
143
+ id: data.collectionTypeData[0].id,
144
+ lifecycleState: {
145
+ exit: true
146
+ }
163
147
  }
164
- }
165
- });
148
+ });
149
+ }
150
+ } catch (error) {
151
+ console.error('Failed to save hasPage data', error);
166
152
  }
167
153
  },
168
154
  async beforeDelete(event) {
@@ -6,11 +6,6 @@ export default {
6
6
 
7
7
  return (strapi as Strapi).service('plugin::page-builder.collection-types').hasPageRelation(uid);
8
8
  },
9
- async hasPlatformRelation(ctx: any) {
10
- const uid = ctx.params?.uid;
11
-
12
- return (strapi as Strapi).service('plugin::page-builder.collection-types').hasPlatformRelation(uid);
13
- },
14
9
  async getTranslationPageLinks(ctx: any): Promise<IGetTranslationPageLinks[] | undefined> {
15
10
  const { uid, ids } = ctx.params || {};
16
11
  const idsArr = (ids as string)
@@ -2,12 +2,10 @@ import page from './page';
2
2
  import pageType from './page-type';
3
3
  import collectionTypes from './collection-types';
4
4
  import template from './template';
5
- import platform from './platform';
6
5
 
7
6
  export default {
8
7
  page,
9
8
  'page-type': pageType,
10
9
  'collection-types': collectionTypes,
11
- template,
12
- platform
10
+ template
13
11
  };
@@ -1,9 +1,32 @@
1
1
  import { Strapi } from '@strapi/strapi';
2
2
 
3
+ import { PAGE_UID } from '../../shared/utils/constants';
4
+
3
5
  export default {
4
6
  async getPage(ctx) {
5
7
  const id = ctx.params?.id;
6
8
 
7
9
  return (strapi as Strapi).service('plugin::page-builder.page')?.getPage(id);
10
+ },
11
+
12
+ async createPage(ctx) {
13
+ const { title, slug, locale, pageTypeId, collectionTypeId, modules } = ctx.request.body;
14
+
15
+ if (!locale) {
16
+ return ctx.badRequest('Locale is required');
17
+ }
18
+
19
+ const page = await (strapi as Strapi).entityService?.create(PAGE_UID, {
20
+ data: {
21
+ title,
22
+ slug,
23
+ locale,
24
+ modules: modules || [],
25
+ collectionTypeId,
26
+ pageType: pageTypeId ? { connect: [{ id: pageTypeId }] } : undefined
27
+ }
28
+ });
29
+
30
+ return page;
8
31
  }
9
32
  };
@@ -1,9 +1,9 @@
1
1
  import pageType from './page-type';
2
- import pageByPath from './page-by-path';
2
+ import pageBySlug from './page-by-slug';
3
3
  import getPageInfoFromUID from './pages-by-uid';
4
4
 
5
5
  export default {
6
6
  getPageInfoFromUID,
7
7
  pageType,
8
- pageByPath
8
+ pageBySlug
9
9
  };
@@ -0,0 +1,113 @@
1
+ import { Strapi } from '@strapi/strapi';
2
+
3
+ import { filterUnderscoreArguments } from '../utils/filter-underscore-arguments';
4
+ import { PAGE_UID } from '../../shared/utils/constants';
5
+
6
+ const getPageBySlug = (strapi: Strapi) => {
7
+ const typeDefs = () => {
8
+ return `
9
+ extend type Page {
10
+ collectionType: GenericMorph
11
+ }
12
+
13
+ type Query {
14
+ getPageBySlug(path: String, _locale: String, _publicationState: PublicationState): PageEntity
15
+ }
16
+
17
+ `;
18
+ };
19
+
20
+ const resolvers = (strapi: Strapi) => {
21
+ const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
22
+
23
+ return {
24
+ Query: {
25
+ getPageBySlug: {
26
+ resolve: async (_parent: any, args: Record<string, any>, ctx: any) => {
27
+ const filteredArgs = {
28
+ ...filterUnderscoreArguments(args)
29
+ };
30
+
31
+ const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
32
+
33
+ const getPage = async () => {
34
+ const transformedArgs = transformArgs(filteredArgs, {
35
+ contentType: strapi.contentTypes[PAGE_UID],
36
+ usePagination: false
37
+ });
38
+
39
+ const results = await strapi.entityService?.findMany(PAGE_UID, {
40
+ filters: transformedArgs,
41
+ locale: args._locale,
42
+ publicationState: args._publicationState,
43
+ populate: '*'
44
+ });
45
+
46
+ const entityResponse = toEntityResponse(results?.[0] || {}, {
47
+ args: transformedArgs,
48
+ resourceUID: PAGE_UID
49
+ });
50
+
51
+ if (!entityResponse?.value || Object.keys(entityResponse.value).length === 0) {
52
+ throw new Error(ctx.koaContext.response.message);
53
+ }
54
+
55
+ // Get collectionTypeData from the entity response
56
+ const collectionTypeData = entityResponse?.value?.collectionTypeData;
57
+
58
+ // Filter out null/undefined items
59
+ const collectionTypeDataFilter = collectionTypeData?.filter(Boolean);
60
+
61
+ // Filter by locale if specified, then take the first item
62
+ let filteredByLocale = collectionTypeDataFilter;
63
+ if (args._locale && Array.isArray(collectionTypeDataFilter)) {
64
+ filteredByLocale = collectionTypeDataFilter.filter((item: any) => {
65
+ return item?.locale === args._locale;
66
+ });
67
+ }
68
+
69
+ // Take the first item (should be only one after locale filtering)
70
+ const collectionType: Record<string, any> | null =
71
+ filteredByLocale && Array.isArray(filteredByLocale) && filteredByLocale.length > 0
72
+ ? filteredByLocale[0]
73
+ : null;
74
+
75
+ const addedAttributes = {
76
+ collectionType: collectionType
77
+ };
78
+
79
+ const result = {
80
+ ...entityResponse.value,
81
+ ...addedAttributes
82
+ };
83
+
84
+ return result;
85
+ };
86
+
87
+ const results: Record<string, any> = await getPage();
88
+
89
+ if (Object.values(results)?.filter(Boolean).length > 0) {
90
+ return results;
91
+ } else {
92
+ throw new Error(ctx.koaContext.response.message);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ };
98
+ };
99
+
100
+ const resolversConfig = {
101
+ 'Query.getPageBySlug': {
102
+ auth: false
103
+ }
104
+ };
105
+
106
+ return {
107
+ typeDefs: typeDefs(),
108
+ resolvers: resolvers(strapi),
109
+ resolversConfig
110
+ };
111
+ };
112
+
113
+ export default getPageBySlug;
@@ -16,16 +16,13 @@ const getPageInfoFromUID = (strapi: Strapi) => {
16
16
  pageSize: Int
17
17
  }`;
18
18
  const entityInfo = collectionTypes.map((collectionType) => {
19
- return `
20
- extend type ${collectionType.type}EntityResponseCollection {
21
- metaInfo: MetaInfo
22
- }
23
-
24
- type Query {
25
- get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput,pagination: PaginationArg, pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
26
- }
19
+ return `extend type ${collectionType.type}EntityResponseCollection {
20
+ metaInfo: MetaInfo
21
+ }
27
22
 
28
- `;
23
+ type Query {
24
+ get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput, pagination: PaginationArg, sort:[String], pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
25
+ }`;
29
26
  });
30
27
 
31
28
  return `${metaInfo} ${entityInfo}`;
@@ -67,8 +64,9 @@ const getPageInfoFromUID = (strapi: Strapi) => {
67
64
  hasPage: { $eq: true },
68
65
  page: { ...transformedpageArgs.filters }
69
66
  },
70
- start,
71
- limit
67
+ sort: transformedArgs.sort,
68
+ start: start,
69
+ limit: limit
72
70
  });
73
71
 
74
72
  const entityResponse = toEntityResponseCollection(results || [], {
@@ -1,6 +1,6 @@
1
1
  import { Strapi } from '@strapi/strapi';
2
2
 
3
- import getPageByPath from './graphql/page-by-path';
3
+ import getPageBySlug from './graphql/page-by-slug';
4
4
  import pageType from './graphql/page-type';
5
5
  import getPageInfoFromUID from './graphql/pages-by-uid';
6
6
 
@@ -8,7 +8,7 @@ export default async ({ strapi }: { strapi: Strapi }) => {
8
8
  const extensionService = strapi.plugin('graphql').service('extension');
9
9
 
10
10
  extensionService.use(pageType);
11
- extensionService.use(getPageByPath(strapi));
11
+ extensionService.use(getPageBySlug(strapi));
12
12
  extensionService.use(getPageInfoFromUID(strapi));
13
13
 
14
14
  await strapi.services?.['plugin::page-builder.builder']?.buildContentTypes();
@@ -18,6 +18,11 @@ const routes = {
18
18
  method: 'GET',
19
19
  path: '/page/:id',
20
20
  handler: 'page.getPage'
21
+ },
22
+ {
23
+ method: 'POST',
24
+ path: '/page/create',
25
+ handler: 'page.createPage'
21
26
  }
22
27
  ]
23
28
  },
@@ -34,11 +39,6 @@ const routes = {
34
39
  method: 'GET',
35
40
  path: '/collection-types-page-links/:uid/:ids?',
36
41
  handler: 'collection-types.getTranslationPageLinks'
37
- },
38
- {
39
- method: 'GET',
40
- path: '/collection-types/hasPlatform/:uid',
41
- handler: 'collection-types.hasPlatformRelation'
42
42
  }
43
43
  ]
44
44
  },
@@ -57,27 +57,6 @@ const routes = {
57
57
  handler: 'template.findOneById'
58
58
  }
59
59
  ]
60
- },
61
- platform: {
62
- type: 'admin',
63
- prefix: undefined,
64
- routes: [
65
- {
66
- method: 'GET',
67
- path: '/platform',
68
- handler: 'platform.findAll'
69
- },
70
- {
71
- method: 'GET',
72
- path: '/platform/:uid',
73
- handler: 'platform.findOneByUid'
74
- },
75
- {
76
- method: 'GET',
77
- path: '/platform/:platform/page-types',
78
- handler: 'platform.findPageTypesByPlatform'
79
- }
80
- ]
81
60
  }
82
61
  };
83
62
 
@@ -86,11 +86,6 @@
86
86
  "type": "relation",
87
87
  "relation": "oneToOne",
88
88
  "target": "api::page-type.page-type"
89
- },
90
- "platform": {
91
- "type": "relation",
92
- "relation": "oneToOne",
93
- "target": "api::platform.platform"
94
89
  }
95
90
  }
96
91
  }
@@ -4,14 +4,13 @@ import { Common } from '@strapi/strapi';
4
4
  import pageStart from '../schema/page-start.json';
5
5
  import pageEnd from '../schema/page-end.json';
6
6
  import pluginId from '../../admin/src/pluginId';
7
- import { PAGE_UID, TEMPLATE_UID, PAGE_TYPE_UID, PLATFORM_UID } from '../../shared/utils/constants';
7
+ import { PAGE_UID, TEMPLATE_UID, PAGE_TYPE_UID } from '../../shared/utils/constants';
8
8
  import { reloadStrapiOnLoad } from '../utils/reload-strapi-on-load';
9
9
  import pageTypeStart from '../schema/page-type-start.json';
10
10
  import pageTypeEnd from '../schema/page-type-end.json';
11
11
  import templateStart from '../schema/template-start.json';
12
- import platformStart from '../schema/platform-start.json';
13
12
 
14
- const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID, PLATFORM_UID, PAGE_UID];
13
+ const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID, PAGE_UID];
15
14
 
16
15
  export default {
17
16
  async buildContentTypes() {
@@ -88,10 +87,6 @@ export default {
88
87
  [TEMPLATE_UID]: {
89
88
  create: this.getTemplateContentType(),
90
89
  update: this.getTemplateContentType()
91
- },
92
- [PLATFORM_UID]: {
93
- create: this.getPlatformContentType(),
94
- update: this.getPlatformContentType()
95
90
  }
96
91
  };
97
92
 
@@ -99,30 +94,23 @@ export default {
99
94
  },
100
95
  getPageContentType(create?: boolean) {
101
96
  const page = create ? pageStart : pageEnd;
102
- const contentType = this.mergeCollectionTypeWithOld(page, PAGE_UID);
97
+ const contentType = this.mergeCollectionTypeWithModules(page, PAGE_UID);
103
98
 
104
99
  return { uid: PAGE_UID, contentType };
105
100
  },
106
101
  getPageTypeContentType(create?: boolean) {
107
102
  const pageType = create ? pageTypeStart : pageTypeEnd;
108
- const contentType = this.mergeCollectionTypeWithOld(pageType, PAGE_TYPE_UID);
103
+ const contentType = this.mergeCollectionTypeWithModules(pageType, PAGE_TYPE_UID);
109
104
 
110
105
  return { uid: PAGE_TYPE_UID, contentType };
111
106
  },
112
107
  getTemplateContentType() {
113
108
  const template = templateStart;
114
- const contentType = this.mergeCollectionTypeWithOld(template, TEMPLATE_UID);
109
+ const contentType = this.mergeCollectionTypeWithModules(template, TEMPLATE_UID);
115
110
 
116
111
  return { uid: TEMPLATE_UID, contentType };
117
112
  },
118
- getPlatformContentType() {
119
- const platform = platformStart;
120
-
121
- const contentType = this.mergeCollectionTypeWithOld(platform, PLATFORM_UID);
122
-
123
- return { uid: PLATFORM_UID, contentType };
124
- },
125
- mergeCollectionTypeWithOld(collectionType: Record<string, any>, uid: Common.UID.ContentType) {
113
+ mergeCollectionTypeWithModules(collectionType: Record<string, any>, uid: Common.UID.ContentType) {
126
114
  const { pluginOptions: oldPluginOptions, __schema__: oldSchema } = (strapi.contentType(uid) as any) || {};
127
115
  const modulesFromConfig = oldSchema?.attributes?.modules ? this.getConfigModuleComponents() : undefined;
128
116