-
Notifications
You must be signed in to change notification settings - Fork 228
Migrate point_of_sale spec to deployConfig + transformRemoteToLocal #6909
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
base: 02-27-rcb_contract-migration-1
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import {createConfigExtensionSpecification, TransformationConfig} from '../specification.js' | ||
| import {createConfigExtensionSpecification, configWithoutFirstClassFields} from '../specification.js' | ||
| import {BaseSchemaWithoutHandle} from '../schemas.js' | ||
| import {zod} from '@shopify/cli-kit/node/schema' | ||
|
|
||
|
|
@@ -12,14 +12,14 @@ const PosConfigurationSchema = BaseSchemaWithoutHandle.extend({ | |
|
|
||
| export const PosSpecIdentifier = 'point_of_sale' | ||
|
|
||
| const PosTransformConfig: TransformationConfig = { | ||
| embedded: 'pos.embedded', | ||
| } | ||
|
|
||
| const appPOSSpec = createConfigExtensionSpecification({ | ||
| identifier: PosSpecIdentifier, | ||
| schema: PosConfigurationSchema, | ||
| transformConfig: PosTransformConfig, | ||
| deployConfig: async (config) => { | ||
| const {name, ...rest} = configWithoutFirstClassFields(config) | ||
| return rest | ||
| }, | ||
| transformRemoteToLocal: (content: object) => ({pos: {embedded: (content as {embedded: boolean}).embedded}}), | ||
|
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. Reverse transform is unsafe on unexpected remote payload
Impact:
|
||
| }) | ||
|
|
||
| export default appPOSSpec | ||
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.
Remote/local config shape mismatch (likely breaking reverse transform)
deployConfignow returns the TOML shape (nested underpos), buttransformRemoteToLocalstill assumes the remote object is flat and readscontent.embedded. If the server stores/returns what we now send ({pos:{embedded:true}}), thencontent.embeddedwill beundefinedand local config becomes{pos:{embedded: undefined}}, which is incorrect and can break downstream validation/behavior.Evidence in code:
Impact:
point_of_saleconfig extension once server returns nested shape.