Skip to content
Open
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
7 changes: 1 addition & 6 deletions packages/app/src/cli/models/app/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,7 @@ describe('manifest', () => {
})

// When
const manifest = await app.manifest({
app: 'API_KEY',
extensions: {app_access: 'UUID_A'},
extensionIds: {},
extensionsNonUuidManaged: {},
})
const manifest = await app.manifest({app_access: 'UUID_A'})

// Then
expect(manifest).toEqual({
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/cli/models/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AppErrors, isWebType} from './loader.js'
import {ensurePathStartsWithSlash} from './validation/common.js'
import {Identifiers} from './identifiers.js'
import {ExtensionUuidsByLocalIdentifier} from './identifiers.js'
import {ExtensionInstance} from '../extensions/extension-instance.js'
import {FunctionConfigType} from '../extensions/specifications/function.js'
import {ExtensionSpecification, RemoteAwareExtensionSpecification} from '../extensions/specification.js'
Expand Down Expand Up @@ -245,7 +245,7 @@ export interface AppInterface<
* If creating an app on the platform based on this app and its configuration, what default options should the app take?
*/
creationDefaultOptions(): CreateAppOptions
manifest: (identifiers: Identifiers | undefined) => Promise<AppManifest>
manifest: (appModuleUuids: ExtensionUuidsByLocalIdentifier | undefined) => Promise<AppManifest>
removeExtension: (extensionUid: string) => void
updateHiddenConfig: (values: Partial<AppHiddenConfig>) => Promise<void>
setDevApplicationURLs: (devApplicationURLs: ApplicationURLs) => void
Expand Down Expand Up @@ -331,7 +331,7 @@ export class App<
this.realExtensions.forEach((ext) => ext.patchWithAppDevURLs(devApplicationURLs))
}

