@prisma/config 6.20.0-integration-merge-release-workflows.2 → 6.20.0-integration-feat-prisma-7-config.3

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 +31 -276
  2. package/dist/index.js +74 -314
  3. package/package.json +4 -3
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { Schema } from 'effect';
2
-
3
1
  /**
4
2
  * An interface that exposes some basic information about the
5
3
  * adapter like its name and provider type.
@@ -87,6 +85,15 @@ declare type ConnectionInfo = {
87
85
  supportsRelationJoins: boolean;
88
86
  };
89
87
 
88
+ export declare type Datasource = {
89
+ url: string;
90
+ /**
91
+ * @deprecated
92
+ */
93
+ directUrl?: string;
94
+ shadowDatabaseUrl?: string;
95
+ };
96
+
90
97
  /**
91
98
  * This default config can be used as basis for unit and integration tests.
92
99
  */
@@ -119,34 +126,7 @@ declare type EnumsConfigShape = {
119
126
 
120
127
  export declare function env<Env extends Record<string, string | undefined>>(name: keyof Env & string): string;
121
128
 
122
- declare type Error_2 = MappedError & {
123
- originalCode?: string;
124
- originalMessage?: string;
125
- };
126
-
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;
128
-
129
- declare type ErrorCapturingInterface<T> = {
130
- [K in keyof T]: ErrorCapturingFunction<T[K]>;
131
- };
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
-
145
129
  declare type ExperimentalConfig = {
146
- /**
147
- * Enable experimental adapter support.
148
- */
149
- adapter?: boolean;
150
130
  /**
151
131
  * Enable experimental Prisma Studio features.
152
132
  */
@@ -204,130 +184,6 @@ declare type LoadConfigFromFileInput = {
204
184
  configRoot?: string;
205
185
  };
206
186
 
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
-
331
187
  declare type MigrationsConfigShape = {
332
188
  /**
333
189
  * The path to the directory where Prisma should store migration files, and look for them.
@@ -352,70 +208,11 @@ declare const PRISMA_CONFIG_INTERNAL_BRAND: unique symbol;
352
208
  * The configuration for the Prisma Development Kit, before it is passed to the `defineConfig` function.
353
209
  * Thanks to the branding, this type is opaque and cannot be constructed directly.
354
210
  */
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;
211
+ export declare type PrismaConfig = {
372
212
  /**
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
213
+ * The datasource URL configuration for the database connection.
378
214
  */
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 = {
215
+ datasource?: Simplify<Datasource>;
419
216
  /**
420
217
  * Experimental feature gates. Each experimental feature must be explicitly enabled.
421
218
  */
@@ -450,6 +247,23 @@ declare type PrismaConfigUnconditional = {
450
247
  typedSql?: Simplify<TypedSqlConfigShape>;
451
248
  };
452
249
 
250
+ export declare class PrismaConfigEnvError extends Error {
251
+ constructor(name: string);
252
+ }
253
+
254
+ /**
255
+ * The configuration for the Prisma Development Kit, after it has been parsed and processed
256
+ * by the `defineConfig` function.
257
+ * Thanks to the branding, this type is opaque and cannot be constructed directly.
258
+ */
259
+ export declare type PrismaConfigInternal = _PrismaConfigInternal & {
260
+ __brand: typeof PRISMA_CONFIG_INTERNAL_BRAND;
261
+ };
262
+
263
+ declare type _PrismaConfigInternal = PrismaConfig & {
264
+ loadedFromFile: string | null;
265
+ };
266
+
453
267
  declare type PrismaStudioConfigShape = {
454
268
  adapter: () => Promise<SqlMigrationAwareDriverAdapterFactory>;
455
269
  };
@@ -467,69 +281,10 @@ declare interface Queryable<Query, Result> extends AdapterInfo {
467
281
  executeRaw(params: Query): Promise<number>;
468
282
  }
469
283
 
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;
485
- };
486
-
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;
496
- };
497
-
498
- export declare type SchemaEngineConfigClassicDatasource = {
499
- url: string;
500
- directUrl?: string;
501
- shadowDatabaseUrl?: string;
284
+ export declare type SchemaEngineConfigInternal = {
285
+ datasource?: Datasource;
502
286
  };
503
287
 
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
-
533
288
  /**
534
289
  * Simplifies the type signature of a type.
535
290
  * Re-exported from `effect/Types`.
package/dist/index.js CHANGED
@@ -34,8 +34,7 @@ __export(index_exports, {
34
34
  defaultTestConfig: () => defaultTestConfig,
35
35
  defineConfig: () => defineConfig,
36
36
  env: () => env,
37
- loadConfigFromFile: () => loadConfigFromFile,
38
- loadConfigFromPackageJson: () => loadConfigFromPackageJson
37
+ loadConfigFromFile: () => loadConfigFromFile
39
38
  });
40
39
  module.exports = __toCommonJS(index_exports);
41
40
 
@@ -226,129 +225,7 @@ function safeStringify(value, indent = 2) {
226
225
  }
227
226
 
228
227
  // ../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
228
  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
229
  var mockAdapterErrors = {
353
230
  queryRaw: new Error("Not implemented: queryRaw"),
354
231
  executeRaw: new Error("Not implemented: executeRaw"),
@@ -358,7 +235,7 @@ var mockAdapterErrors = {
358
235
  };
359
236
 
360
237
  // src/PrismaConfig.ts
361
- var import_effect3 = require("effect");
238
+ var import_effect2 = require("effect");
362
239
  var import_Function = require("effect/Function");
363
240
 
364
241
  // src/defineConfig.ts
@@ -368,18 +245,15 @@ var import_effect = require("effect");
368
245
  function defaultConfig() {
369
246
  return makePrismaConfigInternal({
370
247
  loadedFromFile: null,
371
- deprecatedPackageJson: null
248
+ datasource: {
249
+ url: "<default_datasource_url>"
250
+ }
372
251
  });
373
252
  }
374
253
 
375
254
  // src/defineConfig.ts
376
255
  function validateExperimentalFeatures(config) {
377
256
  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
257
  if (config.studio && !experimental.studio) {
384
258
  return import_effect.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
385
259
  }
@@ -412,7 +286,7 @@ function defineConfig(configInput) {
412
286
  debug2("[default]: %o", config);
413
287
  defineExperimentalConfig(config, configInput);
414
288
  defineSchemaConfig(config, configInput);
415
- defineEngineConfig(config, configInput);
289
+ defineDatasource(config, configInput);
416
290
  defineStudioConfig(config, configInput);
417
291
  defineMigrationsConfig(config, configInput);
418
292
  defineTablesConfig(config, configInput);
@@ -485,25 +359,10 @@ function defineStudioConfig(config, configInput) {
485
359
  };
486
360
  debug2("[config.studio]: %o", config.studio);
487
361
  }
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
- }
362
+ function defineDatasource(config, configInput) {
363
+ const { datasource } = configInput;
364
+ Object.assign(config, { datasource });
365
+ debug2("[config.datasource]: %o", datasource);
507
366
  }
508
367
  function defineExtensionsConfig(config, configInput) {
509
368
  if (!configInput["extensions"]) {
@@ -513,133 +372,73 @@ function defineExtensionsConfig(config, configInput) {
513
372
  debug2("[config.extensions]: %o", config["extensions"]);
514
373
  }
515
374
 
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
- };
542
- }
543
-
544
375
  // src/PrismaConfig.ts
545
376
  var debug3 = Debug("prisma:config:PrismaConfig");
546
- var SqlMigrationAwareDriverAdapterFactoryShape = import_effect3.Schema.declare(
377
+ var SqlMigrationAwareDriverAdapterFactoryShape = import_effect2.Schema.declare(
547
378
  (input) => {
548
379
  return typeof input === "function";
549
380
  },
550
381
  {
551
382
  identifier: "SqlMigrationAwareDriverAdapterFactory",
552
- encode: import_effect3.identity,
553
- decode: import_effect3.identity
383
+ encode: import_effect2.identity,
384
+ decode: import_effect2.identity
554
385
  }
555
386
  );
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
577
- });
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
387
+ var DatasourceShape = import_effect2.Schema.Struct({
388
+ url: import_effect2.Schema.String,
389
+ /**
390
+ * @deprecated
391
+ */
392
+ directUrl: import_effect2.Schema.optional(import_effect2.Schema.String),
393
+ shadowDatabaseUrl: import_effect2.Schema.optional(import_effect2.Schema.String)
589
394
  });
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)
395
+ var ExperimentalConfigShape = import_effect2.Schema.Struct({
396
+ studio: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
397
+ externalTables: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
398
+ extensions: import_effect2.Schema.optional(import_effect2.Schema.Boolean)
600
399
  });
601
400
  if (false) {
602
401
  __testExperimentalConfigShapeValueA;
603
402
  __testExperimentalConfigShapeValueB;
604
403
  }
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)
404
+ var MigrationsConfigShape = import_effect2.Schema.Struct({
405
+ path: import_effect2.Schema.optional(import_effect2.Schema.String),
406
+ initShadowDb: import_effect2.Schema.optional(import_effect2.Schema.String),
407
+ seed: import_effect2.Schema.optional(import_effect2.Schema.NonEmptyString)
609
408
  });
