Skip to content
Closed
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 @@ -12,6 +12,7 @@ import appAccessSpec, {AppAccessSpecIdentifier} from './specifications/app_confi
import appPrivacyComplienceSpec, {
PrivacyComplianceWebhooksSpecIdentifier,
} from './specifications/app_config_privacy_compliance_webhooks.js'
import appBundlesSpec, {BundlesSpecIdentifier} from './specifications/app_config_bundles.js'
import checkoutPostPurchaseSpec from './specifications/checkout_post_purchase.js'
import checkoutSpec from './specifications/checkout_ui_extension.js'
import flowActionSpecification from './specifications/flow_action.js'
Expand All @@ -38,6 +39,7 @@ const SORTED_CONFIGURATION_SPEC_IDENTIFIERS = [
AppProxySpecIdentifier,
PosSpecIdentifier,
AppHomeSpecIdentifier,
BundlesSpecIdentifier,
]

/**
Expand All @@ -61,6 +63,7 @@ function loadSpecifications() {
appWebhooksSpec,
appWebhookSubscriptionSpec,
appEventsSpec,
appBundlesSpec,
]
const moduleSpecs = [
checkoutPostPurchaseSpec,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import spec from './app_config_bundles.js'
import {placeholderAppConfiguration} from '../../app/app.test-data.js'
import {describe, expect, test} from 'vitest'

describe('app_config_bundles', () => {
describe('transform', () => {
test('transforms local config to remote format', () => {
// Given
const object = {bundles: {purchase_options: true}}

// When
const result = spec.transformLocalToRemote!(object, placeholderAppConfiguration)

// Then
expect(result).toMatchObject({purchase_options: true})
})
})

describe('reverseTransform', () => {
test('transforms remote format back to local config', () => {
// Given
const object = {purchase_options: true}

// When
const result = spec.transformRemoteToLocal!(object)

// Then
expect(result).toMatchObject({bundles: {purchase_options: true}})
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {createConfigExtensionSpecification, TransformationConfig} from '../specification.js'
import {BaseSchemaWithoutHandle} from '../schemas.js'
import {zod} from '@shopify/cli-kit/node/schema'

const BundlesConfigurationSchema = BaseSchemaWithoutHandle.extend({
bundles: zod
.object({
purchase_options: zod.boolean({invalid_type_error: 'Value must be Boolean'}),
})
.optional(),
})

export const BundlesSpecIdentifier = 'bundles'

const BundlesTransformConfig: TransformationConfig = {
purchase_options: 'bundles.purchase_options',
}

const appBundlesSpec = createConfigExtensionSpecification({
identifier: BundlesSpecIdentifier,
schema: BundlesConfigurationSchema,
transformConfig: BundlesTransformConfig,
})

export default appBundlesSpec
Loading