@prisma/config 6.13.0-dev.1 → 6.13.0-dev.11

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
@@ -221,12 +221,15 @@ declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABL
221
221
  export declare function loadConfigFromFile({ configFile, configRoot, }: LoadConfigFromFileInput): Promise<ConfigFromFile>;
222
222
 
223
223
  export declare type LoadConfigFromFileError = {
224
+ /**
225
+ * The config file was not found at the specified path.
226
+ */
224
227
  _tag: 'ConfigFileNotFound';
225
228
  } | {
226
- _tag: 'TypeScriptImportFailed';
229
+ _tag: 'ConfigLoadError';
227
230
  error: Error;
228
231
  } | {
229
- _tag: 'ConfigFileParseError';
232
+ _tag: 'ConfigFileSyntaxError';
230
233
  error: Error;
231
234
  } | {
232
235
  _tag: 'UnknownError';
@@ -280,6 +283,10 @@ export declare type PrismaConfig = {
280
283
  * Configuration for Prisma migrations.
281
284
  */
282
285
  migrations?: Simplify<MigrationsConfigShape>;
286
+ /**
287
+ * Configuration for the database table entities.
288
+ */
289
+ tables?: Simplify<TablesConfigShape>;
283
290
  /**
284
291
  * Configuration for the database view entities.
285
292
  */
@@ -414,6 +421,15 @@ declare interface SqlResultSet {
414
421
  lastInsertId?: string;
415
422
  }
416
423
 
424
+ declare type TablesConfigShape = {
425
+ /**
426
+ * List of tables that are externally managed.
427
+ * Prisma will not modify the structure of these tables and not generate migrations for those tables.
428
+ * These tables will still be represented in schema.prisma file and be available in the client API.
429
+ */
430
+ external?: string[];
431
+ };
432
+
417
433
  declare interface Transaction extends AdapterInfo, SqlQueryable {
418
434
  /**
419
435
  * Transaction options.
package/dist/index.js CHANGED
@@ -22774,6 +22774,7 @@ function defineConfig(configInput) {
22774
22774
  defineAdapterConfig(config2, configInput);
22775
22775
  defineStudioConfig(config2, configInput);
22776
22776
  defineMigrationsConfig(config2, configInput);
22777
+ defineTablesConfig(config2, configInput);
22777
22778
  defineTypedSqlConfig(config2, configInput);
22778
22779
  defineViewsConfig(config2, configInput);
22779
22780
  return config2;
@@ -22806,6 +22807,13 @@ function defineViewsConfig(config2, configInput) {
22806
22807
  config2.views = configInput.views;
22807
22808
  debug2("[config.views]: %o", config2.views);
22808
22809
  }
22810
+ function defineTablesConfig(config2, configInput) {
22811
+ if (!configInput.tables) {
22812
+ return;
22813
+ }
22814
+ config2.tables = configInput.tables;
22815
+ debug2("[config.tables]: %o", config2.tables);
22816
+ }
22809
22817
  function defineStudioConfig(config2, configInput) {
22810
22818
  if (!configInput.studio?.adapter) {
22811
22819
  return;
@@ -22862,6 +22870,13 @@ if (false) {
22862
22870
  __testMigrationsConfigShapeValueA;
22863
22871
  __testMigrationsConfigShapeValueB;
22864
22872
  }
22873
+ var TablesConfigShape = Schema_exports.Struct({
22874
+ external: Schema_exports.optional(Schema_exports.mutable(Schema_exports.Array(Schema_exports.String)))
22875
+ });
22876
+ if (false) {
22877
+ __testTablesConfigShapeValueA;
22878
+ __testTablesConfigShapeValueB;
22879
+ }
22865
22880
  var ViewsConfigShape = Schema_exports.Struct({
22866
22881
  path: Schema_exports.optional(Schema_exports.String)
22867
22882
  });
@@ -22896,6 +22911,7 @@ var PrismaConfigShape = Schema_exports.Struct({
22896
22911
  studio: Schema_exports.optional(PrismaStudioConfigShape),
22897
22912
  adapter: Schema_exports.optional(SqlMigrationAwareDriverAdapterFactoryShape),
22898
22913
  migrations: Schema_exports.optional(MigrationsConfigShape),
22914
+ tables: Schema_exports.optional(TablesConfigShape),
22899
22915
  views: Schema_exports.optional(ViewsConfigShape),
22900
22916
  typedSql: Schema_exports.optional(TypedSqlConfigShape)
22901
22917
  });
@@ -22975,33 +22991,18 @@ function defaultTestConfig() {
22975
22991
  }
22976
22992
 
22977
22993
  // src/loadConfigFromFile.ts
22978
- var import_node_fs = __toESM(require("node:fs"));
22979
22994
  var import_node_path = __toESM(require("node:path"));
22980
22995
  var import_node_process = __toESM(require("node:process"));
22981
- var import_jiti = require("jiti");
22982
22996
  var debug4 = Debug("prisma:config:loadConfigFromFile");
22997
+ var SUPPORTED_EXTENSIONS = [".js", ".ts", ".mjs", ".cjs", ".mts", ".cts"];
22983
22998
  async function loadConfigFromFile({
22984
22999
  configFile,
22985
23000
  configRoot = import_node_process.default.cwd()
22986
23001
  }) {
22987
23002
  const start = performance.now();
22988
23003
  const getTime = () => `${(performance.now() - start).toFixed(2)}ms`;
22989
- let resolvedPath;
22990
- if (configFile) {
22991
- resolvedPath = import_node_path.default.resolve(configRoot, configFile);
22992
- if (!import_node_fs.default.existsSync(resolvedPath)) {
22993
- debug4(`The given config file was not found at %s`, resolvedPath);
22994
- return { resolvedPath, error: { _tag: "ConfigFileNotFound" } };
22995
- }
22996
- } else {
22997
- resolvedPath = ["prisma.config.ts"].map((file) => import_node_path.default.resolve(configRoot, file)).find((file) => import_node_fs.default.existsSync(file)) ?? null;
22998
- if (resolvedPath === null) {
22999
- debug4(`No config file found in the current working directory %s`, configRoot);
23000
- return { resolvedPath, config: defaultConfig() };
23001
- }
23002
- }
23003
23004
  try {
23004
- const { required: required3, error } = await requireTypeScriptFile(resolvedPath);
23005
+ const { configModule, resolvedPath, error } = await loadConfigTsOrJs(configRoot, configFile);
23005
23006
  if (error) {
23006
23007
  return {
23007
23008
  resolvedPath,
@@ -23009,22 +23010,26 @@ async function loadConfigFromFile({
23009
23010
  };
23010
23011
  }
23011
23012
  debug4(`Config file loaded in %s`, getTime());
23012
- let defaultExport;
23013
+ if (resolvedPath === null) {
23014
+ debug4(`No config file found in the current working directory %s`, configRoot);
23015
+ return { resolvedPath: null, config: defaultConfig() };
23016
+ }
23017
+ let parsedConfig;
23013
23018
  try {
23014
- defaultExport = parseDefaultExport(required3["default"]);
23019
+ parsedConfig = parseDefaultExport(configModule);
23015
23020
  } catch (e) {
23016
23021
  const error2 = e;
23017
23022
  return {
23018
23023
  resolvedPath,
23019
23024
  error: {
23020
- _tag: "ConfigFileParseError",
23025
+ _tag: "ConfigFileSyntaxError",
23021
23026
  error: error2
23022
23027
  }
23023
23028
  };
23024
23029
  }
23025
23030
  import_node_process.default.stdout.write(`Loaded Prisma config from "${resolvedPath}".
23026
23031
  `);
23027
- const prismaConfig = transformPathsInConfigToAbsolute(defaultExport, resolvedPath);
23032
+ const prismaConfig = transformPathsInConfigToAbsolute(parsedConfig, resolvedPath);
23028
23033
  return {
23029
23034
  config: {
23030
23035
  ...prismaConfig,
@@ -23035,7 +23040,7 @@ async function loadConfigFromFile({
23035
23040
  } catch (e) {
23036
23041
  const error = e;
23037
23042
  return {
23038
- resolvedPath,
23043
+ resolvedPath: configRoot,
23039
23044
  error: {
23040
23045
  _tag: "UnknownError",
23041
23046
  error
@@ -23043,25 +23048,79 @@ async function loadConfigFromFile({
23043
23048
  };
23044
23049
  }
23045
23050
  }
23046
- async function requireTypeScriptFile(resolvedPath) {
23051
+ async function loadConfigTsOrJs(configRoot, configFile) {
23052
+ const { loadConfig: loadConfigWithC12 } = await import("c12");
23053
+ const { deepmerge } = await import("deepmerge-ts");
23047
23054
  try {
23048
- const jiti = (0, import_jiti.createJiti)(__filename, {
23049
- interopDefault: true,
23050
- moduleCache: false
23055
+ const {
23056
+ config: config2,
23057
+ configFile: _resolvedPath,
23058
+ meta
23059
+ } = await loadConfigWithC12({
23060
+ cwd: configRoot,
23061
+ // configuration base name
23062
+ name: "prisma",
23063
+ // the config file to load (without file extensions), defaulting to `${cwd}.${name}`
23064
+ configFile,
23065
+ // do not load .env files
23066
+ dotenv: false,
23067
+ // do not load RC config
23068
+ rcFile: false,
23069
+ // do not extend remote config files
23070
+ giget: false,
23071
+ // do not extend the default config
23072
+ extend: false,
23073
+ // do not load from nearest package.json
23074
+ packageJson: false,
23075
+ // @ts-expect-error: this is a type-error in `c12` itself
23076
+ merger: deepmerge,
23077
+ jitiOptions: {
23078
+ interopDefault: true,
23079
+ moduleCache: false,
23080
+ extensions: SUPPORTED_EXTENSIONS
23081
+ }
23051
23082
  });
23052
- const configExport = await jiti.import(resolvedPath);
23083
+ const resolvedPath = _resolvedPath ? import_node_path.default.normalize(_resolvedPath) : void 0;
23084
+ const doesConfigFileExist = resolvedPath !== void 0 && meta !== void 0;
23085
+ if (configFile && !doesConfigFileExist) {
23086
+ debug4(`The given config file was not found at %s`, resolvedPath);
23087
+ return {
23088
+ require: null,
23089
+ resolvedPath: import_node_path.default.join(configRoot, configFile),
23090
+ error: { _tag: "ConfigFileNotFound" }
23091
+ };
23092
+ }
23093
+ if (doesConfigFileExist) {
23094
+ const extension = import_node_path.default.extname(import_node_path.default.basename(resolvedPath));
23095
+ if (!SUPPORTED_EXTENSIONS.includes(extension)) {
23096
+ return {
23097
+ configModule: config2,
23098
+ resolvedPath,
23099
+ error: {
23100
+ _tag: "ConfigLoadError",
23101
+ error: new Error(`Unsupported Prisma config file extension: ${extension}`)
23102
+ }
23103
+ };
23104
+ }
23105
+ }
23053
23106
  return {
23054
- required: configExport,
23107
+ configModule: config2,
23108
+ resolvedPath: doesConfigFileExist ? resolvedPath : null,
23055
23109
  error: null
23056
23110
  };
23057
23111
  } catch (e) {
23058
23112
  const error = e;
23059
23113
  debug4("jiti import failed: %s", error.message);
23114
+ const configFileMatch = error.message.match(/prisma\.config\.(\w+)/);
23115
+ const extension = configFileMatch?.[1];
23116
+ const filenameWithExtension = import_node_path.default.join(configRoot, extension ? `prisma.config.${extension}` : "");
23117
+ debug4("faulty config file: %s", filenameWithExtension);
23060
23118
  return {
23061
23119
  error: {
23062
- _tag: "TypeScriptImportFailed",
23120
+ _tag: "ConfigLoadError",
23063
23121
  error
23064
- }
23122
+ },
23123
+ resolvedPath: filenameWithExtension
23065
23124
  };
23066
23125
  }
23067
23126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/config",
3
- "version": "6.13.0-dev.1",
3
+ "version": "6.13.0-dev.11",
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",
@@ -12,17 +12,14 @@
12
12
  "license": "Apache-2.0",
13
13
  "author": "Alberto Schiabel <schiabel@prisma.io>",
14
14
  "dependencies": {
15
- "jiti": "2.4.2"
15
+ "c12": "3.1.0",
16
+ "deepmerge-ts": "7.1.5"
16
17
  },
17
18
  "devDependencies": {
18
- "@swc/core": "1.11.5",
19
- "@swc/jest": "0.2.37",
20
- "cross-env": "7.0.3",
21
19
  "effect": "3.16.12",
22
- "jest": "29.7.0",
23
- "jest-junit": "16.0.0",
24
- "@prisma/get-platform": "6.13.0-dev.1",
25
- "@prisma/driver-adapter-utils": "6.13.0-dev.1"
20
+ "vitest": "3.2.4",
21
+ "@prisma/driver-adapter-utils": "6.13.0-dev.11",
22
+ "@prisma/get-platform": "6.13.0-dev.11"
26
23
  },
27
24
  "files": [
28
25
  "dist"
@@ -31,6 +28,6 @@
31
28
  "scripts": {
32
29
  "dev": "DEV=true tsx helpers/build.ts",
33
30
  "build": "tsx helpers/build.ts",
34
- "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest"
31
+ "test": "vitest run"
35
32
  }
36
33
  }