Skip to content

Moved import/export event types and schemas to common#3110

Open
fredrikekelund wants to merge 4 commits intotrunkfrom
stu-1540-studio-depends-on-cli-import-export
Open

Moved import/export event types and schemas to common#3110
fredrikekelund wants to merge 4 commits intotrunkfrom
stu-1540-studio-depends-on-cli-import-export

Conversation

@fredrikekelund
Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

For creating the type definitions that mapped import/export events to payload types, for the ImportExportEventEmitter implementation (including refactoring the classes that extend it), and for refactoring import-manager.ts and export-manager.ts to return event emitters instead of taking an event handler function as an argument.

Proposed Changes

This is the first step towards refactoring Studio to depend on the CLI for import/export.

This PR adds Zod schemas (and inferred types) that map import/export event names to payload definitions. These are stored in tools/common so they're accessible to both the CLI and Studio.

I'll be using these schemas to parse import/export events received in Studio over IPC from the CLI.

Testing Instructions

  1. npm run cli:build
  2. node apps/cli/dist/cli/main.mjs export --path PATH_TO_SITE and ensure the command completes successfully
  3. node apps/cli/dist/cli/main.mjs import --path PATH_TO_SITE IMPORT_FILE and ensure the command completes successfully

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund requested a review from a team April 16, 2026 11:42
@fredrikekelund fredrikekelund self-assigned this Apr 16, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 16, 2026

📊 Performance Test Results

Comparing 8d11952 vs trunk

app-size

Metric trunk 8d11952 Diff Change
App Size (Mac) 1282.23 MB 1282.24 MB +0.01 MB ⚪ 0.0%

site-editor

Metric trunk 8d11952 Diff Change
load 1889 ms 1894 ms +5 ms ⚪ 0.0%

site-startup

Metric trunk 8d11952 Diff Change
siteCreation 8121 ms 8139 ms +18 ms ⚪ 0.0%
siteStartup 4933 ms 4946 ms +13 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Copy link
Copy Markdown
Contributor

@gcsecsey gcsecsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @fredrikekelund! The refactor looks good to me overall, I added a non-blocking comment.

When testing import and export, everything still works as before. 👍

Export Import
Image Image

} as const;

export const backupExtractProgressEventDataSchema = z.object( {
progress: z.number().optional(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude pointed out that progress wasn't optional in the old interface, and all call sites still provide it. We could use z.number() here.

Sign up for free to 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.

3 participants