Add typed JSON output to theme duplicate - #8640
gonzaloriestra wants to merge 1 commit into
Conversation
d0ed9ba to
c3e4082
Compare
c3e4082 to
827589c
Compare
827589c to
25b84a6
Compare
25b84a6 to
af1f31c
Compare
af1f31c to
79c0066
Compare
79c0066 to
d1a063b
Compare
d1a063b to
5c39b71
Compare
5c39b71 to
e67fd64
Compare
be76aef to
b0ed722
Compare
b0ed722 to
10ddf56
Compare
| shop: adminSession.storeFqdn, | ||
| previewUrl: result.theme ? themePreviewUrl(result.theme, adminSession) : undefined, | ||
| ...result, | ||
| }) |
There was a problem hiding this comment.
I'm not seeing any of these fields in the final JSON result, I just see the theme object, but not the status, originalTheme or previewUrl, are we filtering those?
There was a problem hiding this comment.
Right, the presenter was filtering them. Successful JSON now includes status: "success", originalTheme (ID, name, and role), and theme.preview_url, matching the URL naming used by push and pull. Error responses include status: "failed". The internal completed status is not forwarded because the API can complete with user errors or no copied theme.
848aa4f to
3845191
Compare
3845191 to
b9d2115
Compare
b9d2115 to
0e18b79
Compare
0816752 to
53cd727
Compare
53cd727 to
a7fafbf
Compare
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/base-command.d.ts@@ -35,6 +35,7 @@ declare abstract class BaseCommand extends Command {
argv: string[];
}>;
protected environmentsFilename(): string | undefined;
+ protected validateNonTTYFlags(flags: FlagOutput): void;
protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void;
private failMissingNonTTYFlagRequirements;
private applicableNonTTYFlagRequirements;
|
WHY are these changes introduced?
theme duplicatesupports JSON, but its output contract is not discoverable and the service mixes mutation results with presentation.Part of shop/issues-develop#23692.
WHAT is this pull request doing?
Add a shared success schema for theme mutations. Successful duplication returns
status: "success", the original theme identity, and the new theme withpreview_url. Validation and API errors returnstatus: "failed"; an internally completed API call is not treated as success when it contains errors.Add a domain-owned Zod schema, return typed outcomes from duplication, and move final output into a presenter. Preserve compact JSON, error messages, request-ID omission, terminal output, prompts, and exit behavior. Refresh help, the manifest, and the README.
For a theme named
Original, normal output includes:The matching JSON for the new copy is:
{ "status": "success", "originalTheme": { "id": 1, "name": "Original", "role": "unpublished" }, "theme": { "id": 2, "name": "Copy", "role": "unpublished", "shop": "example.myshopify.com", "preview_url": "https://example.myshopify.com?preview_theme_id=2" } }How to manually test your changes?
Checklist