-
Notifications
You must be signed in to change notification settings - Fork 224
add shopify tools type generation #6748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
257c0cc to
d77fe8b
Compare
|
We detected some changes at Caution DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release. |
16010c0 to
a421a8e
Compare
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success3603 tests passing in 1422 suites. Report generated by 🧪jest coverage report action from e7993e6 |
6d50ad7 to
ead2c83
Compare
henrytao-me
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎩-ed including file watching while dev server is running. LGTM
henrytao-me
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that: to temporary test the files watching. Follow these steps:
- Run
dev clone ui-extensions - Add to
packages/ui-extensions/src/surfaces/admin/extension-targets.ts
'admin.app.tools.data': RenderExtension<
BlockExtensionApi<'admin.app.tools.data'>,
BlockExtensionComponents
>;
- Now you can use target
admin.app.tools.data. - You may need to add app beta flag
1p_internalto your app on prod or run local server
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/type-generation.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/type-generation.ts
Outdated
Show resolved
Hide resolved
4432a33 to
09f5bf7
Compare
packages/app/src/cli/models/extensions/specifications/ui_extension.test.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add unit tests for the tools type generation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
09f5bf7 to
8c45152
Compare
8c45152 to
e7993e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vividviolet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some minor feedback. I am also blocked on tophatting until we can get a snapshot release of the new ui-extensions library
| const result = await createToolsTypeDefinition(tools) | ||
|
|
||
| // Then | ||
| expect(result).toContain('interface ComplexToolInput') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to just post the full expected text for these tests? It's hard to understand what the results are supposed to be when the assertions are broken up

WHY are these changes introduced?
Fixes https://github.com/shop/issues-admin-extensibility/issues/2126
Currently, developers building UI extensions with tools don't have TypeScript support for the shopify.tools.register API. This means they lose type safety when registering tool handlers, making it harder to catch errors at compile time and reducing the developer experience with no autocomplete or inline documentation.
WHAT is this pull request doing?
This PR adds automatic TypeScript type generation for Shopify tools in UI extensions. When a tools field is defined in an extension point configuration pointing to a tools.json file, the CLI will:
Summary of changes
Example generated types:
Changes summary:
How to test your changes?
[ { "name": "search-products", "description": "Search for products by query", "inputSchema": { "type": "object", "properties": { "query": {"type": "string"} }, "required": ["query"] }, "outputSchema": { "type": "object", "properties": { "products": {"type": "array", "items": {"type": "string"}} } } } ]Measuring impact
How do we know this change was effective? Please choose one:
Checklist