import type { ConfigMetaFormat } from '../../../engine-commands' ; import { forbiddenTransactionsWithProxyFlagMessage } from './forbiddenTransactionsWithProxyFlagMessage' ; import { mongoFeatureFlagMissingMessage } from './mongoFeatureFlagMissingMessage' ; import { proxyFeatureFlagMissingMessage } from './proxyFeatureFlagMissingMessage' ; export function checkFeatureFlags ( config ) { checkMongoFeatureFlag ( config ) ; checkProxyFeatureFlag ( config ) ; checkForbiddenTransactionsWithProxyFlag ( config ) ; } function checkMongoFeatureFlag ( config ) { if ( config . datasources . some ( ( d ) => d . provider === 'mongodb' ) && ! config . generators . some ( ( g ) => { return g . previewFeatures . some ( ( previewFeature ) => previewFeature . toLowerCase ( ) === 'mongoDb' . toLowerCase ( ) ) ; } ) ) { throw new Error ( mongoFeatureFlagMissingMessage ) ; } } function checkProxyFeatureFlag ( config ) { if ( ( config . generators . some ( ( g ) => g . config . engineType === 'dataproxy' ) || process . env . PRISMA_CLIENT_ENGINE_TYPE === 'dataproxy' ) && ! config . generators . some ( ( g ) => { return g . previewFeatures . some ( ( previewFeature ) => previewFeature . toLowerCase ( ) === 'dataProxy' . toLowerCase ( ) ) ; } ) ) { throw new Error ( proxyFeatureFlagMissingMessage ) ; } } function checkForbiddenTransactionsWithProxyFlag ( config ) { if ( config . generators . some ( ( g ) => { const lowerCasePreviewFeatures = g . previewFeatures . map ( ( pf ) => pf . toLowerCase ( ) ) ; return [ 'dataProxy' , 'interactiveTransactions' ] . every ( ( pf ) => lowerCasePreviewFeatures . includes ( pf . toLowerCase ( ) ) ) ; } ) ) { throw new Error ( forbiddenTransactionsWithProxyFlagMessage ) ; } }