-
Notifications
You must be signed in to change notification settings - Fork 15
Add admin tools data template #358
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
Changes from 9 commits
b350f97
bd14fb9
37b6e7a
6bb3ac1
e284d13
767e10a
34f1430
f128e5b
148bb26
27bab0a
29bd4ef
74436c2
0289e95
158ea11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # {{ name }} | ||
|
|
||
| {{ description }} | ||
|
|
||
| --- | ||
|
|
||
| ## Get started with this extension | ||
|
|
||
| This extension provides search functionality for the Shopify Admin. After installation, your app's search results will appear in Admin search. | ||
|
|
||
| ### Key files | ||
|
|
||
| - `src/index.{{ srcFileExtension }}` - Main extension code that registers the search tool | ||
| - `tools.json` - Schema definition for the search tool inputs and outputs | ||
kbav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### How it works | ||
|
|
||
| 1. The extension registers a `search` tool using `shopify.tools.register()` | ||
| 2. When a user searches in the Admin, your search function is called with the query | ||
| 3. Your function returns results matching the schema defined in `tools.json` | ||
|
|
||
| ### Customizing the search | ||
|
|
||
| Edit `src/index.{{ srcFileExtension }}` to implement your search logic: | ||
|
|
||
| 1. Fetch data from your app's backend or API | ||
| 2. Filter/search the data based on the `query` input | ||
| 3. Return results in the expected format with pagination info | ||
|
|
||
| ### Testing locally | ||
|
|
||
| Run `shopify app dev` to test your extension in development mode. | ||
kbav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "{{ name }}", | ||
| "description": "Search extension for your app" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "{{ name }}", | ||
| "description": "Extension de recherche pour votre application" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "{{ handle }}", | ||
| "private": true, | ||
| "version": "1.0.0", | ||
| "license": "UNLICENSED", | ||
| "dependencies": { | ||
| "@shopify/ui-extensions": "0.0.0-snapshot-20260114193753" | ||
kbav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| api_version = "2025-10" | ||
|
|
||
| [[extensions]] | ||
| # Change the merchant-facing name of the extension in locales/en.default.json | ||
| name = "t:name" | ||
| handle = "{{ handle }}" | ||
| type = "ui_extension" | ||
| {% if uid %}uid = "{{ uid }}"{% endif %} | ||
| description = "t:description" | ||
|
|
||
| [[extensions.targeting]] | ||
| module = "./src/index.{{ srcFileExtension }}" | ||
| target = "admin.app.tools.data" | ||
| tools = "./tools.json" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| export default async function extension() { | ||
| shopify.tools.register('search', (input) => { | ||
| const {query = '', first = 10, after} = input; | ||
|
|
||
| // TODO: Implement your search logic here | ||
|
|
||
| return { | ||
| results: [], | ||
| pageInfo: { | ||
| hasNextPage: false, | ||
| hasPreviousPage: false, | ||
| startCursor: null, | ||
| endCursor: null, | ||
| }, | ||
| }; | ||
| }); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| [ | ||
| { | ||
| "name": "search", | ||
| "description": "Search for resources", | ||
vividviolet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "inputSchema": { | ||
| "type": "object", | ||
| "properties": { | ||
| "query": { | ||
| "type": "string", | ||
| "description": "Search query string" | ||
| }, | ||
| "after": { | ||
| "type": "string", | ||
| "description": "Cursor for pagination - returns elements after this cursor" | ||
| }, | ||
| "first": { | ||
| "type": "integer", | ||
| "description": "Number of results to return (default: 10)" | ||
| } | ||
| }, | ||
| "required": [] | ||
| }, | ||
| "outputSchema": { | ||
| "type": "object", | ||
| "properties": { | ||
| "results": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string", | ||
| "description": "Unique identifier for the result" | ||
| }, | ||
| "type": { | ||
| "type": "string", | ||
| "description": "The type/category of the result" | ||
| }, | ||
| "url": { | ||
| "type": "string", | ||
| "description": "URL to view or edit the resource" | ||
| }, | ||
| "title": { | ||
| "type": "string", | ||
| "description": "Display title for the result" | ||
| } | ||
| }, | ||
| "required": ["id", "type"] | ||
| } | ||
| }, | ||
| "pageInfo": { | ||
| "type": "object", | ||
| "properties": { | ||
| "hasNextPage": { | ||
| "type": "boolean", | ||
| "description": "Whether there are more results available" | ||
| }, | ||
| "hasPreviousPage": { | ||
| "type": "boolean", | ||
| "description": "Whether there are previous results available" | ||
| }, | ||
| "startCursor": { | ||
| "type": "string", | ||
| "nullable": true, | ||
| "description": "Cursor for the first item in results" | ||
| }, | ||
| "endCursor": { | ||
| "type": "string", | ||
| "nullable": true, | ||
| "description": "Cursor for the last item in results" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2020", | ||
| "checkJs": true, | ||
| "allowJs": true, | ||
| "moduleResolution": "node", | ||
| "esModuleInterop": true, | ||
| "noEmit": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -399,6 +399,25 @@ | |||||
| ], | ||||||
| "minimumCliVersion": "3.85.3" | ||||||
| }, | ||||||
| { | ||||||
| "identifier": "app_tools", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make a PR to update the dev docs to match. The convention is to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR created here: https://github.com/Shopify/shopify-dev/pull/67157 |
||||||
| "name": "Admin app tools", | ||||||
| "defaultName": "app-tools", | ||||||
| "group": "UI extensions", | ||||||
| "supportLinks": [], | ||||||
| "url": "https://github.com/Shopify/extensions-templates#bf/add-admin-tools-data-template", | ||||||
|
||||||
| "url": "https://github.com/Shopify/extensions-templates#bf/add-admin-tools-data-template", | |
| "url": "https://github.com/Shopify/extensions-templates", |
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.
Yep, I'm leaving this here for removing yet-another-tophatting-step but will remove prior to merge
Outdated
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.
Leaving as 3.85.3 for tophatting ease, but note that this will not work without CLI 0.0.0-nightly-20260122060923, or 3.90.0 (not yet released).
Uh oh!
There was an error while loading. Please reload this page.