Skip to content

Commit

Permalink
chore: remove the integration level requirement for integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
khendrikse committed Sep 30, 2024
1 parent 517e734 commit b8de244
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
27 changes: 8 additions & 19 deletions src/commands/integration/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function formatScopesForRemote(scopes) {
}

// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
function verifyRequiredFieldsAreInConfig(name, description, scopes, integrationLevel) {
function verifyRequiredFieldsAreInConfig(name, description, scopes) {
const missingFields = []

if (!name) {
Expand All @@ -96,9 +96,6 @@ function verifyRequiredFieldsAreInConfig(name, description, scopes, integrationL
if (!scopes) {
missingFields.push('scopes')
}
if (!integrationLevel) {
missingFields.push('integrationLevel')
}
if (missingFields.length !== 0) {
log(
chalk.yellow(
Expand All @@ -119,7 +116,7 @@ function verifyRequiredFieldsAreInConfig(name, description, scopes, integrationL

// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message
export async function registerIntegration(workingDir, siteId, accountId, localIntegrationConfig, token) {
const { description, integrationLevel, name, scopes, slug } = localIntegrationConfig
const { description, name, scopes, slug } = localIntegrationConfig
log(chalk.yellow(`An integration associated with the site ID ${siteId} is not registered.`))
const registerPrompt = await inquirer.prompt([
{
Expand All @@ -144,7 +141,7 @@ export async function registerIntegration(workingDir, siteId, accountId, localIn
exit(1)
}

if (!verifyRequiredFieldsAreInConfig(name, description, scopes, integrationLevel)) {
if (!verifyRequiredFieldsAreInConfig(name, description, scopes)) {
exit(1)
}

Expand All @@ -161,7 +158,6 @@ export async function registerIntegration(workingDir, siteId, accountId, localIn
description,
hostSiteId: siteId,
scopes: formatScopesForRemote(scopes),
integrationLevel,
}),
}).then(async (res) => {
const response = await res.json()
Expand All @@ -185,7 +181,7 @@ export async function registerIntegration(workingDir, siteId, accountId, localIn

const updatedIntegrationConfig = yaml.dump({
// @ts-expect-error TS(18046) - 'body' is of type 'unknown'
config: { name, description, slug: body.slug, scopes, integrationLevel },
config: { name, description, slug: body.slug, scopes },
})

const filePath = resolve(workingDir, 'integration.yaml')
Expand All @@ -210,7 +206,7 @@ export async function updateIntegration(
// @ts-expect-error TS(7006) FIXME: Parameter 'registeredIntegration' implicitly has a... Remove this comment to see the full error message
registeredIntegration,
) {
let { description, integrationLevel, name, scopes, slug } = localIntegrationConfig
let { description, name, scopes, slug } = localIntegrationConfig

let integrationSlug = slug
if (slug !== registeredIntegration.slug) {
Expand All @@ -231,11 +227,6 @@ export async function updateIntegration(
description = registeredIntegration.description
}

if (!integrationLevel) {
// eslint-disable-next-line prefer-destructuring
integrationLevel = registeredIntegration.integrationLevel
}

// This is returned as a comma separated string and will be easier to manage here as an array
const registeredIntegrationScopes = registeredIntegration.scopes.split(',')

Expand Down Expand Up @@ -286,7 +277,6 @@ export async function updateIntegration(
hostSiteId: siteId,
// @ts-expect-error TS(7005) FIXME: Variable 'localScopes' implicitly has an 'any[]' t... Remove this comment to see the full error message
scopes: localScopes.join(','),
integrationLevel,
}),
},
).then(async (res) => {
Expand Down Expand Up @@ -324,7 +314,7 @@ export async function updateIntegration(
}

const updatedIntegrationConfig = yaml.dump({
config: { name, description, slug: integrationSlug, scopes: scopesToWrite, integrationLevel },
config: { name, description, slug: integrationSlug, scopes: scopesToWrite },
})

const filePath = resolve(workingDir, 'integration.yaml')
Expand All @@ -347,7 +337,6 @@ const IntegrationConfigurationSchema = z.object({
user: z.array(z.enum(['read', 'write'])).optional(),
})
.optional(),
integrationLevel: z.enum(['site', 'team', 'team-and-site']).optional(),
})

// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message
Expand Down Expand Up @@ -409,8 +398,8 @@ export const deploy = async (options: OptionValues, command: BaseCommand) => {
// Confirm that a site is linked and that the user is logged in
checkOptions(buildOptions)

const { description, integrationLevel, name, scopes, slug } = await getConfiguration(command.workingDir)
const localIntegrationConfig = { name, description, scopes, slug, integrationLevel }
const { description, name, scopes, slug } = await getConfiguration(command.workingDir)
const localIntegrationConfig = { name, description, scopes, slug }

// @ts-expect-error TS(2345) FIXME: Argument of type '{ api: any; site: any; siteInfo:... Remove this comment to see the full error message
const { accountId } = await getSiteInformation({
Expand Down
1 change: 0 additions & 1 deletion tests/integration/commands/integration/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe(`integration:deploy`, () => {
scopes:
site:
- read
integrationLevel: team-and-site
`,
},
])
Expand Down

0 comments on commit b8de244

Please sign in to comment.