Skip to content

Commit 592175e

Browse files
authored
feat: introduce page builder data sources and data bindings (#4469)
1 parent 23ba3e0 commit 592175e

File tree

293 files changed

+6658
-1525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+6658
-1525
lines changed

packages/api-audit-logs/src/utils/getAuditConfig.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,17 @@ export const getAuditConfig = (audit: AuditAction) => {
141141

142142
// Check if there is delay on audit log creation for this action.
143143
if (delay) {
144-
return await createOrMergeAuditLog({
145-
app,
146-
payload: auditLogPayload,
147-
delay
148-
});
144+
try {
145+
return await createOrMergeAuditLog({
146+
app,
147+
payload: auditLogPayload,
148+
delay
149+
});
150+
} catch {
151+
// Don't care at this point!
152+
} finally {
153+
return JSON.stringify({});
154+
}
149155
}
150156
return await createAuditLog({
151157
app,

packages/api-headless-cms/src/graphql/generateSchema.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ export const generateSchema = async (params: GenerateSchemaParams): Promise<Grap
2121

2222
context.plugins.register(generatedSchemaPlugins);
2323

24-
const schemaPlugins = context.plugins.byType<ICmsGraphQLSchemaPlugin>(
25-
CmsGraphQLSchemaPlugin.type
26-
);
24+
const schemaPlugins = context.plugins
25+
.byType<ICmsGraphQLSchemaPlugin>(CmsGraphQLSchemaPlugin.type)
26+
.filter(pl => {
27+
if (typeof pl.isApplicable === "function") {
28+
return pl.isApplicable(context);
29+
}
30+
return true;
31+
});
32+
2733
return createExecutableSchema({
2834
plugins: schemaPlugins
2935
});

packages/api-page-builder-import-export/src/export/process/exporters/PageTemplateExporter.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import { extractFilesFromData } from "~/export/utils";
66
export interface ExportedTemplateData {
77
template: Pick<
88
PageTemplate,
9-
"title" | "slug" | "tags" | "description" | "content" | "layout" | "pageCategory"
9+
| "title"
10+
| "slug"
11+
| "tags"
12+
| "description"
13+
| "content"
14+
| "layout"
15+
| "dataBindings"
16+
| "dataSources"
1017
>;
1118
files: File[];
1219
}
@@ -38,7 +45,8 @@ export class PageTemplateExporter {
3845
description: template.description,
3946
content: template.content,
4047
layout: template.layout,
41-
pageCategory: template.pageCategory
48+
dataBindings: template.dataBindings,
49+
dataSources: template.dataSources
4250
},
4351
files: imageFilesData
4452
};

packages/api-page-builder-import-export/src/export/utils.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { CompleteMultipartUploadOutput } from "@webiny/aws-sdk/client-s3";
2-
import { BlockCategory, Page, PageBlock, PageTemplate } from "@webiny/api-page-builder/types";
2+
import {
3+
BlockCategory,
4+
Page,
5+
PageBlock,
6+
PageTemplate,
7+
PageTemplateInput
8+
} from "@webiny/api-page-builder/types";
39
import { FileManagerContext, File } from "@webiny/api-file-manager/types";
410
import get from "lodash/get";
511
import Zipper from "./zipper";
@@ -114,7 +120,14 @@ export async function exportBlock(
114120
export interface ExportedTemplateData {
115121
template: Pick<
116122
PageTemplate,
117-
"title" | "slug" | "tags" | "description" | "content" | "layout" | "pageCategory"
123+
| "title"
124+
| "slug"
125+
| "tags"
126+
| "description"
127+
| "content"
128+
| "layout"
129+
| "dataSources"
130+
| "dataBindings"
118131
>;
119132
files: File[];
120133
}
@@ -135,15 +148,16 @@ export async function exportTemplate(
135148
}
136149

137150
// Extract the template data in a json file and upload it to S3
138-
const templateData = {
151+
const templateData: { template: PageTemplateInput; files: File[] } = {
139152
template: {
140153
title: template.title,
141154
slug: template.slug,
142155
tags: template.tags,
143156
description: template.description,
144157
content: template.content,
145158
layout: template.layout,
146-
pageCategory: template.pageCategory
159+
dataSources: template.dataSources,
160+
dataBindings: template.dataBindings
147161
},
148162
files: imageFilesData
149163
};

packages/api-page-builder-import-export/src/import/process/templates/templatesHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ export const templatesHandler = async (
7777
slug: template.slug,
7878
tags: template.tags,
7979
layout: template.layout,
80-
pageCategory: template.pageCategory,
8180
description: template.description,
82-
content: template.content
81+
content: template.content,
82+
dataBindings: template.dataBindings,
83+
dataSources: template.dataSources
8384
});
8485

8586
// Update task record in DB

packages/api-page-builder-so-ddb-es/__tests__/pages/customField.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ describe("page custom field", () => {
9696
{
9797
name: "revisions"
9898
},
99+
{
100+
name: "dataSources"
101+
},
102+
{
103+
name: "dataBindings"
104+
},
99105
{
100106
name: "customViews"
101107
},
@@ -201,6 +207,12 @@ describe("page custom field", () => {
201207
{
202208
name: "content"
203209
},
210+
{
211+
name: "dataSources"
212+
},
213+
{
214+
name: "dataBindings"
215+
},
204216
{
205217
name: "customViews"
206218
}

packages/api-page-builder-so-ddb-es/src/definitions/pageBlockEntity.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ export const createPageBlockEntity = (params: Params): Entity<any> => {
5555
locale: {
5656
type: "string"
5757
},
58+
dataSources: {
59+
type: "list",
60+
default: []
61+
},
62+
dataBindings: {
63+
type: "list",
64+
default: []
65+
},
5866
...(attributes || {})
5967
}
6068
});

packages/api-page-builder-so-ddb-es/src/definitions/pageEntity.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ export const createPageEntity = (params: Params): Entity<any> => {
8282
webinyVersion: {
8383
type: "string"
8484
},
85+
dataSources: {
86+
type: "list",
87+
default: []
88+
},
89+
dataBindings: {
90+
type: "list",
91+
default: []
92+
},
8593
...(attributes || {})
8694
}
8795
});

packages/api-page-builder-so-ddb/src/definitions/pageBlockEntity.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ export const createPageBlockEntity = (params: Params): Entity<any> => {
5555
locale: {
5656
type: "string"
5757
},
58+
dataSources: {
59+
type: "list",
60+
default: []
61+
},
62+
dataBindings: {
63+
type: "list",
64+
default: []
65+
},
5866
...(attributes || {})
5967
}
6068
});

packages/api-page-builder-so-ddb/src/definitions/pageEntity.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ export const createPageEntity = (params: Params): Entity<any> => {
9191
webinyVersion: {
9292
type: "string"
9393
},
94+
dataSources: {
95+
type: "list",
96+
default: []
97+
},
98+
dataBindings: {
99+
type: "list",
100+
default: []
101+
},
94102
...(attributes || {})
95103
}
96104
});

0 commit comments

Comments
 (0)