@webbio/strapi-plugin-page-builder 0.2.5 → 0.2.6
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 +98 -98
- package/admin/src/api/collection-type.ts +110 -110
- package/admin/src/api/has-page-relation.ts +34 -34
- package/admin/src/api/page-type.ts +31 -31
- package/admin/src/api/template.ts +27 -27
- package/admin/src/components/Combobox/index.tsx +77 -77
- package/admin/src/components/Combobox/react-select-custom-styles.tsx +120 -120
- package/admin/src/components/Combobox/styles.ts +22 -22
- package/admin/src/components/ConfirmModal/index.tsx +90 -90
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +124 -124
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +104 -104
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/styles.ts +19 -19
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +74 -74
- package/admin/src/components/EditView/Details/index.tsx +47 -47
- package/admin/src/components/EditView/Details/styles.ts +51 -51
- package/admin/src/components/EditView/PageSettings/index.tsx +104 -104
- package/admin/src/components/EditView/Template/TemplateConfirmModal/index.tsx +36 -36
- package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +69 -69
- package/admin/src/components/EditView/Template/TemplateSelect/use-template-modules.ts +38 -38
- package/admin/src/components/EditView/index.tsx +29 -29
- package/admin/src/components/EditView/page-type-select.tsx +32 -32
- package/admin/src/components/EditView/wrapper.tsx +35 -35
- package/admin/src/components/Initializer/index.tsx +24 -24
- package/admin/src/components/PageTypeFilter/index.tsx +17 -17
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -130
- package/admin/src/components/PluginIcon/index.tsx +12 -12
- package/admin/src/constants.ts +3 -3
- package/admin/src/index.tsx +59 -59
- package/admin/src/middlewares/index.tsx +37 -37
- package/admin/src/pluginId.ts +5 -5
- package/admin/src/translations/en.json +6 -6
- package/admin/src/translations/nl.json +6 -6
- package/admin/src/utils/getRequestUrl.ts +11 -11
- package/admin/src/utils/getTrad.ts +5 -5
- package/admin/src/utils/hooks/useDebounce.ts +17 -17
- package/admin/src/utils/hooks/useGetLocaleFromUrl.ts +9 -9
- package/admin/src/utils/hooks/usePrevious.ts +12 -12
- package/admin/src/utils/sanitizeModules.ts +93 -90
- package/custom.d.ts +5 -5
- package/dist/package.json +1 -1
- package/dist/server/controllers/platform.js +20 -0
- package/dist/server/graphql/page-by-path.js +90 -0
- package/dist/server/graphql/page-by-slug.js +9 -9
- package/dist/server/graphql/pages-by-uid.js +14 -14
- package/dist/server/schema/platform-start.json +31 -0
- package/dist/server/services/platform.js +36 -0
- package/dist/server/utils/graphql.js +18 -18
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +71 -71
- package/server/bootstrap/collection-type-lifecycles.ts +47 -47
- package/server/bootstrap/permissions.ts +42 -42
- package/server/bootstrap.ts +198 -198
- package/server/config/index.ts +4 -4
- package/server/content-types/index.ts +1 -1
- package/server/controllers/collection-types.ts +27 -27
- package/server/controllers/index.ts +11 -11
- package/server/controllers/page-type.ts +13 -13
- package/server/controllers/page.ts +9 -9
- package/server/controllers/template.ts +16 -16
- package/server/destroy.ts +5 -5
- package/server/graphql/index.ts +9 -9
- package/server/graphql/page-by-slug.ts +98 -98
- package/server/graphql/page-type.ts +67 -67
- package/server/graphql/pages-by-uid.ts +127 -127
- package/server/index.ts +23 -23
- package/server/middlewares/index.ts +1 -1
- package/server/policies/index.ts +1 -1
- package/server/register.ts +15 -15
- package/server/routes/index.ts +58 -58
- package/server/schema/page-end.json +91 -91
- package/server/schema/page-start.json +87 -87
- package/server/schema/page-type-end.json +43 -43
- package/server/schema/page-type-start.json +38 -38
- package/server/schema/template-start.json +35 -35
- package/server/services/builder.ts +137 -137
- package/server/services/collection-types.ts +88 -88
- package/server/services/index.ts +13 -13
- package/server/services/page-type.ts +26 -26
- package/server/services/page.ts +24 -24
- package/server/services/template.ts +13 -13
- package/server/utils/filter-underscore-arguments.ts +12 -12
- package/server/utils/graphql.ts +113 -113
- package/server/utils/paginationValidation.ts +39 -39
- package/server/utils/reload-strapi-on-load.ts +13 -13
- package/server/utils/strapi.ts +45 -45
- package/shared/utils/constants.ts +4 -4
- package/shared/utils/sleep.ts +1 -1
- package/strapi-admin.js +3 -3
- package/strapi-server.js +3 -3
- package/tsconfig.json +20 -20
- package/tsconfig.server.json +25 -25
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../shared/utils/constants");
|
|
4
|
+
const getPageByPath = (strapi) => {
|
|
5
|
+
const typeDefs = () => {
|
|
6
|
+
return `
|
|
7
|
+
extend type Page {
|
|
8
|
+
collectionType: GenericMorph
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Query {
|
|
12
|
+
getPageByPath(path: String, domain: String, publicationState: PublicationState): PageEntity
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
`;
|
|
16
|
+
};
|
|
17
|
+
const resolvers = (strapi) => {
|
|
18
|
+
const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
|
|
19
|
+
return {
|
|
20
|
+
Query: {
|
|
21
|
+
getPageByPath: {
|
|
22
|
+
resolve: async (_parent, args, ctx) => {
|
|
23
|
+
var _a;
|
|
24
|
+
try {
|
|
25
|
+
const filteredArgs = {
|
|
26
|
+
filters: {
|
|
27
|
+
path: args.path,
|
|
28
|
+
platform: args.domain ? { domain: args.domain } : null
|
|
29
|
+
},
|
|
30
|
+
publicationState: args.publicationState,
|
|
31
|
+
locale: args.locale
|
|
32
|
+
};
|
|
33
|
+
const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
|
|
34
|
+
const getPage = async () => {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
const transformedArgs = transformArgs(filteredArgs, {
|
|
37
|
+
contentType: strapi.contentTypes[constants_1.PAGE_UID],
|
|
38
|
+
usePagination: false
|
|
39
|
+
});
|
|
40
|
+
const results = await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findMany(constants_1.PAGE_UID, {
|
|
41
|
+
...filteredArgs,
|
|
42
|
+
populate: '*'
|
|
43
|
+
}));
|
|
44
|
+
const entityResponse = toEntityResponse((results === null || results === void 0 ? void 0 : results[0]) || {}, {
|
|
45
|
+
args: transformedArgs,
|
|
46
|
+
resourceUID: constants_1.PAGE_UID
|
|
47
|
+
});
|
|
48
|
+
if (!(entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) || Object.keys(entityResponse.value).length === 0) {
|
|
49
|
+
throw new Error(ctx.koaContext.response.message);
|
|
50
|
+
}
|
|
51
|
+
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);
|
|
52
|
+
const collectionType = collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter === null || collectionTypeDataFilter === void 0 ? void 0 : collectionTypeDataFilter[0] : null;
|
|
53
|
+
const addedAttributes = {
|
|
54
|
+
collectionType: collectionType
|
|
55
|
+
};
|
|
56
|
+
const result = {
|
|
57
|
+
...entityResponse.value,
|
|
58
|
+
...addedAttributes
|
|
59
|
+
};
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
const results = await getPage();
|
|
63
|
+
if (((_a = Object.values(results)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
|
|
64
|
+
return results;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new Error(ctx.koaContext.response.message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.log('Error in [getPageByPath], args:', args, 'ERROR:', error);
|
|
72
|
+
throw new Error(ctx.koaContext.response.message);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const resolversConfig = {
|
|
80
|
+
'Query.getPageByPath': {
|
|
81
|
+
auth: false
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
typeDefs: typeDefs(),
|
|
86
|
+
resolvers: resolvers(strapi),
|
|
87
|
+
resolversConfig
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
exports.default = getPageByPath;
|
|
@@ -4,15 +4,15 @@ const filter_underscore_arguments_1 = require("../utils/filter-underscore-argume
|
|
|
4
4
|
const constants_1 = require("../../shared/utils/constants");
|
|
5
5
|
const getPageBySlug = (strapi) => {
|
|
6
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
|
-
|
|
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
16
|
`;
|
|
17
17
|
};
|
|
18
18
|
const resolvers = (strapi) => {
|
|
@@ -7,22 +7,22 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
7
7
|
// @ts-ignore service does exist
|
|
8
8
|
const collectionTypes = strapi.service('plugin::page-builder.collection-types').withPageMorph();
|
|
9
9
|
const typeDefs = () => {
|
|
10
|
-
const metaInfo = `type MetaInfo {
|
|
11
|
-
total: Int
|
|
12
|
-
page: Int
|
|
13
|
-
pageCount: Int
|
|
14
|
-
pageSize: Int
|
|
10
|
+
const metaInfo = `type MetaInfo {
|
|
11
|
+
total: Int
|
|
12
|
+
page: Int
|
|
13
|
+
pageCount: Int
|
|
14
|
+
pageSize: Int
|
|
15
15
|
}`;
|
|
16
16
|
const entityInfo = collectionTypes.map((collectionType) => {
|
|
17
|
-
return `
|
|
18
|
-
extend type ${collectionType.type}EntityResponseCollection {
|
|
19
|
-
metaInfo: MetaInfo
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type Query {
|
|
23
|
-
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput,pagination: PaginationArg, sort:[String], pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
|
|
24
|
-
}
|
|
25
|
-
|
|
17
|
+
return `
|
|
18
|
+
extend type ${collectionType.type}EntityResponseCollection {
|
|
19
|
+
metaInfo: MetaInfo
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Query {
|
|
23
|
+
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput,pagination: PaginationArg, sort:[String], pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
|
|
24
|
+
}
|
|
25
|
+
|
|
26
26
|
`;
|
|
27
27
|
});
|
|
28
28
|
return `${metaInfo} ${entityInfo}`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"draftAndPublish": false,
|
|
3
|
+
"displayName": "Platforms",
|
|
4
|
+
"singularName": "platform",
|
|
5
|
+
"pluralName": "platforms",
|
|
6
|
+
"description": "",
|
|
7
|
+
"plugin": "page-builder",
|
|
8
|
+
"pluginOptions": {},
|
|
9
|
+
"kind": "collectionType",
|
|
10
|
+
"collectionName": "platforms",
|
|
11
|
+
"attributes": {
|
|
12
|
+
"title": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"required": true,
|
|
15
|
+
"unique": true
|
|
16
|
+
},
|
|
17
|
+
"domain": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"template": {
|
|
21
|
+
"type": "relation",
|
|
22
|
+
"relation": "oneToMany",
|
|
23
|
+
"target": "api::template.template"
|
|
24
|
+
},
|
|
25
|
+
"pageTypes": {
|
|
26
|
+
"type": "relation",
|
|
27
|
+
"relation": "oneToMany",
|
|
28
|
+
"target": "api::page-type.page-type"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../shared/utils/constants");
|
|
4
|
+
exports.default = {
|
|
5
|
+
async findAll() {
|
|
6
|
+
return await strapi.entityService.findMany(constants_1.PLATFORM_UID, { populate: '*' });
|
|
7
|
+
},
|
|
8
|
+
async findOneByUid(uid) {
|
|
9
|
+
return await strapi.entityService.findMany(constants_1.PLATFORM_UID, {
|
|
10
|
+
populate: '*',
|
|
11
|
+
filters: {
|
|
12
|
+
pagetype: {
|
|
13
|
+
uid
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
async findPageTypesByPlatform(platform) {
|
|
19
|
+
const results = await strapi.entityService.findMany(constants_1.PLATFORM_UID, {
|
|
20
|
+
populate: {
|
|
21
|
+
pagetype: true
|
|
22
|
+
},
|
|
23
|
+
filters: {
|
|
24
|
+
title: {
|
|
25
|
+
$eq: platform
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (results.length > 0) {
|
|
30
|
+
return results;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerGraphQLResolvers = void 0;
|
|
4
4
|
const constants_1 = require("../../shared/utils/constants");
|
|
5
5
|
const findPageByPath = (strapi) => {
|
|
6
|
-
const typeDefs = `
|
|
7
|
-
type Query {
|
|
8
|
-
findPageByPath(path: String, locale: I18NLocaleCode): PageEntityResponse
|
|
9
|
-
}
|
|
6
|
+
const typeDefs = `
|
|
7
|
+
type Query {
|
|
8
|
+
findPageByPath(path: String, locale: I18NLocaleCode): PageEntityResponse
|
|
9
|
+
}
|
|
10
10
|
`;
|
|
11
11
|
const resolvers = (strapi) => {
|
|
12
12
|
const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
|
|
@@ -47,20 +47,20 @@ const findPageByPath = (strapi) => {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
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
|
-
}
|
|
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
64
|
`;
|
|
65
65
|
const resolvers = (strapi) => {
|
|
66
66
|
const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
|