1- import { color , hux , utils } from '@heroku/heroku-cli-util'
21import { flags as Flags } from '@heroku-cli/command'
32import { AddOnAttachment } from '@heroku-cli/schema'
3+ import * as color from '@heroku/heroku-cli-util/color'
4+ import { confirmCommand } from '@heroku/heroku-cli-util/hux'
5+ import {
6+ AddonResolver , getAddonService , isAdvancedDatabase , isEssentialDatabase , isLegacyEssentialDatabase ,
7+ } from '@heroku/heroku-cli-util/utils'
48import { Args , ux } from '@oclif/core'
59
610import type { CredentialInfo , CredentialsInfo } from '../../../../lib/data/types.js'
@@ -33,10 +37,11 @@ export default class DataPgCredentialsDestroy extends BaseCommand {
3337 const { app, confirm, name} = flags
3438 const { database} = args
3539
36- const addonResolver = new utils . AddonResolver ( this . heroku )
37- const addon = await addonResolver . resolve ( database , app , utils . pg . addonService ( ) )
38- const isEssentialTier = utils . pg . isEssentialDatabase ( addon ) || utils . pg . isLegacyEssentialDatabase ( addon )
39- const isAdvancedTier = utils . pg . isAdvancedDatabase ( addon )
40+ const addonResolver = new AddonResolver ( this . heroku )
41+ const addon = await addonResolver . resolve ( database , app , getAddonService ( ) )
42+ const isEssentialTier = isEssentialDatabase ( addon )
43+ const isLegacyEssentialTier = isLegacyEssentialDatabase ( addon )
44+ const isAdvancedTier = isAdvancedDatabase ( addon )
4045 let credAttachments : Required < AddOnAttachment > [ ] = [ ]
4146
4247 if ( isAdvancedTier ) {
@@ -50,7 +55,9 @@ export default class DataPgCredentialsDestroy extends BaseCommand {
5055 }
5156
5257 credAttachments = attachments . filter ( a => a . namespace === `role:${ name } ` )
53- } else if ( isEssentialTier || name === 'default' ) {
58+ } else if ( isEssentialTier ) {
59+ ux . error ( 'You can\'t destroy custom credentials on Essential-tier databases.' )
60+ } else if ( isLegacyEssentialTier || name === 'default' ) {
5461 ux . error ( 'You can\'t destroy the default credential.' )
5562 } else {
5663 const { body : attachments } = await this . heroku . get < Required < AddOnAttachment > [ ] > (
@@ -68,7 +75,7 @@ export default class DataPgCredentialsDestroy extends BaseCommand {
6875 )
6976 }
7077
71- await hux . confirmCommand ( { comparison : app , confirmation : confirm } )
78+ await confirmCommand ( { comparison : app , confirmation : confirm } )
7279
7380 try {
7481 ux . action . start ( `Destroying credential ${ color . name ( name ) } ` )
0 commit comments