Draft
Conversation
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.