@riordanpawley/effect-prisma-generator 0.6.8 → 1.0.0
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.js +81 -91
- package/package.json +3 -5
package/dist/index.js
CHANGED
|
@@ -220,71 +220,71 @@ function generatePrismaInterface(models, customError) {
|
|
|
220
220
|
return ` ${modelNameCamel}: {
|
|
221
221
|
findUnique: <A extends ${argsType("findUnique")}>(
|
|
222
222
|
args: A
|
|
223
|
-
) =>
|
|
223
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'findUnique'> | null, ${errorTypeFor("findUnique")}>
|
|
224
224
|
|
|
225
225
|
findUniqueOrThrow: <A extends ${argsType("findUniqueOrThrow")}>(
|
|
226
226
|
args: A
|
|
227
|
-
) =>
|
|
227
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'findUniqueOrThrow'>, ${errorTypeFor("findUniqueOrThrow")}>
|
|
228
228
|
|
|
229
229
|
findFirst: <A extends ${argsType("findFirst")}>(
|
|
230
230
|
args: A
|
|
231
|
-
) =>
|
|
231
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'findFirst'> | null, ${errorTypeFor("findFirst")}>
|
|
232
232
|
|
|
233
233
|
findFirstOrThrow: <A extends ${argsType("findFirstOrThrow")}>(
|
|
234
234
|
args: A
|
|
235
|
-
) =>
|
|
235
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'findFirstOrThrow'>, ${errorTypeFor("findFirstOrThrow")}>
|
|
236
236
|
|
|
237
237
|
findMany: <A extends ${argsType("findMany")}>(
|
|
238
238
|
args?: A
|
|
239
|
-
) =>
|
|
239
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'findMany'>, ${errorTypeFor("findMany")}>
|
|
240
240
|
|
|
241
241
|
create: <A extends ${argsType("create")}>(
|
|
242
242
|
args: A
|
|
243
|
-
) =>
|
|
243
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'create'>, ${errorTypeFor("create")}>
|
|
244
244
|
|
|
245
245
|
createMany: <A extends ${argsType("createMany")}>(
|
|
246
246
|
args: A
|
|
247
|
-
) =>
|
|
247
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'createMany'>, ${errorTypeFor("createMany")}>
|
|
248
248
|
|
|
249
249
|
createManyAndReturn: <A extends ${argsType("createManyAndReturn")}>(
|
|
250
250
|
args: A
|
|
251
|
-
) =>
|
|
251
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'createManyAndReturn'>, ${errorTypeFor("createManyAndReturn")}>
|
|
252
252
|
|
|
253
253
|
delete: <A extends ${argsType("delete")}>(
|
|
254
254
|
args: A
|
|
255
|
-
) =>
|
|
255
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'delete'>, ${errorTypeFor("delete")}>
|
|
256
256
|
|
|
257
257
|
update: <A extends ${argsType("update")}>(
|
|
258
258
|
args: A
|
|
259
|
-
) =>
|
|
259
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'update'>, ${errorTypeFor("update")}>
|
|
260
260
|
|
|
261
261
|
deleteMany: <A extends ${argsType("deleteMany")}>(
|
|
262
262
|
args?: A
|
|
263
|
-
) =>
|
|
263
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'deleteMany'>, ${errorTypeFor("deleteMany")}>
|
|
264
264
|
|
|
265
265
|
updateMany: <A extends ${argsType("updateMany")}>(
|
|
266
266
|
args: A
|
|
267
|
-
) =>
|
|
267
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'updateMany'>, ${errorTypeFor("updateMany")}>
|
|
268
268
|
|
|
269
269
|
updateManyAndReturn: <A extends ${argsType("updateManyAndReturn")}>(
|
|
270
270
|
args: A
|
|
271
|
-
) =>
|
|
271
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'updateManyAndReturn'>, ${errorTypeFor("updateManyAndReturn")}>
|
|
272
272
|
|
|
273
273
|
upsert: <A extends ${argsType("upsert")}>(
|
|
274
274
|
args: A
|
|
275
|
-
) =>
|
|
275
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'upsert'>, ${errorTypeFor("upsert")}>
|
|
276
276
|
|
|
277
277
|
count: <A extends ${argsType("count")}>(
|
|
278
278
|
args?: A
|
|
279
|
-
) =>
|
|
279
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'count'>, ${errorTypeFor("count")}>
|
|
280
280
|
|
|
281
281
|
aggregate: <A extends ${argsType("aggregate")}>(
|
|
282
282
|
args: A
|
|
283
|
-
) =>
|
|
283
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'aggregate'>, ${errorTypeFor("aggregate")}>
|
|
284
284
|
|
|
285
285
|
groupBy: <A extends ${argsType("groupBy")}>(
|
|
286
286
|
args: A
|
|
287
|
-
) =>
|
|
287
|
+
) => EffectType<PrismaNamespace.Result<${delegate}, A, 'groupBy'>, ${errorTypeFor("groupBy")}>
|
|
288
288
|
}`;
|
|
289
289
|
})
|
|
290
290
|
.join("\n\n");
|
|
@@ -296,41 +296,41 @@ export interface IPrismaService {
|
|
|
296
296
|
client: BasePrismaClient
|
|
297
297
|
// Transaction operations
|
|
298
298
|
$transaction: <R, E, A>(
|
|
299
|
-
effect:
|
|
300
|
-
) =>
|
|
299
|
+
effect: EffectType<A, E, R>
|
|
300
|
+
) => EffectType<A, E | ${errorType}, Exclude<R, PrismaTransactionClientService>>
|
|
301
301
|
|
|
302
302
|
$transactionWith: <R, E, A>(
|
|
303
|
-
effect:
|
|
303
|
+
effect: EffectType<A, E, R>,
|
|
304
304
|
options: TransactionOptions
|
|
305
|
-
) =>
|
|
305
|
+
) => EffectType<A, E | ${errorType}, R>
|
|
306
306
|
|
|
307
307
|
$isolatedTransaction: <R, E, A>(
|
|
308
|
-
effect:
|
|
309
|
-
) =>
|
|
308
|
+
effect: EffectType<A, E, R>
|
|
309
|
+
) => EffectType<A, E | ${errorType}, R>
|
|
310
310
|
|
|
311
311
|
$isolatedTransactionWith: <R, E, A>(
|
|
312
|
-
effect:
|
|
312
|
+
effect: EffectType<A, E, R>,
|
|
313
313
|
options: TransactionOptions
|
|
314
|
-
) =>
|
|
314
|
+
) => EffectType<A, E | ${errorType}, R>
|
|
315
315
|
|
|
316
316
|
// Raw SQL operations
|
|
317
317
|
$executeRaw: (
|
|
318
318
|
args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]
|
|
319
|
-
) =>
|
|
319
|
+
) => EffectType<number, ${errorType}>
|
|
320
320
|
|
|
321
321
|
$executeRawUnsafe: (
|
|
322
322
|
query: string,
|
|
323
323
|
...values: any[]
|
|
324
|
-
) =>
|
|
324
|
+
) => EffectType<number, ${errorType}>
|
|
325
325
|
|
|
326
326
|
$queryRaw: <T = unknown>(
|
|
327
327
|
args: PrismaNamespace.Sql | [PrismaNamespace.Sql, ...any[]]
|
|
328
|
-
) =>
|
|
328
|
+
) => EffectType<T, ${errorType}>
|
|
329
329
|
|
|
330
330
|
$queryRawUnsafe: <T = unknown>(
|
|
331
331
|
query: string,
|
|
332
332
|
...values: any[]
|
|
333
|
-
) =>
|
|
333
|
+
) => EffectType<T, ${errorType}>
|
|
334
334
|
|
|
335
335
|
// Model operations
|
|
336
336
|
${modelInterfaces}
|
|
@@ -550,7 +550,8 @@ async function generateUnifiedService(models, outputDir, clientImportPath, error
|
|
|
550
550
|
function generateCustomErrorService(customError, clientImportPath, rawSqlOperations, modelTypeAliases, prismaInterface, modelOperations, enableTelemetry) {
|
|
551
551
|
const _errorType = customError.className;
|
|
552
552
|
return `${header}
|
|
553
|
-
import {
|
|
553
|
+
import { Effect, Exit, Layer, Option, Scope, ServiceMap } from "effect"
|
|
554
|
+
import type { Effect as EffectType, Error as EffectError, Services as EffectServices, Success as EffectSuccess } from "effect/Effect"
|
|
554
555
|
import { Prisma as PrismaNamespace, PrismaClient as BasePrismaClient } from "${clientImportPath}"
|
|
555
556
|
import { ${customError.className}, mapPrismaError } from "${customError.path}"
|
|
556
557
|
|
|
@@ -595,10 +596,7 @@ type TransactionOptions = {
|
|
|
595
596
|
* transactionOptions: { isolationLevel: "Serializable", timeout: 10000 }
|
|
596
597
|
* })
|
|
597
598
|
*/
|
|
598
|
-
export class PrismaClient extends
|
|
599
|
-
PrismaClient,
|
|
600
|
-
BasePrismaClient
|
|
601
|
-
>() {
|
|
599
|
+
export class PrismaClient extends ServiceMap.Service<PrismaClient, BasePrismaClient>()("PrismaClient") {
|
|
602
600
|
/**
|
|
603
601
|
* Create a PrismaClient layer with the given options.
|
|
604
602
|
* The client will be automatically disconnected when the layer scope ends.
|
|
@@ -620,9 +618,9 @@ export class PrismaClient extends Context.Tag("PrismaClient")<
|
|
|
620
618
|
* transactionOptions: { isolationLevel: "Serializable" }
|
|
621
619
|
* })
|
|
622
620
|
*/
|
|
623
|
-
static layer
|
|
621
|
+
static layer: (
|
|
624
622
|
...args: ConstructorParameters<typeof BasePrismaClient>
|
|
625
|
-
)
|
|
623
|
+
) => Layer.Layer<PrismaClient, never, never> = (...args) => Layer.effect(
|
|
626
624
|
PrismaClient,
|
|
627
625
|
Effect.gen(function* () {
|
|
628
626
|
const prisma: BasePrismaClient = new BasePrismaClient(...args)
|
|
@@ -655,9 +653,9 @@ export class PrismaClient extends Context.Tag("PrismaClient")<
|
|
|
655
653
|
* })
|
|
656
654
|
* )
|
|
657
655
|
*/
|
|
658
|
-
static layerEffect
|
|
659
|
-
optionsEffect:
|
|
660
|
-
)
|
|
656
|
+
static layerEffect: <R, E>(
|
|
657
|
+
optionsEffect: EffectType<ConstructorParameters<typeof BasePrismaClient>[0], E, R>
|
|
658
|
+
) => Layer.Layer<PrismaClient, E, Exclude<R, Scope.Scope>> = (optionsEffect) => Layer.effect(
|
|
661
659
|
PrismaClient,
|
|
662
660
|
Effect.gen(function* () {
|
|
663
661
|
const options: ConstructorParameters<typeof BasePrismaClient>[0] = yield* optionsEffect
|
|
@@ -673,10 +671,7 @@ export class PrismaClient extends Context.Tag("PrismaClient")<
|
|
|
673
671
|
* This service is only available inside \`$transaction\` calls.
|
|
674
672
|
* Use \`Effect.serviceOption(PrismaTransactionClientService)\` to check if you're in a transaction.
|
|
675
673
|
*/
|
|
676
|
-
export class PrismaTransactionClientService extends
|
|
677
|
-
PrismaTransactionClientService,
|
|
678
|
-
PrismaNamespace.TransactionClient
|
|
679
|
-
>() {}
|
|
674
|
+
export class PrismaTransactionClientService extends ServiceMap.Service<PrismaTransactionClientService, PrismaNamespace.TransactionClient>()("PrismaTransactionClientService") {}
|
|
680
675
|
|
|
681
676
|
// Re-export the custom error type for convenience
|
|
682
677
|
export { ${customError.className} }
|
|
@@ -703,10 +698,10 @@ const clientOrTx = (client: BasePrismaClient) => Effect.map(
|
|
|
703
698
|
* - Release errors are surfaced in the error channel, not as defects
|
|
704
699
|
*/
|
|
705
700
|
const acquireUseReleaseWithErrors = <A, E, R, A2, E2, R2, X, E3, R3>(
|
|
706
|
-
acquire:
|
|
707
|
-
use: (a: A) =>
|
|
708
|
-
release: (a: A, exit: Exit.Exit<A2, E2>) =>
|
|
709
|
-
):
|
|
701
|
+
acquire: EffectType<A, E, R>,
|
|
702
|
+
use: (a: A) => EffectType<A2, E2, R2>,
|
|
703
|
+
release: (a: A, exit: Exit.Exit<A2, E2>) => EffectType<X, E3, R3>
|
|
704
|
+
): EffectType<A2, E | E2 | E3, R | R2 | R3> =>
|
|
710
705
|
Effect.uninterruptibleMask((restore) =>
|
|
711
706
|
Effect.flatMap(acquire, (a) =>
|
|
712
707
|
Effect.flatMap(
|
|
@@ -742,8 +737,8 @@ const $begin = (
|
|
|
742
737
|
timeout?: number
|
|
743
738
|
isolationLevel?: PrismaNamespace.TransactionIsolationLevel
|
|
744
739
|
}
|
|
745
|
-
):
|
|
746
|
-
Effect.
|
|
740
|
+
): EffectType<FlatTransactionClient, ${customError.className}> =>
|
|
741
|
+
Effect.callback<FlatTransactionClient, ${customError.className}>((resume) => {
|
|
747
742
|
let setTxClient: (txClient: PrismaNamespace.TransactionClient) => void
|
|
748
743
|
let commit: () => void
|
|
749
744
|
let rollback: () => void
|
|
@@ -828,11 +823,11 @@ const makePrismaService = Effect.gen(function* () {
|
|
|
828
823
|
// If already in a transaction, just run the effect
|
|
829
824
|
if (Option.isSome(currentTx)) {
|
|
830
825
|
// have to get this to pass the Exclude type
|
|
831
|
-
return yield* (effect as
|
|
832
|
-
|
|
833
|
-
|
|
826
|
+
return yield* (effect as EffectType<
|
|
827
|
+
EffectSuccess<typeof effect>,
|
|
828
|
+
EffectError<typeof effect>,
|
|
834
829
|
Exclude<
|
|
835
|
-
|
|
830
|
+
EffectServices<typeof effect>,
|
|
836
831
|
PrismaTransactionClientService
|
|
837
832
|
>
|
|
838
833
|
>);
|
|
@@ -1020,12 +1015,12 @@ const makePrismaService = Effect.gen(function* () {
|
|
|
1020
1015
|
return prismaService;
|
|
1021
1016
|
});
|
|
1022
1017
|
|
|
1023
|
-
export class Prisma extends
|
|
1018
|
+
export class Prisma extends ServiceMap.Service<Prisma, IPrismaService>()("Prisma") {
|
|
1024
1019
|
/**
|
|
1025
1020
|
* Effect that constructs the Prisma service.
|
|
1026
1021
|
* Used internally by layer constructors.
|
|
1027
1022
|
*/
|
|
1028
|
-
static make:
|
|
1023
|
+
static make: EffectType<IPrismaService, never, PrismaClient> = makePrismaService;
|
|
1029
1024
|
static Default: Layer.Layer<Prisma, never, PrismaClient> = Layer.effect(Prisma, this.make);
|
|
1030
1025
|
|
|
1031
1026
|
/**
|
|
@@ -1053,9 +1048,9 @@ export class Prisma extends Context.Tag("Prisma")<Prisma, IPrismaService>() {
|
|
|
1053
1048
|
* // Use it
|
|
1054
1049
|
* Effect.runPromise(program.pipe(Effect.provide(MainLayer)))
|
|
1055
1050
|
*/
|
|
1056
|
-
static layer
|
|
1051
|
+
static layer: (
|
|
1057
1052
|
...args: ConstructorParameters<typeof BasePrismaClient>
|
|
1058
|
-
)
|
|
1053
|
+
) => Layer.Layer<Prisma | PrismaClient, never, never> = (...args) => this.Default.pipe(
|
|
1059
1054
|
Layer.provideMerge(PrismaClient.layer(...args))
|
|
1060
1055
|
);
|
|
1061
1056
|
|
|
@@ -1082,9 +1077,9 @@ export class Prisma extends Context.Tag("Prisma")<Prisma, IPrismaService>() {
|
|
|
1082
1077
|
* })
|
|
1083
1078
|
* )
|
|
1084
1079
|
*/
|
|
1085
|
-
static layerEffect
|
|
1086
|
-
optionsEffect:
|
|
1087
|
-
)
|
|
1080
|
+
static layerEffect: <R, E>(
|
|
1081
|
+
optionsEffect: EffectType<ConstructorParameters<typeof BasePrismaClient>[0], E, R>
|
|
1082
|
+
) => Layer.Layer<Prisma | PrismaClient, E, Exclude<R, Scope.Scope>> = (optionsEffect) => this.Default.pipe(
|
|
1088
1083
|
Layer.provideMerge(PrismaClient.layerEffect(optionsEffect))
|
|
1089
1084
|
);
|
|
1090
1085
|
}
|
|
@@ -1098,7 +1093,8 @@ export class Prisma extends Context.Tag("Prisma")<Prisma, IPrismaService>() {
|
|
|
1098
1093
|
function generateDefaultErrorService(clientImportPath, rawSqlOperations, modelTypeAliases, prismaInterface, modelOperations, enableTelemetry) {
|
|
1099
1094
|
const _errorType = "PrismaError";
|
|
1100
1095
|
return `${header}
|
|
1101
|
-
import {
|
|
1096
|
+
import { Data, Effect, Exit, Layer, Option, Scope, ServiceMap } from "effect"
|
|
1097
|
+
import type { Effect as EffectType, Error as EffectError, Services as EffectServices, Success as EffectSuccess } from "effect/Effect"
|
|
1102
1098
|
import { Prisma as PrismaNamespace, PrismaClient as BasePrismaClient } from "${clientImportPath}"
|
|
1103
1099
|
|
|
1104
1100
|
// Create local reference to error class for proper type narrowing
|
|
@@ -1151,10 +1147,7 @@ type TransactionOptions = {
|
|
|
1151
1147
|
* transactionOptions: { isolationLevel: "Serializable", timeout: 10000 }
|
|
1152
1148
|
* })
|
|
1153
1149
|
*/
|
|
1154
|
-
export class PrismaClient extends
|
|
1155
|
-
PrismaClient,
|
|
1156
|
-
BasePrismaClient
|
|
1157
|
-
>() {
|
|
1150
|
+
export class PrismaClient extends ServiceMap.Service<PrismaClient, BasePrismaClient>()("PrismaClient") {
|
|
1158
1151
|
/**
|
|
1159
1152
|
* Create a PrismaClient layer with the given options.
|
|
1160
1153
|
* The client will be automatically disconnected when the layer scope ends.
|
|
@@ -1176,9 +1169,9 @@ export class PrismaClient extends Context.Tag("PrismaClient")<
|
|
|
1176
1169
|
* transactionOptions: { isolationLevel: "Serializable" }
|
|
1177
1170
|
* })
|
|
1178
1171
|
*/
|
|
1179
|
-
static layer
|
|
1172
|
+
static layer: (
|
|
1180
1173
|
...args: ConstructorParameters<typeof BasePrismaClient>
|
|
1181
|
-
)
|
|
1174
|
+
) => Layer.Layer<PrismaClient, never, never> = (...args) => Layer.effect(
|
|
1182
1175
|
PrismaClient,
|
|
1183
1176
|
Effect.gen(function* () {
|
|
1184
1177
|
const prisma: BasePrismaClient = new BasePrismaClient(...args)
|
|
@@ -1211,9 +1204,9 @@ export class PrismaClient extends Context.Tag("PrismaClient")<
|
|
|
1211
1204
|
* })
|
|
1212
1205
|
* )
|
|
1213
1206
|
*/
|
|
1214
|
-
static layerEffect
|
|
1215
|
-
optionsEffect:
|
|
1216
|
-
)
|
|
1207
|
+
static layerEffect: <R, E>(
|
|
1208
|
+
optionsEffect: EffectType<ConstructorParameters<typeof BasePrismaClient>[0], E, R>
|
|
1209
|
+
) => Layer.Layer<PrismaClient, E, Exclude<R, Scope.Scope>> = (optionsEffect) => Layer.effect(
|
|
1217
1210
|
PrismaClient,
|
|
1218
1211
|
Effect.gen(function* () {
|
|
1219
1212
|
const options: ConstructorParameters<typeof BasePrismaClient>[0] = yield* optionsEffect
|
|
@@ -1229,10 +1222,7 @@ export class PrismaClient extends Context.Tag("PrismaClient")<
|
|
|
1229
1222
|
* This service is only available inside \`$transaction\` calls.
|
|
1230
1223
|
* Use \`Effect.serviceOption(PrismaTransactionClientService)\` to check if you're in a transaction.
|
|
1231
1224
|
*/
|
|
1232
|
-
export class PrismaTransactionClientService extends
|
|
1233
|
-
PrismaTransactionClientService,
|
|
1234
|
-
PrismaNamespace.TransactionClient
|
|
1235
|
-
>() {}
|
|
1225
|
+
export class PrismaTransactionClientService extends ServiceMap.Service<PrismaTransactionClientService, PrismaNamespace.TransactionClient>()("PrismaTransactionClientService") {}
|
|
1236
1226
|
|
|
1237
1227
|
export class PrismaUniqueConstraintError extends Data.TaggedError("PrismaUniqueConstraintError")<{
|
|
1238
1228
|
cause: PrismaNamespace.PrismaClientKnownRequestError
|
|
@@ -1604,10 +1594,10 @@ const clientOrTx = (client: BasePrismaClient) => Effect.map(
|
|
|
1604
1594
|
* - Release errors are surfaced in the error channel, not as defects
|
|
1605
1595
|
*/
|
|
1606
1596
|
const acquireUseReleaseWithErrors = <A, E, R, A2, E2, R2, X, E3, R3>(
|
|
1607
|
-
acquire:
|
|
1608
|
-
use: (a: A) =>
|
|
1609
|
-
release: (a: A, exit: Exit.Exit<A2, E2>) =>
|
|
1610
|
-
):
|
|
1597
|
+
acquire: EffectType<A, E, R>,
|
|
1598
|
+
use: (a: A) => EffectType<A2, E2, R2>,
|
|
1599
|
+
release: (a: A, exit: Exit.Exit<A2, E2>) => EffectType<X, E3, R3>
|
|
1600
|
+
): EffectType<A2, E | E2 | E3, R | R2 | R3> =>
|
|
1611
1601
|
Effect.uninterruptibleMask((restore) =>
|
|
1612
1602
|
Effect.flatMap(acquire, (a) =>
|
|
1613
1603
|
Effect.flatMap(
|
|
@@ -1643,8 +1633,8 @@ const $begin = (
|
|
|
1643
1633
|
timeout?: number
|
|
1644
1634
|
isolationLevel?: PrismaNamespace.TransactionIsolationLevel
|
|
1645
1635
|
}
|
|
1646
|
-
):
|
|
1647
|
-
Effect.
|
|
1636
|
+
): EffectType<FlatTransactionClient, PrismaError> =>
|
|
1637
|
+
Effect.callback<FlatTransactionClient, PrismaError>((resume) => {
|
|
1648
1638
|
let setTxClient: (txClient: PrismaNamespace.TransactionClient) => void
|
|
1649
1639
|
let commit: () => void
|
|
1650
1640
|
let rollback: () => void
|
|
@@ -1728,11 +1718,11 @@ const makePrismaService = Effect.gen(function* () {
|
|
|
1728
1718
|
|
|
1729
1719
|
// If already in a transaction, just run the effect
|
|
1730
1720
|
if (Option.isSome(currentTx)) {
|
|
1731
|
-
return yield* (effect as
|
|
1732
|
-
|
|
1733
|
-
|
|
1721
|
+
return yield* (effect as EffectType<
|
|
1722
|
+
EffectSuccess<typeof effect>,
|
|
1723
|
+
EffectError<typeof effect>,
|
|
1734
1724
|
Exclude<
|
|
1735
|
-
|
|
1725
|
+
EffectServices<typeof effect>,
|
|
1736
1726
|
PrismaTransactionClientService
|
|
1737
1727
|
>
|
|
1738
1728
|
>);
|
|
@@ -1920,12 +1910,12 @@ const makePrismaService = Effect.gen(function* () {
|
|
|
1920
1910
|
return prismaService;
|
|
1921
1911
|
});
|
|
1922
1912
|
|
|
1923
|
-
export class Prisma extends
|
|
1913
|
+
export class Prisma extends ServiceMap.Service<Prisma, IPrismaService>()("Prisma") {
|
|
1924
1914
|
/**
|
|
1925
1915
|
* Effect that constructs the Prisma service.
|
|
1926
1916
|
* Used internally by layer constructors.
|
|
1927
1917
|
*/
|
|
1928
|
-
static make:
|
|
1918
|
+
static make: EffectType<IPrismaService, never, PrismaClient> = makePrismaService;
|
|
1929
1919
|
static Default: Layer.Layer<Prisma, never, PrismaClient> = Layer.effect(Prisma, this.make);
|
|
1930
1920
|
|
|
1931
1921
|
/**
|
|
@@ -1953,9 +1943,9 @@ export class Prisma extends Context.Tag("Prisma")<Prisma, IPrismaService>() {
|
|
|
1953
1943
|
* // Use it
|
|
1954
1944
|
* Effect.runPromise(program.pipe(Effect.provide(MainLayer)))
|
|
1955
1945
|
*/
|
|
1956
|
-
static layer
|
|
1946
|
+
static layer: (
|
|
1957
1947
|
...args: ConstructorParameters<typeof BasePrismaClient>
|
|
1958
|
-
)
|
|
1948
|
+
) => Layer.Layer<Prisma | PrismaClient, never, never> = (...args) => this.Default.pipe(
|
|
1959
1949
|
Layer.provideMerge(PrismaClient.layer(...args))
|
|
1960
1950
|
);
|
|
1961
1951
|
|
|
@@ -1982,9 +1972,9 @@ export class Prisma extends Context.Tag("Prisma")<Prisma, IPrismaService>() {
|
|
|
1982
1972
|
* })
|
|
1983
1973
|
* )
|
|
1984
1974
|
*/
|
|
1985
|
-
static layerEffect
|
|
1986
|
-
optionsEffect:
|
|
1987
|
-
)
|
|
1975
|
+
static layerEffect: <R, E>(
|
|
1976
|
+
optionsEffect: EffectType<ConstructorParameters<typeof BasePrismaClient>[0], E, R>
|
|
1977
|
+
) => Layer.Layer<Prisma | PrismaClient, E, Exclude<R, Scope.Scope>> = (optionsEffect) => this.Default.pipe(
|
|
1988
1978
|
Layer.provideMerge(PrismaClient.layerEffect(optionsEffect))
|
|
1989
1979
|
);
|
|
1990
1980
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riordanpawley/effect-prisma-generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Prisma generator for Effect (fork with Prisma 7 support)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,13 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@biomejs/biome": "^2.3.8",
|
|
31
|
-
"@effect/
|
|
32
|
-
"@effect/platform-node": "^0.101.0",
|
|
33
|
-
"@effect/vitest": "^0.27.0",
|
|
31
|
+
"@effect/vitest": "^4.0.0-beta.10",
|
|
34
32
|
"@prisma/client": "^6.19.0",
|
|
35
33
|
"@prisma/generator": "^6.19.0",
|
|
36
34
|
"@types/node": "^24.10.1",
|
|
37
|
-
"effect": "^
|
|
35
|
+
"effect": "^4.0.0-beta.10",
|
|
38
36
|
"prisma": "^6.19.0",
|
|
39
37
|
"tsx": "^4.20.6",
|
|
40
38
|
"vitest": "^3.0.7"
|