@prisma/config 7.2.0 → 7.3.0-integration-prisma6-fix-cloudflare-engine.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +451 -25
  2. package/dist/index.js +383 -79
  3. package/package.json +3 -4
package/dist/index.d.ts CHANGED
@@ -1,3 +1,61 @@
1
+ import { Schema } from 'effect';
2
+
3
+ /**
4
+ * An interface that exposes some basic information about the
5
+ * adapter like its name and provider type.
6
+ */
7
+ declare interface AdapterInfo {
8
+ readonly provider: Provider;
9
+ readonly adapterName: (typeof officialPrismaAdapters)[number] | (string & {});
10
+ }
11
+
12
+ declare type ArgScalarType = 'string' | 'int' | 'bigint' | 'float' | 'decimal' | 'boolean' | 'enum' | 'uuid' | 'json' | 'datetime' | 'bytes' | 'unknown';
13
+
14
+ declare type ArgType = {
15
+ scalarType: ArgScalarType;
16
+ dbType?: string;
17
+ arity: Arity;
18
+ };
19
+
20
+ declare type Arity = 'scalar' | 'list';
21
+
22
+ declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
23
+
24
+ declare const ColumnTypeEnum: {
25
+ readonly Int32: 0;
26
+ readonly Int64: 1;
27
+ readonly Float: 2;
28
+ readonly Double: 3;
29
+ readonly Numeric: 4;
30
+ readonly Boolean: 5;
31
+ readonly Character: 6;
32
+ readonly Text: 7;
33
+ readonly Date: 8;
34
+ readonly Time: 9;
35
+ readonly DateTime: 10;
36
+ readonly Json: 11;
37
+ readonly Enum: 12;
38
+ readonly Bytes: 13;
39
+ readonly Set: 14;
40
+ readonly Uuid: 15;
41
+ readonly Int32Array: 64;
42
+ readonly Int64Array: 65;
43
+ readonly FloatArray: 66;
44
+ readonly DoubleArray: 67;
45
+ readonly NumericArray: 68;
46
+ readonly BooleanArray: 69;
47
+ readonly CharacterArray: 70;
48
+ readonly TextArray: 71;
49
+ readonly DateArray: 72;
50
+ readonly TimeArray: 73;
51
+ readonly DateTimeArray: 74;
52
+ readonly JsonArray: 75;
53
+ readonly EnumArray: 76;
54
+ readonly BytesArray: 77;
55
+ readonly UuidArray: 78;
56
+ readonly UnknownNumber: 128;
57
+ };
58
+
1
59
  export declare type ConfigDiagnostic = {
2
60
  _tag: 'log';
3
61
  value: (formatters: InjectFormatters) => () => void;
@@ -23,9 +81,10 @@ export declare type ConfigFromFile = {
23
81
  diagnostics: ConfigDiagnostic[];
24
82
  };
25
83
 
26
- export declare type Datasource = {
27
- url?: string;
28
- shadowDatabaseUrl?: string;
84
+ declare type ConnectionInfo = {
85
+ schemaName?: string;
86
+ maxBindValues?: number;
87
+ supportsRelationJoins: boolean;
29
88
  };
30
89
 
31
90
  /**
@@ -38,6 +97,17 @@ export declare function defaultTestConfig(): PrismaConfigInternal;
38
97
  */
39
98
  export declare function defineConfig(configInput: PrismaConfig): PrismaConfigInternal;
40
99
 
100
+ /**
101
+ * A generic driver adapter factory that allows the user to instantiate a
102
+ * driver adapter. The query and result types are specific to the adapter.
103
+ */
104
+ declare interface DriverAdapterFactory<Query, Result> extends AdapterInfo {
105
+ /**
106
+ * Instantiate a driver adapter.
107
+ */
108
+ connect(): Promise<Queryable<Query, Result>>;
109
+ }
110
+
41
111
  declare type EnumsConfigShape = {
42
112
  /**
43
113
  * List of enums that are externally managed.
@@ -47,15 +117,40 @@ declare type EnumsConfigShape = {
47
117
  external?: string[];
48
118
  };
49
119
 
50
- export declare function env(name: string): string;
120
+ export declare function env<Env extends Record<string, string | undefined>>(name: keyof Env & string): string;
121
+
122
+ declare type Error_2 = MappedError & {
123
+ originalCode?: string;
124
+ originalMessage?: string;
125
+ };
51
126
 
52
- export declare function env<Env>(name: EnvKey<Env> & string): string;
127
+ declare type ErrorCapturingFunction<T> = T extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<Result<ErrorCapturingInterface<R>>> : T extends (...args: infer A) => infer R ? (...args: A) => Result<ErrorCapturingInterface<R>> : T;
53
128
 
54
- declare type EnvKey<Env> = keyof {
55
- [K in keyof Env as Env[K] extends string | undefined ? K : never]: Env[K];
129
+ declare type ErrorCapturingInterface<T> = {
130
+ [K in keyof T]: ErrorCapturingFunction<T[K]>;
56
131
  };
57
132
 
133
+ declare interface ErrorCapturingSqlMigrationAwareDriverAdapterFactory extends ErrorCapturingInterface<SqlMigrationAwareDriverAdapterFactory> {
134
+ readonly errorRegistry: ErrorRegistry;
135
+ }
136
+
137
+ declare type ErrorRecord = {
138
+ error: unknown;
139
+ };
140
+
141
+ declare interface ErrorRegistry {
142
+ consumeError(id: number): ErrorRecord | undefined;
143
+ }
144
+
58
145
  declare type ExperimentalConfig = {
146
+ /**
147
+ * Enable experimental adapter support.
148
+ */
149
+ adapter?: boolean;
150
+ /**
151
+ * Enable experimental Prisma Studio features.
152
+ */
153
+ studio?: boolean;
59
154
  /**
60
155
  * Enable experimental external tables support.
61
156
  */
@@ -73,6 +168,8 @@ export declare type InjectFormatters = {
73
168
  link: (data: string) => string;
74
169
  };
75
170
 
171
+ declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SNAPSHOT' | 'SERIALIZABLE';
172
+
76
173
  /**
77
174
  * Load a Prisma config file from the given directory.
78
175
  * This function may fail, but it will never throw.
@@ -107,6 +204,130 @@ declare type LoadConfigFromFileInput = {
107
204
  configRoot?: string;
108
205
  };
109
206
 
207
+ /**
208
+ * User's Prisma configuration should live in `prisma.config.ts` instead of `package.json#prisma`.
209
+ * See: https://pris.ly/prisma-config.
210
+ *
211
+ * This function returns `null` if no `package.json` is found, or if the `prisma` property is not defined therein.
212
+ *
213
+ * TODO: remove in Prisma 7.
214
+ * @deprecated
215
+ */
216
+ export declare function loadConfigFromPackageJson(cwd?: string): Promise<{
217
+ config: PrismaConfigPackageJson;
218
+ loadedFromFile: string;
219
+ } | null>;
220
+
221
+ declare type MappedError = {
222
+ kind: 'GenericJs';
223
+ id: number;
224
+ } | {
225
+ kind: 'UnsupportedNativeDataType';
226
+ type: string;
227
+ } | {
228
+ kind: 'InvalidIsolationLevel';
229
+ level: string;
230
+ } | {
231
+ kind: 'LengthMismatch';
232
+ column?: string;
233
+ } | {
234
+ kind: 'UniqueConstraintViolation';
235
+ constraint?: {
236
+ fields: string[];
237
+ } | {
238
+ index: string;
239
+ } | {
240
+ foreignKey: {};
241
+ };
242
+ } | {
243
+ kind: 'NullConstraintViolation';
244
+ constraint?: {
245
+ fields: string[];
246
+ } | {
247
+ index: string;
248
+ } | {
249
+ foreignKey: {};
250
+ };
251
+ } | {
252
+ kind: 'ForeignKeyConstraintViolation';
253
+ constraint?: {
254
+ fields: string[];
255
+ } | {
256
+ index: string;
257
+ } | {
258
+ foreignKey: {};
259
+ };
260
+ } | {
261
+ kind: 'DatabaseNotReachable';
262
+ host?: string;
263
+ port?: number;
264
+ } | {
265
+ kind: 'DatabaseDoesNotExist';
266
+ db?: string;
267
+ } | {
268
+ kind: 'DatabaseAlreadyExists';
269
+ db?: string;
270
+ } | {
271
+ kind: 'DatabaseAccessDenied';
272
+ db?: string;
273
+ } | {
274
+ kind: 'ConnectionClosed';
275
+ } | {
276
+ kind: 'TlsConnectionError';
277
+ reason: string;
278
+ } | {
279
+ kind: 'AuthenticationFailed';
280
+ user?: string;
281
+ } | {
282
+ kind: 'TransactionWriteConflict';
283
+ } | {
284
+ kind: 'TableDoesNotExist';
285
+ table?: string;
286
+ } | {
287
+ kind: 'ColumnNotFound';
288
+ column?: string;
289
+ } | {
290
+ kind: 'TooManyConnections';
291
+ cause: string;
292
+ } | {
293
+ kind: 'ValueOutOfRange';
294
+ cause: string;
295
+ } | {
296
+ kind: 'MissingFullTextSearchIndex';
297
+ } | {
298
+ kind: 'SocketTimeout';
299
+ } | {
300
+ kind: 'InconsistentColumnData';
301
+ cause: string;
302
+ } | {
303
+ kind: 'TransactionAlreadyClosed';
304
+ cause: string;
305
+ } | {
306
+ kind: 'postgres';
307
+ code: string;
308
+ severity: string;
309
+ message: string;
310
+ detail: string | undefined;
311
+ column: string | undefined;
312
+ hint: string | undefined;
313
+ } | {
314
+ kind: 'mysql';
315
+ code: number;
316
+ message: string;
317
+ state: string;
318
+ } | {
319
+ kind: 'sqlite';
320
+ /**
321
+ * Sqlite extended error code: https://www.sqlite.org/rescode.html
322
+ */
323
+ extendedCode: number;
324
+ message: string;
325
+ } | {
326
+ kind: 'mssql';
327
+ code: number;
328
+ message: string;
329
+ };
330
+
110
331
  declare type MigrationsConfigShape = {
111
332
  /**
112
333
  * The path to the directory where Prisma should store migration files, and look for them.
@@ -123,25 +344,90 @@ declare type MigrationsConfigShape = {
123
344
  seed?: string;
124
345
  };
125
346
 
347
+ declare const officialPrismaAdapters: readonly ["@prisma/adapter-planetscale", "@prisma/adapter-neon", "@prisma/adapter-libsql", "@prisma/adapter-better-sqlite3", "@prisma/adapter-d1", "@prisma/adapter-pg", "@prisma/adapter-mssql", "@prisma/adapter-mariadb"];
348
+
126
349
  declare const PRISMA_CONFIG_INTERNAL_BRAND: unique symbol;
127
350
 
128
351
  /**
129
352
  * The configuration for the Prisma Development Kit, before it is passed to the `defineConfig` function.
130
353
  * Thanks to the branding, this type is opaque and cannot be constructed directly.
131
354
  */
132
- export declare type PrismaConfig = {
355
+ export declare type PrismaConfig = PrismaConfigUnconditional & SchemaEngineConfig;
356
+
357
+ export declare class PrismaConfigEnvError extends Error {
358
+ constructor(name: string);
359
+ }
360
+
361
+ /**
362
+ * The configuration for the Prisma Development Kit, after it has been parsed and processed
363
+ * by the `defineConfig` function.
364
+ * Thanks to the branding, this type is opaque and cannot be constructed directly.
365
+ */
366
+ export declare type PrismaConfigInternal = _PrismaConfigInternal & {
367
+ __brand: typeof PRISMA_CONFIG_INTERNAL_BRAND;
368
+ };
369
+
370
+ declare type _PrismaConfigInternal = Omit<PrismaConfig, 'engine' | 'datasource' | 'adapter'> & {
371
+ loadedFromFile: string | null;
133
372
  /**
134
- * Experimental feature gates. Each experimental feature must be explicitly enabled.
373
+ * The deprecated Prisma configuration from `package.json#prisma`.
374
+ * This is set to `null` if no `package.json#prisma` config was found.
375
+ * The configuration read from the Prisma config file (e.g., `prisma.config.ts`) takes precedence over
376
+ * this `package.json#prisma` config.
377
+ * @deprecated
135
378
  */
136
- experimental?: Simplify<ExperimentalConfig>;
379
+ deprecatedPackageJson: {
380
+ /**
381
+ * The Prisma configuration from `package.json#prisma`.
382
+ * @deprecated
383
+ */
384
+ config: PrismaConfigPackageJson;
385
+ /**
386
+ * The path from where the `package.json` config was loaded.
387
+ * @deprecated
388
+ */
389
+ loadedFromFile: string;
390
+ } | null;
391
+ } & ({
392
+ engine: 'classic';
393
+ datasource: {
394
+ url: string;
395
+ shadowDatabaseUrl?: string;
396
+ };
397
+ } | {
398
+ engine: 'js';
399
+ adapter: () => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>;
400
+ } | {
401
+ engine?: never;
402
+ });
403
+
404
+ /**
405
+ * Example:
406
+ * ```json
407
+ * {
408
+ * "schema": "./prisma/schema.prisma",
409
+ * "seed": "tsx ./prisma/seed.ts"
410
+ * }
411
+ * ```
412
+ */
413
+ declare type PrismaConfigPackageJson = {
414
+ schema?: string;
415
+ seed?: string;
416
+ };
417
+
418
+ declare type PrismaConfigUnconditional = {
137
419
  /**
138
- * The datasource configuration. Optional for most cases, but required for migration / introspection commands.
420
+ * Experimental feature gates. Each experimental feature must be explicitly enabled.
139
421
  */
140
- datasource?: Simplify<Datasource>;
422
+ experimental?: Simplify<ExperimentalConfig>;
141
423
  /**
142
424
  * The path to the schema file, or path to a folder that shall be recursively searched for *.prisma files.
143
425
  */
144
426
  schema?: string;
427
+ /**
428
+ * The configuration for Prisma Studio.
429
+ */
430
+ studio?: Simplify<PrismaStudioConfigShape>;
145
431
  /**
146
432
  * Configuration for Prisma migrations.
147
433
  */
@@ -164,27 +450,86 @@ export declare type PrismaConfig = {
164
450
  typedSql?: Simplify<TypedSqlConfigShape>;
165
451
  };
166
452
 
167
- export declare class PrismaConfigEnvError extends Error {
168
- constructor(name: string);
453
+ declare type PrismaStudioConfigShape = {
454
+ adapter: () => Promise<SqlMigrationAwareDriverAdapterFactory>;
455
+ };
456
+
457
+ declare type Provider = 'mysql' | 'postgres' | 'sqlite' | 'sqlserver';
458
+
459
+ declare interface Queryable<Query, Result> extends AdapterInfo {
460
+ /**
461
+ * Execute a query and return its result.
462
+ */
463
+ queryRaw(params: Query): Promise<Result>;
464
+ /**
465
+ * Execute a query and return the number of affected rows.
466
+ */
467
+ executeRaw(params: Query): Promise<number>;
169
468
  }
170
469
 
171
- /**
172
- * The configuration for the Prisma Development Kit, after it has been parsed and processed
173
- * by the `defineConfig` function.
174
- * Thanks to the branding, this type is opaque and cannot be constructed directly.
175
- */
176
- export declare type PrismaConfigInternal = _PrismaConfigInternal & {
177
- __brand: typeof PRISMA_CONFIG_INTERNAL_BRAND;
470
+ declare type Result<T> = {
471
+ map<U>(fn: (value: T) => U): Result<U>;
472
+ flatMap<U>(fn: (value: T) => Result<U>): Result<U>;
473
+ } & ({
474
+ readonly ok: true;
475
+ readonly value: T;
476
+ } | {
477
+ readonly ok: false;
478
+ readonly error: Error_2;
479
+ });
480
+
481
+ declare type SchemaEngineConfig = SchemaEngineConfigJs | SchemaEngineConfigClassic | SchemaEngineConfigAbsent;
482
+
483
+ declare type SchemaEngineConfigAbsent = {
484
+ engine?: never;
178
485
  };
179
486
 
180
- declare type _PrismaConfigInternal = PrismaConfig & {
181
- loadedFromFile: string | null;
487
+ declare type SchemaEngineConfigClassic = {
488
+ /**
489
+ * Uses the "old classic" Schema Engine binary
490
+ */
491
+ engine: 'classic';
492
+ /**
493
+ * The database connection configuration, which overwrites the `datasource` block's `url`-like attributes in the Prisma schema file.
494
+ */
495
+ datasource: SchemaEngineConfigClassicDatasource;
182
496
  };
183
497
 
184
- export declare type SchemaEngineConfigInternal = {
185
- datasource?: Datasource;
498
+ export declare type SchemaEngineConfigClassicDatasource = {
499
+ url: string;
500
+ directUrl?: string;
501
+ shadowDatabaseUrl?: string;
186
502
  };
187
503
 
504
+ export declare type SchemaEngineConfigInternal = SchemaEngineConfigJsInternal | SchemaEngineConfigClassic | SchemaEngineConfigAbsent;
505
+
506
+ declare type SchemaEngineConfigJs = {
507
+ /**
508
+ * Uses the new, unstable JavaScript based Schema Engine.
509
+ */
510
+ engine: 'js';
511
+ /**
512
+ * The function that instantiates the driver adapter to use for the JavaScript based Schema Engine.
513
+ */
514
+ adapter: () => Promise<SqlMigrationAwareDriverAdapterFactory>;
515
+ };
516
+
517
+ declare type SchemaEngineConfigJsInternal = {
518
+ /**
519
+ * Uses the new, unstable JavaScript based Schema Engine.
520
+ */
521
+ engine: 'js';
522
+ /**
523
+ * The function that instantiates the driver adapter to use for the JavaScript based Schema Engine.
524
+ */
525
+ adapter: () => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>;
526
+ };
527
+
528
+ declare const SchemaEngineConfigJsInternal: Schema.Struct<{
529
+ engine: Schema.Literal<["js"]>;
530
+ adapter: Schema.declare<() => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>, () => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>, readonly [], never>;
531
+ }>;
532
+
188
533
  /**
189
534
  * Simplifies the type signature of a type.
190
535
  * Re-exported from `effect/Types`.
@@ -198,6 +543,68 @@ declare type Simplify<A> = {
198
543
  [K in keyof A]: A[K];
199
544
  } extends infer B ? B : never;
200
545
 
546
+ declare interface SqlDriverAdapter extends SqlQueryable {
547
+ /**
548
+ * Execute multiple SQL statements separated by semicolon.
549
+ */
550
+ executeScript(script: string): Promise<void>;
551
+ /**
552
+ * Start new transaction.
553
+ */
554
+ startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
555
+ /**
556
+ * Optional method that returns extra connection info
557
+ */
558
+ getConnectionInfo?(): ConnectionInfo;
559
+ /**
560
+ * Dispose of the connection and release any resources.
561
+ */
562
+ dispose(): Promise<void>;
563
+ }
564
+
565
+ declare interface SqlDriverAdapterFactory extends DriverAdapterFactory<SqlQuery, SqlResultSet> {
566
+ connect(): Promise<SqlDriverAdapter>;
567
+ }
568
+
569
+ /**
570
+ * An SQL migration adapter that is aware of the notion of a shadow database
571
+ * and can create a connection to it.
572
+ */
573
+ declare interface SqlMigrationAwareDriverAdapterFactory extends SqlDriverAdapterFactory {
574
+ connectToShadowDb(): Promise<SqlDriverAdapter>;
575
+ }
576
+
577
+ declare type SqlQuery = {
578
+ sql: string;
579
+ args: Array<unknown>;
580
+ argTypes: Array<ArgType>;
581
+ };
582
+
583
+ declare interface SqlQueryable extends Queryable<SqlQuery, SqlResultSet> {
584
+ }
585
+
586
+ declare interface SqlResultSet {
587
+ /**
588
+ * List of column types appearing in a database query, in the same order as `columnNames`.
589
+ * They are used within the Query Engine to convert values from JS to Quaint values.
590
+ */
591
+ columnTypes: Array<ColumnType>;
592
+ /**
593
+ * List of column names appearing in a database query, in the same order as `columnTypes`.
594
+ */
595
+ columnNames: Array<string>;
596
+ /**
597
+ * List of rows retrieved from a database query.
598
+ * Each row is a list of values, whose length matches `columnNames` and `columnTypes`.
599
+ */
600
+ rows: Array<Array<unknown>>;
601
+ /**
602
+ * The last ID of an `INSERT` statement, if any.
603
+ * This is required for `AUTO_INCREMENT` columns in databases based on MySQL and SQLite.
604
+ */
605
+ lastInsertId?: string;
606
+ }
607
+
201
608
  declare type TablesConfigShape = {
202
609
  /**
203
610
  * List of tables that are externally managed.
@@ -207,6 +614,25 @@ declare type TablesConfigShape = {
207
614
  external?: string[];
208
615
  };
209
616
 
617
+ declare interface Transaction extends AdapterInfo, SqlQueryable {
618
+ /**
619
+ * Transaction options.
620
+ */
621
+ readonly options: TransactionOptions;
622
+ /**
623
+ * Commit the transaction.
624
+ */
625
+ commit(): Promise<void>;
626
+ /**
627
+ * Roll back the transaction.
628
+ */
629
+ rollback(): Promise<void>;
630
+ }
631
+
632
+ declare type TransactionOptions = {
633
+ usePhantomQuery: boolean;
634
+ };
635
+
210
636
  declare type TypedSqlConfigShape = {
211
637
  /**
212
638
  * The path to the directory where Prisma should look for the `typedSql` queries, where *.sql files will be loaded.
package/dist/index.js CHANGED
@@ -34,7 +34,8 @@ __export(index_exports, {
34
34
  defaultTestConfig: () => defaultTestConfig,
35
35
  defineConfig: () => defineConfig,
36
36
  env: () => env,
37
- loadConfigFromFile: () => loadConfigFromFile
37
+ loadConfigFromFile: () => loadConfigFromFile,
38
+ loadConfigFromPackageJson: () => loadConfigFromPackageJson
38
39
  });
39
40
  module.exports = __toCommonJS(index_exports);
40
41
 
@@ -224,8 +225,140 @@ function safeStringify(value, indent = 2) {
224
225
  );
225
226
  }
226
227
 
228
+ // ../driver-adapter-utils/dist/index.mjs
229
+ function isDriverAdapterError(error) {
230
+ return error["name"] === "DriverAdapterError" && typeof error["cause"] === "object";
231
+ }
232
+ function ok(value) {
233
+ return {
234
+ ok: true,
235
+ value,
236
+ map(fn) {
237
+ return ok(fn(value));
238
+ },
239
+ flatMap(fn) {
240
+ return fn(value);
241
+ }
242
+ };
243
+ }
244
+ function err(error) {
245
+ return {
246
+ ok: false,
247
+ error,
248
+ map() {
249
+ return err(error);
250
+ },
251
+ flatMap() {
252
+ return err(error);
253
+ }
254
+ };
255
+ }
256
+ var debug = Debug("driver-adapter-utils");
257
+ var ErrorRegistryInternal = class {
258
+ registeredErrors = [];
259
+ consumeError(id) {
260
+ return this.registeredErrors[id];
261
+ }
262
+ registerNewError(error) {
263
+ let i = 0;
264
+ while (this.registeredErrors[i] !== void 0) {
265
+ i++;
266
+ }
267
+ this.registeredErrors[i] = { error };
268
+ return i;
269
+ }
270
+ };
271
+ function copySymbolsFromSource(source, target) {
272
+ const symbols = Object.getOwnPropertySymbols(source);
273
+ const symbolObject = Object.fromEntries(symbols.map((symbol) => [symbol, true]));
274
+ Object.assign(target, symbolObject);
275
+ }
276
+ var bindMigrationAwareSqlAdapterFactory = (adapterFactory) => {
277
+ const errorRegistry = new ErrorRegistryInternal();
278
+ const boundFactory = {
279
+ adapterName: adapterFactory.adapterName,
280
+ provider: adapterFactory.provider,
281
+ errorRegistry,
282
+ connect: async (...args) => {
283
+ const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args);
284
+ return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
285
+ },
286
+ connectToShadowDb: async (...args) => {
287
+ const ctx = await wrapAsync(errorRegistry, adapterFactory.connectToShadowDb.bind(adapterFactory))(...args);
288
+ return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
289
+ }
290
+ };
291
+ copySymbolsFromSource(adapterFactory, boundFactory);
292
+ return boundFactory;
293
+ };
294
+ var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal()) => {
295
+ const boundAdapter = {
296
+ adapterName: adapter.adapterName,
297
+ errorRegistry,
298
+ queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)),
299
+ executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)),
300
+ executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
301
+ dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
302
+ provider: adapter.provider,
303
+ startTransaction: async (...args) => {
304
+ const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args);
305
+ return ctx.map((ctx2) => bindTransaction(errorRegistry, ctx2));
306
+ }
307
+ };
308
+ if (adapter.getConnectionInfo) {
309
+ boundAdapter.getConnectionInfo = wrapSync(errorRegistry, adapter.getConnectionInfo.bind(adapter));
310
+ }
311
+ return boundAdapter;
312
+ };
313
+ var bindTransaction = (errorRegistry, transaction) => {
314
+ return {
315
+ adapterName: transaction.adapterName,
316
+ provider: transaction.provider,
317
+ options: transaction.options,
318
+ queryRaw: wrapAsync(errorRegistry, transaction.queryRaw.bind(transaction)),
319
+ executeRaw: wrapAsync(errorRegistry, transaction.executeRaw.bind(transaction)),
320
+ commit: wrapAsync(errorRegistry, transaction.commit.bind(transaction)),
321
+ rollback: wrapAsync(errorRegistry, transaction.rollback.bind(transaction))
322
+ };
323
+ };
324
+ function wrapAsync(registry, fn) {
325
+ return async (...args) => {
326
+ try {
327
+ return ok(await fn(...args));
328
+ } catch (error) {
329
+ debug("[error@wrapAsync]", error);
330
+ if (isDriverAdapterError(error)) {
331
+ return err(error.cause);
332
+ }
333
+ const id = registry.registerNewError(error);
334
+ return err({ kind: "GenericJs", id });
335
+ }
336
+ };
337
+ }
338
+ function wrapSync(registry, fn) {
339
+ return (...args) => {
340
+ try {
341
+ return ok(fn(...args));
342
+ } catch (error) {
343
+ debug("[error@wrapSync]", error);
344
+ if (isDriverAdapterError(error)) {
345
+ return err(error.cause);
346
+ }
347
+ const id = registry.registerNewError(error);
348
+ return err({ kind: "GenericJs", id });
349
+ }
350
+ };
351
+ }
352
+ var mockAdapterErrors = {
353
+ queryRaw: new Error("Not implemented: queryRaw"),
354
+ executeRaw: new Error("Not implemented: executeRaw"),
355
+ startTransaction: new Error("Not implemented: startTransaction"),
356
+ executeScript: new Error("Not implemented: executeScript"),
357
+ dispose: new Error("Not implemented: dispose")
358
+ };
359
+
227
360
  // src/PrismaConfig.ts
228
- var import_effect2 = require("effect");
361
+ var import_effect3 = require("effect");
229
362
  var import_Function = require("effect/Function");
230
363
 
231
364
  // src/defineConfig.ts
@@ -234,13 +367,22 @@ var import_effect = require("effect");
234
367
  // src/defaultConfig.ts
235
368
  function defaultConfig() {
236
369
  return makePrismaConfigInternal({
237
- loadedFromFile: null
370
+ loadedFromFile: null,
371
+ deprecatedPackageJson: null
238
372
  });
239
373
  }
240
374
 
241
375
  // src/defineConfig.ts
242
376
  function validateExperimentalFeatures(config) {
243
377
  const experimental = config.experimental || {};
378
+ if (config.engine === "js" && !experimental.adapter) {
379
+ return import_effect.Either.left(
380
+ new Error('The `engine === "js"` configuration requires `experimental.adapter` to be set to `true`.')
381
+ );
382
+ }
383
+ if (config.studio && !experimental.studio) {
384
+ return import_effect.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
385
+ }
244
386
  if (config.tables?.external && !experimental.externalTables) {
245
387
  return import_effect.Either.left(
246
388
  new Error("The `tables.external` configuration requires `experimental.externalTables` to be set to `true`.")
@@ -260,17 +402,18 @@ function validateExperimentalFeatures(config) {
260
402
  }
261
403
  return import_effect.Either.right(config);
262
404
  }
263
- var debug = Debug("prisma:config:defineConfig");
405
+ var debug2 = Debug("prisma:config:defineConfig");
264
406
  function defineConfig(configInput) {
265
407
  const validationResult = validateExperimentalFeatures(configInput);
266
408
  if (validationResult._tag === "Left") {
267
409
  throw validationResult.left;
268
410
  }
269
411
  const config = defaultConfig();
270
- debug("[default]: %o", config);
412
+ debug2("[default]: %o", config);
271
413
  defineExperimentalConfig(config, configInput);
272
414
  defineSchemaConfig(config, configInput);
273
- defineDatasource(config, configInput);
415
+ defineEngineConfig(config, configInput);
416
+ defineStudioConfig(config, configInput);
274
417
  defineMigrationsConfig(config, configInput);
275
418
  defineTablesConfig(config, configInput);
276
419
  defineEnumsConfig(config, configInput);
@@ -284,172 +427,306 @@ function defineExperimentalConfig(config, configInput) {
284
427
  return;
285
428
  }
286
429
  config.experimental = configInput.experimental;
287
- debug("[config.experimental]: %o", config.experimental);
430
+ debug2("[config.experimental]: %o", config.experimental);
288
431
  }
289
432
  function defineSchemaConfig(config, configInput) {
290
433
  if (!configInput.schema) {
291
434
  return;
292
435
  }
293
436
  config.schema = configInput.schema;
294
- debug("[config.schema]: %o", config.schema);
437
+ debug2("[config.schema]: %o", config.schema);
295
438
  }
296
439
  function defineMigrationsConfig(config, configInput) {
297
440
  if (!configInput.migrations) {
298
441
  return;
299
442
  }
300
443
  config.migrations = configInput.migrations;
301
- debug("[config.migrations]: %o", config.migrations);
444
+ debug2("[config.migrations]: %o", config.migrations);
302
445
  }
303
446
  function defineTypedSqlConfig(config, configInput) {
304
447
  if (!configInput.typedSql) {
305
448
  return;
306
449
  }
307
450
  config.typedSql = configInput.typedSql;
308
- debug("[config.typedSql]: %o", config.typedSql);
451
+ debug2("[config.typedSql]: %o", config.typedSql);
309
452
  }
310
453
  function defineViewsConfig(config, configInput) {
311
454
  if (!configInput.views) {
312
455
  return;
313
456
  }
314
457
  config.views = configInput.views;
315
- debug("[config.views]: %o", config.views);
458
+ debug2("[config.views]: %o", config.views);
316
459
  }
317
460
  function defineTablesConfig(config, configInput) {
318
461
  if (!configInput.tables) {
319
462
  return;
320
463
  }
321
464
  config.tables = configInput.tables;
322
- debug("[config.tables]: %o", config.tables);
465
+ debug2("[config.tables]: %o", config.tables);
323
466
  }
324
467
  function defineEnumsConfig(config, configInput) {
325
468
  if (!configInput.enums) {
326
469
  return;
327
470
  }
328
471
  config.enums = configInput.enums;
329
- debug("[config.enums]: %o", config.enums);
472
+ debug2("[config.enums]: %o", config.enums);
330
473
  }
331
- function defineDatasource(config, configInput) {
332
- const { datasource } = configInput;
333
- Object.assign(config, { datasource });
334
- debug("[config.datasource]: %o", datasource);
474
+ function defineStudioConfig(config, configInput) {
475
+ if (!configInput.studio?.adapter) {
476
+ return;
477
+ }
478
+ const { adapter: getAdapterFactory } = configInput.studio;
479
+ config.studio = {
480
+ adapter: async () => {
481
+ const adapterFactory = await getAdapterFactory();
482
+ debug2("[config.studio.adapter]: %o", adapterFactory.adapterName);
483
+ return adapterFactory;
484
+ }
485
+ };
486
+ debug2("[config.studio]: %o", config.studio);
487
+ }
488
+ function defineEngineConfig(config, configInput) {
489
+ if (configInput.engine === void 0) {
490
+ return;
491
+ } else if (configInput.engine === "js") {
492
+ const { engine, adapter: getAdapterFactory } = configInput;
493
+ const adapter = async () => {
494
+ const adapterFactory = await getAdapterFactory();
495
+ debug2("[config.adapter]: %o", adapterFactory.adapterName);
496
+ return bindMigrationAwareSqlAdapterFactory(adapterFactory);
497
+ };
498
+ Object.assign(config, { engine, adapter });
499
+ debug2("[config.engine]: %o", engine);
500
+ debug2("[config.adapter]: %o", adapter);
501
+ } else if (configInput.engine === "classic") {
502
+ const { engine, datasource } = configInput;
503
+ Object.assign(config, { engine, datasource });
504
+ debug2("[config.engine]: %o", engine);
505
+ debug2("[config.datasource]: %o", datasource);
506
+ }
335
507
  }
336
508
  function defineExtensionsConfig(config, configInput) {
337
509
  if (!configInput["extensions"]) {
338
510
  return;
339
511
  }
340
512
  config["extensions"] = configInput["extensions"];
341
- debug("[config.extensions]: %o", config["extensions"]);
513
+ debug2("[config.extensions]: %o", config["extensions"]);
514
+ }
515
+
516
+ // src/loadConfigFromPackageJson.ts
517
+ var import_promises = require("node:fs/promises");
518
+ var import_node_process = __toESM(require("node:process"));
519
+ var import_effect2 = require("effect");
520
+ var import_package = require("empathic/package");
521
+ var PrismaConfigPackageJsonShape = import_effect2.Schema.Struct({
522
+ schema: import_effect2.Schema.optional(import_effect2.Schema.String),
523
+ seed: import_effect2.Schema.optional(import_effect2.Schema.NonEmptyString)
524
+ });
525
+ async function loadConfigFromPackageJson(cwd = import_node_process.default.cwd()) {
526
+ const pkgPath = (0, import_package.up)({ cwd });
527
+ if (pkgPath === void 0) {
528
+ return null;
529
+ }
530
+ const pkgJson = await (0, import_promises.readFile)(pkgPath, { encoding: "utf-8" }).then((p) => JSON.parse(p));
531
+ const deprecatedConfig = pkgJson["prisma"];
532
+ if (deprecatedConfig === void 0) {
533
+ return null;
534
+ }
535
+ if (Object.keys(deprecatedConfig).length === 1 && deprecatedConfig["prismaCommit"] !== void 0) {
536
+ return null;
537
+ }
538
+ return {
539
+ config: deprecatedConfig,
540
+ loadedFromFile: pkgPath
541
+ };
342
542
  }
343
543
 
344
544
  // src/PrismaConfig.ts
345
- var debug2 = Debug("prisma:config:PrismaConfig");
346
- var DatasourceShape = import_effect2.Schema.Struct({
347
- url: import_effect2.Schema.optional(import_effect2.Schema.String),
348
- shadowDatabaseUrl: import_effect2.Schema.optional(import_effect2.Schema.String)
545
+ var debug3 = Debug("prisma:config:PrismaConfig");
546
+ var SqlMigrationAwareDriverAdapterFactoryShape = import_effect3.Schema.declare(
547
+ (input) => {
548
+ return typeof input === "function";
549
+ },
550
+ {
551
+ identifier: "SqlMigrationAwareDriverAdapterFactory",
552
+ encode: import_effect3.identity,
553
+ decode: import_effect3.identity
554
+ }
555
+ );
556
+ var ErrorCapturingSqlMigrationAwareDriverAdapterFactoryShape = import_effect3.Schema.declare(
557
+ (input) => {
558
+ return typeof input === "function";
559
+ },
560
+ {
561
+ identifier: "ErrorCapturingSqlMigrationAwareDriverAdapterFactory",
562
+ encode: import_effect3.identity,
563
+ decode: import_effect3.identity
564
+ }
565
+ );
566
+ var SchemaEngineConfigClassicShape = import_effect3.Schema.Struct({
567
+ engine: import_effect3.Schema.Literal("classic"),
568
+ datasource: import_effect3.Schema.Struct({
569
+ url: import_effect3.Schema.String,
570
+ directUrl: import_effect3.Schema.optional(import_effect3.Schema.String),
571
+ shadowDatabaseUrl: import_effect3.Schema.optional(import_effect3.Schema.String)
572
+ })
573
+ });
574
+ var SchemaEngineConfigJsShape = import_effect3.Schema.Struct({
575
+ engine: import_effect3.Schema.Literal("js"),
576
+ adapter: SqlMigrationAwareDriverAdapterFactoryShape
349
577
  });
350
- var ExperimentalConfigShape = import_effect2.Schema.Struct({
351
- externalTables: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
352
- extensions: import_effect2.Schema.optional(import_effect2.Schema.Boolean)
578
+ var SchemaEngineConfigAbsentShape = import_effect3.Schema.Struct({
579
+ engine: import_effect3.Schema.optional(import_effect3.Schema.Never)
580
+ });
581
+ var SchemaEngineConfigShape = import_effect3.Schema.Union(
582
+ SchemaEngineConfigClassicShape,
583
+ SchemaEngineConfigJsShape,
584
+ SchemaEngineConfigAbsentShape
585
+ );
586
+ var SchemaEngineConfigJsInternal = import_effect3.Schema.Struct({
587
+ engine: import_effect3.Schema.Literal("js"),
588
+ adapter: ErrorCapturingSqlMigrationAwareDriverAdapterFactoryShape
589
+ });
590
+ var SchemaEngineConfigInternal = import_effect3.Schema.Union(
591
+ SchemaEngineConfigClassicShape,
592
+ SchemaEngineConfigJsInternal,
593
+ SchemaEngineConfigAbsentShape
594
+ );
595
+ var ExperimentalConfigShape = import_effect3.Schema.Struct({
596
+ adapter: import_effect3.Schema.optional(import_effect3.Schema.Boolean),
597
+ studio: import_effect3.Schema.optional(import_effect3.Schema.Boolean),
598
+ externalTables: import_effect3.Schema.optional(import_effect3.Schema.Boolean),
599
+ extensions: import_effect3.Schema.optional(import_effect3.Schema.Boolean)
353
600
  });
354
601
  if (false) {
355
602
  __testExperimentalConfigShapeValueA;
356
603
  __testExperimentalConfigShapeValueB;
357
604
  }
358
- var MigrationsConfigShape = import_effect2.Schema.Struct({
359
- path: import_effect2.Schema.optional(import_effect2.Schema.String),
360
- initShadowDb: import_effect2.Schema.optional(import_effect2.Schema.String),
361
- seed: import_effect2.Schema.optional(import_effect2.Schema.NonEmptyString)
605
+ var MigrationsConfigShape = import_effect3.Schema.Struct({
606
+ path: import_effect3.Schema.optional(import_effect3.Schema.String),
607
+ initShadowDb: import_effect3.Schema.optional(import_effect3.Schema.String),
608
+ seed: import_effect3.Schema.optional(import_effect3.Schema.NonEmptyString)
362
609
  });
363
610
  if (false) {
364
611
  __testMigrationsConfigShapeValueA;
365
612
  __testMigrationsConfigShapeValueB;
366
613
  }
367
- var TablesConfigShape = import_effect2.Schema.Struct({
368
- external: import_effect2.Schema.optional(import_effect2.Schema.mutable(import_effect2.Schema.Array(import_effect2.Schema.String)))
614
+ var TablesConfigShape = import_effect3.Schema.Struct({
615
+ external: import_effect3.Schema.optional(import_effect3.Schema.mutable(import_effect3.Schema.Array(import_effect3.Schema.String)))
369
616
  });
370
617
  if (false) {
371
618
  __testTablesConfigShapeValueA;
372
619
  __testTablesConfigShapeValueB;
373
620
  }
374
- var EnumsConfigShape = import_effect2.Schema.Struct({
375
- external: import_effect2.Schema.optional(import_effect2.Schema.mutable(import_effect2.Schema.Array(import_effect2.Schema.String)))
621
+ var EnumsConfigShape = import_effect3.Schema.Struct({
622
+ external: import_effect3.Schema.optional(import_effect3.Schema.mutable(import_effect3.Schema.Array(import_effect3.Schema.String)))
376
623
  });
377
624
  if (false) {
378
625
  __testEnumsConfigShapeValueA;
379
626
  __testEnumsConfigShapeValueB;
380
627
  }
381
- var ViewsConfigShape = import_effect2.Schema.Struct({
382
- path: import_effect2.Schema.optional(import_effect2.Schema.String)
628
+ var ViewsConfigShape = import_effect3.Schema.Struct({
629
+ path: import_effect3.Schema.optional(import_effect3.Schema.String)
383
630
  });
384
631
  if (false) {
385
632
  __testViewsConfigShapeValueA;
386
633
  __testViewsConfigShapeValueB;
387
634
  }
388
- var TypedSqlConfigShape = import_effect2.Schema.Struct({
389
- path: import_effect2.Schema.optional(import_effect2.Schema.String)
635
+ var TypedSqlConfigShape = import_effect3.Schema.Struct({
636
+ path: import_effect3.Schema.optional(import_effect3.Schema.String)
390
637
  });
391
638
  if (false) {
392
639
  __testTypedSqlConfigShapeValueA;
393
640
  __testTypedSqlConfigShapeValueB;
394
641
  }
642
+ var PrismaStudioConfigShape = import_effect3.Schema.Struct({
643
+ /**
644
+ * Instantiates the Prisma driver adapter to use for Prisma Studio.
645
+ */
646
+ adapter: SqlMigrationAwareDriverAdapterFactoryShape
647
+ });
648
+ if (false) {
649
+ __testPrismaStudioConfigShapeValueA;
650
+ __testPrismaStudioConfigShapeValueB;
651
+ }
395
652
  if (false) {
396
653
  __testPrismaConfig;
397
654
  __testPrismaConfigInternal;
398
655
  }
399
- var PrismaConfigShape = import_effect2.Schema.Struct({
400
- experimental: import_effect2.Schema.optional(ExperimentalConfigShape),
401
- datasource: import_effect2.Schema.optional(DatasourceShape),
402
- schema: import_effect2.Schema.optional(import_effect2.Schema.String),
403
- migrations: import_effect2.Schema.optional(MigrationsConfigShape),
404
- tables: import_effect2.Schema.optional(TablesConfigShape),
405
- enums: import_effect2.Schema.optional(EnumsConfigShape),
406
- views: import_effect2.Schema.optional(ViewsConfigShape),
407
- typedSql: import_effect2.Schema.optional(TypedSqlConfigShape),
408
- extensions: import_effect2.Schema.optional(import_effect2.Schema.Any)
656
+ var PrismaConfigUnconditionalShape = import_effect3.Schema.Struct({
657
+ experimental: import_effect3.Schema.optional(ExperimentalConfigShape),
658
+ schema: import_effect3.Schema.optional(import_effect3.Schema.String),
659
+ studio: import_effect3.Schema.optional(PrismaStudioConfigShape),
660
+ migrations: import_effect3.Schema.optional(MigrationsConfigShape),
661
+ tables: import_effect3.Schema.optional(TablesConfigShape),
662
+ enums: import_effect3.Schema.optional(EnumsConfigShape),
663
+ views: import_effect3.Schema.optional(ViewsConfigShape),
664
+ typedSql: import_effect3.Schema.optional(TypedSqlConfigShape),
665
+ extensions: import_effect3.Schema.optional(import_effect3.Schema.Any)
409
666
  });
667
+ var PrismaConfigShape = import_effect3.Schema.extend(SchemaEngineConfigShape, PrismaConfigUnconditionalShape);
410
668
  if (false) {
411
669
  __testPrismaConfigValueA;
412
670
  __testPrismaConfigValueB;
413
671
  }
414
672
  function validateExperimentalFeatures2(config) {
415
673
  const experimental = config.experimental || {};
674
+ if (config.engine === "js" && !experimental.adapter) {
675
+ return import_effect3.Either.left(
676
+ new Error("The `engine === 'js'` configuration requires `experimental.adapter` to be set to `true`.")
677
+ );
678
+ }
679
+ if (config.studio && !experimental.studio) {
680
+ return import_effect3.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
681
+ }
416
682
  if (config.tables?.external && !experimental.externalTables) {
417
- return import_effect2.Either.left(
683
+ return import_effect3.Either.left(
418
684
  new Error("The `tables.external` configuration requires `experimental.externalTables` to be set to `true`.")
419
685
  );
420
686
  }
421
687
  if (config.enums?.external && !experimental.externalTables) {
422
- return import_effect2.Either.left(
688
+ return import_effect3.Either.left(
423
689
  new Error("The `enums.external` configuration requires `experimental.externalTables` to be set to `true`.")
424
690
  );
425
691
  }
426
692
  if (config.migrations?.initShadowDb && !experimental.externalTables) {
427
- return import_effect2.Either.left(
693
+ return import_effect3.Either.left(
428
694
  new Error(
429
695
  "The `migrations.initShadowDb` configuration requires `experimental.externalTables` to be set to `true`."
430
696
  )
431
697
  );
432
698
  }
433
699
  if (config["extensions"] && !experimental.extensions) {
434
- return import_effect2.Either.left(
700
+ return import_effect3.Either.left(
435
701
  new Error("The `extensions` configuration requires `experimental.extensions` to be set to `true`.")
436
702
  );
437
703
  }
438
- return import_effect2.Either.right(config);
704
+ return import_effect3.Either.right(config);
439
705
  }
440
706
  function parsePrismaConfigShape(input) {
441
707
  return (0, import_Function.pipe)(
442
- import_effect2.Schema.decodeUnknownEither(PrismaConfigShape, {})(input, {
708
+ import_effect3.Schema.decodeUnknownEither(PrismaConfigShape, {})(input, {
443
709
  onExcessProperty: "error"
444
710
  }),
445
- import_effect2.Either.flatMap(validateExperimentalFeatures2)
711
+ import_effect3.Either.flatMap(validateExperimentalFeatures2)
446
712
  );
447
713
  }
448
714
  var PRISMA_CONFIG_INTERNAL_BRAND = Symbol.for("PrismaConfigInternal");
449
- var PrismaConfigInternalShape = import_effect2.Schema.Struct({
450
- ...PrismaConfigShape.fields,
451
- loadedFromFile: import_effect2.Schema.NullOr(import_effect2.Schema.String)
452
- });
715
+ var PrismaConfigInternalShape = import_effect3.Schema.extend(
716
+ PrismaConfigUnconditionalShape,
717
+ import_effect3.Schema.extend(
718
+ SchemaEngineConfigInternal,
719
+ import_effect3.Schema.Struct({
720
+ loadedFromFile: import_effect3.Schema.NullOr(import_effect3.Schema.String),
721
+ deprecatedPackageJson: import_effect3.Schema.NullOr(
722
+ import_effect3.Schema.Struct({
723
+ config: PrismaConfigPackageJsonShape,
724
+ loadedFromFile: import_effect3.Schema.String
725
+ })
726
+ )
727
+ })
728
+ )
729
+ );
453
730
  function brandPrismaConfigInternal(config) {
454
731
  Object.defineProperty(config, "__brand", {
455
732
  value: PRISMA_CONFIG_INTERNAL_BRAND,
@@ -460,13 +737,13 @@ function brandPrismaConfigInternal(config) {
460
737
  return config;
461
738
  }
462
739
  function parsePrismaConfigInternalShape(input) {
463
- debug2("Parsing PrismaConfigInternal: %o", input);
740
+ debug3("Parsing PrismaConfigInternal: %o", input);
464
741
  if (typeof input === "object" && input !== null && input["__brand"] === PRISMA_CONFIG_INTERNAL_BRAND) {
465
- debug2("Short-circuit: input is already a PrismaConfigInternal object");
466
- return import_effect2.Either.right(input);
742
+ debug3("Short-circuit: input is already a PrismaConfigInternal object");
743
+ return import_effect3.Either.right(input);
467
744
  }
468
745
  return (0, import_Function.pipe)(
469
- import_effect2.Schema.decodeUnknownEither(PrismaConfigInternalShape, {})(input, {
746
+ import_effect3.Schema.decodeUnknownEither(PrismaConfigInternalShape, {})(input, {
470
747
  onExcessProperty: "error"
471
748
  }),
472
749
  // Brand the output type to make `PrismaConfigInternal` opaque, without exposing the `Effect/Brand` type
@@ -475,24 +752,24 @@ function parsePrismaConfigInternalShape(input) {
475
752
  // - https://github.com/microsoft/rushstack/issues/1308
476
753
  // - https://github.com/microsoft/rushstack/issues/4034
477
754
  // - https://github.com/microsoft/TypeScript/issues/58914
478
- import_effect2.Either.map(brandPrismaConfigInternal)
755
+ import_effect3.Either.map(brandPrismaConfigInternal)
479
756
  );
480
757
  }
481
758
  function makePrismaConfigInternal(makeArgs) {
482
- return (0, import_Function.pipe)(PrismaConfigInternalShape.make(makeArgs), brandPrismaConfigInternal);
759
+ return brandPrismaConfigInternal(makeArgs);
483
760
  }
484
761
  function parseDefaultExport(defaultExport) {
485
762
  const parseResultEither = (0, import_Function.pipe)(
486
763
  // If the given config conforms to the `PrismaConfig` shape, feed it to `defineConfig`.
487
764
  parsePrismaConfigShape(defaultExport),
488
- import_effect2.Either.map((config) => {
489
- debug2("Parsed `PrismaConfig` shape: %o", config);
765
+ import_effect3.Either.map((config) => {
766
+ debug3("Parsed `PrismaConfig` shape: %o", config);
490
767
  return defineConfig(config);
491
768
  }),
492
769
  // Otherwise, try to parse it as a `PrismaConfigInternal` shape.
493
- import_effect2.Either.orElse(() => parsePrismaConfigInternalShape(defaultExport))
770
+ import_effect3.Either.orElse(() => parsePrismaConfigInternalShape(defaultExport))
494
771
  );
495
- if (import_effect2.Either.isLeft(parseResultEither)) {
772
+ if (import_effect3.Either.isLeft(parseResultEither)) {
496
773
  throw parseResultEither.left;
497
774
  }
498
775
  return parseResultEither.right;
@@ -501,14 +778,15 @@ function parseDefaultExport(defaultExport) {
501
778
  // src/defaultTestConfig.ts
502
779
  function defaultTestConfig() {
503
780
  return makePrismaConfigInternal({
504
- loadedFromFile: null
781
+ loadedFromFile: null,
782
+ deprecatedPackageJson: null
505
783
  });
506
784
  }
507
785
 
508
786
  // src/env.ts
509
787
  var PrismaConfigEnvError = class extends Error {
510
788
  constructor(name) {
511
- super(`Cannot resolve environment variable: ${name}.`);
789
+ super(`Missing required environment variable: ${name}`);
512
790
  this.name = "PrismaConfigEnvError";
513
791
  }
514
792
  };
@@ -522,16 +800,27 @@ function env(name) {
522
800
 
523
801
  // src/loadConfigFromFile.ts
524
802
  var import_node_path = __toESM(require("node:path"));
525
- var import_node_process = __toESM(require("node:process"));
526
- var debug3 = Debug("prisma:config:loadConfigFromFile");
803
+ var import_node_process2 = __toESM(require("node:process"));
804
+ var debug4 = Debug("prisma:config:loadConfigFromFile");
527
805
  var SUPPORTED_EXTENSIONS = [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts"];
528
806
  async function loadConfigFromFile({
529
807
  configFile,
530
- configRoot = import_node_process.default.cwd()
808
+ configRoot = import_node_process2.default.cwd()
531
809
  }) {
532
810
  const start = performance.now();
533
811
  const getTime = () => `${(performance.now() - start).toFixed(2)}ms`;
534
812
  const diagnostics = [];
813
+ const deprecatedPrismaConfigFromJson = await loadConfigFromPackageJson(configRoot);
814
+ if (deprecatedPrismaConfigFromJson) {
815
+ diagnostics.push({
816
+ _tag: "warn",
817
+ value: ({ warn, link }) => () => warn(
818
+ `The configuration property \`package.json#prisma\` is deprecated and will be removed in Prisma 7. Please migrate to a Prisma config file (e.g., \`prisma.config.ts\`).
819
+ For more information, see: ${link("https://pris.ly/prisma-config")}
820
+ `
821
+ )
822
+ });
823
+ }
535
824
  try {
536
825
  const { configModule, resolvedPath, error } = await loadConfigTsOrJs(configRoot, configFile);
537
826
  if (error) {
@@ -541,9 +830,9 @@ async function loadConfigFromFile({
541
830
  diagnostics
542
831
  };
543
832
  }
544
- debug3(`Config file loaded in %s`, getTime());
833
+ debug4(`Config file loaded in %s`, getTime());
545
834
  if (resolvedPath === null) {
546
- debug3(`No config file found in the current working directory %s`, configRoot);
835
+ debug4(`No config file found in the current working directory %s`, configRoot);
547
836
  return { resolvedPath: null, config: defaultConfig(), diagnostics };
548
837
  }
549
838
  let parsedConfig;
@@ -566,6 +855,20 @@ async function loadConfigFromFile({
566
855
  `))
567
856
  });
568
857
  const prismaConfig = transformPathsInConfigToAbsolute(parsedConfig, resolvedPath);
858
+ if (deprecatedPrismaConfigFromJson) {
859
+ diagnostics.push({
860
+ _tag: "warn",
861
+ value: ({ warn, link }) => () => warn(`The Prisma config file in ${import_node_path.default.relative(
862
+ configRoot,
863
+ resolvedPath
864
+ )} overrides the deprecated \`package.json#prisma\` property in ${import_node_path.default.relative(
865
+ configRoot,
866
+ deprecatedPrismaConfigFromJson.loadedFromFile
867
+ )}.
868
+ For more information, see: ${link("https://pris.ly/prisma-config")}
869
+ `)
870
+ });
871
+ }
569
872
  return {
570
873
  config: {
571
874
  ...prismaConfig,
@@ -621,7 +924,7 @@ async function loadConfigTsOrJs(configRoot, configFile) {
621
924
  const resolvedPath = _resolvedPath ? import_node_path.default.normalize(_resolvedPath) : void 0;
622
925
  const doesConfigFileExist = resolvedPath !== void 0 && meta !== void 0;
623
926
  if (configFile && !doesConfigFileExist) {
624
- debug3(`The given config file was not found at %s`, resolvedPath);
927
+ debug4(`The given config file was not found at %s`, resolvedPath);
625
928
  return {
626
929
  require: null,
627
930
  resolvedPath: import_node_path.default.join(configRoot, configFile),
@@ -648,11 +951,11 @@ async function loadConfigTsOrJs(configRoot, configFile) {
648
951
  };
649
952
  } catch (e) {
650
953
  const error = e;
651
- debug3("jiti import failed: %s", error.message);
954
+ debug4("jiti import failed: %s", error.message);
652
955
  const configFileMatch = error.message.match(/prisma\.config\.(\w+)/);
653
956
  const extension = configFileMatch?.[1];
654
957
  const filenameWithExtension = import_node_path.default.join(configRoot, extension ? `prisma.config.${extension}` : "");
655
- debug3("faulty config file: %s", filenameWithExtension);
958
+ debug4("faulty config file: %s", filenameWithExtension);
656
959
  return {
657
960
  error: {
658
961
  _tag: "ConfigLoadError",
@@ -692,5 +995,6 @@ function transformPathsInConfigToAbsolute(prismaConfig, resolvedPath) {
692
995
  defaultTestConfig,
693
996
  defineConfig,
694
997
  env,
695
- loadConfigFromFile
998
+ loadConfigFromFile,
999
+ loadConfigFromPackageJson
696
1000
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/config",
3
- "version": "7.2.0",
3
+ "version": "7.3.0-integration-prisma6-fix-cloudflare-engine.1",
4
4
  "description": "Internal package used to define and read Prisma configuration files",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,10 +18,9 @@
18
18
  "empathic": "2.0.0"
19
19
  },
20
20
  "devDependencies": {
21
- "dotenv": "17.2.3",
22
21
  "vitest": "3.2.4",
23
- "@prisma/debug": "7.2.0",
24
- "@prisma/get-platform": "7.2.0"
22
+ "@prisma/driver-adapter-utils": "7.3.0-integration-prisma6-fix-cloudflare-engine.1",
23
+ "@prisma/get-platform": "7.3.0-integration-prisma6-fix-cloudflare-engine.1"
25
24
  },
26
25
  "files": [
27
26
  "dist"