Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/app/src/cli/models/extensions/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const NewExtensionPointSchema = zod.object({
chat: zod.string().optional(),
})
.optional(),
assets: zod.string().optional(),
Comment thread
elanalynn marked this conversation as resolved.
})

export const NewExtensionPointsSchema = zod.array(NewExtensionPointSchema)
Expand Down
Comment thread
elanalynn marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('ui_extension', async () => {
tools: undefined,
instructions: undefined,
intents: undefined,
assets: undefined,
module: './src/ExtensionPointA.js',
metafields: [{namespace: 'test', key: 'test'}],
default_placement_reference: undefined,
Expand Down Expand Up @@ -219,6 +220,7 @@ describe('ui_extension', async () => {
tools: undefined,
instructions: undefined,
intents: undefined,
assets: undefined,
module: './src/ExtensionPointA.js',
metafields: [],
default_placement_reference: 'PLACEMENT_REFERENCE1',
Expand Down Expand Up @@ -283,6 +285,7 @@ describe('ui_extension', async () => {
tools: undefined,
instructions: undefined,
intents: undefined,
assets: undefined,
module: './src/ExtensionPointA.js',
metafields: [],
urls: {},
Expand Down Expand Up @@ -347,6 +350,7 @@ describe('ui_extension', async () => {
tools: undefined,
instructions: undefined,
intents: undefined,
assets: undefined,
module: './src/ExtensionPointA.js',
metafields: [],
default_placement_reference: undefined,
Expand Down Expand Up @@ -414,6 +418,7 @@ describe('ui_extension', async () => {
tools: undefined,
instructions: undefined,
intents: undefined,
assets: undefined,
module: './src/ExtensionPointA.js',
metafields: [],
default_placement_reference: undefined,
Expand Down Expand Up @@ -483,6 +488,7 @@ describe('ui_extension', async () => {
tools: undefined,
instructions: undefined,
intents: undefined,
assets: undefined,
module: './src/ExtensionPointA.js',
metafields: [],
default_placement_reference: undefined,
Expand Down Expand Up @@ -552,6 +558,7 @@ describe('ui_extension', async () => {
tools: './tools.json',
instructions: undefined,
intents: undefined,
assets: undefined,
metafields: [],
default_placement_reference: undefined,
capabilities: undefined,
Expand Down Expand Up @@ -616,6 +623,72 @@ describe('ui_extension', async () => {
tools: undefined,
instructions: './instructions.md',
intents: undefined,
assets: undefined,
metafields: [],
default_placement_reference: undefined,
capabilities: undefined,
preloads: {},
build_manifest: {
assets: {
main: {
filepath: 'test-ui-extension.js',
module: './src/ExtensionPointA.js',
},
},
},
urls: {},
},
])
})

test('targeting object passes through assets when configured', async () => {
const allSpecs = await loadLocalExtensionsSpecifications()
const specification = allSpecs.find((spec) => spec.identifier === 'ui_extension')!
const configuration = {
targeting: [
{
target: 'EXTENSION::POINT::A',
module: './src/ExtensionPointA.js',
assets: './assets',
},
],
api_version: '2023-01' as const,
name: 'UI Extension',
description: 'This is an ordinary test extension',
type: 'ui_extension',
handle: 'test-ui-extension',
capabilities: {
block_progress: false,
network_access: false,
api_access: false,
collect_buyer_consent: {
customer_privacy: true,
sms_marketing: false,
},
iframe: {
sources: [],
},
},
settings: {},
}

// When
const parsed = specification.parseConfigurationObject(configuration)
if (parsed.state !== 'ok') {
throw new Error("Couldn't parse configuration")
}

const got = parsed.data

// Then
expect(got.extension_points).toStrictEqual([
{
target: 'EXTENSION::POINT::A',
module: './src/ExtensionPointA.js',
tools: undefined,
instructions: undefined,
intents: undefined,
assets: './assets',
metafields: [],
default_placement_reference: undefined,
capabilities: undefined,
Expand Down Expand Up @@ -779,6 +852,7 @@ Please check the configuration in ${uiExtension.configurationPath}`),
tools: './tools.json',
instructions: './instructions.md',
intents: undefined,
assets: undefined,
metafields: [],
default_placement_reference: undefined,
capabilities: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const UIExtensionSchema = BaseSchema.extend({
tools: targeting.tools,
instructions: targeting.instructions,
intents: targeting.intents,
assets: targeting.assets,
}
})
return {...config, extension_points: extensionPoints}
Expand Down Expand Up @@ -101,6 +102,12 @@ const uiExtensionSpec = createExtensionSpecification({
config: {
generatesAssetsManifest: true,
inclusions: [
{
type: 'configKey',
anchor: 'extension_points[]',
groupBy: 'target',
key: 'extension_points[].assets',
},
{
type: 'configKey',
anchor: 'extension_points[]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface Asset {
lastUpdated: number
}

export interface DevNewExtensionPointSchema extends Omit<NewExtensionPointSchemaType, 'intents'> {
export interface DevNewExtensionPointSchema extends Omit<NewExtensionPointSchemaType, 'intents' | 'assets'> {
assets: {
Comment thread
elanalynn marked this conversation as resolved.
[name: string]: Asset
}
Expand Down
Loading