Skip to content

Commit 8a440ce

Browse files
ryancbahanclaude
andcommitted
Migrate app_access spec to deployConfig + transformRemoteToLocal
Remove transformConfig, set deployConfig (configWithoutFirstClassFields pass-through) and transformRemoteToLocal directly (flat scopes → access_scopes.scopes, redirect_url_allowlist → auth.redirect_urls, etc.). transformLocalToRemote is now undefined. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 81f5457 commit 8a440ce

File tree

3 files changed

+33
-46
lines changed

3 files changed

+33
-46
lines changed

packages/app/src/cli/models/app/app.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ describe('manifest', () => {
836836
assets: appAccessModule.uid,
837837
target: appAccessModule.contextValue,
838838
config: expect.objectContaining({
839-
redirect_url_allowlist: ['https://example.com/auth/callback'],
839+
auth: {redirect_urls: ['https://example.com/auth/callback']},
840840
}),
841841
},
842842
],
@@ -906,7 +906,7 @@ describe('manifest', () => {
906906
assets: appAccess.uid,
907907
target: appAccess.contextValue,
908908
config: expect.objectContaining({
909-
redirect_url_allowlist: ['https://new-url.io/auth/callback'],
909+
auth: {redirect_urls: ['https://new-url.io/auth/callback']},
910910
}),
911911
},
912912
],

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

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
11
import spec from './app_config_app_access.js'
2-
import {placeholderAppConfiguration} from '../../app/app.test-data.js'
32
import {describe, expect, test} from 'vitest'
43

54
describe('app_config_app_access', () => {
65
describe('transform', () => {
7-
test('should return the transformed object', () => {
8-
// Given
9-
const object = {
10-
access: {
11-
admin: {direct_api_mode: 'online'},
12-
},
13-
access_scopes: {
14-
scopes: 'read_products,write_products',
15-
optional_scopes: ['read_customers'],
16-
required_scopes: ['write_orders', 'read_inventory'],
17-
use_legacy_install_flow: true,
18-
},
19-
auth: {
20-
redirect_urls: ['https://example.com/auth/callback'],
21-
},
22-
}
23-
const appAccessSpec = spec
24-
25-
// When
26-
const result = appAccessSpec.transformLocalToRemote!(object, placeholderAppConfiguration)
27-
28-
// Then
29-
expect(result).toMatchObject({
30-
access: {
31-
admin: {direct_api_mode: 'online'},
32-
},
33-
scopes: 'read_products,write_products',
34-
optional_scopes: ['read_customers'],
35-
required_scopes: ['write_orders', 'read_inventory'],
36-
use_legacy_install_flow: true,
37-
redirect_url_allowlist: ['https://example.com/auth/callback'],
38-
})
6+
test('transformLocalToRemote should be undefined', () => {
7+
expect(spec.transformLocalToRemote).toBeUndefined()
398
})
409
})
4110

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

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {validateUrl} from '../../app/validation/common.js'
2-
import {TransformationConfig, createConfigExtensionSpecification} from '../specification.js'
2+
import {configWithoutFirstClassFields, createConfigExtensionSpecification} from '../specification.js'
33
import {BaseSchemaWithoutHandle} from '../schemas.js'
44
import {normalizeDelimitedString} from '@shopify/cli-kit/common/string'
55
import {zod} from '@shopify/cli-kit/node/schema'
@@ -33,19 +33,37 @@ const AppAccessSchema = BaseSchemaWithoutHandle.extend({
3333

3434
export const AppAccessSpecIdentifier = 'app_access'
3535

36-
const AppAccessTransformConfig: TransformationConfig = {
37-
access: 'access',
38-
scopes: 'access_scopes.scopes',
39-
required_scopes: 'access_scopes.required_scopes',
40-
optional_scopes: 'access_scopes.optional_scopes',
41-
use_legacy_install_flow: 'access_scopes.use_legacy_install_flow',
42-
redirect_url_allowlist: 'auth.redirect_urls',
43-
}
44-
4536
const appAccessSpec = createConfigExtensionSpecification({
4637
identifier: AppAccessSpecIdentifier,
4738
schema: AppAccessSchema,
48-
transformConfig: AppAccessTransformConfig,
39+
deployConfig: async (config) => {
40+
const {name, ...rest} = configWithoutFirstClassFields(config)
41+
return rest
42+
},
43+
transformRemoteToLocal: (remoteContent: object) => {
44+
const remote = remoteContent as {[key: string]: unknown}
45+
const result: {[key: string]: unknown} = {}
46+
47+
if (remote.access !== undefined) {
48+
result.access = remote.access
49+
}
50+
51+
const accessScopes: {[key: string]: unknown} = {}
52+
if (remote.scopes !== undefined) accessScopes.scopes = remote.scopes
53+
if (remote.required_scopes !== undefined) accessScopes.required_scopes = remote.required_scopes
54+
if (remote.optional_scopes !== undefined) accessScopes.optional_scopes = remote.optional_scopes
55+
if (remote.use_legacy_install_flow !== undefined)
56+
accessScopes.use_legacy_install_flow = remote.use_legacy_install_flow
57+
if (Object.keys(accessScopes).length > 0) {
58+
result.access_scopes = accessScopes
59+
}
60+
61+
if (remote.redirect_url_allowlist !== undefined) {
62+
result.auth = {redirect_urls: remote.redirect_url_allowlist}
63+
}
64+
65+
return result
66+
},
4967
getDevSessionUpdateMessages: async (config) => {
5068
const hasAccessModule = config.access_scopes !== undefined
5169
const isLegacyInstallFlow = config.access_scopes?.use_legacy_install_flow === true

0 commit comments

Comments
 (0)