From 871412eed7d68a0a2903745cbcf0ff95d4dcbba7 Mon Sep 17 00:00:00 2001 From: gurjotkaur20 Date: Wed, 20 Mar 2024 12:25:04 +0530 Subject: [PATCH 1/2] fix: add types in dmmfparser for encryption --- src/dmmf.ts | 2 +- src/types.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dmmf.ts b/src/dmmf.ts index d310342..2a19eb9 100644 --- a/src/dmmf.ts +++ b/src/dmmf.ts @@ -30,7 +30,7 @@ const supportedCursorTypes = ['Int', 'String', 'BigInt'] export function analyseDMMF(input: DMMFDocument): DMMFModels { const dmmf = dmmfDocumentParser.parse(input) - const allModels = dmmf.datamodel.models + const allModels = [...dmmf.datamodel.models, ...dmmf.datamodel.types]; return allModels.reduce((output, model) => { const idField = model.fields.find( diff --git a/src/types.ts b/src/types.ts index 61c05b5..ec91a46 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,7 +54,8 @@ export const dmmfDocumentParser = z .object({ datamodel: z .object({ - models: z.array(dmmfModelParser).readonly() + models: z.array(dmmfModelParser).readonly(), + types: z.array(dmmfModelParser).readonly() }) .readonly() }) From 34d30f7f3125313fa39ee3232838569d24e0ea66 Mon Sep 17 00:00:00 2001 From: gurjotkaur20 Date: Thu, 21 Mar 2024 11:31:04 +0530 Subject: [PATCH 2/2] fix: check model.connections on decryptOnRead During create or update, return from decryptOnRead only if the model doesn't have any connections --- src/encryption.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/encryption.ts b/src/encryption.ts index 8ba0fea..7940da3 100644 --- a/src/encryption.ts +++ b/src/encryption.ts @@ -146,6 +146,7 @@ export function decryptOnRead( const model = models[params.model!] if ( Object.keys(model.fields).length === 0 && + Object.keys(model.connections).length === 0 && !params.args?.include && !params.args?.select ) {