@prisma/config 6.20.0-integration-feat-prisma-7-config.1 → 6.20.0-integration-next.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.
- package/dist/index.d.ts +231 -33
- package/dist/index.js +205 -27
- package/package.json +3 -4
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.
|
|
@@ -85,15 +87,6 @@ declare type ConnectionInfo = {
|
|
|
85
87
|
supportsRelationJoins: boolean;
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
export declare type Datasource = {
|
|
89
|
-
url: string;
|
|
90
|
-
/**
|
|
91
|
-
* @deprecated
|
|
92
|
-
*/
|
|
93
|
-
directUrl?: string;
|
|
94
|
-
shadowDatabaseUrl?: string;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
90
|
/**
|
|
98
91
|
* This default config can be used as basis for unit and integration tests.
|
|
99
92
|
*/
|
|
@@ -126,7 +119,34 @@ declare type EnumsConfigShape = {
|
|
|
126
119
|
|
|
127
120
|
export declare function env<Env extends Record<string, string | undefined>>(name: keyof Env & string): string;
|
|
128
121
|
|
|
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
|
+
|
|
129
145
|
declare type ExperimentalConfig = {
|
|
146
|
+
/**
|
|
147
|
+
* Enable experimental adapter support.
|
|
148
|
+
*/
|
|
149
|
+
adapter?: boolean;
|
|
130
150
|
/**
|
|
131
151
|
* Enable experimental Prisma Studio features.
|
|
132
152
|
*/
|
|
@@ -184,6 +204,116 @@ declare type LoadConfigFromFileInput = {
|
|
|
184
204
|
configRoot?: string;
|
|
185
205
|
};
|
|
186
206
|
|
|
207
|
+
declare type MappedError = {
|
|
208
|
+
kind: 'GenericJs';
|
|
209
|
+
id: number;
|
|
210
|
+
} | {
|
|
211
|
+
kind: 'UnsupportedNativeDataType';
|
|
212
|
+
type: string;
|
|
213
|
+
} | {
|
|
214
|
+
kind: 'InvalidIsolationLevel';
|
|
215
|
+
level: string;
|
|
216
|
+
} | {
|
|
217
|
+
kind: 'LengthMismatch';
|
|
218
|
+
column?: string;
|
|
219
|
+
} | {
|
|
220
|
+
kind: 'UniqueConstraintViolation';
|
|
221
|
+
constraint?: {
|
|
222
|
+
fields: string[];
|
|
223
|
+
} | {
|
|
224
|
+
index: string;
|
|
225
|
+
} | {
|
|
226
|
+
foreignKey: {};
|
|
227
|
+
};
|
|
228
|
+
} | {
|
|
229
|
+
kind: 'NullConstraintViolation';
|
|
230
|
+
constraint?: {
|
|
231
|
+
fields: string[];
|
|
232
|
+
} | {
|
|
233
|
+
index: string;
|
|
234
|
+
} | {
|
|
235
|
+
foreignKey: {};
|
|
236
|
+
};
|
|
237
|
+
} | {
|
|
238
|
+
kind: 'ForeignKeyConstraintViolation';
|
|
239
|
+
constraint?: {
|
|
240
|
+
fields: string[];
|
|
241
|
+
} | {
|
|
242
|
+
index: string;
|
|
243
|
+
} | {
|
|
244
|
+
foreignKey: {};
|
|
245
|
+
};
|
|
246
|
+
} | {
|
|
247
|
+
kind: 'DatabaseNotReachable';
|
|
248
|
+
host?: string;
|
|
249
|
+
port?: number;
|
|
250
|
+
} | {
|
|
251
|
+
kind: 'DatabaseDoesNotExist';
|
|
252
|
+
db?: string;
|
|
253
|
+
} | {
|
|
254
|
+
kind: 'DatabaseAlreadyExists';
|
|
255
|
+
db?: string;
|
|
256
|
+
} | {
|
|
257
|
+
kind: 'DatabaseAccessDenied';
|
|
258
|
+
db?: string;
|
|
259
|
+
} | {
|
|
260
|
+
kind: 'ConnectionClosed';
|
|
261
|
+
} | {
|
|
262
|
+
kind: 'TlsConnectionError';
|
|
263
|
+
reason: string;
|
|
264
|
+
} | {
|
|
265
|
+
kind: 'AuthenticationFailed';
|
|
266
|
+
user?: string;
|
|
267
|
+
} | {
|
|
268
|
+
kind: 'TransactionWriteConflict';
|
|
269
|
+
} | {
|
|
270
|
+
kind: 'TableDoesNotExist';
|
|
271
|
+
table?: string;
|
|
272
|
+
} | {
|
|
273
|
+
kind: 'ColumnNotFound';
|
|
274
|
+
column?: string;
|
|
275
|
+
} | {
|
|
276
|
+
kind: 'TooManyConnections';
|
|
277
|
+
cause: string;
|
|
278
|
+
} | {
|
|
279
|
+
kind: 'ValueOutOfRange';
|
|
280
|
+
cause: string;
|
|
281
|
+
} | {
|
|
282
|
+
kind: 'MissingFullTextSearchIndex';
|
|
283
|
+
} | {
|
|
284
|
+
kind: 'SocketTimeout';
|
|
285
|
+
} | {
|
|
286
|
+
kind: 'InconsistentColumnData';
|
|
287
|
+
cause: string;
|
|
288
|
+
} | {
|
|
289
|
+
kind: 'TransactionAlreadyClosed';
|
|
290
|
+
cause: string;
|
|
291
|
+
} | {
|
|
292
|
+
kind: 'postgres';
|
|
293
|
+
code: string;
|
|
294
|
+
severity: string;
|
|
295
|
+
message: string;
|
|
296
|
+
detail: string | undefined;
|
|
297
|
+
column: string | undefined;
|
|
298
|
+
hint: string | undefined;
|
|
299
|
+
} | {
|
|
300
|
+
kind: 'mysql';
|
|
301
|
+
code: number;
|
|
302
|
+
message: string;
|
|
303
|
+
state: string;
|
|
304
|
+
} | {
|
|
305
|
+
kind: 'sqlite';
|
|
306
|
+
/**
|
|
307
|
+
* Sqlite extended error code: https://www.sqlite.org/rescode.html
|
|
308
|
+
*/
|
|
309
|
+
extendedCode: number;
|
|
310
|
+
message: string;
|
|
311
|
+
} | {
|
|
312
|
+
kind: 'mssql';
|
|
313
|
+
code: number;
|
|
314
|
+
message: string;
|
|
315
|
+
};
|
|
316
|
+
|
|
187
317
|
declare type MigrationsConfigShape = {
|
|
188
318
|
/**
|
|
189
319
|
* The path to the directory where Prisma should store migration files, and look for them.
|
|
@@ -208,11 +338,37 @@ declare const PRISMA_CONFIG_INTERNAL_BRAND: unique symbol;
|
|
|
208
338
|
* The configuration for the Prisma Development Kit, before it is passed to the `defineConfig` function.
|
|
209
339
|
* Thanks to the branding, this type is opaque and cannot be constructed directly.
|
|
210
340
|
*/
|
|
211
|
-
export declare type PrismaConfig =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
341
|
+
export declare type PrismaConfig = PrismaConfigUnconditional & SchemaEngineConfig;
|
|
342
|
+
|
|
343
|
+
export declare class PrismaConfigEnvError extends Error {
|
|
344
|
+
constructor(name: string);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The configuration for the Prisma Development Kit, after it has been parsed and processed
|
|
349
|
+
* by the `defineConfig` function.
|
|
350
|
+
* Thanks to the branding, this type is opaque and cannot be constructed directly.
|
|
351
|
+
*/
|
|
352
|
+
export declare type PrismaConfigInternal = _PrismaConfigInternal & {
|
|
353
|
+
__brand: typeof PRISMA_CONFIG_INTERNAL_BRAND;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
declare type _PrismaConfigInternal = Omit<PrismaConfig, 'engine' | 'datasource' | 'adapter'> & {
|
|
357
|
+
loadedFromFile: string | null;
|
|
358
|
+
} & ({
|
|
359
|
+
engine: 'classic';
|
|
360
|
+
datasource: {
|
|
361
|
+
url: string;
|
|
362
|
+
shadowDatabaseUrl?: string;
|
|
363
|
+
};
|
|
364
|
+
} | {
|
|
365
|
+
engine: 'js';
|
|
366
|
+
adapter: () => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>;
|
|
367
|
+
} | {
|
|
368
|
+
engine?: never;
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
declare type PrismaConfigUnconditional = {
|
|
216
372
|
/**
|
|
217
373
|
* Experimental feature gates. Each experimental feature must be explicitly enabled.
|
|
218
374
|
*/
|
|
@@ -247,23 +403,6 @@ export declare type PrismaConfig = {
|
|
|
247
403
|
typedSql?: Simplify<TypedSqlConfigShape>;
|
|
248
404
|
};
|
|
249
405
|
|
|
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
|
-
|
|
267
406
|
declare type PrismaStudioConfigShape = {
|
|
268
407
|
adapter: () => Promise<SqlMigrationAwareDriverAdapterFactory>;
|
|
269
408
|
};
|
|
@@ -281,10 +420,69 @@ declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
|
281
420
|
executeRaw(params: Query): Promise<number>;
|
|
282
421
|
}
|
|
283
422
|
|
|
284
|
-
|
|
285
|
-
|
|
423
|
+
declare type Result<T> = {
|
|
424
|
+
map<U>(fn: (value: T) => U): Result<U>;
|
|
425
|
+
flatMap<U>(fn: (value: T) => Result<U>): Result<U>;
|
|
426
|
+
} & ({
|
|
427
|
+
readonly ok: true;
|
|
428
|
+
readonly value: T;
|
|
429
|
+
} | {
|
|
430
|
+
readonly ok: false;
|
|
431
|
+
readonly error: Error_2;
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
declare type SchemaEngineConfig = SchemaEngineConfigJs | SchemaEngineConfigClassic | SchemaEngineConfigAbsent;
|
|
435
|
+
|
|
436
|
+
declare type SchemaEngineConfigAbsent = {
|
|
437
|
+
engine?: never;
|
|
286
438
|
};
|
|
287
439
|
|
|
440
|
+
declare type SchemaEngineConfigClassic = {
|
|
441
|
+
/**
|
|
442
|
+
* Uses the "old classic" Schema Engine binary
|
|
443
|
+
*/
|
|
444
|
+
engine: 'classic';
|
|
445
|
+
/**
|
|
446
|
+
* The database connection configuration, which overwrites the `datasource` block's `url`-like attributes in the Prisma schema file.
|
|
447
|
+
*/
|
|
448
|
+
datasource: SchemaEngineConfigClassicDatasource;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
export declare type SchemaEngineConfigClassicDatasource = {
|
|
452
|
+
url: string;
|
|
453
|
+
directUrl?: string;
|
|
454
|
+
shadowDatabaseUrl?: string;
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
export declare type SchemaEngineConfigInternal = SchemaEngineConfigJsInternal | SchemaEngineConfigClassic | SchemaEngineConfigAbsent;
|
|
458
|
+
|
|
459
|
+
declare type SchemaEngineConfigJs = {
|
|
460
|
+
/**
|
|
461
|
+
* Uses the new, unstable JavaScript based Schema Engine.
|
|
462
|
+
*/
|
|
463
|
+
engine: 'js';
|
|
464
|
+
/**
|
|
465
|
+
* The function that instantiates the driver adapter to use for the JavaScript based Schema Engine.
|
|
466
|
+
*/
|
|
467
|
+
adapter: () => Promise<SqlMigrationAwareDriverAdapterFactory>;
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
declare type SchemaEngineConfigJsInternal = {
|
|
471
|
+
/**
|
|
472
|
+
* Uses the new, unstable JavaScript based Schema Engine.
|
|
473
|
+
*/
|
|
474
|
+
engine: 'js';
|
|
475
|
+
/**
|
|
476
|
+
* The function that instantiates the driver adapter to use for the JavaScript based Schema Engine.
|
|
477
|
+
*/
|
|
478
|
+
adapter: () => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
declare const SchemaEngineConfigJsInternal: Schema.Struct<{
|
|
482
|
+
engine: Schema.Literal<["js"]>;
|
|
483
|
+
adapter: Schema.declare<() => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>, () => Promise<ErrorCapturingSqlMigrationAwareDriverAdapterFactory>, readonly [], never>;
|
|
484
|
+
}>;
|
|
485
|
+
|
|
288
486
|
/**
|
|
289
487
|
* Simplifies the type signature of a type.
|
|
290
488
|
* Re-exported from `effect/Types`.
|
package/dist/index.js
CHANGED
|
@@ -225,7 +225,129 @@ function safeStringify(value, indent = 2) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
// ../driver-adapter-utils/dist/index.mjs
|
|
228
|
+
function isDriverAdapterError(error) {
|
|
229
|
+
return error["name"] === "DriverAdapterError" && typeof error["cause"] === "object";
|
|
230
|
+
}
|
|
231
|
+
function ok(value) {
|
|
232
|
+
return {
|
|
233
|
+
ok: true,
|
|
234
|
+
value,
|
|
235
|
+
map(fn) {
|
|
236
|
+
return ok(fn(value));
|
|
237
|
+
},
|
|
238
|
+
flatMap(fn) {
|
|
239
|
+
return fn(value);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function err(error) {
|
|
244
|
+
return {
|
|
245
|
+
ok: false,
|
|
246
|
+
error,
|
|
247
|
+
map() {
|
|
248
|
+
return err(error);
|
|
249
|
+
},
|
|
250
|
+
flatMap() {
|
|
251
|
+
return err(error);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
228
255
|
var debug = Debug("driver-adapter-utils");
|
|
256
|
+
var ErrorRegistryInternal = class {
|
|
257
|
+
registeredErrors = [];
|
|
258
|
+
consumeError(id) {
|
|
259
|
+
return this.registeredErrors[id];
|
|
260
|
+
}
|
|
261
|
+
registerNewError(error) {
|
|
262
|
+
let i = 0;
|
|
263
|
+
while (this.registeredErrors[i] !== void 0) {
|
|
264
|
+
i++;
|
|
265
|
+
}
|
|
266
|
+
this.registeredErrors[i] = { error };
|
|
267
|
+
return i;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
function copySymbolsFromSource(source, target) {
|
|
271
|
+
const symbols = Object.getOwnPropertySymbols(source);
|
|
272
|
+
const symbolObject = Object.fromEntries(symbols.map((symbol) => [symbol, true]));
|
|
273
|
+
Object.assign(target, symbolObject);
|
|
274
|
+
}
|
|
275
|
+
var bindMigrationAwareSqlAdapterFactory = (adapterFactory) => {
|
|
276
|
+
const errorRegistry = new ErrorRegistryInternal();
|
|
277
|
+
const boundFactory = {
|
|
278
|
+
adapterName: adapterFactory.adapterName,
|
|
279
|
+
provider: adapterFactory.provider,
|
|
280
|
+
errorRegistry,
|
|
281
|
+
connect: async (...args) => {
|
|
282
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args);
|
|
283
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
284
|
+
},
|
|
285
|
+
connectToShadowDb: async (...args) => {
|
|
286
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connectToShadowDb.bind(adapterFactory))(...args);
|
|
287
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
copySymbolsFromSource(adapterFactory, boundFactory);
|
|
291
|
+
return boundFactory;
|
|
292
|
+
};
|
|
293
|
+
var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal()) => {
|
|
294
|
+
const boundAdapter = {
|
|
295
|
+
adapterName: adapter.adapterName,
|
|
296
|
+
errorRegistry,
|
|
297
|
+
queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)),
|
|
298
|
+
executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)),
|
|
299
|
+
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
300
|
+
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
301
|
+
provider: adapter.provider,
|
|
302
|
+
startTransaction: async (...args) => {
|
|
303
|
+
const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args);
|
|
304
|
+
return ctx.map((ctx2) => bindTransaction(errorRegistry, ctx2));
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
if (adapter.getConnectionInfo) {
|
|
308
|
+
boundAdapter.getConnectionInfo = wrapSync(errorRegistry, adapter.getConnectionInfo.bind(adapter));
|
|
309
|
+
}
|
|
310
|
+
return boundAdapter;
|
|
311
|
+
};
|
|
312
|
+
var bindTransaction = (errorRegistry, transaction) => {
|
|
313
|
+
return {
|
|
314
|
+
adapterName: transaction.adapterName,
|
|
315
|
+
provider: transaction.provider,
|
|
316
|
+
options: transaction.options,
|
|
317
|
+
queryRaw: wrapAsync(errorRegistry, transaction.queryRaw.bind(transaction)),
|
|
318
|
+
executeRaw: wrapAsync(errorRegistry, transaction.executeRaw.bind(transaction)),
|
|
319
|
+
commit: wrapAsync(errorRegistry, transaction.commit.bind(transaction)),
|
|
320
|
+
rollback: wrapAsync(errorRegistry, transaction.rollback.bind(transaction))
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
function wrapAsync(registry, fn) {
|
|
324
|
+
return async (...args) => {
|
|
325
|
+
try {
|
|
326
|
+
return ok(await fn(...args));
|
|
327
|
+
} catch (error) {
|
|
328
|
+
debug("[error@wrapAsync]", error);
|
|
329
|
+
if (isDriverAdapterError(error)) {
|
|
330
|
+
return err(error.cause);
|
|
331
|
+
}
|
|
332
|
+
const id = registry.registerNewError(error);
|
|
333
|
+
return err({ kind: "GenericJs", id });
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function wrapSync(registry, fn) {
|
|
338
|
+
return (...args) => {
|
|
339
|
+
try {
|
|
340
|
+
return ok(fn(...args));
|
|
341
|
+
} catch (error) {
|
|
342
|
+
debug("[error@wrapSync]", error);
|
|
343
|
+
if (isDriverAdapterError(error)) {
|
|
344
|
+
return err(error.cause);
|
|
345
|
+
}
|
|
346
|
+
const id = registry.registerNewError(error);
|
|
347
|
+
return err({ kind: "GenericJs", id });
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}
|
|
229
351
|
var mockAdapterErrors = {
|
|
230
352
|
queryRaw: new Error("Not implemented: queryRaw"),
|
|
231
353
|
executeRaw: new Error("Not implemented: executeRaw"),
|
|
@@ -244,16 +366,18 @@ var import_effect = require("effect");
|
|
|
244
366
|
// src/defaultConfig.ts
|
|
245
367
|
function defaultConfig() {
|
|
246
368
|
return makePrismaConfigInternal({
|
|
247
|
-
loadedFromFile: null
|
|
248
|
-
datasource: {
|
|
249
|
-
url: "<default_datasource_url>"
|
|
250
|
-
}
|
|
369
|
+
loadedFromFile: null
|
|
251
370
|
});
|
|
252
371
|
}
|
|
253
372
|
|
|
254
373
|
// src/defineConfig.ts
|
|
255
374
|
function validateExperimentalFeatures(config) {
|
|
256
375
|
const experimental = config.experimental || {};
|
|
376
|
+
if (config.engine === "js" && !experimental.adapter) {
|
|
377
|
+
return import_effect.Either.left(
|
|
378
|
+
new Error('The `engine === "js"` configuration requires `experimental.adapter` to be set to `true`.')
|
|
379
|
+
);
|
|
380
|
+
}
|
|
257
381
|
if (config.studio && !experimental.studio) {
|
|
258
382
|
return import_effect.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
|
|
259
383
|
}
|
|
@@ -286,7 +410,7 @@ function defineConfig(configInput) {
|
|
|
286
410
|
debug2("[default]: %o", config);
|
|
287
411
|
defineExperimentalConfig(config, configInput);
|
|
288
412
|
defineSchemaConfig(config, configInput);
|
|
289
|
-
|
|
413
|
+
defineEngineConfig(config, configInput);
|
|
290
414
|
defineStudioConfig(config, configInput);
|
|
291
415
|
defineMigrationsConfig(config, configInput);
|
|
292
416
|
defineTablesConfig(config, configInput);
|
|
@@ -359,10 +483,25 @@ function defineStudioConfig(config, configInput) {
|
|
|
359
483
|
};
|
|
360
484
|
debug2("[config.studio]: %o", config.studio);
|
|
361
485
|
}
|
|
362
|
-
function
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
486
|
+
function defineEngineConfig(config, configInput) {
|
|
487
|
+
if (configInput.engine === void 0) {
|
|
488
|
+
return;
|
|
489
|
+
} else if (configInput.engine === "js") {
|
|
490
|
+
const { engine, adapter: getAdapterFactory } = configInput;
|
|
491
|
+
const adapter = async () => {
|
|
492
|
+
const adapterFactory = await getAdapterFactory();
|
|
493
|
+
debug2("[config.adapter]: %o", adapterFactory.adapterName);
|
|
494
|
+
return bindMigrationAwareSqlAdapterFactory(adapterFactory);
|
|
495
|
+
};
|
|
496
|
+
Object.assign(config, { engine, adapter });
|
|
497
|
+
debug2("[config.engine]: %o", engine);
|
|
498
|
+
debug2("[config.adapter]: %o", adapter);
|
|
499
|
+
} else if (configInput.engine === "classic") {
|
|
500
|
+
const { engine, datasource } = configInput;
|
|
501
|
+
Object.assign(config, { engine, datasource });
|
|
502
|
+
debug2("[config.engine]: %o", engine);
|
|
503
|
+
debug2("[config.datasource]: %o", datasource);
|
|
504
|
+
}
|
|
366
505
|
}
|
|
367
506
|
function defineExtensionsConfig(config, configInput) {
|
|
368
507
|
if (!configInput["extensions"]) {
|
|
@@ -384,15 +523,47 @@ var SqlMigrationAwareDriverAdapterFactoryShape = import_effect2.Schema.declare(
|
|
|
384
523
|
decode: import_effect2.identity
|
|
385
524
|
}
|
|
386
525
|
);
|
|
387
|
-
var
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
526
|
+
var ErrorCapturingSqlMigrationAwareDriverAdapterFactoryShape = import_effect2.Schema.declare(
|
|
527
|
+
(input) => {
|
|
528
|
+
return typeof input === "function";
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
identifier: "ErrorCapturingSqlMigrationAwareDriverAdapterFactory",
|
|
532
|
+
encode: import_effect2.identity,
|
|
533
|
+
decode: import_effect2.identity
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
var SchemaEngineConfigClassicShape = import_effect2.Schema.Struct({
|
|
537
|
+
engine: import_effect2.Schema.Literal("classic"),
|
|
538
|
+
datasource: import_effect2.Schema.Struct({
|
|
539
|
+
url: import_effect2.Schema.String,
|
|
540
|
+
directUrl: import_effect2.Schema.optional(import_effect2.Schema.String),
|
|
541
|
+
shadowDatabaseUrl: import_effect2.Schema.optional(import_effect2.Schema.String)
|
|
542
|
+
})
|
|
543
|
+
});
|
|
544
|
+
var SchemaEngineConfigJsShape = import_effect2.Schema.Struct({
|
|
545
|
+
engine: import_effect2.Schema.Literal("js"),
|
|
546
|
+
adapter: SqlMigrationAwareDriverAdapterFactoryShape
|
|
547
|
+
});
|
|
548
|
+
var SchemaEngineConfigAbsentShape = import_effect2.Schema.Struct({
|
|
549
|
+
engine: import_effect2.Schema.optional(import_effect2.Schema.Never)
|
|
550
|
+
});
|
|
551
|
+
var SchemaEngineConfigShape = import_effect2.Schema.Union(
|
|
552
|
+
SchemaEngineConfigClassicShape,
|
|
553
|
+
SchemaEngineConfigJsShape,
|
|
554
|
+
SchemaEngineConfigAbsentShape
|
|
555
|
+
);
|
|
556
|
+
var SchemaEngineConfigJsInternal = import_effect2.Schema.Struct({
|
|
557
|
+
engine: import_effect2.Schema.Literal("js"),
|
|
558
|
+
adapter: ErrorCapturingSqlMigrationAwareDriverAdapterFactoryShape
|
|
394
559
|
});
|
|
560
|
+
var SchemaEngineConfigInternal = import_effect2.Schema.Union(
|
|
561
|
+
SchemaEngineConfigClassicShape,
|
|
562
|
+
SchemaEngineConfigJsInternal,
|
|
563
|
+
SchemaEngineConfigAbsentShape
|
|
564
|
+
);
|
|
395
565
|
var ExperimentalConfigShape = import_effect2.Schema.Struct({
|
|
566
|
+
adapter: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
|
|
396
567
|
studio: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
|
|
397
568
|
externalTables: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
|
|
398
569
|
extensions: import_effect2.Schema.optional(import_effect2.Schema.Boolean)
|
|
@@ -452,8 +623,7 @@ if (false) {
|
|
|
452
623
|
__testPrismaConfig;
|
|
453
624
|
__testPrismaConfigInternal;
|
|
454
625
|
}
|
|
455
|
-
var
|
|
456
|
-
datasource: DatasourceShape,
|
|
626
|
+
var PrismaConfigUnconditionalShape = import_effect2.Schema.Struct({
|
|
457
627
|
experimental: import_effect2.Schema.optional(ExperimentalConfigShape),
|
|
458
628
|
schema: import_effect2.Schema.optional(import_effect2.Schema.String),
|
|
459
629
|
studio: import_effect2.Schema.optional(PrismaStudioConfigShape),
|
|
@@ -464,12 +634,18 @@ var PrismaConfigShape = import_effect2.Schema.Struct({
|
|
|
464
634
|
typedSql: import_effect2.Schema.optional(TypedSqlConfigShape),
|
|
465
635
|
extensions: import_effect2.Schema.optional(import_effect2.Schema.Any)
|
|
466
636
|
});
|
|
637
|
+
var PrismaConfigShape = import_effect2.Schema.extend(SchemaEngineConfigShape, PrismaConfigUnconditionalShape);
|
|
467
638
|
if (false) {
|
|
468
639
|
__testPrismaConfigValueA;
|
|
469
640
|
__testPrismaConfigValueB;
|
|
470
641
|
}
|
|
471
642
|
function validateExperimentalFeatures2(config) {
|
|
472
643
|
const experimental = config.experimental || {};
|
|
644
|
+
if (config.engine === "js" && !experimental.adapter) {
|
|
645
|
+
return import_effect2.Either.left(
|
|
646
|
+
new Error("The `engine === 'js'` configuration requires `experimental.adapter` to be set to `true`.")
|
|
647
|
+
);
|
|
648
|
+
}
|
|
473
649
|
if (config.studio && !experimental.studio) {
|
|
474
650
|
return import_effect2.Either.left(new Error("The `studio` configuration requires `experimental.studio` to be set to `true`."));
|
|
475
651
|
}
|
|
@@ -506,10 +682,15 @@ function parsePrismaConfigShape(input) {
|
|
|
506
682
|
);
|
|
507
683
|
}
|
|
508
684
|
var PRISMA_CONFIG_INTERNAL_BRAND = Symbol.for("PrismaConfigInternal");
|
|
509
|
-
var PrismaConfigInternalShape = import_effect2.Schema.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
685
|
+
var PrismaConfigInternalShape = import_effect2.Schema.extend(
|
|
686
|
+
PrismaConfigUnconditionalShape,
|
|
687
|
+
import_effect2.Schema.extend(
|
|
688
|
+
SchemaEngineConfigInternal,
|
|
689
|
+
import_effect2.Schema.Struct({
|
|
690
|
+
loadedFromFile: import_effect2.Schema.NullOr(import_effect2.Schema.String)
|
|
691
|
+
})
|
|
692
|
+
)
|
|
693
|
+
);
|
|
513
694
|
function brandPrismaConfigInternal(config) {
|
|
514
695
|
Object.defineProperty(config, "__brand", {
|
|
515
696
|
value: PRISMA_CONFIG_INTERNAL_BRAND,
|
|
@@ -539,7 +720,7 @@ function parsePrismaConfigInternalShape(input) {
|
|
|
539
720
|
);
|
|
540
721
|
}
|
|
541
722
|
function makePrismaConfigInternal(makeArgs) {
|
|
542
|
-
return (
|
|
723
|
+
return brandPrismaConfigInternal(makeArgs);
|
|
543
724
|
}
|
|
544
725
|
function parseDefaultExport(defaultExport) {
|
|
545
726
|
const parseResultEither = (0, import_Function.pipe)(
|
|
@@ -561,10 +742,7 @@ function parseDefaultExport(defaultExport) {
|
|
|
561
742
|
// src/defaultTestConfig.ts
|
|
562
743
|
function defaultTestConfig() {
|
|
563
744
|
return makePrismaConfigInternal({
|
|
564
|
-
loadedFromFile: null
|
|
565
|
-
datasource: {
|
|
566
|
-
url: "<default_datasource_url>"
|
|
567
|
-
}
|
|
745
|
+
loadedFromFile: null
|
|
568
746
|
});
|
|
569
747
|
}
|
|
570
748
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/config",
|
|
3
|
-
"version": "6.20.0-integration-
|
|
3
|
+
"version": "6.20.0-integration-next.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,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/driver-adapter-utils": "6.20.0-integration-
|
|
24
|
-
"@prisma/get-platform": "6.20.0-integration-
|
|
22
|
+
"@prisma/driver-adapter-utils": "6.20.0-integration-next.3",
|
|
23
|
+
"@prisma/get-platform": "6.20.0-integration-next.3"
|
|
25
24
|
},
|
|
26
25
|
"files": [
|
|
27
26
|
"dist"
|