diff --git a/packages/app/src/cli/commands/app/import-extensions.ts b/packages/app/src/cli/commands/app/import-extensions.ts index bd7d77bf4b6..6eff533f4c3 100644 --- a/packages/app/src/cli/commands/app/import-extensions.ts +++ b/packages/app/src/cli/commands/app/import-extensions.ts @@ -48,7 +48,7 @@ export default class ImportExtensions extends AppLinkedCommand { ...appContext, extensions, extensionTypes: migrationChoice.extensionTypes, - buildTomlObject: migrationChoice.buildTomlObject, + buildExtensionConfig: migrationChoice.buildExtensionConfig, }) } diff --git a/packages/app/src/cli/prompts/import-extensions.test.ts b/packages/app/src/cli/prompts/import-extensions.test.ts index f4e24840faa..f44bc323946 100644 --- a/packages/app/src/cli/prompts/import-extensions.test.ts +++ b/packages/app/src/cli/prompts/import-extensions.test.ts @@ -23,10 +23,10 @@ describe('allMigrationChoices', () => { expect(choice).toHaveProperty('label') expect(choice).toHaveProperty('value') expect(choice).toHaveProperty('extensionTypes') - expect(choice).toHaveProperty('buildTomlObject') + expect(choice).toHaveProperty('buildExtensionConfig') expect(Array.isArray(choice.extensionTypes)).toBe(true) expect(choice.extensionTypes.length).toBeGreaterThan(0) - expect(typeof choice.buildTomlObject).toBe('function') + expect(typeof choice.buildExtensionConfig).toBe('function') }) }) @@ -134,7 +134,7 @@ describe('selectMigrationChoice', () => { label: 'Test Extension', value: 'test', extensionTypes: ['test_type'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), } const result = await selectMigrationChoice([singleChoice]) expect(result).toBe(singleChoice) @@ -147,13 +147,13 @@ describe('selectMigrationChoice', () => { label: 'Choice 1', value: 'choice1', extensionTypes: ['type1'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), }, { label: 'Choice 2', value: 'choice2', extensionTypes: ['type2'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), }, ] @@ -177,13 +177,13 @@ describe('selectMigrationChoice', () => { label: 'Choice 1', value: 'choice1', extensionTypes: ['type1'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), }, { label: 'Choice 2', value: 'choice2', extensionTypes: ['type2'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), }, ] @@ -204,19 +204,19 @@ describe('selectMigrationChoice', () => { label: 'Payments Extensions', value: 'payments', extensionTypes: ['payments_app'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), }, { label: 'Flow Extensions', value: 'flow', extensionTypes: ['flow_action_definition'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), }, { label: 'Marketing Activity Extensions', value: 'marketing activity', extensionTypes: ['marketing_activity_extension'], - buildTomlObject: vi.fn(), + buildExtensionConfig: vi.fn(), }, ] diff --git a/packages/app/src/cli/prompts/import-extensions.ts b/packages/app/src/cli/prompts/import-extensions.ts index 347b5a8be03..bb0928a99ec 100644 --- a/packages/app/src/cli/prompts/import-extensions.ts +++ b/packages/app/src/cli/prompts/import-extensions.ts @@ -1,8 +1,8 @@ -import {buildTomlObject as buildPaymentsTomlObject} from '../services/payments/extension-to-toml.js' -import {buildTomlObject as buildFlowTomlObject} from '../services/flow/extension-to-toml.js' -import {buildTomlObject as buildAdminLinkTomlObject} from '../services/admin-link/extension-to-toml.js' -import {buildTomlObject as buildMarketingActivityTomlObject} from '../services/marketing_activity/extension-to-toml.js' -import {buildTomlObject as buildSubscriptionLinkTomlObject} from '../services/subscription_link/extension-to-toml.js' +import {buildExtensionConfig as buildPaymentsConfig} from '../services/payments/extension-config-builder.js' +import {buildExtensionConfig as buildFlowConfig} from '../services/flow/extension-config-builder.js' +import {buildExtensionConfig as buildAdminLinkConfig} from '../services/admin-link/extension-config-builder.js' +import {buildExtensionConfig as buildMarketingActivityConfig} from '../services/marketing_activity/extension-config-builder.js' +import {buildExtensionConfig as buildSubscriptionLinkConfig} from '../services/subscription_link/extension-config-builder.js' import {ExtensionRegistration} from '../api/graphql/all_app_extension_registrations.js' import {CurrentAppConfiguration} from '../models/app/app.js' import {AbortError} from '@shopify/cli-kit/node/error' @@ -12,7 +12,7 @@ export interface MigrationChoice { label: string value: string extensionTypes: string[] - buildTomlObject: ( + buildExtensionConfig: ( ext: ExtensionRegistration, allExtensions: ExtensionRegistration[], appConfiguration: CurrentAppConfiguration, @@ -31,31 +31,31 @@ export const allMigrationChoices: MigrationChoice[] = [ 'payments_app_redeemable', 'payments_extension', ], - buildTomlObject: buildPaymentsTomlObject, + buildExtensionConfig: buildPaymentsConfig, }, { label: 'Flow Extensions', value: 'flow', extensionTypes: ['flow_action_definition', 'flow_trigger_definition', 'flow_trigger_discovery_webhook'], - buildTomlObject: buildFlowTomlObject, + buildExtensionConfig: buildFlowConfig, }, { label: 'Marketing Activity Extensions', value: 'marketing activity', extensionTypes: ['marketing_activity_extension'], - buildTomlObject: buildMarketingActivityTomlObject, + buildExtensionConfig: buildMarketingActivityConfig, }, { label: 'Subscription Link Extensions', value: 'subscription link', extensionTypes: ['subscription_link', 'subscription_link_extension'], - buildTomlObject: buildSubscriptionLinkTomlObject, + buildExtensionConfig: buildSubscriptionLinkConfig, }, { label: 'Admin Link extensions', value: 'link extension', extensionTypes: ['app_link', 'bulk_action'], - buildTomlObject: buildAdminLinkTomlObject, + buildExtensionConfig: buildAdminLinkConfig, }, ] diff --git a/packages/app/src/cli/services/admin-link/extension-to-toml.test.ts b/packages/app/src/cli/services/admin-link/extension-config-builder.test.ts similarity index 82% rename from packages/app/src/cli/services/admin-link/extension-to-toml.test.ts rename to packages/app/src/cli/services/admin-link/extension-config-builder.test.ts index 82066d9ea44..06bccfe42dd 100644 --- a/packages/app/src/cli/services/admin-link/extension-to-toml.test.ts +++ b/packages/app/src/cli/services/admin-link/extension-config-builder.test.ts @@ -1,9 +1,9 @@ -import {buildTomlObject} from './extension-to-toml.js' +import {buildExtensionConfig} from './extension-config-builder.js' import {ExtensionRegistration} from '../../api/graphql/all_app_extension_registrations.js' import {describe, expect, test} from 'vitest' -describe('extension-to-toml', () => { - test('correctly builds a toml object for a app_link extension on a non embedded app', () => { +describe('extension-config-builder', () => { + test('correctly builds a config object for a app_link extension on a non embedded app', () => { // Given const appConfig = { path: '', @@ -25,7 +25,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [], appConfig) + const got = buildExtensionConfig(extension1, [], appConfig) // Then expect(got).toEqual({ @@ -45,7 +45,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for bulk_action extension with path in an embedded app', () => { + test('correctly builds a config object for bulk_action extension with path in an embedded app', () => { // Given const appConfig = { path: '', @@ -66,7 +66,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [], appConfig) + const got = buildExtensionConfig(extension1, [], appConfig) // Then expect(got).toEqual({ @@ -85,7 +85,7 @@ describe('extension-to-toml', () => { ], }) }) - test('correctly builds a toml object for bulk_action extension with no path in an embedded app', () => { + test('correctly builds a config object for bulk_action extension with no path in an embedded app', () => { // Given const appConfig = { path: '', @@ -106,7 +106,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [], appConfig) + const got = buildExtensionConfig(extension1, [], appConfig) // Then expect(got).toEqual({ @@ -125,7 +125,7 @@ describe('extension-to-toml', () => { ], }) }) - test('correctly builds a toml object for bulk_action extension with no path but search query in an embedded app', () => { + test('correctly builds a config object for bulk_action extension with no path but search query in an embedded app', () => { // Given const appConfig = { path: '', @@ -146,7 +146,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [], appConfig) + const got = buildExtensionConfig(extension1, [], appConfig) // Then expect(got).toEqual({ diff --git a/packages/app/src/cli/services/admin-link/extension-to-toml.ts b/packages/app/src/cli/services/admin-link/extension-config-builder.ts similarity index 98% rename from packages/app/src/cli/services/admin-link/extension-to-toml.ts rename to packages/app/src/cli/services/admin-link/extension-config-builder.ts index 71e426fd361..a77295ca087 100644 --- a/packages/app/src/cli/services/admin-link/extension-to-toml.ts +++ b/packages/app/src/cli/services/admin-link/extension-config-builder.ts @@ -12,7 +12,7 @@ interface AdminLinkConfig { /** * Given an app_link or bulk_action extension config file, convert it to toml */ -export function buildTomlObject( +export function buildExtensionConfig( extension: ExtensionRegistration, _: ExtensionRegistration[], appConfiguration: CurrentAppConfiguration, diff --git a/packages/app/src/cli/services/flow/extension-to-toml.test.ts b/packages/app/src/cli/services/flow/extension-config-builder.test.ts similarity index 94% rename from packages/app/src/cli/services/flow/extension-to-toml.test.ts rename to packages/app/src/cli/services/flow/extension-config-builder.test.ts index 0764c0f50d6..ad0c2eaa107 100644 --- a/packages/app/src/cli/services/flow/extension-to-toml.test.ts +++ b/packages/app/src/cli/services/flow/extension-config-builder.test.ts @@ -1,9 +1,9 @@ -import {buildTomlObject} from './extension-to-toml.js' +import {buildExtensionConfig} from './extension-config-builder.js' import {ExtensionRegistration} from '../../api/graphql/all_app_extension_registrations.js' import {describe, expect, test} from 'vitest' -describe('extension-to-toml', () => { - test('correctly builds a toml object for a flow_action', () => { +describe('extension-config-builder', () => { + test('correctly builds a config object for a flow_action', () => { // Given const extension1: ExtensionRegistration = { id: '26237698049', @@ -17,7 +17,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1) + const got = buildExtensionConfig(extension1) // Then expect(got).toEqual({ @@ -64,7 +64,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1) + const got = buildExtensionConfig(extension1) // Then expect(got).toEqual({ @@ -97,7 +97,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for a flow_trigger', () => { + test('correctly builds a config object for a flow_trigger', () => { // Given const extension2 = { id: '26237861889', @@ -115,7 +115,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension2) + const got = buildExtensionConfig(extension2) // Then expect(got).toEqual({ diff --git a/packages/app/src/cli/services/flow/extension-to-toml.ts b/packages/app/src/cli/services/flow/extension-config-builder.ts similarity index 97% rename from packages/app/src/cli/services/flow/extension-to-toml.ts rename to packages/app/src/cli/services/flow/extension-config-builder.ts index 6c5f1775531..3d800cd5e60 100644 --- a/packages/app/src/cli/services/flow/extension-to-toml.ts +++ b/packages/app/src/cli/services/flow/extension-config-builder.ts @@ -31,7 +31,7 @@ interface FlowWebhookConfig { * Given a flow extension config file, convert it to toml * Works for both trigger and action because trigger config is a subset of action config */ -export function buildTomlObject(extension: ExtensionRegistration): object { +export function buildExtensionConfig(extension: ExtensionRegistration): object { const versionConfig = extension.activeVersion?.config ?? extension.draftVersion?.config if (!versionConfig) throw new Error('No config found for extension') diff --git a/packages/app/src/cli/services/import-extensions.test.ts b/packages/app/src/cli/services/import-extensions.test.ts index 060d886297b..47e60a58c9a 100644 --- a/packages/app/src/cli/services/import-extensions.test.ts +++ b/packages/app/src/cli/services/import-extensions.test.ts @@ -1,5 +1,5 @@ import {importExtensions, filterOutImportedExtensions} from './import-extensions.js' -import {buildTomlObject} from './flow/extension-to-toml.js' +import {buildExtensionConfig} from './flow/extension-config-builder.js' import {testAppLinked, testDeveloperPlatformClient, testUIExtension} from '../models/app/app.test-data.js' import {OrganizationApp} from '../models/organization.js' import {ExtensionRegistration} from '../api/graphql/all_app_extension_registrations.js' @@ -110,7 +110,7 @@ describe('import-extensions', () => { 'subscription_link_extension', ], extensions, - buildTomlObject, + buildExtensionConfig, }) expect(renderSuccess).toHaveBeenCalledWith({ @@ -167,7 +167,7 @@ describe('import-extensions', () => { developerPlatformClient: testDeveloperPlatformClient(), extensionTypes: ['flow_action_definition'], extensions, - buildTomlObject, + buildExtensionConfig, }) // Then - expect the success message to be shown (even for skipped extensions) @@ -213,7 +213,7 @@ describe('import-extensions', () => { developerPlatformClient: testDeveloperPlatformClient(), extensionTypes: ['flow_action_definition'], extensions, - buildTomlObject, + buildExtensionConfig, }) // Then - expect the success message to be shown @@ -261,7 +261,7 @@ describe('import-extensions', () => { developerPlatformClient: testDeveloperPlatformClient(), extensionTypes: ['flow_action_definition'], extensions, - buildTomlObject, + buildExtensionConfig, }), ).rejects.toThrow(AbortSilentError) @@ -300,7 +300,7 @@ describe('import-extensions', () => { 'subscription_link_extension', ], extensions, - buildTomlObject, + buildExtensionConfig, }) expect(renderSuccess).toHaveBeenCalledWith({ @@ -349,7 +349,7 @@ describe('import-extensions', () => { 'subscription_link_extension', ], extensions, - buildTomlObject, + buildExtensionConfig, }), ).rejects.toThrow('No extensions to migrate') diff --git a/packages/app/src/cli/services/import-extensions.ts b/packages/app/src/cli/services/import-extensions.ts index 2bbd726b6ab..9c72206eaf1 100644 --- a/packages/app/src/cli/services/import-extensions.ts +++ b/packages/app/src/cli/services/import-extensions.ts @@ -26,7 +26,7 @@ interface ImportAllOptions { interface ImportOptions extends ImportAllOptions { extensionTypes: string[] - buildTomlObject: ( + buildExtensionConfig: ( ext: ExtensionRegistration, allExtensions: ExtensionRegistration[], appConfig: CurrentAppConfiguration, @@ -79,7 +79,7 @@ async function handleExtensionDirectory({ } export async function importExtensions(options: ImportOptions) { - const {app, remoteApp, developerPlatformClient, extensionTypes, extensions, buildTomlObject, all} = options + const {app, remoteApp, developerPlatformClient, extensionTypes, extensions, buildExtensionConfig, all} = options let extensionsToMigrate = extensions.filter((ext) => extensionTypes.includes(ext.type.toLowerCase())) extensionsToMigrate = filterOutImportedExtensions(app, extensionsToMigrate) @@ -111,7 +111,7 @@ export async function importExtensions(options: ImportOptions) { extensionUuids[handle] = ext.uuid if (action === DirectoryAction.Write) { - const tomlContent = buildTomlObject(ext, extensions, app.configuration) + const tomlContent = buildExtensionConfig(ext, extensions, app.configuration) const tomlPath = joinPath(directory, 'shopify.extension.toml') const file = new TomlFile(tomlPath, tomlContent as JsonMapType) await file.replace(tomlContent as JsonMapType) @@ -150,7 +150,7 @@ export async function importAllExtensions(options: ImportAllOptions) { return importExtensions({ ...options, extensionTypes: choice.extensionTypes, - buildTomlObject: choice.buildTomlObject, + buildExtensionConfig: choice.buildExtensionConfig, all: true, }) }), diff --git a/packages/app/src/cli/services/marketing_activity/extension-to-toml.test.ts b/packages/app/src/cli/services/marketing_activity/extension-config-builder.test.ts similarity index 88% rename from packages/app/src/cli/services/marketing_activity/extension-to-toml.test.ts rename to packages/app/src/cli/services/marketing_activity/extension-config-builder.test.ts index b3e44d8db52..99d4368cbdc 100644 --- a/packages/app/src/cli/services/marketing_activity/extension-to-toml.test.ts +++ b/packages/app/src/cli/services/marketing_activity/extension-config-builder.test.ts @@ -1,4 +1,4 @@ -import {buildTomlObject, MarketingActivityDashboardConfig} from './extension-to-toml.js' +import {buildExtensionConfig, MarketingActivityDashboardConfig} from './extension-config-builder.js' import {ExtensionRegistration} from '../../api/graphql/all_app_extension_registrations.js' import {describe, expect, test} from 'vitest' @@ -24,7 +24,7 @@ const defaultDashboardConfig: MarketingActivityDashboardConfig = { }, ], } -describe('extension-to-toml', () => { +describe('extension-config-builder', () => { test('converts the dashboard config to the new cli config', () => { // Given const extension: ExtensionRegistration = { @@ -38,7 +38,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension) + const got = buildExtensionConfig(extension) // Then expect(got).toEqual({ @@ -86,7 +86,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension) as {extensions: {handle: string}[]} + const got = buildExtensionConfig(extension) as {extensions: {handle: string}[]} // Then expect(got.extensions[0]!.handle).toBe('mae-test-12345555555554444447777778888888123455') @@ -105,7 +105,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension) as {extensions: {marketing_channel: string; referring_domain: string}[]} + const got = buildExtensionConfig(extension) as {extensions: {marketing_channel: string; referring_domain: string}[]} // Then expect(got.extensions[0]!.marketing_channel).toBe('') diff --git a/packages/app/src/cli/services/marketing_activity/extension-to-toml.ts b/packages/app/src/cli/services/marketing_activity/extension-config-builder.ts similarity index 98% rename from packages/app/src/cli/services/marketing_activity/extension-to-toml.ts rename to packages/app/src/cli/services/marketing_activity/extension-config-builder.ts index 268a87ba9cc..92eba4cf761 100644 --- a/packages/app/src/cli/services/marketing_activity/extension-to-toml.ts +++ b/packages/app/src/cli/services/marketing_activity/extension-config-builder.ts @@ -162,7 +162,7 @@ function getUrlPath(url: string) { /** * Given a dashboard-built marketing activity extension config file, convert it to toml for the CLI extension */ -export function buildTomlObject(extension: ExtensionRegistration): object { +export function buildExtensionConfig(extension: ExtensionRegistration): object { const versionConfig = extension.activeVersion?.config ?? extension.draftVersion?.config if (!versionConfig) throw new Error('No config found for extension') const config: MarketingActivityDashboardConfig = JSON.parse(versionConfig) diff --git a/packages/app/src/cli/services/payments/extension-to-toml.test.ts b/packages/app/src/cli/services/payments/extension-config-builder.test.ts similarity index 94% rename from packages/app/src/cli/services/payments/extension-to-toml.test.ts rename to packages/app/src/cli/services/payments/extension-config-builder.test.ts index d3bdd64a555..7915b412476 100644 --- a/packages/app/src/cli/services/payments/extension-to-toml.test.ts +++ b/packages/app/src/cli/services/payments/extension-config-builder.test.ts @@ -1,4 +1,4 @@ -import {buildTomlObject, DashboardPaymentExtensionType} from './extension-to-toml.js' +import {buildExtensionConfig, DashboardPaymentExtensionType} from './extension-config-builder.js' import {ExtensionRegistration} from '../../api/graphql/all_app_extension_registrations.js' import {describe, expect, test} from 'vitest' @@ -53,8 +53,8 @@ const expectObjectIncludesKeys = (got: object, config: string) => { } } -describe('extension-to-toml', () => { - test('correctly builds a toml object for a CLI payments extension', async () => { +describe('extension-config-builder', () => { + test('correctly builds a config object for a CLI payments extension', async () => { // Given const extension1: ExtensionRegistration = { id: '30366498817', @@ -68,7 +68,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1]) + const got = buildExtensionConfig(extension1, [extension1]) // Then expectObjectIncludesKeys(got, SAMPLE_OFFSITE_CONFIG) @@ -116,7 +116,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1]) + const got = buildExtensionConfig(extension1, [extension1]) // Then expectObjectIncludesKeys(got, SAMPLE_OFFSITE_CONFIG) @@ -150,7 +150,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for an offsite app', async () => { + test('correctly builds a config object for an offsite app', async () => { // Given const extension1: ExtensionRegistration = { id: '30366498817', @@ -163,7 +163,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1]) + const got = buildExtensionConfig(extension1, [extension1]) // Then expectObjectIncludesKeys(got, SAMPLE_OFFSITE_CONFIG) @@ -197,7 +197,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for a credit card app', async () => { + test('correctly builds a config object for a credit card app', async () => { // Given const extension1: ExtensionRegistration = { id: '30366498817', @@ -216,7 +216,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1, extension2]) + const got = buildExtensionConfig(extension1, [extension1, extension2]) // Then expectObjectIncludesKeys(got, SAMPLE_CREDIT_CARD_CONFIG) @@ -252,7 +252,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for a custom credit card app', async () => { + test('correctly builds a config object for a custom credit card app', async () => { // Given const extension1: ExtensionRegistration = { id: '30366498817', @@ -271,7 +271,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1, extension2]) + const got = buildExtensionConfig(extension1, [extension1, extension2]) // Then expectObjectIncludesKeys(got, SAMPLE_CUSTOM_CREDIT_CARD_CONFIG) @@ -306,7 +306,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for a custom onsite app', async () => { + test('correctly builds a config object for a custom onsite app', async () => { // Given const extension1: ExtensionRegistration = { id: '30366498817', @@ -325,7 +325,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1, extension2]) + const got = buildExtensionConfig(extension1, [extension1, extension2]) // Then expectObjectIncludesKeys(got, SAMPLE_CUSTOM_ONSITE_CONFIG) @@ -364,7 +364,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for a redeemable app', async () => { + test('correctly builds a config object for a redeemable app', async () => { // Given const extension1: ExtensionRegistration = { id: '30366498817', @@ -383,7 +383,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1, extension2]) + const got = buildExtensionConfig(extension1, [extension1, extension2]) // Then expectObjectIncludesKeys(got, SAMPLE_REDEEMABLE_CONFIG) @@ -417,7 +417,7 @@ describe('extension-to-toml', () => { }) }) - test('correctly builds a toml object for a card present app', async () => { + test('correctly builds a config object for a card present app', async () => { // Given const extension1: ExtensionRegistration = { id: '30366498817', @@ -430,7 +430,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension1, [extension1]) + const got = buildExtensionConfig(extension1, [extension1]) // Then expectObjectIncludesKeys(got, SAMPLE_CARD_PRESENT_CONFIG) diff --git a/packages/app/src/cli/services/payments/extension-to-toml.ts b/packages/app/src/cli/services/payments/extension-config-builder.ts similarity index 97% rename from packages/app/src/cli/services/payments/extension-to-toml.ts rename to packages/app/src/cli/services/payments/extension-config-builder.ts index 522d8de2630..8be80b6bc36 100644 --- a/packages/app/src/cli/services/payments/extension-to-toml.ts +++ b/packages/app/src/cli/services/payments/extension-config-builder.ts @@ -58,7 +58,7 @@ export enum DashboardPaymentExtensionType { CardPresent = 'payments_app_card_present', } -export function buildTomlObject(extension: ExtensionRegistration, allExtensions: ExtensionRegistration[]): object { +export function buildExtensionConfig(extension: ExtensionRegistration, allExtensions: ExtensionRegistration[]): object { const context = extension.activeVersion?.context || extension.draftVersion?.context || typeToContext(extension.type) switch (context) { case OFFSITE_TARGET: diff --git a/packages/app/src/cli/services/subscription_link/extension-to-toml.test.ts b/packages/app/src/cli/services/subscription_link/extension-config-builder.test.ts similarity index 86% rename from packages/app/src/cli/services/subscription_link/extension-to-toml.test.ts rename to packages/app/src/cli/services/subscription_link/extension-config-builder.test.ts index 9a7fae4c5e7..19fe08d97ac 100644 --- a/packages/app/src/cli/services/subscription_link/extension-to-toml.test.ts +++ b/packages/app/src/cli/services/subscription_link/extension-config-builder.test.ts @@ -1,11 +1,11 @@ -import {buildTomlObject, SubscriptionLinkDashboardConfig} from './extension-to-toml.js' +import {buildExtensionConfig, SubscriptionLinkDashboardConfig} from './extension-config-builder.js' import {ExtensionRegistration} from '../../api/graphql/all_app_extension_registrations.js' import {describe, expect, test} from 'vitest' const defaultDashboardConfig: SubscriptionLinkDashboardConfig = { pattern: '/subscriptions{?customer_id,shop}&id={contract_id}', } -describe('extension-to-toml', () => { +describe('extension-config-builder', () => { test('converts the dashboard config to the new cli config', () => { // Given const extension: ExtensionRegistration = { @@ -19,7 +19,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension) + const got = buildExtensionConfig(extension) // Then expect(got).toEqual({ @@ -47,7 +47,7 @@ describe('extension-to-toml', () => { } // When - const got = buildTomlObject(extension) + const got = buildExtensionConfig(extension) // Then expect((got as {extensions: [{handle: string}]}).extensions[0].handle).toBe( diff --git a/packages/app/src/cli/services/subscription_link/extension-to-toml.ts b/packages/app/src/cli/services/subscription_link/extension-config-builder.ts similarity index 92% rename from packages/app/src/cli/services/subscription_link/extension-to-toml.ts rename to packages/app/src/cli/services/subscription_link/extension-config-builder.ts index 9ba6df67bc7..3e816c13da4 100644 --- a/packages/app/src/cli/services/subscription_link/extension-to-toml.ts +++ b/packages/app/src/cli/services/subscription_link/extension-config-builder.ts @@ -9,7 +9,7 @@ export interface SubscriptionLinkDashboardConfig { /** * Given a dashboard-built subscription link extension config file, convert it to toml for the CLI extension */ -export function buildTomlObject(extension: ExtensionRegistration): object { +export function buildExtensionConfig(extension: ExtensionRegistration): object { const versionConfig = extension.activeVersion?.config ?? extension.draftVersion?.config if (!versionConfig) throw new Error('No config found for extension') const config: SubscriptionLinkDashboardConfig = JSON.parse(versionConfig)