PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev4
Elementor Website Builder – more than just a page builder v3.35.0-dev4
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / migrations / README.md

README.md in Elementor Website Builder – more than just a page builder 3.35.0-dev4, at migrations/README.md

336 lines 9.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # Prop Type Migrations
2 ## Appendix
3 - [](#structureStructure](#structure](#structure)
4 - [](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+InvestigationLanguage Design](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation)
5 - [](#pathsPaths](#paths](#paths)
6 - [](#conditionsConditions](#conditions](#conditions)
7 - [](#functionsFunctions](#functions](#functions)
8 - [](#examplesExamples](#examples](#examples)
9
10 ## Structure
11 ### Manifest
12 Manifest describes the different migrations, it can contain widget key migrations and prop-type migrations
13 ```json
14 {
15 "widgetKeys": {
16 "e-logo": [
17 { "from": "svg", "to": "icon" }
18 ]
19 },
20 "propTypes": {
21 "string-to-html": {
22 "fromType": "string",
23 "toType": "html",
24 "url": "string-to-html.json"
25 }
26 }
27 }
28 ```
29 ### Prop Type Migrations
30 Prop type migrations are a set of operations, **up** for upgrade and reverse **down** for downgrade.
31 Prop type migrations support wildcard paths and conditions (see below)
32 ```json
33 {
34 "up": [
35 {
36 "op": {
37 "fn": "set",
38 "path": "$$type",
39 "value": "html"
40 }
41 }
42 ],
43 "down": [
44 {
45 "op": {
46 "fn": "set",
47 "path": "$$type",
48 "value": "string"
49 }
50 }
51 ]
52 }
53 ```
54
55 ## Paths
56 Path parameter works with wildcard, starting from the **root of prop type or widget** (depending on the type of migration)
57
58 ## Conditions
59 Conditions check whether to run the migration or not, with many helper functions such as `exists`, conditions can be compounded by `AND` and `OR`.
60 Full list can be found [](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#Available-Conditionshere](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#Available-Conditions](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#Available-Conditions)
61
62 ## Important Notes
63
64 ### Data Transformations
65 **Migrations do NOT support value transformations.** Migrations are purely structural - they create or update, but can't activate any functions on the data.
66
67 Handle transformations in transformer code
68 - Migrations change structure: `{ "color": "#fff" }``{ "color": { "$$type": "color", "value": "#fff" } }`
69 - Transformers can take current values, and transform them `{ "oldColor": "#fff", "newColor": {} }` -> `{ "oldColor": "#fff", "newColor": { "gradient": "something", "value": "#fff" }}`
70
71 ### Migration Scope
72 - **Prop Type Migrations**: Operate on a single prop instance, paths start at prop root
73 - **Widget Key Migrations**: Operate on entire widget element, paths start at element root
74 - Migrations run **before** validation and transformation in the data processing pipeline
75
76 ### Performance Considerations
77 - Migration state is cached per document with version + manifest hash
78 - Cache clears on Elementor version change, manifest change, or feature flag toggle
79
80 ## Functions
81 ### Set
82 `set` creates or updates data, it can update key / value or both. Full Documentation [](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#sethere](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#set](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#set)
83 Params:
84 - key (optional)
85 - value (optional)
86 - merge **default** true - attempts to deep merge objects instead of replace
87
88 #### Usage
89 Replaces nested key and value
90 ```json
91 { "op": { "fn": "set", "path": "value.*.nested", "value": ["a"], "key": "nested2" } }
92 ```
93 Appends to array
94 ```json
95 { "op": { "fn": "set", "path": "value.*.nested.[]", "value": "a" } }
96 ```
97 Creates empty object at path
98 ```json
99 { "op": { "fn": "set", "path": "value.*.nested.[*]" } }
100 ```
101
102 ### Delete
103 `delete` removes keys/values at specified path. Full Documentation [](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#deletehere](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#delete](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#delete)
104 Params:
105 - clean **default** true - deletes empty parent paths until reaching an object that has siblings
106
107 #### Usage
108 Delete specific nested key
109 ```json
110 { "op": { "fn": "delete", "path": "value.deprecated" } }
111 ```
112 Delete all matching wildcard paths
113 ```json
114 { "op": { "fn": "delete", "path": "value.items[*].legacy" } }
115 ```
116 Delete without cleaning empty parents
117 ```json
118 { "op": { "fn": "delete", "path": "value.old", "clean": false } }
119 ```
120
121 ### Move
122 `move` relocates values from one path to another. Full Documentation [](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#movehere](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#move](https://elementor.atlassian.net/wiki/spaces/UE/pages/1999110146/Prop+Types+Migration+Schema+Design+Investigation#move)
123 Params:
124 - src - Source path
125 - dest - Destination path
126 - clean **default** true - deletes source path after move (will delete empty paths until reaching an object that has siblings)
127
128 #### Usage
129 Move simple value to new location
130 ```json
131 { "op": { "fn": "move", "src": "value.oldField", "dest": "value.nested.newField" } }
132 ```
133 Move without cleaning source
134 ```json
135 { "op": { "fn": "move", "src": "value.data", "dest": "value.backup", "clean": false } }
136 ```
137 Move nested object structure
138 ```json
139 { "op": { "fn": "move", "src": "value.settings", "dest": "value.config.settings" } }
140 ```
141
142 ## Examples
143
144 ### Prop Type Migration: Change Type
145
146 **Context**: Migrate `string``html` type. Paths start at **prop root**.
147
148 ```json
149 {
150 "up": [
151 { "op": { "fn": "set", "path": "$$type", "value": "html" } }
152 ],
153 "down": [
154 { "op": { "fn": "set", "path": "$$type", "value": "string" } }
155 ]
156 }
157 ```
158
159 **Before**: `{ "$$type": "string", "value": "Hello" }`
160 **After**: `{ "$$type": "html", "value": "Hello" }`
161
162 ### Prop Type Migration: Rename Keys (Simple and Wildcard)
163
164 **Context**: Rename keys using `key` parameter, with and without wildcards. Paths start at **prop root**.
165
166 **Simple key rename:**
167 ```json
168 {
169 "up": [
170 { "op": { "fn": "set", "path": "value.oldName", "key": "newName" } }
171 ],
172 "down": [
173 { "op": { "fn": "set", "path": "value.newName", "key": "oldName" } }
174 ]
175 }
176 ```
177
178 **Wildcard key rename across multiple objects:**
179 ```json
180 {
181 "up": [
182 {
183 "op": { "fn": "set", "path": "value.*.oldName", "key": "newName" },
184 "condition": { "fn": "exists", "path": "value.*.oldName" }
185 }
186 ],
187 "down": [
188 {
189 "op": { "fn": "set", "path": "value.*.newName", "key": "oldName" },
190 "condition": { "fn": "exists", "path": "value.*.newName" }
191 }
192 ]
193 }
194 ```
195
196 **Before** (wildcard example):
197 ```json
198 {
199 "$$type": "responsive",
200 "value": {
201 "desktop": { "oldName": "value1" },
202 "tablet": { "oldName": "value2" },
203 "mobile": { "oldName": "value3" }
204 }
205 }
206 ```
207
208 **After**:
209 ```json
210 {
211 "$$type": "responsive",
212 "value": {
213 "desktop": { "newName": "value1" },
214 "tablet": { "newName": "value2" },
215 "mobile": { "newName": "value3" }
216 }
217 }
218 ```
219
220 ### Prop Type Migration: Wildcards with Array Items
221
222 **Context**: Update all color types in a gradient using array wildcards `[*]`. Paths start at **prop root**.
223
224 ```json
225 {
226 "up": [
227 {
228 "op": { "fn": "set", "path": "value.stops[*].color.$$type", "value": "color" },
229 "condition": { "fn": "equals", "path": "value.stops[*].color.$$type", "value": "string" }
230 }
231 ],
232 "down": [
233 {
234 "op": { "fn": "set", "path": "value.stops[*].color.$$type", "value": "string" },
235 "condition": { "fn": "equals", "path": "value.stops[*].color.$$type", "value": "color" }
236 }
237 ]
238 }
239 ```
240
241 **Before**:
242 ```json
243 {
244 "$$type": "gradient",
245 "value": {
246 "stops": [
247 { "position": 0, "color": { "$$type": "string", "value": "#ff0000" } },
248 { "position": 50, "color": { "$$type": "string", "value": "#00ff00" } },
249 { "position": 100, "color": { "$$type": "string", "value": "#0000ff" } }
250 ]
251 }
252 }
253 ```
254
255 **After**:
256 ```json
257 {
258 "$$type": "gradient",
259 "value": {
260 "stops": [
261 { "position": 0, "color": { "$$type": "color", "value": "#ff0000" } },
262 { "position": 50, "color": { "$$type": "color", "value": "#00ff00" } },
263 { "position": 100, "color": { "$$type": "color", "value": "#0000ff" } }
264 ]
265 }
266 }
267 ```
268
269 ### Prop Type Migration: Compound Conditions (AND/OR)
270
271 **Context**: Use `and`/`or` conditions to selectively migrate items. Paths start at **prop root**.
272
273 ```json
274 {
275 "up": [
276 {
277 "op": { "fn": "set", "path": "value.items[*].type", "value": "enhanced" },
278 "condition": {
279 "fn": "and",
280 "conditions": [
281 { "fn": "equals", "path": "value.items[*].type", "value": "legacy" },
282 { "fn": "exists", "path": "value.items[*].data" }
283 ]
284 }
285 },
286 {
287 "op": { "fn": "set", "path": "value.items[*].migrated", "value": true },
288 "condition": {
289 "fn": "or",
290 "conditions": [
291 { "fn": "equals", "path": "value.items[*].type", "value": "enhanced" },
292 { "fn": "not_exists", "path": "value.items[*].migrated" }
293 ]
294 }
295 }
296 ],
297 "down": [
298 {
299 "op": { "fn": "set", "path": "value.items[*].type", "value": "legacy" },
300 "condition": { "fn": "equals", "path": "value.items[*].type", "value": "enhanced" }
301 },
302 {
303 "op": { "fn": "delete", "path": "value.items[*].migrated" }
304 }
305 ]
306 }
307 ```
308
309 **Before**:
310 ```json
311 {
312 "$$type": "list",
313 "value": {
314 "items": [
315 { "type": "legacy", "data": { "content": "Item 1" } },
316 { "type": "legacy", "data": { "content": "Item 2" } },
317 { "type": "new", "data": { "content": "Item 3" } }
318 ]
319 }
320 }
321 ```
322
323 **After**:
324 ```json
325 {
326 "$$type": "list",
327 "value": {
328 "items": [
329 { "type": "enhanced", "data": { "content": "Item 1" }, "migrated": true },
330 { "type": "enhanced", "data": { "content": "Item 2" }, "migrated": true },
331 { "type": "new", "data": { "content": "Item 3" }, "migrated": true }
332 ]
333 }
334 }
335 ```
336