Skip to content

Commit

Permalink
feat(migrations): add block element ids migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Apr 28, 2024
1 parent f4d6356 commit 86d4dad
Show file tree
Hide file tree
Showing 8 changed files with 768 additions and 2 deletions.
399 changes: 399 additions & 0 deletions packages/migrations/__tests__/migrations/5.40.0/001/ddb/001.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,399 @@
import { compress } from "~/migrations/5.40.0/001/ddb/compression";

export const rawContent = {
path: ["vYyuUH3RPN"],
type: "block",
data: {
settings: {
width: {
desktop: {
value: "100%"
}
},
padding: {
"mobile-portrait": {
top: "20px",
advanced: true,
bottom: "20px"
},
desktop: {
all: "10px",
right: "10px",
top: "40px",
advanced: true,
left: "10px",
bottom: "20px"
}
},
horizontalAlignFlex: {
desktop: "center"
},
verticalAlign: {
desktop: "flex-start"
},
margin: {
desktop: {
right: "0px",
top: "0px",
left: "0px",
advanced: true,
bottom: "0px"
}
},
background: {
desktop: {
color: null
}
}
},
variables: [
{
id: "e0LV1SGW8E",
label: "Title",
type: "heading",
value: '{"root":{"children":[{"children":[{"detail":0,"format":1,"mode":"normal","style":"font-size: 18px;","text":"LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT","type":"font-color-node","version":1,"themeColor":"color4","color":"#616161"}],"direction":"ltr","format":"","indent":0,"type":"heading-element","version":1,"tag":"h3","styles":[{"styleId":"heading3","type":"typography"}]}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}'
},
{
id: "RN9CtkSL0b",
label: "Logo Image",
type: "image",
value: {
src: "https://d2b8of00q5koup.cloudfront.net/files/648c2584fc82b0000881f865/LogoCloudV1.svg",
id: "648c2584fc82b0000881f865"
}
}
]
},
elements: [
{
path: ["vYyuUH3RPN", "6JBEyzzdUY"],
type: "grid",
data: {
settings: {
gridSettings: {
tablet: {
flexDirection: "column"
},
"mobile-landscape": {
flexDirection: "column"
},
desktop: {
flexDirection: "column"
}
},
padding: {
desktop: {
all: "10px"
}
},
horizontalAlignFlex: {
desktop: "flex-start"
},
verticalAlign: {
tablet: "stretch",
desktop: "stretch",
"mobile-landscape": "flex-start",
"mobile-portrait": "flex-start"
},
margin: {
desktop: {
right: "0px",
top: "0px",
left: "0px",
advanced: true,
bottom: "0px"
}
},
grid: {
cellsType: "12",
rowCount: 2
},
width: {
desktop: {
value: "1100px"
}
}
}
},
elements: [
{
path: ["vYyuUH3RPN", "6JBEyzzdUY", "j3XI0MiQ3M"],
type: "cell",
data: {
settings: {
padding: {
desktop: {
all: "0px"
}
},
horizontalAlignFlex: {
desktop: "flex-start"
},
verticalAlign: {
desktop: "center"
},
margin: {
desktop: {
right: "0px",
top: "0px",
left: "0px",
advanced: true,
bottom: "0px"
}
},
grid: {
size: 12
}
}
},
elements: [
{
path: ["vYyuUH3RPN", "6JBEyzzdUY", "j3XI0MiQ3M", "h8QcsWnLnp"],
type: "heading",
data: {
settings: {
padding: {
desktop: {
all: "0px"
}
},
margin: {
desktop: {
all: "0px"
}
}
},
variableId: "e0LV1SGW8E",
text: {
data: {
text: '{"root":{"children":[{"children":[{"detail":0,"format":1,"mode":"normal","style":"font-size: 18px;","text":"LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT","type":"font-color-node","version":1,"themeColor":"color4","color":"#616161"}],"direction":"ltr","format":"","indent":0,"type":"heading-element","version":1,"tag":"h3","styles":[{"styleId":"heading3","type":"typography"}]}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}'
},
desktop: {
type: "heading",
alignment: "center",
tag: "h1"
}
}
},
elements: []
}
]
},
{
path: ["vYyuUH3RPN", "6JBEyzzdUY", "j3XI0MiQ3M"],
type: "cell",
data: {
settings: {
padding: {
desktop: {
all: "0px"
}
},
horizontalAlignFlex: {
desktop: "flex-start"
},
margin: {
desktop: {
right: "0px",
top: "0px",
left: "0px",
advanced: true,
bottom: "0px"
}
},
grid: {
size: 12
}
}
},
elements: [
{
path: ["vYyuUH3RPN", "6JBEyzzdUY", "j3XI0MiQ3M", "XUrIerQSDG"],
type: "image",
data: {
link: {
href: null
},
settings: {
horizontalAlignFlex: {
desktop: "center"
},
padding: {
desktop: {
all: "0px"
}
},
margin: {
desktop: {
all: "0px"
}
}
},
image: {
file: {
name: "Logo Cloud V1.svg",
id: "65415260b431680008ad4596",
src: "https://d26watk6chcr2b.cloudfront.net/files/65415260b431680008ad4596/LogoCloudV1.svg",
key: "65415260b431680008ad4596/LogoCloudV1.svg"
}
},
variableId: "RN9CtkSL0b"
},
elements: []
}
]
}
]
}
]
};

