@webbio/strapi-plugin-page-builder 0.9.2-platform → 0.9.4-platform

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.9.2-platform",
3
+ "version": "0.9.4-platform",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-ignore
4
- exports.default = (strapi) => {
5
- return async (ctx, next) => {
6
- console.log(ctx);
7
- await next();
8
- // // then logs info
9
- // console.log('REQUEST:')
10
- // console.log(ctx.request.body.query);
11
- // console.log('RESPONSE:')
12
- // console.log(ctx.body);
13
- // const result = JSON.parse(ctx.response.body);
14
- // console.log('result');
15
- // if (result && result.data.getPageByPath) {
16
- // console.log(result.data.getPageByPath.attributes);
17
- // }
18
- // console.log("middleware state")
19
- // console.log(context.request.header.host)
20
- // if(context.request.header.host == "localhost:1337") {
21
- // return context.badRequest('name is missing', { foo: 'bar' })
22
- // }
23
- // try {
24
- // if (
25
- // (context.state.user.platform && context.args.domain === context.state.user.platform.domain) ||
26
- // (context.state.user.roles && context.state.user.roles[0].name !== 'Public')
27
- // ) {
28
- // return true;
29
- // }
30
- // } catch (error) {
31
- // console.log(error);
32
- // }
33
- // return false;
34
- };
35
- };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = (ctx) => {
4
- // console.log('user state');
5
- // console.log(ctx.state.user);
6
- // console.log('End User State');
7
- // || ctx.state.user.roles && ctx.state.user.roles[0].name !== "Public"
8
- try {
9
- if ((ctx.state.user.platform && ctx.args.domain === ctx.state.user.platform.domain) ||
10
- (ctx.state.user.roles && ctx.state.user.roles[0].name !== 'Public')) {
11
- return true;
12
- }
13
- }
14
- catch (error) {
15
- console.log(error);
16
- }
17
- return false;
18
- };
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerGraphQLResolvers = void 0;
4
- const constants_1 = require("../../shared/utils/constants");
5
- const findPageByPath = (strapi) => {
6
- const typeDefs = `
7
- type Query {
8
- findPageByPath(path: String, locale: I18NLocaleCode): PageEntityResponse
9
- }
10
- `;
11
- const resolvers = (strapi) => {
12
- const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
13
- const { toEntityResponse, toEntityResponseCollection } = strapi.plugin('graphql').service('format').returnTypes;
14
- return {
15
- Query: {
16
- findPageByPath: {
17
- resolve: async (parent, args, ctx) => {
18
- const contentType = strapi.getModel(constants_1.PAGE_UID);
19
- const transformedArgs = transformArgs(args, { contentType });
20
- const queryResult = await strapi.entityService.findMany(contentType.uid, {
21
- filters: {
22
- path: {
23
- $eq: transformedArgs.path
24
- }
25
- },
26
- locale: transformedArgs.locale
27
- });
28
- const result = queryResult === null || queryResult === void 0 ? void 0 : queryResult[0];
29
- return toEntityResponse(result, {
30
- args: transformedArgs,
31
- resourceUID: contentType.uid
32
- });
33
- }
34
- }
35
- }
36
- };
37
- };
38
- const resolversConfig = {
39
- 'Query.findPageByPath': {
40
- auth: false
41
- }
42
- };
43
- return {
44
- typeDefs,
45
- resolvers: resolvers(strapi),
46
- resolversConfig
47
- };
48
- };
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
- }
64
- `;
65
- const resolvers = (strapi) => {
66
- const { transformArgs } = strapi.plugin('graphql').service('builders').utils;
67
- return {
68
- Query: {
69
- findPagePaths: {
70
- resolve: async (parent, args, ctx) => {
71
- const contentType = strapi.getModel(constants_1.PAGE_UID);
72
- const transformedArgs = transformArgs(args, { contentType });
73
- const queryResult = await strapi.entityService.findMany(contentType.uid, {
74
- populate: '*',
75
- locale: transformedArgs.locale
76
- });
77
- const result = queryResult.filter((page) => page === null || page === void 0 ? void 0 : page.path);
78
- return result;
79
- }
80
- }
81
- }
82
- };
83
- };
84
- const resolversConfig = {
85
- 'Query.findPagePaths': {
86
- auth: false
87
- }
88
- };
89
- return {
90
- typeDefs,
91
- resolvers: resolvers(strapi),
92
- resolversConfig
93
- };
94
- };
95
- const registerGraphQLResolvers = (strapi) => {
96
- const extensionService = strapi.plugin('graphql').service('extension');
97
- extensionService.use(findPageByPath(strapi));
98
- extensionService.use(findPagePaths(strapi));
99
- };
100
- exports.registerGraphQLResolvers = registerGraphQLResolvers;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Pagination = void 0;
4
- class Pagination {
5
- static checkPagination(page, pageSize) {
6
- const startPage = page === 1 ? 0 : page - 1;
7
- const start = startPage * pageSize;
8
- const limit = (startPage + 1) * pageSize;
9
- return { start, limit };
10
- }
11
- static async getPaginationInfo(transformedpageArgs, transformArgs, start, pageSize, entityResponse, uid) {
12
- var _a;
13
- const total = await ((_a = strapi === null || strapi === void 0 ? void 0 : strapi.entityService) === null || _a === void 0 ? void 0 : _a.count(uid, {
14
- filters: {
15
- ...transformArgs.filters,
16
- hasPage: { $eq: true },
17
- page: { ...transformedpageArgs.filters }
18
- }
19
- }));
20
- const pageCount = Math.ceil(total / pageSize);
21
- const page = Math.floor(start / pageSize) + 1;
22
- entityResponse.metaInfo = {
23
- total,
24
- pageCount,
25
- page,
26
- pageSize
27
- };
28
- return entityResponse;
29
- }
30
- }
31
- exports.Pagination = Pagination;