@webbio/strapi-plugin-page-builder 0.2.2 → 0.2.4

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 (93) hide show
  1. package/README.md +98 -98
  2. package/admin/src/api/collection-type.ts +110 -110
  3. package/admin/src/api/has-page-relation.ts +34 -34
  4. package/admin/src/api/page-type.ts +31 -31
  5. package/admin/src/api/template.ts +27 -27
  6. package/admin/src/components/Combobox/index.tsx +77 -77
  7. package/admin/src/components/Combobox/react-select-custom-styles.tsx +120 -111
  8. package/admin/src/components/Combobox/styles.ts +22 -22
  9. package/admin/src/components/ConfirmModal/index.tsx +90 -90
  10. package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +124 -124
  11. package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +104 -101
  12. package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/styles.ts +19 -19
  13. package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +74 -74
  14. package/admin/src/components/EditView/Details/index.tsx +47 -47
  15. package/admin/src/components/EditView/Details/styles.ts +51 -51
  16. package/admin/src/components/EditView/PageSettings/index.tsx +104 -104
  17. package/admin/src/components/EditView/Template/TemplateConfirmModal/index.tsx +36 -36
  18. package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +69 -69
  19. package/admin/src/components/EditView/Template/TemplateSelect/use-template-modules.ts +38 -38
  20. package/admin/src/components/EditView/index.tsx +29 -29
  21. package/admin/src/components/EditView/page-type-select.tsx +32 -32
  22. package/admin/src/components/EditView/wrapper.tsx +35 -35
  23. package/admin/src/components/Initializer/index.tsx +24 -24
  24. package/admin/src/components/PageTypeFilter/index.tsx +17 -17
  25. package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -130
  26. package/admin/src/components/PluginIcon/index.tsx +12 -12
  27. package/admin/src/constants.ts +3 -3
  28. package/admin/src/index.tsx +59 -59
  29. package/admin/src/middlewares/index.tsx +37 -37
  30. package/admin/src/pluginId.ts +5 -5
  31. package/admin/src/translations/en.json +6 -6
  32. package/admin/src/translations/nl.json +6 -6
  33. package/admin/src/utils/getRequestUrl.ts +11 -11
  34. package/admin/src/utils/getTrad.ts +5 -5
  35. package/admin/src/utils/hooks/useDebounce.ts +17 -17
  36. package/admin/src/utils/hooks/useGetLocaleFromUrl.ts +9 -9
  37. package/admin/src/utils/hooks/usePrevious.ts +12 -12
  38. package/admin/src/utils/sanitizeModules.ts +43 -10
  39. package/custom.d.ts +5 -5
  40. package/dist/package.json +9 -9
  41. package/dist/server/graphql/page-by-slug.js +9 -9
  42. package/dist/server/graphql/pages-by-uid.js +14 -14
  43. package/dist/server/services/builder.js +7 -4
  44. package/dist/server/services/template.js +1 -2
  45. package/dist/server/utils/graphql.js +18 -18
  46. package/dist/server/utils/strapi.js +1 -4
  47. package/dist/tsconfig.server.tsbuildinfo +1 -1
  48. package/package.json +71 -71
  49. package/server/bootstrap/collection-type-lifecycles.ts +47 -47
  50. package/server/bootstrap/permissions.ts +42 -42
  51. package/server/bootstrap.ts +198 -198
  52. package/server/config/index.ts +4 -4
  53. package/server/content-types/index.ts +1 -1
  54. package/server/controllers/collection-types.ts +27 -27
  55. package/server/controllers/index.ts +11 -11
  56. package/server/controllers/page-type.ts +13 -13
  57. package/server/controllers/page.ts +9 -9
  58. package/server/controllers/template.ts +16 -16
  59. package/server/destroy.ts +5 -5
  60. package/server/graphql/index.ts +9 -9
  61. package/server/graphql/page-by-slug.ts +98 -98
  62. package/server/graphql/page-type.ts +67 -67
  63. package/server/graphql/pages-by-uid.ts +127 -127
  64. package/server/index.ts +23 -23
  65. package/server/middlewares/index.ts +1 -1
  66. package/server/policies/index.ts +1 -1
  67. package/server/register.ts +15 -15
  68. package/server/routes/index.ts +58 -58
  69. package/server/schema/page-end.json +91 -91
  70. package/server/schema/page-start.json +87 -87
  71. package/server/schema/page-type-end.json +43 -43
  72. package/server/schema/page-type-start.json +38 -38
  73. package/server/schema/template-start.json +35 -35
  74. package/server/services/builder.ts +137 -134
  75. package/server/services/collection-types.ts +88 -88
  76. package/server/services/index.ts +13 -13
  77. package/server/services/page-type.ts +26 -26
  78. package/server/services/page.ts +24 -24
  79. package/server/services/template.ts +13 -14
  80. package/server/utils/filter-underscore-arguments.ts +12 -12
  81. package/server/utils/graphql.ts +113 -113
  82. package/server/utils/paginationValidation.ts +39 -39
  83. package/server/utils/reload-strapi-on-load.ts +13 -13
  84. package/server/utils/strapi.ts +45 -49
  85. package/shared/utils/constants.ts +4 -4
  86. package/shared/utils/sleep.ts +1 -1
  87. package/strapi-admin.js +3 -3
  88. package/strapi-server.js +3 -3
  89. package/tsconfig.json +20 -20
  90. package/tsconfig.server.json +25 -25
  91. package/dist/server/controllers/platform.js +0 -20
  92. package/dist/server/schema/platform-start.json +0 -31
  93. package/dist/server/services/platform.js +0 -36
