(options: GenerateClientOptions)
| 301 | } |
| 302 | |
| 303 | export async function generateClient(options: GenerateClientOptions): Promise<void> { |
| 304 | const { |
| 305 | datamodel, |
| 306 | schemaPath, |
| 307 | generator, |
| 308 | dmmf, |
| 309 | datasources, |
| 310 | binaryPaths, |
| 311 | testMode, |
| 312 | copyRuntime, |
| 313 | copyRuntimeSourceMaps = false, |
| 314 | runtimeSourcePath, |
| 315 | clientVersion, |
| 316 | engineVersion, |
| 317 | activeProvider, |
| 318 | typedSql, |
| 319 | compilerBuild, |
| 320 | } = options |
| 321 | |
| 322 | const { runtimeBase, outputDir } = await getGenerationDirs(options) |
| 323 | |
| 324 | const { prismaClientDmmf, fileMap } = await buildClient({ |
| 325 | datamodel, |
| 326 | schemaPath, |
| 327 | runtimeBase, |
| 328 | runtimeSourcePath, |
| 329 | outputDir, |
| 330 | generator, |
| 331 | dmmf, |
| 332 | datasources, |
| 333 | binaryPaths, |
| 334 | clientVersion, |
| 335 | engineVersion, |
| 336 | activeProvider, |
| 337 | testMode, |
| 338 | typedSql, |
| 339 | compilerBuild, |
| 340 | }) |
| 341 | |
| 342 | const provider = datasources[0].provider |
| 343 | |
| 344 | const denylistsErrors = validateDmmfAgainstDenylists(prismaClientDmmf) |
| 345 | |
| 346 | if (denylistsErrors) { |
| 347 | let message = `${bold( |
| 348 | red('Error: '), |
| 349 | )}The schema at "${schemaPath}" contains reserved keywords.\n Rename the following items:` |
| 350 | |
| 351 | for (const error of denylistsErrors) { |
| 352 | message += '\n - ' + error.message |
| 353 | } |
| 354 | |
| 355 | message += `\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models` |
| 356 | |
| 357 | throw new DenylistError(message) |
| 358 | } |
| 359 | |
| 360 | await ensureDir(outputDir) |
no test coverage detected