Strata · Migrations

Nested documents (embeds)

For each document step, Strata finds every document of the step’s kind through the grammar’s embeds, at any depth, and passes them to the transform one at a time, deepest first. A step’s transform never traverses the tree itself. Here the transform given to createUpgrader records the path and component of each document it receives, then calls Prism.

Sequence (description, kind)
{
  id: 'theatre.kit',
  migrations: [
    {
      description: 'Button: label is now text',
      at: 'nisc.nova/layout',
    },
  ],
}
Document
{
  component: 'Stack',
  children: [
    {
      component: 'Card',
      children: [
        { component: 'Text', children: 'The Tempest' },
        {
          component: 'Button',
          props: { label: 'Show my ticket', tone: 'primary' },
        },
      ],
    },
    {
      component: 'Button',
      props: { label: 'All shows', tone: 'quiet' },
    },
  ],
}
Transform calls, in order
[
  { path: 'children[0].children[0]', component: 'Text' },
  { path: 'children[0].children[1]', component: 'Button' },
  { path: 'children[0]', component: 'Card' },
  { path: 'children[1]', component: 'Button' },
  { path: '', component: 'Stack' },
]
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.