Generate types for UI extension intents#7342
Merged
Merged
Conversation
501d4be to
eee043c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds CLI support to generate TypeScript typings for UI extension intent schemas (similar to existing tools typing) and wires the generated types into the emitted shopify.d.ts module augmentations.
Changes:
- Parse/validate intent schema JSON assets for UI extension targets and generate intent request/response/value/input/output types.
- Extend
createTypeDefinitionto optionally wrap the baseApitype withWithGeneratedIntents(and compose withWithGeneratedTools) plus supporting utility types. - Add/update Vitest coverage for intent type generation and updated
shopify.d.tsoutput expectations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/app/src/cli/models/extensions/specifications/ui_extension.ts | Collects per-entrypoint intent definitions, reads/validates schema JSON, and passes generated intent typings into createTypeDefinition. |
| packages/app/src/cli/models/extensions/specifications/ui_extension.test.ts | Updates expected shopify.d.ts output formatting and adds integration tests for intent typing generation behavior. |
| packages/app/src/cli/models/extensions/specifications/type-generation.ts | Implements intent type generation (createIntentsTypeDefinition), adds WithGeneratedIntents (and related utility types), and updates how the shopify type is constructed. |
| packages/app/src/cli/models/extensions/specifications/type-generation.test.ts | Adds unit tests for createIntentsTypeDefinition and keeps existing tools tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
03f0f5c to
3cbca04
Compare
olavoasantos
approved these changes
Apr 23, 2026
vividviolet
reviewed
Apr 23, 2026
f6c4e49 to
88b18b8
Compare
gonzaloriestra
left a comment
Contributor
There was a problem hiding this comment.
I added some minor comments, but Copilot also left some good feedback.
Could you also add tophatting instructions? With AI the default PR template is now overwritten sometimes and it has some good points...
88b18b8 to
392534b
Compare
392534b to
6a79ccf
Compare
6a79ccf to
dd6da36
Compare
gonzaloriestra
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
UI extensions can now declare intents — a
declarative way of saying "this target handles the
create:application/emailintent" and shipping an input/output/value JSON Schema alongside it.
At runtime the host passes the intent payload to the extension via
shopify.intents.request, and the extension acknowledges it withshopify.intents.response.ok(data). Without type generation, developers have noway of knowing the shape of
request.data, whatrequest.valuecontains, orwhat
response.okexpects — they're back toanyterritory and have to cross-reference the schema file by hand.
We already generate types for the related
toolsconcept in the sameshopify.d.tsfile. This PR brings intents to feature parity.WHAT is this pull request doing?
For any UI-extension target that declares
[[extensions.targeting.intents]]entries with a
schemafile, the CLI now:inputSchemarequired,valueandoutputSchemaoptional).json-schema-to-typescript, yielding (for e.g.create/application/email):CreateApplicationEmailIntentInputCreateApplicationEmailIntentValueCreateApplicationEmailIntentOutputCreateApplicationEmailIntentRequest— the discriminated request shapewith literal
action/typeand a typeddata/value.ShopifyGeneratedIntentResponse<Data>— theok(data?: Data)handle.ShopifyGeneratedIntentsApi<Request, ResponseData>— request/responsepair, plus a
ShopifyGeneratedIntentVariantsunion of every declaredintent.
shopifydeclaration through anew
WithGeneratedIntents<T>wrapper that merges them with whatever thetarget's own
Api['intents']already exposes (so base host properties likecancel, etc. survive augmentation).The wrapper composes with the existing
WithGeneratedTools<T>:Duplicate
action:typepairs within a target throw anAbortError, matchingthe existing behaviour for duplicate tool names. Missing / invalid schema files
emit a warning and skip generation rather than aborting, consistent with how
tools handles bad input.
Intent types are only emitted for the extension's entry-point file, not for any
file it imports (same behaviour as tools).
Edge cases to spot-check:
schemafile: the CLI shouldoutputWarnand regenerateshopify.d.tswithout the intent types (no crash).action:typepair within a single target: the CLI shouldabort with a clear error.
valuekey: the compiled*IntentValueinterface should reflect that schema and be wired intorequest.value.Tophatting
shopify app generate extensionshopify app devshopify.intents.response.ok()andshopify.intents.request.value