610
409
  if (false) {
611
410
  __testMigrationsConfigShapeValueA;
612
411
  __testMigrationsConfigShapeValueB;
613
412
  }
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)))
413
+ var TablesConfigShape = import_effect2.Schema.Struct({
414
+ external: import_effect2.Schema.optional(import_effect2.Schema.mutable(import_effect2.Schema.Array(import_effect2.Schema.String)))
616
415
  });
617
416
  if (false) {
618
417
  __testTablesConfigShapeValueA;
619
418
  __testTablesConfigShapeValueB;
620
419
  }
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)))
420
+ var EnumsConfigShape = import_effect2.Schema.Struct({
421
+ external: import_effect2.Schema.optional(import_effect2.Schema.mutable(import_effect2.Schema.Array(import_effect2.Schema.String)))
623
422
  });
624
423
  if (false) {
625
424
  __testEnumsConfigShapeValueA;
626
425
  __testEnumsConfigShapeValueB;
627
426
  }
628
- var ViewsConfigShape = import_effect3.Schema.Struct({
629
- path: import_effect3.Schema.optional(import_effect3.Schema.String)
427
+ var ViewsConfigShape = import_effect2.Schema.Struct({
428
+ path: import_effect2.Schema.optional(import_effect2.Schema.String)
630
429
  });
631
430
  if (false) {
632
431
  __testViewsConfigShapeValueA;
633
432
  __testViewsConfigShapeValueB;
634
433
  }
635
- var TypedSqlConfigShape = import_effect3.Schema.Struct({
636
- path: import_effect3.Schema.optional(import_effect3.Schema.String)
434
+ var TypedSqlConfigShape = import_effect2.Schema.Struct({
435
+ path: import_effect2.Schema.optional(import_effect2.Schema.String)
637
436
  });
638
437
  if (false) {
639
438
  __testTypedSqlConfigShapeValueA;
640
439
  __testTypedSqlConfigShapeValueB;
641
440
  }
642
- var PrismaStudioConfigShape = import_effect3.Schema.Struct({
441
+ var PrismaStudioConfigShape = import_effect2.Schema.Struct({
643
442
  /**
644
443
  * Instantiates the Prisma driver adapter to use for Prisma Studio.
645
444
  */
@@ -653,80 +452,65 @@ if (false) {
653
452
  __testPrismaConfig;
654
453
  __testPrismaConfigInternal;
655
454
  }
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)
455
+ var PrismaConfigShape = import_effect2.Schema.Struct({
456
+ // @aqrln: datasource should be mandatory once we close https://linear.app/prisma-company/issue/TML-1545/remove-url-datasource-attribute-from-psl
457
+ datasource: import_effect2.Schema.optional(DatasourceShape),
458
+ experimental: import_effect2.Schema.optional(ExperimentalConfigShape),
459
+ schema: import_effect2.Schema.optional(import_effect2.Schema.String),
460
+ studio: import_effect2.Schema.optional(PrismaStudioConfigShape),
461
+ migrations: import_effect2.Schema.optional(MigrationsConfigShape),
462
+ tables: import_effect2.Schema.optional(TablesConfigShape),
463
+ enums: import_effect2.Schema.optional(EnumsConfigShape),
464
+ views: import_effect2.Schema.optional(ViewsConfigShape),
465
+ typedSql: import_effect2.Schema.optional(TypedSqlConfigShape),
466
+ extensions: import_effect2.Schema.optional(import_effect2.Schema.Any)
666
467
  });
667
- var PrismaConfigShape = import_effect3.Schema.extend(SchemaEngineConfigShape, PrismaConfigUnconditionalShape);
668
468
  if (false) {
669
469
  __testPrismaConfigValueA;
670
470
  __testPrismaConfigValueB;
671
471
  }
672
472
  function validateExperimentalFeatures2(config) {
673
473
  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
474
  if (config.studio && !experimental.studio) {
680
- return import_effect3.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
475
+ return import_effect2.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
681
476
  }
682
477
  if (config.tables?.external && !experimental.externalTables) {
683
- return import_effect3.Either.left(
478
+ return import_effect2.Either.left(
684
479
  new Error("The `tables.external` configuration requires `experimental.externalTables` to be set to `true`.")
685
480
  );
686
481
  }
687
482
  if (config.enums?.external && !experimental.externalTables) {
688
- return import_effect3.Either.left(
483
+ return import_effect2.Either.left(
689
484
  new Error("The `enums.external` configuration requires `experimental.externalTables` to be set to `true`.")
690
485
  );
691
486
  }
692
487
  if (config.migrations?.initShadowDb && !experimental.externalTables) {
693
- return import_effect3.Either.left(
488
+ return import_effect2.Either.left(
694
489
  new Error(
695
490
  "The `migrations.initShadowDb` configuration requires `experimental.externalTables` to be set to `true`."
696
491
  )
697
492
  );
698
493
  }
699
494
  if (config["extensions"] && !experimental.extensions) {
700
- return import_effect3.Either.left(
495
+ return import_effect2.Either.left(
701
496
  new Error("The `extensions` configuration requires `experimental.extensions` to be set to `true`.")
702
497
  );
703
498
  }
704
- return import_effect3.Either.right(config);
499
+ return import_effect2.Either.right(config);
705
500
  }
706
501
  function parsePrismaConfigShape(input) {
707
502
  return (0, import_Function.pipe)(
708
- import_effect3.Schema.decodeUnknownEither(PrismaConfigShape, {})(input, {
503
+ import_effect2.Schema.decodeUnknownEither(PrismaConfigShape, {})(input, {
709
504
  onExcessProperty: "error"
710
505
  }),
711
- import_effect3.Either.flatMap(validateExperimentalFeatures2)
506
+ import_effect2.Either.flatMap(validateExperimentalFeatures2)
712
507
  );
713
508
  }
714
509
  var PRISMA_CONFIG_INTERNAL_BRAND = Symbol.for("PrismaConfigInternal");
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
- );
510
+ var PrismaConfigInternalShape = import_effect2.Schema.Struct({
511
+ ...PrismaConfigShape.fields,
512
+ loadedFromFile: import_effect2.Schema.NullOr(import_effect2.Schema.String)
513
+ });
730
514
  function brandPrismaConfigInternal(config) {
731
515
  Object.defineProperty(config, "__brand", {
732
516
  value: PRISMA_CONFIG_INTERNAL_BRAND,
@@ -740,10 +524,10 @@ function parsePrismaConfigInternalShape(input) {
740
524
  debug3("Parsing PrismaConfigInternal: %o", input);
741
525
  if (typeof input === "object" && input !== null && input["__brand"] === PRISMA_CONFIG_INTERNAL_BRAND) {
742
526
  debug3("Short-circuit: input is already a PrismaConfigInternal object");
743
- return import_effect3.Either.right(input);
527
+ return import_effect2.Either.right(input);
744
528
  }
745
529
  return (0, import_Function.pipe)(
746
- import_effect3.Schema.decodeUnknownEither(PrismaConfigInternalShape, {})(input, {
530
+ import_effect2.Schema.decodeUnknownEither(PrismaConfigInternalShape, {})(input, {
747
531
  onExcessProperty: "error"
748
532
  }),
749
533
  // Brand the output type to make `PrismaConfigInternal` opaque, without exposing the `Effect/Brand` type
@@ -752,24 +536,24 @@ function parsePrismaConfigInternalShape(input) {
752
536
  // - https://github.com/microsoft/rushstack/issues/1308
753
537
  // - https://github.com/microsoft/rushstack/issues/4034
754
538
  // - https://github.com/microsoft/TypeScript/issues/58914
755
- import_effect3.Either.map(brandPrismaConfigInternal)
539
+ import_effect2.Either.map(brandPrismaConfigInternal)
756
540
  );
757
541
  }
758
542
  function makePrismaConfigInternal(makeArgs) {
759
- return brandPrismaConfigInternal(makeArgs);
543
+ return (0, import_Function.pipe)(PrismaConfigInternalShape.make(makeArgs), brandPrismaConfigInternal);
760
544
  }
761
545
  function parseDefaultExport(defaultExport) {
762
546
  const parseResultEither = (0, import_Function.pipe)(
763
547
  // If the given config conforms to the `PrismaConfig` shape, feed it to `defineConfig`.
764
548
  parsePrismaConfigShape(defaultExport),
765
- import_effect3.Either.map((config) => {
549
+ import_effect2.Either.map((config) => {
766
550
  debug3("Parsed `PrismaConfig` shape: %o", config);
767
551
  return defineConfig(config);
768
552
  }),
769
553
  // Otherwise, try to parse it as a `PrismaConfigInternal` shape.
770
- import_effect3.Either.orElse(() => parsePrismaConfigInternalShape(defaultExport))
554
+ import_effect2.Either.orElse(() => parsePrismaConfigInternalShape(defaultExport))
771
555
  );
772
- if (import_effect3.Either.isLeft(parseResultEither)) {
556
+ if (import_effect2.Either.isLeft(parseResultEither)) {
773
557
  throw parseResultEither.left;
774
558
  }
775
559
  return parseResultEither.right;
@@ -779,7 +563,9 @@ function parseDefaultExport(defaultExport) {
779
563
  function defaultTestConfig() {
780
564
  return makePrismaConfigInternal({
781
565
  loadedFromFile: null,
782
- deprecatedPackageJson: null
566
+ datasource: {
567
+ url: "<default_datasource_url>"
568
+ }
783
569
  });
784
570
  }
785
571
 
@@ -800,27 +586,16 @@ function env(name) {
800
586
 
801
587
  // src/loadConfigFromFile.ts
802
588
  var import_node_path = __toESM(require("node:path"));
803
- var import_node_process2 = __toESM(require("node:process"));
589
+ var import_node_process = __toESM(require("node:process"));
804
590
  var debug4 = Debug("prisma:config:loadConfigFromFile");
805
591
  var SUPPORTED_EXTENSIONS = [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts"];
806
592
  async function loadConfigFromFile({
807
593
  configFile,
808
- configRoot = import_node_process2.default.cwd()
594
+ configRoot = import_node_process.default.cwd()
809
595
  }) {
810
596
  const start = performance.now();
811
597
  const getTime = () => `${(performance.now() - start).toFixed(2)}ms`;
812
598
  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
- }
824
599
  try {
825
600
  const { configModule, resolvedPath, error } = await loadConfigTsOrJs(configRoot, configFile);
826
601
  if (error) {
@@ -855,20 +630,6 @@ For more information, see: ${link("https://pris.ly/prisma-config")}
855
630
  `))
856
631
  });
857
632
  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
- }
872
633
  return {
873
634
  config: {
874
635
  ...prismaConfig,
@@ -995,6 +756,5 @@ function transformPathsInConfigToAbsolute(prismaConfig, resolvedPath) {
995
756
  defaultTestConfig,
996
757
  defineConfig,
997
758
  env,
998
- loadConfigFromFile,
999
- loadConfigFromPackageJson
759
+ loadConfigFromFile
1000
760
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/config",
3
- "version": "6.20.0-integration-merge-release-workflows.2",
3
+ "version": "6.20.0-integration-feat-prisma-7-config.3",
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,9 +18,10 @@
18
18
  "empathic": "2.0.0"
19
19
  },
20
20
  "devDependencies": {
21
+ "dotenv": "17.2.3",
21
22
  "vitest": "3.2.4",
22
- "@prisma/driver-adapter-utils": "6.20.0-integration-merge-release-workflows.2",
23
- "@prisma/get-platform": "6.20.0-integration-merge-release-workflows.2"
23
+ "@prisma/driver-adapter-utils": "6.20.0-integration-feat-prisma-7-config.3",
24
+ "@prisma/get-platform": "6.20.0-integration-feat-prisma-7-config.3"
24
25
  },
25
26
  "files": [
26
27
  "dist"