* Validates that experimental features are enabled when using corresponding configuration options.
(config: PrismaConfig)
| 9 | * Validates that experimental features are enabled when using corresponding configuration options. |
| 10 | */ |
| 11 | function validateExperimentalFeatures(config: PrismaConfig): Either.Either<PrismaConfig, Error> { |
| 12 | const experimental = config.experimental || {} |
| 13 | |
| 14 | class="cm">// Check external tables configuration |
| 15 | if (config.tables?.external && !experimental.externalTables) { |
| 16 | return Either.left( |
| 17 | new Error(class="st">'The `tables.external` configuration requires `experimental.externalTables` to be set to `true`.'), |
| 18 | ) |
| 19 | } |
| 20 | |
| 21 | class="cm">// Check migrations initShadowDb configuration |
| 22 | if (config.migrations?.initShadowDb && !experimental.externalTables) { |
| 23 | return Either.left( |
| 24 | new Error( |
| 25 | class="st">'The `migrations.initShadowDb` configuration requires `experimental.externalTables` to be set to `true`.', |
| 26 | ), |
| 27 | ) |
| 28 | } |
| 29 | |
| 30 | if (config[class="st">'extensions'] !== undefined && !experimental.extensions) { |
| 31 | return Either.left( |
| 32 | new Error(class="st">'The `extensions` configuration requires `experimental.extensions` to be set to `true`.'), |
| 33 | ) |
| 34 | } |
| 35 | |
| 36 | return Either.right(config) |
| 37 | } |
| 38 | |
| 39 | export type { PrismaConfigInternal } |
| 40 |