@webbio/strapi-plugin-page-builder 0.3.2 → 0.3.3-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 +21 -6
- package/admin/src/api/collection-type.ts +1 -7
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +11 -14
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +27 -9
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +16 -6
- package/admin/src/components/EditView/Details/index.tsx +1 -1
- package/admin/src/components/EditView/PageSettings/index.tsx +6 -57
- 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 +11 -9
- package/dist/server/bootstrap.js +24 -40
- package/dist/server/content-types/user-categories/schema.json +18 -0
- package/dist/server/content-types/user-category/schema.json +23 -0
- package/dist/server/controllers/index.js +1 -3
- package/dist/server/controllers/platform.js +5 -5
- package/dist/server/controllers/private-content.js +18 -0
- package/dist/server/controllers/sitemap.js +29 -0
- package/dist/server/controllers/user-category.js +4 -0
- package/dist/server/graphql/page-by-path.js +113 -0
- package/dist/server/graphql/pages-by-uid.js +7 -9
- package/dist/server/policies/isAuthorizedPage.js +11 -0
- package/dist/server/routes/index.js +0 -21
- package/dist/server/routes/user-category.js +4 -0
- package/dist/server/schema/page-end.json +0 -5
- package/dist/server/schema/platform-start.json +0 -10
- package/dist/server/schema/template-end.json +40 -0
- package/dist/server/services/builder.js +5 -15
- package/dist/server/services/email.js +160 -0
- package/dist/server/services/index.js +1 -3
- package/dist/server/services/platform.js +6 -11
- package/dist/server/services/private-content/components/admin-email.json +22 -0
- package/dist/server/services/private-content/components/email.json +22 -0
- package/dist/server/services/private-content/components/platform-email.json +33 -0
- package/dist/server/services/private-content/constants/index.js +16 -0
- package/dist/server/services/private-content/graphql/index.js +77 -0
- package/dist/server/services/private-content/graphql/resolvers/findOnePage.js +40 -0
- package/dist/server/services/private-content/graphql/resolvers/findPage.js +44 -0
- package/dist/server/services/private-content/graphql/resolvers/forgot-password.js +29 -0
- package/dist/server/services/private-content/graphql/resolvers/login.js +49 -0
- package/dist/server/services/private-content/graphql/resolvers/register.js +68 -0
- package/dist/server/services/private-content/graphql/resolvers/reset-password.js +41 -0
- package/dist/server/services/private-content/graphql/types/index.js +89 -0
- package/dist/server/services/private-content/index.js +94 -0
- package/dist/server/services/private-content/mail-template/txtMail.email.template.text.js +12 -0
- package/dist/server/services/private-content/page.js +22 -0
- package/dist/server/services/private-content/platform.js +22 -0
- package/dist/server/services/private-content/schemas/index.js +30 -0
- package/dist/server/services/private-content/user.js +170 -0
- package/dist/server/services/sitemap.js +78 -0
- package/dist/server/services/template.js +1 -2
- package/dist/server/services/user-category.js +4 -0
- 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 +11 -9
- package/server/bootstrap/collection-type-lifecycles.ts +1 -1
- package/server/bootstrap.ts +24 -43
- package/server/controllers/index.ts +1 -3
- package/server/graphql/pages-by-uid.ts +7 -9
- package/server/routes/index.ts +0 -21
- package/server/schema/page-end.json +0 -5
- package/server/services/builder.ts +6 -18
- 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/platform.ts +0 -34
- package/admin/src/components/EditView/Platform/platform-select.tsx +0 -30
- 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/server/controllers/platform.ts +0 -21
- package/server/schema/platform-start.json +0 -31
- package/server/services/platform.ts +0 -36
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webbio/strapi-plugin-page-builder",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3-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.
|
|
24
|
-
"@strapi/helper-plugin": "
|
|
23
|
+
"@strapi/design-system": "^1.13.1",
|
|
24
|
+
"@strapi/helper-plugin": "<4.15.0",
|
|
25
25
|
"@strapi/icons": "^1.11.0",
|
|
26
|
-
"@strapi/typescript-utils": "
|
|
27
|
-
"@strapi/utils": "
|
|
28
|
-
"react-select": "^5.7.4"
|
|
26
|
+
"@strapi/typescript-utils": "<4.15.0",
|
|
27
|
+
"@strapi/utils": "<4.15.0",
|
|
28
|
+
"react-select": "^5.7.4",
|
|
29
|
+
"slugify": "^1.6.6"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
32
|
+
"@strapi/typescript-utils": "<4.15.0",
|
|
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": "
|
|
43
|
-
"@webbio/strapi-plugin-slug": "^2.0.
|
|
44
|
+
"@strapi/strapi": "<4.15.0",
|
|
45
|
+
"@webbio/strapi-plugin-slug": "^2.0.5",
|
|
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 <=
|
|
64
|
+
"node": ">=14.19.1 <=20.x.x",
|
|
63
65
|
"npm": ">=6.0.0"
|
|
64
66
|
},
|
|
65
67
|
"license": "MIT",
|
package/dist/server/bootstrap.js
CHANGED
|
@@ -25,31 +25,19 @@ exports.default = async ({ strapi }) => {
|
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
models: [constants_1.PAGE_UID],
|
|
27
27
|
async beforeCreate(event) {
|
|
28
|
-
var _a, _b, _c, _d
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
29
|
let { data } = event.params;
|
|
30
30
|
const collectionTypeId = data === null || data === void 0 ? void 0 : data.collectionTypeId;
|
|
31
31
|
const pageTypeId = ((_b = (_a = data === null || data === void 0 ? void 0 : data.pageType.connect) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) || data.initialPageType;
|
|
32
|
-
const platformId = (_d = (_c = data === null || data === void 0 ? void 0 : data.platform.connect) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.id;
|
|
33
32
|
if (collectionTypeId && pageTypeId) {
|
|
34
|
-
const pageType = await ((
|
|
35
|
-
const collectionToConnect = await ((
|
|
33
|
+
const pageType = await ((_c = strapi.entityService) === null || _c === void 0 ? void 0 : _c.findOne(constants_1.PAGE_TYPE_UID, pageTypeId));
|
|
34
|
+
const collectionToConnect = await ((_d = strapi.entityService) === null || _d === void 0 ? void 0 : _d.findOne(pageType === null || pageType === void 0 ? void 0 : pageType.uid, collectionTypeId, {
|
|
36
35
|
populate: { page: true }
|
|
37
36
|
}));
|
|
38
37
|
const page = collectionToConnect === null || collectionToConnect === void 0 ? void 0 : collectionToConnect.page;
|
|
39
|
-
const foundPlatforms = await ((_g = strapi.entityService) === null || _g === void 0 ? void 0 : _g.findMany(constants_1.PLATFORM_UID, {
|
|
40
|
-
populate: '*',
|
|
41
|
-
filters: {
|
|
42
|
-
pagetype: {
|
|
43
|
-
uid: pageType === null || pageType === void 0 ? void 0 : pageType.uid
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
47
38
|
if (page && page.length > 0) {
|
|
48
39
|
throw new utils_1.errors.ValidationError('You can only link one CollectionType to one page');
|
|
49
40
|
}
|
|
50
|
-
if (platformId && !(foundPlatforms === null || foundPlatforms === void 0 ? void 0 : foundPlatforms.some((platform) => platform.id === platformId))) {
|
|
51
|
-
throw new utils_1.errors.ValidationError('Platform not found');
|
|
52
|
-
}
|
|
53
41
|
data = updateCollectionTypeData(data, collectionTypeId, pageType === null || pageType === void 0 ? void 0 : pageType.uid);
|
|
54
42
|
}
|
|
55
43
|
},
|
|
@@ -86,6 +74,8 @@ exports.default = async ({ strapi }) => {
|
|
|
86
74
|
}
|
|
87
75
|
data = updateCollectionTypeData(data, collectionTypeId, pageType === null || pageType === void 0 ? void 0 : pageType.uid);
|
|
88
76
|
}
|
|
77
|
+
// needs to check if the collectionTypeData is already connected to another page
|
|
78
|
+
// if so, remove the hasPage for filtering
|
|
89
79
|
if (data.collectionTypeData &&
|
|
90
80
|
((_r = (_q = originalEntity === null || originalEntity === void 0 ? void 0 : originalEntity.collectionTypeData) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.__type) &&
|
|
91
81
|
((_t = (_s = originalEntity === null || originalEntity === void 0 ? void 0 : originalEntity.collectionTypeData) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.id) &&
|
|
@@ -102,33 +92,27 @@ exports.default = async ({ strapi }) => {
|
|
|
102
92
|
}
|
|
103
93
|
},
|
|
104
94
|
async afterUpdate(event) {
|
|
105
|
-
var _a, _b
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
95
|
+
var _a, _b;
|
|
96
|
+
try {
|
|
97
|
+
// Result not correctly typed within Strapi
|
|
98
|
+
const data = event === null || event === void 0 ? void 0 : event['result'];
|
|
99
|
+
const hasCollectionTypeRelation = data && ((_a = data === null || data === void 0 ? void 0 : data.collectionTypeData) === null || _a === void 0 ? void 0 : _a[0]) && (data === null || data === void 0 ? void 0 : data.collectionTypeData[0].__type) && (data === null || data === void 0 ? void 0 : data.collectionTypeData[0].id);
|
|
100
|
+
if (hasCollectionTypeRelation) {
|
|
101
|
+
const isPublished = data.publishedAt !== undefined;
|
|
102
|
+
const pageData = isPublished ? { hasPage: !!data.publishedAt } : {};
|
|
103
|
+
await ((_b = strapi.entityService) === null || _b === void 0 ? void 0 : _b.update(data.collectionTypeData[0].__type, data.collectionTypeData[0].id, {
|
|
104
|
+
data: {
|
|
105
|
+
...pageData,
|
|
106
|
+
id: data.collectionTypeData[0].id,
|
|
107
|
+
lifecycleState: {
|
|
108
|
+
exit: true
|
|
109
|
+
}
|
|
114
110
|
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
117
113
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var _a, _b, _c;
|
|
121
|
-
const data = (_a = event === null || event === void 0 ? void 0 : event.params) === null || _a === void 0 ? void 0 : _a.data;
|
|
122
|
-
if (((_b = data.collectionTypeData) === null || _b === void 0 ? void 0 : _b.__type) && data.collectionTypeData.id) {
|
|
123
|
-
await ((_c = strapi.entityService) === null || _c === void 0 ? void 0 : _c.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
|
|
124
|
-
data: {
|
|
125
|
-
id: data.collectionTypeData.id,
|
|
126
|
-
hasPage: true,
|
|
127
|
-
lifecycleState: {
|
|
128
|
-
exit: true
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}));
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error('Failed to save hasPage data', error);
|
|
132
116
|
}
|
|
133
117
|
},
|
|
134
118
|
async beforeDelete(event) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collectionType",
|
|
3
|
+
"collectionName": "user-categories",
|
|
4
|
+
"info": {
|
|
5
|
+
"singularName": "user-category",
|
|
6
|
+
"pluralName": "user-categories",
|
|
7
|
+
"displayName": "User Categories"
|
|
8
|
+
},
|
|
9
|
+
"options": {
|
|
10
|
+
"draftAndPublish": false,
|
|
11
|
+
"comment": ""
|
|
12
|
+
},
|
|
13
|
+
"attributes": {
|
|
14
|
+
"title": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collectionType",
|
|
3
|
+
"collectionName": "user-categories",
|
|
4
|
+
"info": {
|
|
5
|
+
"singularName": "user-category",
|
|
6
|
+
"pluralName": "user-categories",
|
|
7
|
+
"displayName": "User Categories"
|
|
8
|
+
},
|
|
9
|
+
"options": {
|
|
10
|
+
"draftAndPublish": false,
|
|
11
|
+
"comment": ""
|
|
12
|
+
},
|
|
13
|
+
"attributes": {
|
|
14
|
+
"title": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"platform": {
|
|
18
|
+
"type": "relation",
|
|
19
|
+
"relation": "oneToOne",
|
|
20
|
+
"target": "api::platform.platform"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -7,11 +7,9 @@ const page_1 = __importDefault(require("./page"));
|
|
|
7
7
|
const page_type_1 = __importDefault(require("./page-type"));
|
|
8
8
|
const collection_types_1 = __importDefault(require("./collection-types"));
|
|
9
9
|
const template_1 = __importDefault(require("./template"));
|
|
10
|
-
const platform_1 = __importDefault(require("./platform"));
|
|
11
10
|
exports.default = {
|
|
12
11
|
page: page_1.default,
|
|
13
12
|
'page-type': page_type_1.default,
|
|
14
13
|
'collection-types': collection_types_1.default,
|
|
15
|
-
template: template_1.default
|
|
16
|
-
platform: platform_1.default
|
|
14
|
+
template: template_1.default
|
|
17
15
|
};
|
|
@@ -4,13 +4,13 @@ exports.default = {
|
|
|
4
4
|
async findAll() {
|
|
5
5
|
return await strapi.service('plugin::page-builder.platform').findAll();
|
|
6
6
|
},
|
|
7
|
-
async
|
|
7
|
+
async findOneById(ctx) {
|
|
8
8
|
var _a;
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
return ctx.badRequest('
|
|
9
|
+
const id = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.params) === null || _a === void 0 ? void 0 : _a.id;
|
|
10
|
+
if (!id) {
|
|
11
|
+
return ctx.badRequest('id is missing.');
|
|
12
12
|
}
|
|
13
|
-
return await strapi.service('plugin::page-builder.platform').
|
|
13
|
+
return await strapi.service('plugin::page-builder.platform').findOneById(id);
|
|
14
14
|
},
|
|
15
15
|
async findPageTypesByPlatform(ctx) {
|
|
16
16
|
var _a;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
async activateUser(ctx) {
|
|
5
|
+
try {
|
|
6
|
+
const user = await strapi.service('plugin::page-builder.private-content').activateUser(ctx.params.token);
|
|
7
|
+
const callbackUrl = `${user.platform.domain}/inloggen`;
|
|
8
|
+
return ctx.redirect(callbackUrl);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.log('Activate User Error', error, ctx);
|
|
12
|
+
return ctx.unauthorized('User is already confirmed or token is invalid');
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
removeInactiveUsers(ctx) {
|
|
16
|
+
return strapi.service('plugin::page-builder.private-content').removeInactiveUsers();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@strapi/utils");
|
|
4
|
+
const constants_1 = require("../../shared/utils/constants");
|
|
5
|
+
exports.default = {
|
|
6
|
+
async generate(ctx) {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
ctx.set('Content-Type', 'text/xml');
|
|
10
|
+
const domain = (_a = ctx.query) === null || _a === void 0 ? void 0 : _a.domain;
|
|
11
|
+
if (domain == null) {
|
|
12
|
+
return ctx.badRequest('Domain is required.');
|
|
13
|
+
}
|
|
14
|
+
const platform = await strapi.query(constants_1.PLATFORM_UID).findOne({
|
|
15
|
+
select: ['domain'],
|
|
16
|
+
where: {
|
|
17
|
+
domain
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (platform == null) {
|
|
21
|
+
return ctx.notFound('No platform found for specified domain.');
|
|
22
|
+
}
|
|
23
|
+
return strapi.service('plugin::page-builder.sitemap').generateSitemap(domain);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new utils_1.errors.ApplicationError('Unknown error while generating the sitemap.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../shared/utils/constants");
|
|
4
|
+
const apollo_server_koa_1 = require("apollo-server-koa");
|
|
5
|
+
const strapi_1 = require("../utils/strapi");
|
|
6
|
+
const getPageByPath = (strapi) => {
|
|
7
|
+
const typeDefs = () => {
|
|
8
|
+
return `
|
|
9
|
+
extend type Page {
|
|
10
|
+
collectionType: GenericMorph
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Query {
|
|
14
|
+
getPageByPath(path: String, domain: String, publicationState: PublicationState): PageEntity
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
`;
|
|
18
|
+
};
|
|
19
|
+
const resolvers = (strapi) => {
|
|
20
|
+
const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
|
|
21
|
+
return {
|
|
22
|
+
Query: {
|
|
23
|
+
getPageByPath: {
|
|
24
|
+
resolve: async (_parent, args, ctx) => {
|
|
25
|
+
var _a, _b, _c, _d, _e;
|
|
26
|
+
try {
|
|
27
|
+
const filteredArgs = {
|
|
28
|
+
filters: {
|
|
29
|
+
path: args.path,
|
|
30
|
+
platform: args.domain ? { domain: args.domain } : null
|
|
31
|
+
},
|
|
32
|
+
publicationState: args.publicationState,
|
|
33
|
+
locale: args.locale
|
|
34
|
+
};
|
|
35
|
+
const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
|
|
36
|
+
const getPage = async () => {
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
const transformedArgs = transformArgs(filteredArgs, {
|
|
39
|
+
contentType: strapi.contentTypes[constants_1.PAGE_UID],
|
|
40
|
+
usePagination: false
|
|
41
|
+
});
|
|
42
|
+
const results = await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findMany(constants_1.PAGE_UID, {
|
|
43
|
+
...filteredArgs,
|
|
44
|
+
populate: '*'
|
|
45
|
+
}));
|
|
46
|
+
const entityResponse = toEntityResponse((results === null || results === void 0 ? void 0 : results[0]) || {}, {
|
|
47
|
+
args: transformedArgs,
|
|
48
|
+
resourceUID: constants_1.PAGE_UID
|
|
49
|
+
});
|
|
50
|
+
if (!(entityResponse === null || entityResponse === void 0 ? void 0 : entityResponse.value) || Object.keys(entityResponse.value).length === 0) {
|
|
51
|
+
throw new Error(ctx.koaContext.response.message);
|
|
52
|
+
}
|
|
53
|
+
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);
|
|
54
|
+
const collectionType = collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter === null || collectionTypeDataFilter === void 0 ? void 0 : collectionTypeDataFilter[0] : null;
|
|
55
|
+
const addedAttributes = {
|
|
56
|
+
collectionType: collectionType
|
|
57
|
+
};
|
|
58
|
+
const result = {
|
|
59
|
+
...entityResponse.value,
|
|
60
|
+
...addedAttributes
|
|
61
|
+
};
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
const result = await getPage();
|
|
65
|
+
if (((_a = Object.values(result)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
|
|
66
|
+
if ((result === null || result === void 0 ? void 0 : result.path) === '404' || result.path === '500') {
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
if (!((_b = result === null || result === void 0 ? void 0 : result.platform) === null || _b === void 0 ? void 0 : _b.isPrivate) && !(result === null || result === void 0 ? void 0 : result.isPrivate)) {
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
if ((((_c = result === null || result === void 0 ? void 0 : result.platform) === null || _c === void 0 ? void 0 : _c.isPrivate) === true && ctx.koaContext.req.headers.authorization) ||
|
|
73
|
+
((result === null || result === void 0 ? void 0 : result.isPrivate) === true && ctx.koaContext.req.headers.authorization)) {
|
|
74
|
+
const auth = ctx.koaContext.req.headers.authorization;
|
|
75
|
+
const token = auth.split(' ');
|
|
76
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
77
|
+
const decodedToken = await jwtService.verify(token[1]);
|
|
78
|
+
if (decodedToken) {
|
|
79
|
+
const user = ctx.state.user;
|
|
80
|
+
if (((_d = user === null || user === void 0 ? void 0 : user.platform) === null || _d === void 0 ? void 0 : _d.id) === ((_e = result === null || result === void 0 ? void 0 : result.platform) === null || _e === void 0 ? void 0 : _e.id)) {
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return new apollo_server_koa_1.ForbiddenError('Forbidden access');
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
throw new Error(ctx.koaContext.response.message);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.log('Error in [getPageByPath], args:', args, 'ERROR:', error);
|
|
93
|
+
throw new Error(ctx.koaContext.response.message);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const pageBuilderConfig = (0, strapi_1.getConfig)();
|
|
101
|
+
const resolversConfig = {
|
|
102
|
+
'Query.getPageByPath': {
|
|
103
|
+
policies: (pageBuilderConfig === null || pageBuilderConfig === void 0 ? void 0 : pageBuilderConfig.privateContent) === true ? ['plugin::page-builder.isAuthorizedForPage'] : [],
|
|
104
|
+
auth: false
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
typeDefs: typeDefs(),
|
|
109
|
+
resolvers: resolvers(strapi),
|
|
110
|
+
resolversConfig
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
exports.default = getPageByPath;
|
|
@@ -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,6 +57,7 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
60
57
|
hasPage: { $eq: true },
|
|
61
58
|
page: { ...transformedpageArgs.filters }
|
|
62
59
|
},
|
|
60
|
+
sort: transformedArgs.sort,
|
|
63
61
|
start: start,
|
|
64
62
|
limit: limit
|
|
65
63
|
}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const isAuthorizedForPage = (policyContext, _config, { strapi }) => {
|
|
4
|
+
const pageToken = policyContext.http.request.headers['x-strapi-page-secret'];
|
|
5
|
+
const pageEnvToken = process.env.STRAPI_PAGE_SECRET;
|
|
6
|
+
if (pageToken && pageEnvToken && pageToken === pageEnvToken) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
exports.default = isAuthorizedForPage;
|
|
@@ -54,27 +54,6 @@ const routes = {
|
|
|
54
54
|
handler: 'template.findOneById'
|
|
55
55
|
}
|
|
56
56
|
]
|
|
57
|
-
},
|
|
58
|
-
platform: {
|
|
59
|
-
type: 'admin',
|
|
60
|
-
prefix: undefined,
|
|
61
|
-
routes: [
|
|
62
|
-
{
|
|
63
|
-
method: 'GET',
|
|
64
|
-
path: '/platform',
|
|
65
|
-
handler: 'platform.findAll'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
method: 'GET',
|
|
69
|
-
path: '/platform/:uid',
|
|
70
|
-
handler: 'platform.findOneByUid'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
method: 'GET',
|
|
74
|
-
path: '/platform/:platform/page-types',
|
|
75
|
-
handler: 'platform.findPageTypesByPlatform'
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
57
|
}
|
|
79
58
|
};
|
|
80
59
|
exports.default = routes;
|
|
@@ -16,16 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"domain": {
|
|
18
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
19
|
}
|
|
30
20
|
}
|
|
31
21
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
"platform": {
|
|
26
|
+
"type": "relation",
|
|
27
|
+
"relation": "oneToOne",
|
|
28
|
+
"target": "api::platform.platform"
|
|
29
|
+
},
|
|
30
|
+
"modules": {
|
|
31
|
+
"type": "dynamiczone",
|
|
32
|
+
"components": [],
|
|
33
|
+
"pluginOptions": {
|
|
34
|
+
"i18n": {
|
|
35
|
+
"localized": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -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;
|