Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,77 @@ describe('build', async () => {
})
})

test('copies intent schema files when building UI extensions with intents', async () => {
await inTemporaryDirectory(async (tmpDir) => {
// Given
const intentsDir = joinPath(tmpDir, 'intents')
await mkdir(intentsDir)
await writeFile(joinPath(intentsDir, 'create-schema.json'), '{"type": "create"}')
await writeFile(joinPath(intentsDir, 'update-schema.json'), '{"type": "update"}')

const distDir = joinPath(tmpDir, 'dist')
await mkdir(distDir)

const extensionInstance = await testUIExtension({
type: 'ui_extension',
directory: tmpDir,
configuration: {
name: 'test-ui-extension',
type: 'ui_extension',
api_version: '2025-10',
metafields: [],
capabilities: {
network_access: false,
api_access: false,
block_progress: false,
},
extension_points: [
{
target: 'EXTENSION::POINT::A',
module: './src/ExtensionPointA.js',
build_manifest: {
assets: {
main: {
filepath: 'test-ui-extension.js',
module: './src/ExtensionPointA.js',
},
intents: [
{
filepath: 'test-ui-extension-intent-create-app_intent-create-schema.json',
module: './intents/create-schema.json',
static: true,
},
{
filepath: 'test-ui-extension-intent-update-app_intent-update-schema.json',
module: './intents/update-schema.json',
static: true,
},
],
},
},
},
],
},
outputPath: joinPath(distDir, 'test-ui-extension.js'),
})

// When
await extensionInstance.copyStaticAssets()

// Then
const createSchemaOutput = joinPath(distDir, 'test-ui-extension-intent-create-app_intent-create-schema.json')
const updateSchemaOutput = joinPath(distDir, 'test-ui-extension-intent-update-app_intent-update-schema.json')

expect(fileExistsSync(createSchemaOutput)).toBe(true)
expect(fileExistsSync(updateSchemaOutput)).toBe(true)

const createContent = await readFile(createSchemaOutput)
const updateContent = await readFile(updateSchemaOutput)
expect(createContent).toBe('{"type": "create"}')
expect(updateContent).toBe('{"type": "update"}')
})
})

test('does not copy shopify.extension.toml file when bundling theme extensions', async () => {
await inTemporaryDirectory(async (tmpDir) => {
// Given
Expand Down
11 changes: 11 additions & 0 deletions packages/app/src/cli/models/extensions/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ const NewExtensionPointSchema = zod.object({
should_render: ShouldRenderSchema.optional(),
tools: zod.string().optional(),
instructions: zod.string().optional(),
intents: zod
.array(
zod.object({
type: zod.string(),
action: zod.string(),
schema: zod.string(),
name: zod.string().optional(),
description: zod.string().optional(),
}),
)
.optional(),
metafields: zod.array(MetafieldSchema).optional(),
default_placement: zod.string().optional(),
urls: zod
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/cli/models/extensions/specification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export enum AssetIdentifier {
Main = 'main',
Tools = 'tools',
Instructions = 'instructions',
Intents = 'intents',
}

export interface Asset {
Expand Down
Loading
Loading