Skip to content

Commit

Permalink
Merge pull request #3411 from Shopify/remove-api-client-config-from-link
Browse files Browse the repository at this point in the history
Remove API Client config from `link` command
  • Loading branch information
alvaro-shopify committed Feb 9, 2024
2 parents 1d48f56 + 8e37004 commit c43c4d9
Show file tree
Hide file tree
Showing 9 changed files with 556 additions and 776 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-pets-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Remove api client configuration from the link command
28 changes: 0 additions & 28 deletions packages/app/src/cli/api/graphql/create_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ export const CreateAppQuery = gql`
applicationUrl
redirectUrlWhitelist
requestedAccessScopes
webhookApiVersion
embedded
posEmbedded
preferencesUrl
gdprWebhooks {
customerDeletionUrl
customerDataRequestUrl
shopDeletionUrl
}
appProxy {
subPath
subPathPrefix
url
}
}
userErrors {
field
Expand Down Expand Up @@ -79,20 +65,6 @@ export interface CreateAppQuerySchema {
applicationUrl: string
redirectUrlWhitelist: string[]
requestedAccessScopes?: string[]
webhookApiVersion: string
embedded: boolean
posEmbedded?: boolean
preferencesUrl?: string
gdprWebhooks?: {
customerDeletionUrl?: string
customerDataRequestUrl?: string
shopDeletionUrl?: string
}
appProxy?: {
subPath: string
subPathPrefix: string
url: string
}
}
userErrors: {
field: string[]
Expand Down
28 changes: 0 additions & 28 deletions packages/app/src/cli/api/graphql/find_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ export const FindAppQuery = gql`
applicationUrl
redirectUrlWhitelist
requestedAccessScopes
webhookApiVersion
embedded
posEmbedded
preferencesUrl
gdprWebhooks {
customerDeletionUrl
customerDataRequestUrl
shopDeletionUrl
}
appProxy {
subPath
subPathPrefix
url
}
developmentStorePreviewEnabled
disabledBetas
}
Expand All @@ -49,20 +35,6 @@ export interface FindAppQuerySchema {
applicationUrl: string
redirectUrlWhitelist: string[]
requestedAccessScopes?: string[]
webhookApiVersion: string
embedded: boolean
posEmbedded?: boolean
preferencesUrl?: string
gdprWebhooks?: {
customerDeletionUrl?: string
customerDataRequestUrl?: string
shopDeletionUrl?: string
}
appProxy?: {
subPath: string
subPathPrefix: string
url: string
}
developmentStorePreviewEnabled: boolean
disabledBetas: string[]
}
Expand Down
93 changes: 49 additions & 44 deletions packages/app/src/cli/models/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,61 +294,66 @@ export class App implements AppInterface {
if (isLegacyAppSchema(configuration)) return configuration
return {
...configuration,
...this.homeConfiguration(configuration),
...this.appProxyConfiguration(configuration),
...this.posConfiguration(configuration),
...this.webhooksConfiguration(configuration),
...this.accessConfiguration(configuration),
...buildSpecsAppConfiguration(configuration),
} as CurrentAppConfiguration & SpecsAppConfiguration
}
}

private appProxyConfiguration(configuration: AppConfiguration) {
if (!getPathValue(configuration, 'app_proxy')) return
return {
app_proxy: {
url: getPathValue<string>(configuration, 'app_proxy.url')!,
prefix: getPathValue<string>(configuration, 'app_proxy.prefix')!,
subpath: getPathValue<string>(configuration, 'app_proxy.subpath')!,
},
}
export function buildSpecsAppConfiguration(content: object) {
return {
...homeConfiguration(content),
...appProxyConfiguration(content),
...posConfiguration(content),
...webhooksConfiguration(content),
...accessConfiguration(content),
}
}

private homeConfiguration(configuration: AppConfiguration) {
const appPreferencesUrl = getPathValue<string>(configuration, 'app_preferences.url')
return {
application_url: getPathValue<string>(configuration, 'application_url')!,
embedded: getPathValue<boolean>(configuration, 'embedded')!,
...(appPreferencesUrl ? {app_preferences: {url: appPreferencesUrl}} : {}),
}
function appProxyConfiguration(configuration: object) {
if (!getPathValue(configuration, 'app_proxy')) return
return {
app_proxy: {
url: getPathValue<string>(configuration, 'app_proxy.url')!,
prefix: getPathValue<string>(configuration, 'app_proxy.prefix')!,
subpath: getPathValue<string>(configuration, 'app_proxy.subpath')!,
},
}
}

private posConfiguration(configuration: AppConfiguration) {
const embedded = getPathValue<boolean>(configuration, 'pos.embedded')
return embedded === undefined
? undefined
: {
pos: {
embedded,
},
}
function homeConfiguration(configuration: object) {
const appPreferencesUrl = getPathValue<string>(configuration, 'app_preferences.url')
return {
name: getPathValue<string>(configuration, 'name')!,
application_url: getPathValue<string>(configuration, 'application_url')!,
embedded: getPathValue<boolean>(configuration, 'embedded')!,
...(appPreferencesUrl ? {app_preferences: {url: appPreferencesUrl}} : {}),
}
}

private webhooksConfiguration(configuration: AppConfiguration) {
return {
webhooks: {...getPathValue<WebhooksConfig>(configuration, 'webhooks')},
}
function posConfiguration(configuration: object) {
const embedded = getPathValue<boolean>(configuration, 'pos.embedded')
return embedded === undefined
? undefined
: {
pos: {
embedded,
},
}
}

function webhooksConfiguration(configuration: object) {
return {
webhooks: {...getPathValue<WebhooksConfig>(configuration, 'webhooks')},
}
}

private accessConfiguration(configuration: AppConfiguration) {
const scopes = getPathValue<string>(configuration, 'access_scopes.scopes')
const useLegacyInstallFlow = getPathValue<boolean>(configuration, 'access_scopes.use_legacy_install_flow')
const redirectUrls = getPathValue<string[]>(configuration, 'auth.redirect_urls')
return {
...(scopes || useLegacyInstallFlow
? {access_scopes: {scopes, use_legacy_install_flow: useLegacyInstallFlow}}
: {}),
...(redirectUrls ? {auth: {redirect_urls: redirectUrls}} : {}),
}
function accessConfiguration(configuration: object) {
const scopes = getPathValue<string>(configuration, 'access_scopes.scopes')
const useLegacyInstallFlow = getPathValue<boolean>(configuration, 'access_scopes.use_legacy_install_flow')
const redirectUrls = getPathValue<string[]>(configuration, 'auth.redirect_urls')
return {
...(scopes || useLegacyInstallFlow ? {access_scopes: {scopes, use_legacy_install_flow: useLegacyInstallFlow}} : {}),
...(redirectUrls ? {auth: {redirect_urls: redirectUrls}} : {}),
}
}

Expand Down
14 changes: 0 additions & 14 deletions packages/app/src/cli/models/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ export type OrganizationApp = MinimalOrganizationApp & {
applicationUrl: string
redirectUrlWhitelist: string[]
requestedAccessScopes?: string[]
webhookApiVersion?: string
embedded?: boolean
posEmbedded?: boolean
preferencesUrl?: string
gdprWebhooks?: {
customerDeletionUrl?: string
customerDataRequestUrl?: string
shopDeletionUrl?: string
}
appProxy?: {
subPath: string
subPathPrefix: string
url: string
}
developmentStorePreviewEnabled?: boolean
betas?: BetaFlag[]
}
Expand Down
Loading

0 comments on commit c43c4d9

Please sign in to comment.