async manifest(identifiers: Identifiers | undefined): Promise<AppManifest> {
async manifest(appModuleUuids: ExtensionUuidsByLocalIdentifier | undefined): Promise<AppManifest> {
const modules = await Promise.all(
this.realExtensions.map(async (module) => {
const config = await module.deployConfig({
Expand All @@ -342,7 +342,7 @@ export class App<
type: module.externalType,
handle: module.handle,
uid: module.uid,
uuid: identifiers?.extensions[module.localIdentifier],
uuid: appModuleUuids?.[module.localIdentifier],
assets: module.uid,
target: module.contextValue,
config: (config ?? {}) as JsonMapType,
Expand Down
9 changes: 9 additions & 0 deletions packages/app/src/cli/models/app/identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export interface Identifiers {
extensionsNonUuidManaged: IdentifiersExtensions
}

export interface ExtensionUuidsByLocalIdentifier {
[localIdentifier: string]: string
}

export interface DeployIdentifiers {
appModuleUuids: ExtensionUuidsByLocalIdentifier
appModuleRegistrationIds: ExtensionUuidsByLocalIdentifier
}

type UuidOnlyIdentifiers = Omit<Identifiers, 'extensionIds' | 'extensionsNonUuidManaged'>
type UpdateAppIdentifiersCommand = 'dev' | 'deploy' | 'release' | 'import-extensions'
interface UpdateAppIdentifiersOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,11 @@ describe('deployConfig', async () => {
})

describe('bundleConfig', async () => {
test('returns the uuid from extensions when the extension is uuid managed', async () => {
test('returns the uuid from appModuleUuids', async () => {
const extensionInstance = await testThemeExtensions()

const got = await extensionInstance.bundleConfig({
identifiers: {
extensions: {'theme-extension-name': 'theme-uuid'},
extensionIds: {},
app: 'My app',
extensionsNonUuidManaged: {},
},
appModuleUuids: {'theme-extension-name': 'theme-uuid'},
developerPlatformClient,
apiKey: 'apiKey',
appConfiguration: placeholderAppConfiguration,
Expand All @@ -260,12 +255,7 @@ describe('bundleConfig', async () => {
const extensionInstance = await testPaymentExtensions()

const got = await extensionInstance.bundleConfig({
identifiers: {
extensions: {'payment-extension-name': 'payment-uuid'},
extensionIds: {},
app: 'My app',
extensionsNonUuidManaged: {},
},
appModuleUuids: {'payment-extension-name': 'payment-uuid'},
developerPlatformClient,
apiKey: 'apiKey',
appConfiguration: placeholderAppConfiguration,
Expand All @@ -279,16 +269,11 @@ describe('bundleConfig', async () => {
)
})

test('returns the uuid from extensionsNonUuidManaged when the extension is not uuid managed', async () => {
test('returns the uuid for a non-uuid-managed extension', async () => {
const extensionInstance = await testAppConfigExtensions()

const got = await extensionInstance.bundleConfig({
identifiers: {
extensions: {},
extensionIds: {},
app: 'My app',
extensionsNonUuidManaged: {point_of_sale: 'uuid'},
},
appModuleUuids: {point_of_sale: 'uuid'},
developerPlatformClient,
apiKey: 'apiKey',
appConfiguration: placeholderAppConfiguration,
Expand Down
27 changes: 11 additions & 16 deletions packages/app/src/cli/models/extensions/extension-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {FunctionConfigType} from './specifications/function.js'
import {DevSessionWatchConfig, ExtensionFeature, ExtensionSpecification} from './specification.js'
import {SingleWebhookSubscriptionType} from './specifications/app_config_webhook_schemas/webhooks_schema.js'
import {ExtensionBuildOptions} from '../../services/build/extension.js'
import {Identifiers} from '../app/identifiers.js'
import {ExtensionUuidsByLocalIdentifier} from '../app/identifiers.js'
import {DeveloperPlatformClient} from '../../utilities/developer-platform-client.js'
import {AppConfiguration} from '../app/app.js'
import {ApplicationURLs} from '../../services/dev/urls.js'
Expand Down Expand Up @@ -245,10 +245,8 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
return `https://${fqdn}/${options.orgId}/apps/${options.appId}/extensions/${parnersPath}/${options.extensionId}`
}

getOutputFolderId(outputId?: string) {
// Ideally we want to return `this.uid` always. To keep supporting Partners API we accept a value to override that.

return outputId ?? this.uid
getOutputFolderId() {
return this.uid
}

// UI Specific properties
Expand Down Expand Up @@ -347,17 +345,16 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
}
}

async buildForBundle(options: ExtensionBuildOptions, bundleDirectory: string, outputId?: string) {
this.outputPath = this.getOutputPathForDirectory(bundleDirectory, outputId)
async buildForBundle(options: ExtensionBuildOptions, bundleDirectory: string) {
this.outputPath = this.getOutputPathForDirectory(bundleDirectory)
await this.build(options)

const bundleInputPath = joinPath(bundleDirectory, this.getOutputFolderId(outputId))
const bundleInputPath = joinPath(bundleDirectory, this.getOutputFolderId())
await this.keepBuiltSourcemapsLocally(bundleInputPath)
}

getOutputPathForDirectory(directory: string, outputId?: string) {
const id = this.getOutputFolderId(outputId)
return joinPath(directory, id, this.outputRelativePath)
getOutputPathForDirectory(directory: string) {
return joinPath(directory, this.getOutputFolderId(), this.outputRelativePath)
}

get singleTarget() {
Expand All @@ -373,7 +370,7 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
}

async bundleConfig({
identifiers,
appModuleUuids,
developerPlatformClient,
apiKey,
appConfiguration,
Expand All @@ -387,9 +384,7 @@ export class ExtensionInstance<TConfiguration extends BaseConfigType = BaseConfi
handle: this.handle,
}

const uuid = this.isUUIDStrategyExtension
? identifiers.extensions[this.localIdentifier]!
: identifiers.extensionsNonUuidManaged[this.localIdentifier]!
const uuid = appModuleUuids[this.localIdentifier]!

return {
...result,
Expand Down Expand Up @@ -557,7 +552,7 @@ interface ExtensionDeployConfigOptions {
}

interface ExtensionBundleConfigOptions {
identifiers: Identifiers
appModuleUuids: ExtensionUuidsByLocalIdentifier
developerPlatformClient: DeveloperPlatformClient
apiKey: string
appConfiguration: AppConfiguration
Expand Down
16 changes: 12 additions & 4 deletions packages/app/src/cli/services/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export async function deploy(options: DeployOptions) {
allowDeletes,
})

const appModuleUuids = {...identifiers.extensions, ...identifiers.extensionsNonUuidManaged}

const release = !noRelease
const apiKey = remoteApp.apiKey

Expand All @@ -178,15 +180,13 @@ export async function deploy(options: DeployOptions) {
)
await mkdir(dirname(candidateBundlePath))

const appManifest = await app.manifest(identifiers)
const appManifest = await app.manifest(appManifestUuids(app, appModuleUuids))

const bundlePath = await bundleAndBuildExtensions({
app,
appManifest,
bundlePath: candidateBundlePath,
identifiers,
skipBuild: options.skipBuild,
isDevDashboardApp: true,
})

let uploadTaskTitle
Expand All @@ -209,7 +209,7 @@ export async function deploy(options: DeployOptions) {
task: async () => {
const appModules = await Promise.all(
app.allExtensions.flatMap((ext) =>
ext.bundleConfig({identifiers, developerPlatformClient, apiKey, appConfiguration: app.configuration}),
ext.bundleConfig({appModuleUuids, developerPlatformClient, apiKey, appConfiguration: app.configuration}),
),
)

Expand Down Expand Up @@ -346,3 +346,11 @@ async function outputCompletionMessage({
],
})
}

function appManifestUuids(app: AppLinkedInterface, appModuleUuids: {[localIdentifier: string]: string}) {
return Object.fromEntries(
app.allExtensions
.filter((extension) => extension.isUUIDStrategyExtension)
.map((extension) => [extension.localIdentifier, appModuleUuids[extension.localIdentifier]!]),
)
}
Loading
Loading