47ng / prisma-field-encryption

Transparent field-level encryption at rest for Prisma
https://github.com/franky47/prisma-field-encryption-sandbox
MIT License
223 stars 27 forks source link

Breaks with 5.9.1 release of Prisma #97

Closed kimchinosys closed 5 months ago

kimchinosys commented 5 months ago

Here is the error that gets thrown

Type 'BaseDMMF' is not assignable to type '{ datamodel: { models: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; }; }'.
  The types of 'datamodel.models' are incompatible between these types.
    The type 'readonly ReadonlyDeep_2<ReadonlyDeep_2<ReadonlyDeep_2<{ name: string; dbName: string | null; fields: ReadonlyDeep_2<{ kind: FieldKind; name: string; isRequired: boolean; isList: boolean; isUnique: boolean; isId: boolean; isReadOnly: boolean; ... 10 more ...; documentation?: string | undefined; }>[]; ... 4 more ...; ...' is 'readonly' and cannot be assigned to the mutable type '{ name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]'.

It is related to this step in the setup: https://www.npmjs.com/package/prisma-field-encryption#custom-prisma-client-location

franky47 commented 5 months ago

From the error it looks like they made the exported DMMF type readonly, which is fair enough. However doing so recursively with a non-native type helper may make it difficult to properly type on our end.

Does it work at runtime if you // @ts-expect-error the dmmf assignment line?

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 1.5.2-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

franky47 commented 5 months ago

@kimchinosys thanks to Zod it was an easy fix, could you try the 1.5.2-beta.1 release and let me know if it works OK for you? Then I'll publish to latest.

kimchinosys commented 5 months ago

Amazing, it works, thank you for the quick fix.

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 1.5.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: