@prisma/config 6.18.0-dev.20 → 6.18.0-dev.22

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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Schema } from 'effect';
2
+
1
3
  /**
2
4
  * An interface that exposes some basic information about the
3
5
  * adapter like its name and provider type.
@@ -115,6 +117,8 @@ declare type EnumsConfigShape = {
115
117
  external?: string[];
116
118
  };
117
119
 
120
+ export declare function env(name: string): string;
121
+
118
122
  declare type Error_2 = MappedError & {
119
123
  originalCode?: string;
120
124
  originalMessage?: string;
@@ -348,44 +352,11 @@ declare const PRISMA_CONFIG_INTERNAL_BRAND: unique symbol;
348
352
  * The configuration for the Prisma Development Kit, before it is passed to the `defineConfig` function.
349
353
  * Thanks to the branding, this type is opaque and cannot be constructed directly.
350
354
  */
351
- export declare type PrismaConfig = {
352
- /**
353
- * Experimental feature gates. Each experimental feature must be explicitly enabled.
354
- */
355
- experimental?: Simplify<ExperimentalConfig>;
356
- /**
357
- * The path to the schema file, or path to a folder that shall be recursively searched for *.prisma files.
358
- */
359
- schema?: string;
360
- /**
361
- * The Driver Adapter used for Prisma CLI.
362
- */
363
- adapter?: () => Promise<SqlMigrationAwareDriverAdapterFactory>;
364
- /**
365
- * The configuration for Prisma Studio.
366
- */
367
- studio?: Simplify<PrismaStudioConfigShape>;
368
- /**
369
- * Configuration for Prisma migrations.
370
- */
371
- migrations?: Simplify<MigrationsConfigShape>;
372
- /**
373
- * Configuration for the database table entities.
374
- */
375
- tables?: Simplify<TablesConfigShape>;
376
- /**
377
- * Configuration for the database enum entities.
378
- */
379
- enums?: Simplify<EnumsConfigShape>;
380
- /**
381
- * Configuration for the database view entities.
382
- */
383
- views?: Simplify<ViewsConfigShape>;
384
- /**
385
- * Configuration for the `typedSql` preview feature.
386
- */
387
- typedSql?: Simplify<TypedSqlConfigShape>;
388
- };
355
+ export declare type PrismaConfig = PrismaConfigUnconditional & SchemaEngineConfig;
356
+
357
+ export declare class PrismaConfigEnvError extends Error {
358
+ constructor(name: string);
359
+ }
389
360
 
390
361
  /**
391
362
  * The configuration for the Prisma Development Kit, after it has been parsed and processed
@@ -396,15 +367,7 @@ export declare type PrismaConfigInternal = _PrismaConfigInternal & {
396
367
  __brand: typeof PRISMA_CONFIG_INTERNAL_BRAND;
397
368
  };
398
369
 
399
- declare type _PrismaConfigInternal = Omit<PrismaConfig, 'adapter'> & {
400
- /**
401
- * The Driver Adapter used for Prisma CLI.
402
- */
403
- adapter?: () => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>;
404
- /**
405
- * The path from where the config was loaded.
406
- * It's set to `null` if no config file was found and only default config is applied.
407
- */
370
+ declare type _PrismaConfigInternal = Omit<PrismaConfig, 'engine' | 'datasource' | 'adapter'> & {
408
371
  loadedFromFile: string | null;
409
372
  /**
410
373
  * The deprecated Prisma configuration from `package.json#prisma`.
@@ -425,7 +388,18 @@ declare type _PrismaConfigInternal = Omit<PrismaConfig, 'adapter'> & {
425
388
  */
426
389
  loadedFromFile: string;
427
390
  } | null;
428
- };
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
+ });
429
403
 
430
404
  /**
431
405
  * Example:
@@ -441,6 +415,41 @@ declare type PrismaConfigPackageJson = {
441
415
  seed?: string;
442
416
  };
443
417
 
418
+ declare type PrismaConfigUnconditional = {
419
+ /**
420
+ * Experimental feature gates. Each experimental feature must be explicitly enabled.
421
+ */
422
+ experimental?: Simplify<ExperimentalConfig>;
423
+ /**
424
+ * The path to the schema file, or path to a folder that shall be recursively searched for *.prisma files.
425
+ */
426
+ schema?: string;
427
+ /**
428
+ * The configuration for Prisma Studio.
429
+ */
430
+ studio?: Simplify<PrismaStudioConfigShape>;
431
+ /**
432
+ * Configuration for Prisma migrations.
433
+ */
434
+ migrations?: Simplify<MigrationsConfigShape>;
435
+ /**
436
+ * Configuration for the database table entities.
437
+ */
438
+ tables?: Simplify<TablesConfigShape>;
439
+ /**
440
+ * Configuration for the database enum entities.
441
+ */
442
+ enums?: Simplify<EnumsConfigShape>;
443
+ /**
444
+ * Configuration for the database view entities.
445
+ */
446
+ views?: Simplify<ViewsConfigShape>;
447
+ /**
448
+ * Configuration for the `typedSql` preview feature.
449
+ */
450
+ typedSql?: Simplify<TypedSqlConfigShape>;
451
+ };
452
+
444
453
  declare type PrismaStudioConfigShape = {
445
454
  adapter: () => Promise<SqlMigrationAwareDriverAdapterFactory>;
446
455
  };
@@ -469,6 +478,58 @@ declare type Result<T> = {
469
478
  readonly error: Error_2;
470
479
  });
471
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;
502
+ };
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
+
472
533
  /**
473
534
  * Simplifies the type signature of a type.
474
535
  * Re-exported from `effect/Types`.
package/dist/index.js CHANGED
@@ -30,8 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ PrismaConfigEnvError: () => PrismaConfigEnvError,
33
34
  defaultTestConfig: () => defaultTestConfig,
34
35
  defineConfig: () => defineConfig,
36
+ env: () => env,
35
37
  loadConfigFromFile: () => loadConfigFromFile,
36
38
  loadConfigFromPackageJson: () => loadConfigFromPackageJson
37
39
  });
@@ -266,6 +268,11 @@ var ErrorRegistryInternal = class {
266
268
  return i;
267
269
  }
268
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
+ }
269
276
  var bindMigrationAwareSqlAdapterFactory = (adapterFactory) => {
270
277
  const errorRegistry = new ErrorRegistryInternal();
271
278
  const boundFactory = {
@@ -281,6 +288,7 @@ var bindMigrationAwareSqlAdapterFactory = (adapterFactory) => {
281
288
  return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
282
289
  }
283
290
  };
291
+ copySymbolsFromSource(adapterFactory, boundFactory);
284
292
  return boundFactory;
285
293
  };
286
294
  var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal()) => {
@@ -367,8 +375,10 @@ function defaultConfig() {
367
375
  // src/defineConfig.ts
368
376
  function validateExperimentalFeatures(config) {
369
377
  const experimental = config.experimental || {};
370
- if (config.adapter && !experimental.adapter) {
371
- return import_effect.Either.left(new Error("The `adapter` configuration requires `experimental.adapter` to be set to `true`."));
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
+ );
372
382
  }
373
383
  if (config.studio && !experimental.studio) {
374
384
  return import_effect.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
@@ -402,7 +412,7 @@ function defineConfig(configInput) {
402
412
  debug2("[default]: %o", config);
403
413
  defineExperimentalConfig(config, configInput);
404
414
  defineSchemaConfig(config, configInput);
405
- defineAdapterConfig(config, configInput);
415
+ defineEngineConfig(config, configInput);
406
416
  defineStudioConfig(config, configInput);
407
417
  defineMigrationsConfig(config, configInput);
408
418
  defineTablesConfig(config, configInput);
@@ -475,17 +485,25 @@ function defineStudioConfig(config, configInput) {
475
485
  };
476
486
  debug2("[config.studio]: %o", config.studio);
477
487
  }
478
- function defineAdapterConfig(config, configInput) {
479
- if (!configInput.adapter) {
488
+ function defineEngineConfig(config, configInput) {
489
+ if (configInput.engine === void 0) {
480
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);
481
506
  }
482
- const { adapter: getAdapterFactory } = configInput;
483
- config.adapter = async () => {
484
- const adapterFactory = await getAdapterFactory();
485
- debug2("[config.adapter]: %o", adapterFactory.adapterName);
486
- return bindMigrationAwareSqlAdapterFactory(adapterFactory);
487
- };
488
- debug2("[config.adapter]: %o", config.adapter);
489
507
  }
490
508
  function defineExtensionsConfig(config, configInput) {
491
509
  if (!configInput["extensions"]) {
@@ -545,6 +563,35 @@ var ErrorCapturingSqlMigrationAwareDriverAdapterFactoryShape = import_effect3.Sc
545
563
  decode: import_effect3.identity
546
564
  }
547
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
589
+ });
590
+ var SchemaEngineConfigInternal = import_effect3.Schema.Union(
591
+ SchemaEngineConfigClassicShape,
592
+ SchemaEngineConfigJsInternal,
593
+ SchemaEngineConfigAbsentShape
594
+ );
548
595
  var ExperimentalConfigShape = import_effect3.Schema.Struct({
549
596
  adapter: import_effect3.Schema.optional(import_effect3.Schema.Boolean),
550
597
  studio: import_effect3.Schema.optional(import_effect3.Schema.Boolean),
@@ -606,11 +653,10 @@ if (false) {
606
653
  __testPrismaConfig;
607
654
  __testPrismaConfigInternal;
608
655
  }
609
- var PrismaConfigShape = import_effect3.Schema.Struct({
656
+ var PrismaConfigUnconditionalShape = import_effect3.Schema.Struct({
610
657
  experimental: import_effect3.Schema.optional(ExperimentalConfigShape),
611
658
  schema: import_effect3.Schema.optional(import_effect3.Schema.String),
612
659
  studio: import_effect3.Schema.optional(PrismaStudioConfigShape),
613
- adapter: import_effect3.Schema.optional(SqlMigrationAwareDriverAdapterFactoryShape),
614
660
  migrations: import_effect3.Schema.optional(MigrationsConfigShape),
615
661
  tables: import_effect3.Schema.optional(TablesConfigShape),
616
662
  enums: import_effect3.Schema.optional(EnumsConfigShape),
@@ -618,14 +664,17 @@ var PrismaConfigShape = import_effect3.Schema.Struct({
618
664
  typedSql: import_effect3.Schema.optional(TypedSqlConfigShape),
619
665
  extensions: import_effect3.Schema.optional(import_effect3.Schema.Any)
620
666
  });
667
+ var PrismaConfigShape = import_effect3.Schema.extend(SchemaEngineConfigShape, PrismaConfigUnconditionalShape);
621
668
  if (false) {
622
669
  __testPrismaConfigValueA;
623
670
  __testPrismaConfigValueB;
624
671
  }
625
672
  function validateExperimentalFeatures2(config) {
626
673
  const experimental = config.experimental || {};
627
- if (config.adapter && !experimental.adapter) {
628
- return import_effect3.Either.left(new Error("The `adapter` configuration requires `experimental.adapter` to be set to `true`."));
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
+ );
629
678
  }
630
679
  if (config.studio && !experimental.studio) {
631
680
  return import_effect3.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
@@ -663,21 +712,21 @@ function parsePrismaConfigShape(input) {
663
712
  );
664
713
  }
665
714
  var PRISMA_CONFIG_INTERNAL_BRAND = Symbol.for("PrismaConfigInternal");
666
- var PrismaConfigInternalShape = import_effect3.Schema.Struct({
667
- ...import_effect3.Struct.omit(PrismaConfigShape.fields, "adapter"),
668
- adapter: import_effect3.Schema.optional(ErrorCapturingSqlMigrationAwareDriverAdapterFactoryShape),
669
- loadedFromFile: import_effect3.Schema.NullOr(import_effect3.Schema.String),
670
- deprecatedPackageJson: import_effect3.Schema.NullOr(
715
+ var PrismaConfigInternalShape = import_effect3.Schema.extend(
716
+ PrismaConfigUnconditionalShape,
717
+ import_effect3.Schema.extend(
718
+ SchemaEngineConfigInternal,
671
719
  import_effect3.Schema.Struct({
672
- config: PrismaConfigPackageJsonShape,
673
- loadedFromFile: import_effect3.Schema.String
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
+ )
674
727
  })
675
728
  )
676
- });
677
- if (false) {
678
- __testPrismaConfigInternalValueA;
679
- __testPrismaConfigInternalValueB;
680
- }
729
+ );
681
730
  function brandPrismaConfigInternal(config) {
682
731
  Object.defineProperty(config, "__brand", {
683
732
  value: PRISMA_CONFIG_INTERNAL_BRAND,
@@ -707,7 +756,7 @@ function parsePrismaConfigInternalShape(input) {
707
756
  );
708
757
  }
709
758
  function makePrismaConfigInternal(makeArgs) {
710
- return (0, import_Function.pipe)(PrismaConfigInternalShape.make(makeArgs), brandPrismaConfigInternal);
759
+ return brandPrismaConfigInternal(makeArgs);
711
760
  }
712
761
  function parseDefaultExport(defaultExport) {
713
762
  const parseResultEither = (0, import_Function.pipe)(
@@ -734,6 +783,21 @@ function defaultTestConfig() {
734
783
  });
735
784
  }
736
785
 
786
+ // src/env.ts
787
+ var PrismaConfigEnvError = class extends Error {
788
+ constructor(name) {
789
+ super(`Missing required environment variable: ${name}`);
790
+ this.name = "PrismaConfigEnvError";
791
+ }
792
+ };
793
+ function env(name) {
794
+ const value = process.env[name];
795
+ if (!value) {
796
+ throw new PrismaConfigEnvError(name);
797
+ }
798
+ return value;
799
+ }
800
+
737
801
  // src/loadConfigFromFile.ts
738
802
  var import_node_path = __toESM(require("node:path"));
739
803
  var import_node_process2 = __toESM(require("node:process"));
@@ -927,8 +991,10 @@ function transformPathsInConfigToAbsolute(prismaConfig, resolvedPath) {
927
991
  }
928
992
  // Annotate the CommonJS export names for ESM import in node:
929
993
  0 && (module.exports = {
994
+ PrismaConfigEnvError,
930
995
  defaultTestConfig,
931
996
  defineConfig,
997
+ env,
932
998
  loadConfigFromFile,
933
999
  loadConfigFromPackageJson
934
1000
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/config",
3
- "version": "6.18.0-dev.20",
3
+ "version": "6.18.0-dev.22",
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",
@@ -14,13 +14,13 @@
14
14
  "dependencies": {
15
15
  "c12": "3.1.0",
16
16
  "deepmerge-ts": "7.1.5",
17
- "effect": "3.16.12",
17
+ "effect": "3.18.4",
18
18
  "empathic": "2.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "vitest": "3.2.4",
22
- "@prisma/driver-adapter-utils": "6.18.0-dev.20",
23
- "@prisma/get-platform": "6.18.0-dev.20"
22
+ "@prisma/driver-adapter-utils": "6.18.0-dev.22",
23
+ "@prisma/get-platform": "6.18.0-dev.22"
24
24
  },
25
25
  "files": [
26
26
  "dist"