| 305 | ReturnType<typeof getPrismaClient> extends new (optionsArg: PrismaClientOptions) => infer T ? T : never |
| 306 | |
| 307 | export function getPrismaClient(config: GetPrismaClientConfig) { |
| 308 | class PrismaClient { |
| 309 | _originalClient = this |
| 310 | _runtimeDataModel: RuntimeDataModel |
| 311 | _requestHandler: RequestHandler |
| 312 | _connectionPromise?: Promise<any> |
| 313 | _disconnectionPromise?: Promise<any> |
| 314 | _engineConfig: EngineConfig |
| 315 | _accelerateEngineConfig: AccelerateEngineConfig |
| 316 | _clientVersion: string |
| 317 | _errorFormat: ErrorFormat |
| 318 | _tracingHelper: TracingHelper |
| 319 | _previewFeatures: string[] |
| 320 | _activeProvider: string |
| 321 | _globalOmit?: GlobalOmitOptions |
| 322 | _extensions: MergedExtensionsList |
| 323 | /** |
| 324 | * @remarks This is used internally by Policy, do not rename or remove |
| 325 | */ |
| 326 | _engine: Engine |
| 327 | /** |
| 328 | * A fully constructed/applied Client that references the parent |
| 329 | * PrismaClient. This is used for Client extensions only. |
| 330 | */ |
| 331 | _appliedParent: PrismaClient |
| 332 | _createPrismaPromise = createPrismaPromiseFactory() |
| 333 | |
| 334 | constructor(optionsArg: PrismaClientOptions) { |
| 335 | if (!optionsArg) { |
| 336 | throw new PrismaClientInitializationError( |
| 337 | `\ |
| 338 | \`PrismaClient\` needs to be constructed with a non-empty, valid \`PrismaClientOptions\`: |
| 339 | |
| 340 | \`\`\` |
| 341 | new PrismaClient({ |
| 342 | ... |
| 343 | }) |
| 344 | \`\`\` |
| 345 | |
| 346 | or |
| 347 | |
| 348 | \`\`\` |
| 349 | constructor() { |
| 350 | super({ ... }); |
| 351 | } |
| 352 | \`\`\` |
| 353 | `, |
| 354 | clientVersion, |
| 355 | ) |
| 356 | } |
| 357 | config = optionsArg.__internal?.configOverride?.(config) ?? config |
| 358 | validatePrismaClientOptions(optionsArg, config) |
| 359 | |
| 360 | // prevents unhandled error events when users do not explicitly listen to them |
| 361 | const logEmitter = new EventEmitter().on('error', () => {}) as LogEmitter |
| 362 | |
| 363 | this._extensions = MergedExtensionsList.empty() |
| 364 | this._previewFeatures = config.previewFeatures |