Skip to content

Read, clone, update, and delete email templates from the CLI - #19

Merged
jbedient-kizen merged 1 commit into
mainfrom
feat/email-template-commands-and-drift-checks
Sep 1, 2026
Merged

Read, clone, update, and delete email templates from the CLI#19
jbedient-kizen merged 1 commit into
mainfrom
feat/email-template-commands-and-drift-checks

Conversation

@jbedient-kizen

Copy link
Copy Markdown
Contributor

Adds get, clone, update, and delete to kizen messages templates, which
could only list before this.

The thing to know before reviewing

An email template stores two independent fields:

  • craft_json — the editable node tree the builder UI renders
  • content — the compiled, Outlook-safe HTML that is actually sent

The server compiles neither from the other, on POST or on PATCH.
Confirmed live by PATCHing a modified craft_json alone and reading content
back byte-identical. So writing one without the other leaves the builder showing
one email while recipients receive a different one, with nothing anywhere
reporting a problem.

Every design decision in this PR and the ones stacked on it follows from that.

What's here

  • get prints the template body plus two drift checks:

    • structure coupled — every Section/Row node has its matching
      section-<nodeId> class in the compiled HTML
    • text in sync — every Text node's copy actually appears there

    --raw dumps the full payload.

  • clone always copies both content fields together, making it the safe way
    to branch a design built in the builder UI.

  • update/delete PATCH and DELETE directly.

Generating a template from a spec file is deliberately not wired here — that's
the next PR in the stack. The node shapes and compile findings it needs are
written up in kizen docs show email-templates.

Reviewing

9 files, +775/-26. Self-contained: nothing else in the stack is required for
this to be correct on its own.

The drift checks are worth the closest look. They are necessary but not
sufficient
— they compare node ids and text, so they cannot see a divergence
where both still match and only styling or width differs. A later PR in the
stack fixes several defects of exactly that shape, all of which these checks
report as green. If you can think of a cheap check that would have caught those,
it's worth adding.

`kizen messages templates` could only list templates before this; now
`get`, `clone`, `update`, and `delete` round out the surface.
The thing to know: a template stores the editable `craft_json` tree and
the compiled `content` HTML that actually gets sent as two independent
fields, and the server compiles neither from the other (confirmed live
by PATCHing a modified `craft_json` alone and reading `content` back
byte-identical). Writing one without the other leaves the builder
showing one email while recipients silently receive another.
- `get` shows a template's body, plus two drift checks: `structure
coupled` (every Section/Row node has its matching `section-<nodeId>`
class in the compiled HTML) and `text in sync` (every Text node's
copy actually appears there). `--raw` dumps the full payload.
- `clone` always copies both content fields together, making it the
safe way to branch a design built in the builder UI.
- `update` and `delete` PATCH/DELETE a template directly.
Generating a new template from a spec file is still not wired; the
node shapes and compile findings needed for that are written up in
`kizen docs show email-templates`.
@jbedient-kizen
jbedient-kizen merged commit a417c98 into mainSep 1, 2026
4 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jbedient-kizen@annaliu-kizen