@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.
- package/README.md +35 -11
- package/admin/src/api/collection-type.ts +1 -7
- package/admin/src/api/page-type.ts +4 -5
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +12 -15
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +41 -34
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +39 -80
- package/admin/src/components/EditView/Details/index.tsx +2 -13
- package/admin/src/components/EditView/PageSettings/index.tsx +5 -61
- package/admin/src/components/EditView/index.tsx +2 -8
- package/admin/src/components/PageTypeFilter/index.tsx +17 -0
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -0
- package/admin/src/index.tsx +2 -2
- package/admin/src/utils/sanitizeModules.ts +92 -9
- package/dist/package.json +12 -10
- package/dist/server/bootstrap/permissions.js +10 -68
- package/dist/server/bootstrap.js +33 -46
- package/dist/server/controllers/collection-types.js +0 -5
- package/dist/server/controllers/index.js +1 -3
- package/dist/server/controllers/page.js +19 -0
- package/dist/server/graphql/index.js +2 -2
- package/dist/server/graphql/page-by-slug.js +50 -44
- package/dist/server/graphql/pages-by-uid.js +9 -11
- package/dist/server/register.js +2 -2
- package/dist/server/routes/index.js +5 -26
- package/dist/server/schema/page-end.json +0 -5
- package/dist/server/services/builder.js +5 -15
- package/dist/server/services/collection-types.js +0 -7
- package/dist/server/services/index.js +1 -3
- package/dist/server/services/template.js +1 -2
- package/dist/server/utils/strapi.js +1 -4
- package/dist/shared/utils/constants.js +1 -3
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +12 -10
- package/server/bootstrap/collection-type-lifecycles.ts +1 -1
- package/server/bootstrap/permissions.ts +10 -75
- package/server/bootstrap.ts +35 -49
- package/server/controllers/collection-types.ts +0 -5
- package/server/controllers/index.ts +1 -3
- package/server/controllers/page.ts +23 -0
- package/server/graphql/index.ts +2 -2
- package/server/graphql/page-by-slug.ts +113 -0
- package/server/graphql/pages-by-uid.ts +9 -11
- package/server/register.ts +2 -2
- package/server/routes/index.ts +5 -26
- package/server/schema/page-end.json +0 -5
- package/server/services/builder.ts +6 -18
- package/server/services/collection-types.ts +1 -8
- package/server/services/index.ts +1 -3
- package/server/services/template.ts +1 -2
- package/server/utils/strapi.ts +1 -5
- package/shared/utils/constants.ts +0 -2
- package/admin/src/api/has-platform-relation.ts +0 -37
- package/admin/src/api/platform-page-types.ts +0 -40
- package/admin/src/api/platform.ts +0 -34
- package/admin/src/components/EditView/Platform/platform-select.tsx +0 -31
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +0 -39
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +0 -28
- package/admin/src/components/PageFilters/filters.tsx +0 -180
- package/admin/src/components/PageFilters/index.tsx +0 -30
- package/dist/server/controllers/platform.js +0 -20
- package/dist/server/graphql/page-by-path.js +0 -89
- package/dist/server/schema/platform-start.json +0 -31
- package/dist/server/services/platform.js +0 -36
- package/server/controllers/platform.ts +0 -21
- package/server/graphql/page-by-path.ts +0 -105
- package/server/schema/platform-start.json +0 -31
- package/server/services/platform.ts +0 -36
|
@@ -10,7 +10,7 @@ const getPageBySlug = (strapi) => {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
type Query {
|
|
13
|
-
getPageBySlug(path: String,
|
|
13
|
+
getPageBySlug(path: String, _locale: String, _publicationState: PublicationState): PageEntity
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
`;
|
|
@@ -22,52 +22,58 @@ const getPageBySlug = (strapi) => {
|
|
|
22
22
|
getPageBySlug: {
|
|
23
23
|
resolve: async (_parent, args, ctx) => {
|
|
24
24
|
var _a;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
if (!(entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) || Object.keys(entityResponse.value).length === 0) {
|
|
48
|
-
throw new Error(ctx.koaContext.response.message);
|
|
49
|
-
}
|
|
50
|
-
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);
|
|
51
|
-
const collectionType = collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter === null || collectionTypeDataFilter === void 0 ? void 0 : collectionTypeDataFilter[0] : null;
|
|
52
|
-
const addedAttributes = {
|
|
53
|
-
collectionType: collectionType
|
|
54
|
-
};
|
|
55
|
-
const result = {
|
|
56
|
-
...entityResponse.value,
|
|
57
|
-
...addedAttributes
|
|
58
|
-
};
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
const results = await getPage();
|
|
62
|
-
if (((_a = Object.values(results)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
|
|
63
|
-
return results;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
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;
|
|
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) {
|
|
66
46
|
throw new Error(ctx.koaContext.response.message);
|
|
67
47
|
}
|
|
48
|
+
// Get collectionTypeData from the entity response
|
|
49
|
+
const collectionTypeData = (_b = entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) === null || _b === void 0 ? void 0 : _b.collectionTypeData;
|
|
50
|
+
// Filter out null/undefined items
|
|
51
|
+
const collectionTypeDataFilter = collectionTypeData === null || collectionTypeData === void 0 ? void 0 : collectionTypeData.filter(Boolean);
|
|
52
|
+
// Filter by locale if specified, then take the first item
|
|
53
|
+
let filteredByLocale = collectionTypeDataFilter;
|
|
54
|
+
if (args._locale && Array.isArray(collectionTypeDataFilter)) {
|
|
55
|
+
filteredByLocale = collectionTypeDataFilter.filter((item) => {
|
|
56
|
+
return (item === null || item === void 0 ? void 0 : item.locale) === args._locale;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Take the first item (should be only one after locale filtering)
|
|
60
|
+
const collectionType = filteredByLocale && Array.isArray(filteredByLocale) && filteredByLocale.length > 0
|
|
61
|
+
? filteredByLocale[0]
|
|
62
|
+
: null;
|
|
63
|
+
const addedAttributes = {
|
|
64
|
+
collectionType: collectionType
|
|
65
|
+
};
|
|
66
|
+
const result = {
|
|
67
|
+
...entityResponse.value,
|
|
68
|
+
...addedAttributes
|
|
69
|
+
};
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
const results = await getPage();
|
|
73
|
+
if (((_a = Object.values(results)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
|
|
74
|
+
return results;
|
|
68
75
|
}
|
|
69
|
-
|
|
70
|
-
console.log('Error in getPageBySlug:', error);
|
|
76
|
+
else {
|
|
71
77
|
throw new Error(ctx.koaContext.response.message);
|
|
72
78
|
}
|
|
73
79
|
}
|
|
@@ -14,16 +14,13 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
14
14
|
pageSize: Int
|
|
15
15
|
}`;
|
|
16
16
|
const entityInfo = collectionTypes.map((collectionType) => {
|
|
17
|
-
return `
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
return `extend type ${collectionType.type}EntityResponseCollection {
|
|
18
|
+
metaInfo: MetaInfo
|
|
19
|
+
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`;
|
|
21
|
+
type Query {
|
|
22
|
+
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput, pagination: PaginationArg, sort:[String], pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
|
|
23
|
+
}`;
|
|
27
24
|
});
|
|
28
25
|
return `${metaInfo} ${entityInfo}`;
|
|
29
26
|
};
|
|
@@ -60,8 +57,9 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
60
57
|
hasPage: { $eq: true },
|
|
61
58
|
page: { ...transformedpageArgs.filters }
|
|
62
59
|
},
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
sort: transformedArgs.sort,
|
|
61
|
+
start: start,
|
|
62
|
+
limit: limit
|
|
65
63
|
}));
|
|
66
64
|
const entityResponse = toEntityResponseCollection(results || [], {
|
|
67
65
|
args: transformedArgs,
|
package/dist/server/register.js
CHANGED
|
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const page_by_slug_1 = __importDefault(require("./graphql/page-by-slug"));
|
|
7
7
|
const page_type_1 = __importDefault(require("./graphql/page-type"));
|
|
8
8
|
const pages_by_uid_1 = __importDefault(require("./graphql/pages-by-uid"));
|
|
9
9
|
exports.default = async ({ strapi }) => {
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const extensionService = strapi.plugin('graphql').service('extension');
|
|
12
12
|
extensionService.use(page_type_1.default);
|
|
13
|
-
extensionService.use((0,
|
|
13
|
+
extensionService.use((0, page_by_slug_1.default)(strapi));
|
|
14
14
|
extensionService.use((0, pages_by_uid_1.default)(strapi));
|
|
15
15
|
await ((_b = (_a = strapi.services) === null || _a === void 0 ? void 0 : _a['plugin::page-builder.builder']) === null || _b === void 0 ? void 0 : _b.buildContentTypes());
|
|
16
16
|
};
|
|
@@ -20,6 +20,11 @@ const routes = {
|
|
|
20
20
|
method: 'GET',
|
|
21
21
|
path: '/page/:id',
|
|
22
22
|
handler: 'page.getPage'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
method: 'POST',
|
|
26
|
+
path: '/page/create',
|
|
27
|
+
handler: 'page.createPage'
|
|
23
28
|
}
|
|
24
29
|
]
|
|
25
30
|
},
|
|
@@ -36,11 +41,6 @@ const routes = {
|
|
|
36
41
|
method: 'GET',
|
|
37
42
|
path: '/collection-types-page-links/:uid/:ids?',
|
|
38
43
|
handler: 'collection-types.getTranslationPageLinks'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
method: 'GET',
|
|
42
|
-
path: '/collection-types/hasPlatform/:uid',
|
|
43
|
-
handler: 'collection-types.hasPlatformRelation'
|
|
44
44
|
}
|
|
45
45
|
]
|
|
46
46
|
},
|
|
@@ -59,27 +59,6 @@ const routes = {
|
|
|
59
59
|
handler: 'template.findOneById'
|
|
60
60
|
}
|
|
61
61
|
]
|
|
62
|
-
},
|
|
63
|
-
platform: {
|
|
64
|
-
type: 'admin',
|
|
65
|
-
prefix: undefined,
|
|
66
|
-
routes: [
|
|
67
|
-
{
|
|
68
|
-
method: 'GET',
|
|
69
|
-
path: '/platform',
|
|
70
|
-
handler: 'platform.findAll'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
method: 'GET',
|
|
74
|
-
path: '/platform/:uid',
|
|
75
|
-
handler: 'platform.findOneByUid'
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
method: 'GET',
|
|
79
|
-
path: '/platform/:platform/page-types',
|
|
80
|
-
handler: 'platform.findPageTypesByPlatform'
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
62
|
}
|
|
84
63
|
};
|
|
85
64
|
exports.default = routes;
|
|
@@ -12,8 +12,7 @@ const reload_strapi_on_load_1 = require("../utils/reload-strapi-on-load");
|
|
|
12
12
|
const page_type_start_json_1 = __importDefault(require("../schema/page-type-start.json"));
|
|
13
13
|
const page_type_end_json_1 = __importDefault(require("../schema/page-type-end.json"));
|
|
14
14
|
const template_start_json_1 = __importDefault(require("../schema/template-start.json"));
|
|
15
|
-
const
|
|
16
|
-
const UIDS = [constants_1.TEMPLATE_UID, constants_1.PAGE_TYPE_UID, constants_1.PLATFORM_UID, constants_1.PAGE_UID];
|
|
15
|
+
const UIDS = [constants_1.TEMPLATE_UID, constants_1.PAGE_TYPE_UID, constants_1.PAGE_UID];
|
|
17
16
|
exports.default = {
|
|
18
17
|
async buildContentTypes() {
|
|
19
18
|
this.listenToCreatedContentTypes();
|
|
@@ -73,35 +72,26 @@ exports.default = {
|
|
|
73
72
|
[constants_1.TEMPLATE_UID]: {
|
|
74
73
|
create: this.getTemplateContentType(),
|
|
75
74
|
update: this.getTemplateContentType()
|
|
76
|
-
},
|
|
77
|
-
[constants_1.PLATFORM_UID]: {
|
|
78
|
-
create: this.getPlatformContentType(),
|
|
79
|
-
update: this.getPlatformContentType()
|
|
80
75
|
}
|
|
81
76
|
};
|
|
82
77
|
return contentTypes === null || contentTypes === void 0 ? void 0 : contentTypes[uid];
|
|
83
78
|
},
|
|
84
79
|
getPageContentType(create) {
|
|
85
80
|
const page = create ? page_start_json_1.default : page_end_json_1.default;
|
|
86
|
-
const contentType = this.
|
|
81
|
+
const contentType = this.mergeCollectionTypeWithModules(page, constants_1.PAGE_UID);
|
|
87
82
|
return { uid: constants_1.PAGE_UID, contentType };
|
|
88
83
|
},
|
|
89
84
|
getPageTypeContentType(create) {
|
|
90
85
|
const pageType = create ? page_type_start_json_1.default : page_type_end_json_1.default;
|
|
91
|
-
const contentType = this.
|
|
86
|
+
const contentType = this.mergeCollectionTypeWithModules(pageType, constants_1.PAGE_TYPE_UID);
|
|
92
87
|
return { uid: constants_1.PAGE_TYPE_UID, contentType };
|
|
93
88
|
},
|
|
94
89
|
getTemplateContentType() {
|
|
95
90
|
const template = template_start_json_1.default;
|
|
96
|
-
const contentType = this.
|
|
91
|
+
const contentType = this.mergeCollectionTypeWithModules(template, constants_1.TEMPLATE_UID);
|
|
97
92
|
return { uid: constants_1.TEMPLATE_UID, contentType };
|
|
98
93
|
},
|
|
99
|
-
|
|
100
|
-
const platform = platform_start_json_1.default;
|
|
101
|
-
const contentType = this.mergeCollectionTypeWithOld(platform, constants_1.PLATFORM_UID);
|
|
102
|
-
return { uid: constants_1.PLATFORM_UID, contentType };
|
|
103
|
-
},
|
|
104
|
-
mergeCollectionTypeWithOld(collectionType, uid) {
|
|
94
|
+
mergeCollectionTypeWithModules(collectionType, uid) {
|
|
105
95
|
var _a, _b, _c, _d, _e, _f;
|
|
106
96
|
const { pluginOptions: oldPluginOptions, __schema__: oldSchema } = strapi.contentType(uid) || {};
|
|
107
97
|
const modulesFromConfig = ((_a = oldSchema === null || oldSchema === void 0 ? void 0 : oldSchema.attributes) === null || _a === void 0 ? void 0 : _a.modules) ? this.getConfigModuleComponents() : undefined;
|
|
@@ -22,13 +22,6 @@ exports.default = {
|
|
|
22
22
|
pageTypesWithUid.length > 0)
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
|
-
async hasPlatformRelation(uid) {
|
|
26
|
-
var _a, _b, _c;
|
|
27
|
-
const contentType = (_a = strapi.contentTypes) === null || _a === void 0 ? void 0 : _a[uid];
|
|
28
|
-
return {
|
|
29
|
-
hasPlatformRelation: Boolean(((_c = (_b = contentType === null || contentType === void 0 ? void 0 : contentType.attributes) === null || _b === void 0 ? void 0 : _b.platform) === null || _c === void 0 ? void 0 : _c.target) === constants_1.PLATFORM_UID)
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
25
|
withPageMorph() {
|
|
33
26
|
const { getTypeName, getFiltersInputTypeName } = strapi.plugin('graphql').service('utils').naming;
|
|
34
27
|
const collectionTypes = Object.entries(strapi.contentTypes)
|
|
@@ -8,12 +8,10 @@ const builder_1 = __importDefault(require("./builder"));
|
|
|
8
8
|
const page_type_1 = __importDefault(require("./page-type"));
|
|
9
9
|
const collection_types_1 = __importDefault(require("./collection-types"));
|
|
10
10
|
const template_1 = __importDefault(require("./template"));
|
|
11
|
-
const platform_1 = __importDefault(require("./platform"));
|
|
12
11
|
exports.default = {
|
|
13
12
|
page: page_1.default,
|
|
14
13
|
builder: builder_1.default,
|
|
15
14
|
'page-type': page_type_1.default,
|
|
16
15
|
'collection-types': collection_types_1.default,
|
|
17
|
-
template: template_1.default
|
|
18
|
-
platform: platform_1.default
|
|
16
|
+
template: template_1.default
|
|
19
17
|
};
|
|
@@ -8,7 +8,6 @@ exports.default = {
|
|
|
8
8
|
return foundTemplates;
|
|
9
9
|
},
|
|
10
10
|
async findOne(id) {
|
|
11
|
-
|
|
12
|
-
return getpopulatedTemplate;
|
|
11
|
+
return await (0, strapi_1.getPopulatedEntity)(constants_1.TEMPLATE_UID, id);
|
|
13
12
|
}
|
|
14
13
|
};
|
|
@@ -11,15 +11,12 @@ const getDeepPopulate = (uid, populate, depth = 0) => {
|
|
|
11
11
|
const { attributes } = strapi.getModel(uid);
|
|
12
12
|
return Object.keys(attributes).reduce((populateAcc, attributeName) => {
|
|
13
13
|
const attribute = attributes[attributeName];
|
|
14
|
-
if (attribute.type === 'relation') {
|
|
15
|
-
return populateAcc;
|
|
16
|
-
}
|
|
17
14
|
if (attribute.type === 'component') {
|
|
18
15
|
populateAcc[attributeName] = {
|
|
19
16
|
populate: (0, exports.getDeepPopulate)(attribute.component, null, depth + 1)
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
if (attribute.type === 'media') {
|
|
19
|
+
if (attribute.type === 'relation' || attribute.type === 'media') {
|
|
23
20
|
populateAcc[attributeName] = true;
|
|
24
21
|
}
|
|
25
22
|
if (attribute.type === 'dynamiczone') {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PAGE_TYPE_PAGE = exports.PAGE_TYPE_UID = exports.TEMPLATE_UID = exports.PAGE_UID = void 0;
|
|
4
4
|
exports.PAGE_UID = 'api::page.page';
|
|
5
5
|
exports.TEMPLATE_UID = 'api::template.template';
|
|
6
6
|
exports.PAGE_TYPE_UID = 'api::page-type.page-type';
|
|
7
|
-
exports.PLATFORM_UID = 'api::platform.platform';
|
|
8
7
|
exports.PAGE_TYPE_PAGE = 'page';
|
|
9
|
-
exports.PLATFORM = 'platform';
|