@@ -1,35 +1,35 @@
1
- {
2
- "draftAndPublish": false,
3
- "displayName": "Templates",
4
- "singularName": "template",
5
- "pluralName": "templates",
6
- "description": "",
7
- "plugin": "page-builder",
8
- "pluginOptions": {
9
- "i18n": {
10
- "localized": true
11
- }
12
- },
13
- "kind": "collectionType",
14
- "collectionName": "templates",
15
- "attributes": {
16
- "title": {
17
- "type": "string",
18
- "required": true,
19
- "pluginOptions": {
20
- "i18n": {
21
- "localized": true
22
- }
23
- }
24
- },
25
- "modules": {
26
- "type": "dynamiczone",
27
- "components": [],
28
- "pluginOptions": {
29
- "i18n": {
30
- "localized": true
31
- }
32
- }
33
- }
34
- }
35
- }
1
+ {
2
+ "draftAndPublish": false,
3
+ "displayName": "Templates",
4
+ "singularName": "template",
5
+ "pluralName": "templates",
6
+ "description": "",
7
+ "plugin": "page-builder",
8
+ "pluginOptions": {
9
+ "i18n": {
10
+ "localized": true
11
+ }
12
+ },
13
+ "kind": "collectionType",
14
+ "collectionName": "templates",
15
+ "attributes": {
16
+ "title": {
17
+ "type": "string",
18
+ "required": true,
19
+ "pluginOptions": {
20
+ "i18n": {
21
+ "localized": true
22
+ }
23
+ }
24
+ },
25
+ "modules": {
26
+ "type": "dynamiczone",
27
+ "components": [],
28
+ "pluginOptions": {
29
+ "i18n": {
30
+ "localized": true
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
@@ -1,134 +1,137 @@
1
- import partition from 'lodash/partition';
2
- import { Common } from '@strapi/strapi';
3
-
4
- import pageStart from '../schema/page-start.json';
5
- import pageEnd from '../schema/page-end.json';
6
- import pluginId from '../../admin/src/pluginId';
7
- import { PAGE_UID, TEMPLATE_UID, PAGE_TYPE_UID } from '../../shared/utils/constants';
8
- import { reloadStrapiOnLoad } from '../utils/reload-strapi-on-load';
9
- import pageTypeStart from '../schema/page-type-start.json';
10
- import pageTypeEnd from '../schema/page-type-end.json';
11
- import templateStart from '../schema/template-start.json';
12
-
13
- const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID, PAGE_UID];
14
-
15
- export default {
16
- async buildContentTypes() {
17
- this.listenToCreatedContentTypes();
18
-
19
- await this.createContentTypes();
20
-
21
- await this.updateContentTypes();
22
- },
23
- listenToCreatedContentTypes() {
24
- strapi.eventHub.on('content-type.create', async (e) => {
25
- if (e.contentType.uid === PAGE_UID) {
26
- reloadStrapiOnLoad();
27
- }
28
- });
29
- },
30
-
31
- async createContentTypes() {
32
- const newContentTypes = UIDS.filter((c) => !Boolean(strapi.contentType(c)))
33
- .map((c) => this.getContentType(c)?.create)
34
- .filter(Boolean);
35
-
36
- await this.synchronizeContentTypes(newContentTypes);
37
- },
38
- async updateContentTypes() {
39
- const updateContentTypes = UIDS.filter((c) => Boolean(strapi.contentType(c)))
40
- .map((c) => this.getContentType(c).update)
41
- .filter(Boolean);
42
-
43
- await this.synchronizeContentTypes(updateContentTypes);
44
- },
45
- async synchronizeContentTypes(contentTypes: { uid: Common.UID.ContentType; contentType: Record<string, any> }[]) {
46
- const ctb = strapi.service('plugin::content-type-builder.content-types');
47
-
48
- const [updateTypes, newTypes] = partition(contentTypes, (c) => Boolean(strapi.contentType(c.uid)));
49
-
50
- if (newTypes.length > 0) {
51
- console.log(
52
- '[Plugin Page Builder]: Creating content types',
53
- newTypes.map((x) => x.uid)
54
- );
55
- }
56
-
57
- if (updateTypes.length > 0) {
58
- console.log(
59
- '[Plugin Page Builder]: Updating content types',
60
- updateTypes.map((x) => x.uid)
61
- );
62
- }
63
-
64
- if ((newTypes || []).length > 0) {
65
- await ctb.createContentTypes(newTypes.map((c) => ({ contentType: c.contentType, components: [] })));
66
- }
67
-
68
- if ((updateTypes || []).length > 0) {
69
- for await (const updateType of updateTypes) {
70
- await ctb.editContentType(updateType.uid, {
71
- contentType: updateType.contentType,
72
- components: []
73
- });
74
- }
75
- }
76
- },
77
- getContentType(uid: string) {
78
- const contentTypes = {
79
- [PAGE_UID]: {
80
- create: this.getPageContentType(true),
81
- update: this.getPageContentType()
82
- },
83
- [PAGE_TYPE_UID]: {
84
- create: this.getPageTypeContentType(true),
85
- update: this.getPageTypeContentType()
86
- },
87
- [TEMPLATE_UID]: {
88
- create: this.getTemplateContentType(),
89
- update: this.getTemplateContentType()
90
- }
91
- };
92
-
93
- return contentTypes?.[uid];
94
- },
95
- getPageContentType(create?: boolean) {
96
- const page = create ? pageStart : pageEnd;
97
- const contentType = this.mergeCollectionTypeWithModules(page, PAGE_UID);
98
-
99
- return { uid: PAGE_UID, contentType };
100
- },
101
- getPageTypeContentType(create?: boolean) {
102
- const pageType = create ? pageTypeStart : pageTypeEnd;
103
- const contentType = this.mergeCollectionTypeWithModules(pageType, PAGE_TYPE_UID);
104
-
105
- return { uid: PAGE_TYPE_UID, contentType };
106
- },
107
- getTemplateContentType() {
108
- const template = templateStart;
109
- const contentType = this.mergeCollectionTypeWithModules(template, TEMPLATE_UID);
110
-
111
- return { uid: TEMPLATE_UID, contentType };
112
- },
113
- mergeCollectionTypeWithModules(collectionType: Record<string, any>, uid: Common.UID.ContentType) {
114
- const { pluginOptions: oldPluginOptions, __schema__: oldSchema } = (strapi.contentType(uid) as any) || {};
115
- const components = this.getConfigModuleComponents();
116
-
117
- return {
118
- ...collectionType,
119
- displayName: oldSchema?.info?.displayName || collectionType?.displayName,
120
- pluginOptions: {
121
- ...oldPluginOptions,
122
- ...collectionType?.pluginOptions
123
- },
124
- attributes: {
125
- ...oldSchema?.attributes,
126
- ...collectionType.attributes,
127
- modules: { ...collectionType.attributes.modules, components }
128
- }
129
- };
130
- },
131
- getConfigModuleComponents() {
132
- return ((strapi.config.get(`plugin.${pluginId}`) as Record<string, any>)?.modules || []).filter(Boolean);
133
- }
134
- };
1
+ import partition from 'lodash/partition';
2
+ import { Common } from '@strapi/strapi';
3
+
4
+ import pageStart from '../schema/page-start.json';
5
+ import pageEnd from '../schema/page-end.json';
6
+ import pluginId from '../../admin/src/pluginId';
7
+ import { PAGE_UID, TEMPLATE_UID, PAGE_TYPE_UID } from '../../shared/utils/constants';
8
+ import { reloadStrapiOnLoad } from '../utils/reload-strapi-on-load';
9
+ import pageTypeStart from '../schema/page-type-start.json';
10
+ import pageTypeEnd from '../schema/page-type-end.json';
11
+ import templateStart from '../schema/template-start.json';
12
+
13
+ const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID, PAGE_UID];
14
+
15
+ export default {
16
+ async buildContentTypes() {
17
+ this.listenToCreatedContentTypes();
18
+
19
+ await this.createContentTypes();
20
+
21
+ await this.updateContentTypes();
22
+ },
23
+ listenToCreatedContentTypes() {
24
+ strapi.eventHub.on('content-type.create', async (e) => {
25
+ if (e.contentType.uid === PAGE_UID) {
26
+ reloadStrapiOnLoad();
27
+ }
28
+ });
29
+ },
30
+
31
+ async createContentTypes() {
32
+ const newContentTypes = UIDS.filter((c) => !Boolean(strapi.contentType(c)))
33
+ .map((c) => this.getContentType(c)?.create)
34
+ .filter(Boolean);
35
+
36
+ await this.synchronizeContentTypes(newContentTypes);
37
+ },
38
+ async updateContentTypes() {
39
+ const updateContentTypes = UIDS.filter((c) => Boolean(strapi.contentType(c)))
40
+ .map((c) => this.getContentType(c).update)
41
+ .filter(Boolean);
42
+
43
+ await this.synchronizeContentTypes(updateContentTypes);
44
+ },
45
+ async synchronizeContentTypes(contentTypes: { uid: Common.UID.ContentType; contentType: Record<string, any> }[]) {
46
+ const ctb = strapi.service('plugin::content-type-builder.content-types');
47
+
48
+ const [updateTypes, newTypes] = partition(contentTypes, (c) => Boolean(strapi.contentType(c.uid)));
49
+
50
+ if (newTypes.length > 0) {
51
+ console.log(
52
+ '[Plugin Page Builder]: Creating content types',
53
+ newTypes.map((x) => x.uid)
54
+ );
55
+ }
56
+
57
+ if (updateTypes.length > 0) {
58
+ console.log(
59
+ '[Plugin Page Builder]: Updating content types',
60
+ updateTypes.map((x) => x.uid)
61
+ );
62
+ }
63
+
64
+ if ((newTypes || []).length > 0) {
65
+ await ctb.createContentTypes(newTypes.map((c) => ({ contentType: c.contentType, components: [] })));
66
+ }
67
+
68
+ if ((updateTypes || []).length > 0) {
69
+ for await (const updateType of updateTypes) {
70
+ await ctb.editContentType(updateType.uid, {
71
+ contentType: updateType.contentType,
72
+ components: []
73
+ });
74
+ }
75
+ }
76
+ },
77
+ getContentType(uid: string) {
78
+ const contentTypes = {
79
+ [PAGE_UID]: {
80
+ create: this.getPageContentType(true),
81
+ update: this.getPageContentType()
82
+ },
83
+ [PAGE_TYPE_UID]: {
84
+ create: this.getPageTypeContentType(true),
85
+ update: this.getPageTypeContentType()
86
+ },
87
+ [TEMPLATE_UID]: {
88
+ create: this.getTemplateContentType(),
89
+ update: this.getTemplateContentType()
90
+ }
91
+ };
92
+
93
+ return contentTypes?.[uid];
94
+ },
95
+ getPageContentType(create?: boolean) {
96
+ const page = create ? pageStart : pageEnd;
97
+ const contentType = this.mergeCollectionTypeWithModules(page, PAGE_UID);
98
+
99
+ return { uid: PAGE_UID, contentType };
100
+ },
101
+ getPageTypeContentType(create?: boolean) {
102
+ const pageType = create ? pageTypeStart : pageTypeEnd;
103
+ const contentType = this.mergeCollectionTypeWithModules(pageType, PAGE_TYPE_UID);
104
+
105
+ return { uid: PAGE_TYPE_UID, contentType };
106
+ },
107
+ getTemplateContentType() {
108
+ const template = templateStart;
109
+ const contentType = this.mergeCollectionTypeWithModules(template, TEMPLATE_UID);
110
+
111
+ return { uid: TEMPLATE_UID, contentType };
112
+ },
113
+ mergeCollectionTypeWithModules(collectionType: Record<string, any>, uid: Common.UID.ContentType) {
114
+ const { pluginOptions: oldPluginOptions, __schema__: oldSchema } = (strapi.contentType(uid) as any) || {};
115
+ const modulesFromConfig = oldSchema?.attributes?.modules ? this.getConfigModuleComponents() : undefined;
116
+
117
+ return {
118
+ ...collectionType,
119
+ displayName: oldSchema?.info?.displayName || collectionType?.displayName,
120
+ pluginOptions: {
121
+ ...oldPluginOptions,
122
+ ...collectionType?.pluginOptions
123
+ },
124
+ attributes: {
125
+ ...oldSchema?.attributes,
126
+ ...collectionType.attributes,
127
+ ...(((collectionType?.attributes?.modules && collectionType?.attributes?.modules?.length > 0) ||
128
+ modulesFromConfig) && {
129
+ modules: { ...collectionType?.attributes?.modules, components: modulesFromConfig }
130
+ })
131
+ }
132
+ };
133
+ },
134
+ getConfigModuleComponents() {
135
+ return ((strapi.config.get(`plugin.${pluginId}`) as Record<string, any>)?.modules || []).filter(Boolean);
136
+ }
137
+ };
@@ -1,88 +1,88 @@
1
- import uniqBy from 'lodash/uniqBy';
2
- import { Common } from '@strapi/strapi';
3
-
4
- import { IGetTranslationPageLinks } from '../controllers/collection-types';
5
- import { PAGE_TYPE_UID } from '../../shared/utils/constants';
6
-
7
- export interface ICollectionTypeGL {
8
- uid: string;
9
- type: string;
10
- inputType: string;
11
- }
12
-
13
- export default {
14
- async hasPageRelation(uid: string): Promise<{ hasPageRelation: boolean }> {
15
- const contentType = strapi.contentTypes?.[uid];
16
- const pageTypesWithUid =
17
- (await strapi.entityService.findMany(PAGE_TYPE_UID, {
18
- filters: {
19
- uid: {
20
- $eq: uid
21
- }
22
- }
23
- })) || [];
24
-
25
- return {
26
- hasPageRelation: Boolean(
27
- contentType?.attributes?.page &&
28
- contentType?.attributes?.page?.morphBy === 'collectionTypeData' &&
29
- (pageTypesWithUid as Record<string, any>[]).length > 0
30
- )
31
- };
32
- },
33
- withPageMorph(): ICollectionTypeGL[] {
34
- const { getTypeName, getFiltersInputTypeName } = strapi.plugin('graphql').service('utils').naming;
35
-
36
- const collectionTypes = Object.entries(strapi.contentTypes)
37
- .map((ct) => {
38
- const uid: string = ct?.[0];
39
- const contentType = ct?.[1] as Record<string, any>;
40
- const type = contentType ? getTypeName(contentType) : undefined;
41
- const hasPageMorph = contentType?.attributes?.page?.morphBy === 'collectionTypeData';
42
-
43
- if (uid && type && hasPageMorph) {
44
- return {
45
- uid,
46
- type: getTypeName(contentType),
47
- inputType: getFiltersInputTypeName(contentType)
48
- };
49
- }
50
- })
51
- .filter(Boolean) as ICollectionTypeGL[];
52
-
53
- return collectionTypes;
54
- },
55
- async getTranslationPageLinks(uid: Common.UID.ContentType, ids: string[]) {
56
- try {
57
- const entities = await strapi.entityService.findMany(uid, {
58
- filters: {
59
- id: { $in: ids }
60
- },
61
- populate: {
62
- page: {
63
- populate: {
64
- localizations: true
65
- }
66
- }
67
- }
68
- } as any);
69
-
70
- let pages: IGetTranslationPageLinks[] = [];
71
-
72
- // Get all pages linked to the entity
73
- entities?.forEach((x: any) => {
74
- x?.page?.forEach((p: any) => {
75
- pages.push({ id: p.id, locale: p.locale });
76
-
77
- p.localizations.forEach((l: any) => {
78
- pages.push({ id: l.id, locale: l.locale });
79
- });
80
- });
81
- });
82
-
83
- return uniqBy(pages, 'id');
84
- } catch {
85
- return [];
86
- }
87
- }
88
- };
1
+ import uniqBy from 'lodash/uniqBy';
2
+ import { Common } from '@strapi/strapi';
3
+
4
+ import { IGetTranslationPageLinks } from '../controllers/collection-types';
5
+ import { PAGE_TYPE_UID } from '../../shared/utils/constants';
6
+
7
+ export interface ICollectionTypeGL {
8
+ uid: string;
9
+ type: string;
10
+ inputType: string;
11
+ }
12
+
13
+ export default {
14
+ async hasPageRelation(uid: string): Promise<{ hasPageRelation: boolean }> {
15
+ const contentType = strapi.contentTypes?.[uid];
16
+ const pageTypesWithUid =
17
+ (await strapi.entityService.findMany(PAGE_TYPE_UID, {
18
+ filters: {
19
+ uid: {
20
+ $eq: uid
21
+ }
22
+ }
23
+ })) || [];
24
+
25
+ return {
26
+ hasPageRelation: Boolean(
27
+ contentType?.attributes?.page &&
28
+ contentType?.attributes?.page?.morphBy === 'collectionTypeData' &&
29
+ (pageTypesWithUid as Record<string, any>[]).length > 0
30
+ )
31
+ };
32
+ },
33
+ withPageMorph(): ICollectionTypeGL[] {
34
+ const { getTypeName, getFiltersInputTypeName } = strapi.plugin('graphql').service('utils').naming;
35
+
36
+ const collectionTypes = Object.entries(strapi.contentTypes)
37
+ .map((ct) => {
38
+ const uid: string = ct?.[0];
39
+ const contentType = ct?.[1] as Record<string, any>;
40
+ const type = contentType ? getTypeName(contentType) : undefined;
41
+ const hasPageMorph = contentType?.attributes?.page?.morphBy === 'collectionTypeData';
42
+
43
+ if (uid && type && hasPageMorph) {
44
+ return {
45
+ uid,
46
+ type: getTypeName(contentType),
47
+ inputType: getFiltersInputTypeName(contentType)
48
+ };
49
+ }
50
+ })
51
+ .filter(Boolean) as ICollectionTypeGL[];
52
+
53
+ return collectionTypes;
54
+ },
55
+ async getTranslationPageLinks(uid: Common.UID.ContentType, ids: string[]) {
56
+ try {
57
+ const entities = await strapi.entityService.findMany(uid, {
58
+ filters: {
59
+ id: { $in: ids }
60
+ },
61
+ populate: {
62
+ page: {
63
+ populate: {
64
+ localizations: true
65
+ }
66
+ }
67
+ }
68
+ } as any);
69
+
70
+ let pages: IGetTranslationPageLinks[] = [];
71
+
72
+ // Get all pages linked to the entity
73
+ entities?.forEach((x: any) => {
74
+ x?.page?.forEach((p: any) => {
75
+ pages.push({ id: p.id, locale: p.locale });
76
+
77
+ p.localizations.forEach((l: any) => {
78
+ pages.push({ id: l.id, locale: l.locale });
79
+ });
80
+ });
81
+ });
82
+
83
+ return uniqBy(pages, 'id');
84
+ } catch {
85
+ return [];
86
+ }
87
+ }
88
+ };
@@ -1,13 +1,13 @@
1
- import page from './page';
2
- import builder from './builder';
3
- import pageType from './page-type';
4
- import collectionTypes from './collection-types';
5
- import template from './template';
6
-
7
- export default {
8
- page,
9
- builder,
10
- 'page-type': pageType,
11
- 'collection-types': collectionTypes,
12
- template
13
- };
1
+ import page from './page';
2
+ import builder from './builder';
3
+ import pageType from './page-type';
4
+ import collectionTypes from './collection-types';
5
+ import template from './template';
6
+
7
+ export default {
8
+ page,
9
+ builder,
10
+ 'page-type': pageType,
11
+ 'collection-types': collectionTypes,
12
+ template
13
+ };
@@ -1,26 +1,26 @@
1
- import { PAGE_TYPE_UID } from '../../shared/utils/constants';
2
-
3
- export default {
4
- async findOneByUid(uid: string) {
5
- const results = await strapi.entityService?.findMany(PAGE_TYPE_UID, {
6
- populate: {
7
- template: {
8
- populate: {
9
- modules: true
10
- }
11
- }
12
- },
13
- filters: {
14
- uid
15
- }
16
- });
17
-
18
- const result = (results as any[]).length > 0 ? results?.[0] : undefined;
19
-
20
- if (result) {
21
- return result;
22
- } else {
23
- return null;
24
- }
25
- }
26
- };
1
+ import { PAGE_TYPE_UID } from '../../shared/utils/constants';
2
+
3
+ export default {
4
+ async findOneByUid(uid: string) {
5
+ const results = await strapi.entityService?.findMany(PAGE_TYPE_UID, {
6
+ populate: {
7
+ template: {
8
+ populate: {
9
+ modules: true
10
+ }
11
+ }
12
+ },
13
+ filters: {
14
+ uid
15
+ }
16
+ });
17
+
18
+ const result = (results as any[]).length > 0 ? results?.[0] : undefined;
19
+
20
+ if (result) {
21
+ return result;
22
+ } else {
23
+ return null;
24
+ }
25
+ }
26
+ };
@@ -1,24 +1,24 @@
1
- import { PAGE_UID } from '../../shared/utils/constants';
2
-
3
- export default {
4
- async getPage(id: string) {
5
- // @ts-ignore
6
- const page = await strapi.db.query(PAGE_UID).findOne({
7
- // @ts-ignore
8
- select: 'id',
9
- populate: {
10
- // @ts-ignore
11
- collectionTypeData: true,
12
- pageType: true
13
- },
14
- where: {
15
- id
16
- }
17
- });
18
-
19
- return {
20
- pageType: page.pageType,
21
- collectionTypeData: page.collectionTypeData?.[0] ?? null
22
- };
23
- }
24
- };
1
+ import { PAGE_UID } from '../../shared/utils/constants';
2
+
3
+ export default {
4
+ async getPage(id: string) {
5
+ // @ts-ignore
6
+ const page = await strapi.db.query(PAGE_UID).findOne({
7
+ // @ts-ignore
8
+ select: 'id',
9
+ populate: {
10
+ // @ts-ignore
11
+ collectionTypeData: true,
12
+ pageType: true
13
+ },
14
+ where: {
15
+ id
16
+ }
17
+ });
18
+
19
+ return {
20
+ pageType: page.pageType,
21
+ collectionTypeData: page.collectionTypeData?.[0] ?? null
22
+ };
23
+ }
24
+ };
@@ -1,14 +1,13 @@
1
- import { getPopulatedEntity } from '../utils/strapi';
2
- import { TEMPLATE_UID } from '../../shared/utils/constants';
3
-
4
- export default {
5
- async findAll() {
6
- const foundTemplates = await strapi.entityService.findMany(TEMPLATE_UID);
7
-
8
- return foundTemplates;
9
- },
10
- async findOne(id: number) {
11
- const getpopulatedTemplate = getPopulatedEntity(TEMPLATE_UID, id);
12
- return getpopulatedTemplate;
13
- }
14
- };
1
+ import { getPopulatedEntity } from '../utils/strapi';
2
+ import { TEMPLATE_UID } from '../../shared/utils/constants';
3
+
4
+ export default {
5
+ async findAll() {
6
+ const foundTemplates = await strapi.entityService.findMany(TEMPLATE_UID);
7
+
8
+ return foundTemplates;
9
+ },
10
+ async findOne(id: number) {
11
+ return await getPopulatedEntity(TEMPLATE_UID, id);
12
+ }
13
+ };