export const createBlocksData = async (amount = 100) => {
return Promise.all([
...Array.from({ length: amount }).map(async (_, index) => {
const id = `65415260b431680008ad4598${index.toString().padStart(4, "0")}`;

return {
content: await compress(rawContent),
locale: "en-US",
entity: "PbPageBlocks",
createdBy: {
type: "admin",
displayName: "Pavel Denisjuk",
id: "6496fbd7d6062300081e4727"
},
name: `Logo Cloud ${index}`,
created: "2023-10-31T19:15:44.897Z",
TYPE: "pb.pageBlock",
tenant: "root",
modified: "2023-10-31T19:15:44.897Z",
blockCategory: "logo-cloud",
createdOn: "2023-10-31T19:15:44.896Z",
id,
SK: `A`,
PK: `T#root#L#en-US#PB#BLOCK#${id}`,
GSI1_PK: `T#root#L#en-US#PB#BLOCKS`,
GSI1_SK: `logo-cloud#${id}`
};
}),
{
PK: "T#root",
SK: "A",
createdOn: "2023-01-25T09:37:58.183Z",
description: "The top-level Webiny tenant.",
GSI1_PK: "TENANTS",
GSI1_SK: "T#null#2023-01-25T09:37:58.183Z",
data: {
id: "root",
name: "Root",
savedOn: "2023-01-25T09:37:58.183Z",
settings: {
domains: []
},
status: "active",
TYPE: "tenancy.tenant",
webinyVersion: "0.0.0",
createdBy: {
type: "admin",
displayName: "ad min",
id: "6540185ca0f1c30008594e34"
}
}
},
{
PK: "T#otherTenant",
SK: "A",
createdOn: "2023-03-11T09:59:17.327Z",
description: "Tenant #1",
GSI1_PK: "TENANTS",
GSI1_SK: "T#root#2023-03-11T09:59:17.327Z",
data: {
id: "otherTenant",
name: "Other Tenant",
parent: "root",
savedOn: "2023-03-11T09:59:17.327Z",
settings: {
domains: []
},
status: "active",
TYPE: "tenancy.tenant",
webinyVersion: "0.0.0",
createdBy: {
type: "admin",
displayName: "ad min",
id: "6540185ca0f1c30008594e34"
}
}
},
{
PK: `T#root#I18N#L`,
SK: "en-US",
code: "en-US",
default: true,
createdOn: "2023-01-25T09:37:58.220Z",
createdBy: {
type: "admin",
displayName: "ad min",
id: "6540185ca0f1c30008594e34"
},
tenant: "root",
webinyVersion: "0.0.0"
},
{
PK: `T#root#I18N#L`,
SK: "de-DE",
code: "de-DE",
default: false,
createdOn: "2023-01-25T09:37:58.220Z",
createdBy: {
type: "admin",
displayName: "ad min",
id: "6540185ca0f1c30008594e34"
},
tenant: "root",
webinyVersion: "0.0.0"
},
{
PK: `T#root#I18N#L`,
SK: "fr-FR",
code: "fr-FR",
default: false,
createdOn: "2023-01-25T09:37:58.220Z",
createdBy: {
type: "admin",
displayName: "ad min",
id: "6540185ca0f1c30008594e34"
},
tenant: "root",
webinyVersion: "0.0.0"
},
{
PK: `T#otherTenant#I18N#L`,
SK: "fr-FR",
code: "fr-FR",
default: false,
createdOn: "2023-01-25T09:37:58.220Z",
createdBy: {
type: "admin",
displayName: "ad min",
id: "6540185ca0f1c30008594e34"
},
tenant: "otherTenant",
webinyVersion: "0.0.0"
},
{
PK: `T#otherTenant#I18N#L`,
SK: "de-DE",
code: "de-DE",
default: true,
createdOn: "2023-01-25T09:37:58.220Z",
createdBy: {
type: "admin",
displayName: "ad min",
id: "6540185ca0f1c30008594e34"
},
tenant: "otherTenant",
webinyVersion: "0.0.0"
}
]);
};
Loading

0 comments on commit 86d4dad

Please sign in to comment.