Skip to content

Commit bc115a4

Browse files
ryancbahanclaude
andcommitted
Migrate app_proxy spec to deployConfig + transformRemoteToLocal
Remove transformConfig including prependApplicationUrl forward logic. Set deployConfig (configWithoutFirstClassFields pass-through) and transformRemoteToLocal directly (flat url/prefix/subpath → nested app_proxy). transformLocalToRemote is now undefined — server handles URL resolution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 34af0cc commit bc115a4

File tree

2 files changed

+8
-92
lines changed

2 files changed

+8
-92
lines changed

packages/app/src/cli/models/extensions/specifications/app_config_app_proxy.test.ts

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,9 @@
11
import spec, {type AppProxyConfigType} from './app_config_app_proxy.js'
2-
import {placeholderAppConfiguration} from '../../app/app.test-data.js'
3-
import {AppConfigurationWithoutPath} from '../../app/app.js'
42
import {describe, expect, test} from 'vitest'
53

64
describe('app_config_app_proxy', () => {
7-
describe('transform', () => {
8-
test('should return the transformed object', () => {
9-
// Given
10-
const object = {
11-
app_proxy: {
12-
url: 'https://my-proxy-new.dev',
13-
subpath: 'subpath-whatever',
14-
prefix: 'apps',
15-
},
16-
}
17-
const appConfigSpec = spec
18-
19-
// When
20-
const result = appConfigSpec.transformLocalToRemote!(object, placeholderAppConfiguration)
21-
22-
// Then
23-
expect(result).toMatchObject({
24-
url: 'https://my-proxy-new.dev',
25-
subpath: 'subpath-whatever',
26-
prefix: 'apps',
27-
})
28-
})
29-
30-
test('when a relative URL is used, it inherits the application_url', () => {
31-
// Given
32-
const object = {
33-
app_proxy: {
34-
url: '/api/proxy',
35-
subpath: 'tools',
36-
prefix: 'apps',
37-
},
38-
}
39-
const appConfigSpec = spec
40-
41-
// When
42-
const result = appConfigSpec.transformLocalToRemote!(object, {
43-
application_url: 'https://my-app-url.com/',
44-
} as unknown as AppConfigurationWithoutPath)
45-
46-
// Then
47-
expect(result).toMatchObject({
48-
url: 'https://my-app-url.com/api/proxy',
49-
subpath: 'tools',
50-
prefix: 'apps',
51-
})
52-
})
53-
54-
test('returns empty object when app_proxy is not configured', () => {
55-
// Given
56-
const object = {}
57-
const appConfigSpec = spec
58-
59-
// When
60-
const result = appConfigSpec.transformLocalToRemote!(object, placeholderAppConfiguration)
61-
62-
// Then
63-
expect(result).toEqual({})
64-
})
5+
test('transformLocalToRemote is not defined', () => {
6+
expect(spec.transformLocalToRemote).toBeUndefined()
657
})
668

679
describe('reverseTransform', () => {

packages/app/src/cli/models/extensions/specifications/app_config_app_proxy.ts

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import {prependApplicationUrl} from './validation/url_prepender.js'
21
import {removeTrailingSlash} from './validation/common.js'
32
import {validateRelativeUrl} from '../../app/validation/common.js'
4-
import {
5-
ExtensionSpecification,
6-
CustomTransformationConfig,
7-
createConfigExtensionSpecification,
8-
} from '../specification.js'
3+
import {ExtensionSpecification, createConfigExtensionSpecification, configWithoutFirstClassFields} from '../specification.js'
94
import {BaseSchemaWithoutHandle} from '../schemas.js'
10-
import {CurrentAppConfiguration} from '../../app/app.js'
115
import {zod} from '@shopify/cli-kit/node/schema'
126

137
const AppProxySchema = BaseSchemaWithoutHandle.extend({
@@ -27,25 +21,11 @@ export type AppProxyConfigType = zod.infer<typeof AppProxySchema>
2721

2822
export const AppProxySpecIdentifier = 'app_proxy'
2923

30-
const AppProxyTransformConfig: CustomTransformationConfig = {
31-
forward: (content, appConfiguration) => {
32-
const appProxyConfig = content as {app_proxy?: {url: string; subpath: string; prefix: string}}
33-
34-
if (!appProxyConfig.app_proxy) {
35-
return {}
36-
}
37-
38-
let appUrl: string | undefined
39-
if ('application_url' in appConfiguration) {
40-
appUrl = (appConfiguration as CurrentAppConfiguration)?.application_url
41-
}
42-
return {
43-
url: prependApplicationUrl(appProxyConfig.app_proxy.url, appUrl),
44-
subpath: appProxyConfig.app_proxy.subpath,
45-
prefix: appProxyConfig.app_proxy.prefix,
46-
}
47-
},
48-
reverse: (content) => {
24+
const appProxySpec: ExtensionSpecification = createConfigExtensionSpecification({
25+
identifier: AppProxySpecIdentifier,
26+
schema: AppProxySchema,
27+
deployConfig: async (config) => configWithoutFirstClassFields(config),
28+
transformRemoteToLocal: (content) => {
4929
const proxyConfig = content as {url: string; subpath: string; prefix: string}
5030
return {
5131
app_proxy: {
@@ -55,12 +35,6 @@ const AppProxyTransformConfig: CustomTransformationConfig = {
5535
},
5636
}
5737
},
58-
}
59-
60-
const appProxySpec: ExtensionSpecification = createConfigExtensionSpecification({
61-
identifier: AppProxySpecIdentifier,
62-
schema: AppProxySchema,
63-
transformConfig: AppProxyTransformConfig,
6438
getDevSessionUpdateMessages: async (config) => {
6539
if (!config.app_proxy) {
6640
return []

0 commit comments

Comments
 (0)