fix prisma type issues

This commit is contained in:
Matthias Nannt
2024-09-30 12:11:05 +02:00
parent 9b109bf4d3
commit e2cacfc743
4 changed files with 74 additions and 90 deletions

View File

@@ -52,7 +52,6 @@
},
"dependencies": {
"@prisma/client": "^5.20.0",
"@prisma/extension-accelerate": "^1.2.0",
"dotenv-cli": "^7.4.2"
},
"devDependencies": {
@@ -62,7 +61,7 @@
"@formbricks/eslint-config": "workspace:*",
"prisma": "^5.20.0",
"prisma-dbml-generator": "^0.12.0",
"prisma-json-types-generator": "^3.1.1",
"prisma-json-types-generator": "^3.0.4",
"ts-node": "^10.9.2",
"zod": "^3.23.8",
"zod-prisma": "^0.5.4"

View File

@@ -1,20 +1,14 @@
import { PrismaClient } from "@prisma/client";
const prismaClientSingleton = () => {
return new PrismaClient({
datasources: { db: { url: process.env.DATABASE_URL } },
...(process.env.DEBUG === "1" && {
log: ["query", "info"],
}),
});
const prismaClientSingleton = (): PrismaClient => {
return new PrismaClient();
};
type PrismaClientSingleton = ReturnType<typeof prismaClientSingleton>;
declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClientSingleton | undefined;
};
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- as stated by the Prisma documentation
export const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();
export const prisma = globalForPrisma.prisma ?? prismaClientSingleton();
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;

View File

@@ -4,7 +4,11 @@ import "server-only";
import { Prisma } from "@prisma/client";
import { cache as reactCache } from "react";
import { prisma } from "@formbricks/database";
import { TActionClass, TActionClassInput, ZActionClassInput } from "@formbricks/types/action-classes";
import {
type TActionClass,
type TActionClassInput,
ZActionClassInput,
} from "@formbricks/types/action-classes";
import { ZOptionalNumber, ZString } from "@formbricks/types/common";
import { ZId } from "@formbricks/types/common";
import { DatabaseError, ResourceNotFoundError } from "@formbricks/types/errors";

133
pnpm-lock.yaml generated
View File

@@ -623,9 +623,6 @@ importers:
'@prisma/client':
specifier: ^5.20.0
version: 5.20.0(prisma@5.20.0)
'@prisma/extension-accelerate':
specifier: ^1.2.0
version: 1.2.0(@prisma/client@5.20.0(prisma@5.20.0))
dotenv-cli:
specifier: ^7.4.2
version: 7.4.2
@@ -649,7 +646,7 @@ importers:
specifier: ^0.12.0
version: 0.12.0(encoding@0.1.13)
prisma-json-types-generator:
specifier: ^3.1.1
specifier: ^3.0.4
version: 3.1.1(prisma@5.20.0)(typescript@5.5.4)
ts-node:
specifier: ^10.9.2
@@ -4028,12 +4025,6 @@ packages:
'@prisma/engines@5.20.0':
resolution: {integrity: sha512-DtqkP+hcZvPEbj8t8dK5df2b7d3B8GNauKqaddRRqQBBlgkbdhJkxhoJTrOowlS3vaRt2iMCkU0+CSNn0KhqAQ==}
'@prisma/extension-accelerate@1.2.0':
resolution: {integrity: sha512-bELNCWi1iZx4Q1iFFEDcUEc+KR9M8I2lhO2fO9DabKOQjLQc/WkPXbaNB1dr81WZPqzj7FwFVAqpex3NNkxSPw==}
engines: {node: '>=16'}
peerDependencies:
'@prisma/client': '>=4.16.1'
'@prisma/fetch-engine@5.0.0':
resolution: {integrity: sha512-eSzHTE0KcMvM5+O1++eaMuVf4D1zwWHdqjWr6D70skCg37q7RYsuty4GFnlWBuqC4aXwVf06EvIxiJ0SQIIeRw==}
@@ -13998,13 +13989,13 @@ snapshots:
dependencies:
'@aws-crypto/util': 5.2.0
'@aws-sdk/types': 3.654.0
tslib: 2.6.3
tslib: 2.7.0
'@aws-crypto/crc32c@5.2.0':
dependencies:
'@aws-crypto/util': 5.2.0
'@aws-sdk/types': 3.654.0
tslib: 2.6.3
tslib: 2.7.0
'@aws-crypto/sha1-browser@5.2.0':
dependencies:
@@ -14033,13 +14024,13 @@ snapshots:
'@aws-crypto/supports-web-crypto@5.2.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@aws-crypto/util@5.2.0':
dependencies:
'@aws-sdk/types': 3.654.0
'@smithy/util-utf8': 2.3.0
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/client-s3@3.658.1(aws-crt@1.22.0)':
dependencies:
@@ -14188,7 +14179,7 @@ snapshots:
'@smithy/util-middleware': 3.0.6
'@smithy/util-retry': 3.0.6
'@smithy/util-utf8': 3.0.0
tslib: 2.6.3
tslib: 2.7.0
transitivePeerDependencies:
- aws-crt
@@ -14255,7 +14246,7 @@ snapshots:
'@aws-sdk/types': 3.654.0
'@smithy/property-provider': 3.1.6
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/credential-provider-http@3.658.1':
dependencies:
@@ -14267,7 +14258,7 @@ snapshots:
'@smithy/smithy-client': 3.3.5
'@smithy/types': 3.4.2
'@smithy/util-stream': 3.1.8
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/credential-provider-ini@3.658.1(@aws-sdk/client-sso-oidc@3.658.1(@aws-sdk/client-sts@3.658.1(aws-crt@1.22.0))(aws-crt@1.22.0))(@aws-sdk/client-sts@3.658.1(aws-crt@1.22.0))(aws-crt@1.22.0)':
dependencies:
@@ -14282,7 +14273,7 @@ snapshots:
'@smithy/property-provider': 3.1.6
'@smithy/shared-ini-file-loader': 3.1.7
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
transitivePeerDependencies:
- '@aws-sdk/client-sso-oidc'
- aws-crt
@@ -14312,7 +14303,7 @@ snapshots:
'@smithy/property-provider': 3.1.6
'@smithy/shared-ini-file-loader': 3.1.7
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/credential-provider-sso@3.658.1(@aws-sdk/client-sso-oidc@3.658.1(@aws-sdk/client-sts@3.658.1(aws-crt@1.22.0))(aws-crt@1.22.0))(aws-crt@1.22.0)':
dependencies:
@@ -14322,7 +14313,7 @@ snapshots:
'@smithy/property-provider': 3.1.6
'@smithy/shared-ini-file-loader': 3.1.7
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
transitivePeerDependencies:
- '@aws-sdk/client-sso-oidc'
- aws-crt
@@ -14333,7 +14324,7 @@ snapshots:
'@aws-sdk/types': 3.654.0
'@smithy/property-provider': 3.1.6
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/middleware-bucket-endpoint@3.654.0':
dependencies:
@@ -14472,7 +14463,7 @@ snapshots:
'@smithy/property-provider': 3.1.6
'@smithy/shared-ini-file-loader': 3.1.7
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/types@3.654.0':
dependencies:
@@ -14481,7 +14472,7 @@ snapshots:
'@aws-sdk/util-arn-parser@3.568.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/util-endpoints@3.654.0':
dependencies:
@@ -14499,7 +14490,7 @@ snapshots:
'@aws-sdk/util-locate-window@3.568.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/util-user-agent-browser@3.654.0':
dependencies:
@@ -14519,7 +14510,7 @@ snapshots:
'@aws-sdk/util-utf8-browser@3.259.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@aws-sdk/xml-builder@3.654.0':
dependencies:
@@ -15953,7 +15944,7 @@ snapshots:
'@emnapi/runtime@1.2.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
optional: true
'@emotion/is-prop-valid@0.8.8':
@@ -16415,7 +16406,7 @@ snapshots:
password-prompt: 1.1.3
sudo-prompt: 8.2.5
tmp: 0.0.33
tslib: 2.6.3
tslib: 2.7.0
transitivePeerDependencies:
- supports-color
@@ -17636,10 +17627,6 @@ snapshots:
'@prisma/fetch-engine': 5.20.0
'@prisma/get-platform': 5.20.0
'@prisma/extension-accelerate@1.2.0(@prisma/client@5.20.0(prisma@5.20.0))':
dependencies:
'@prisma/client': 5.20.0(prisma@5.20.0)
'@prisma/fetch-engine@5.0.0(encoding@0.1.13)':
dependencies:
'@prisma/debug': 5.0.0
@@ -19757,16 +19744,16 @@ snapshots:
'@smithy/abort-controller@3.1.4':
dependencies:
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@smithy/chunked-blob-reader-native@3.0.0':
dependencies:
'@smithy/util-base64': 3.0.0
tslib: 2.6.3
tslib: 2.7.0
'@smithy/chunked-blob-reader@3.0.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@smithy/config-resolver@3.0.8':
dependencies:
@@ -19795,14 +19782,14 @@ snapshots:
'@smithy/property-provider': 3.1.6
'@smithy/types': 3.4.2
'@smithy/url-parser': 3.0.6
tslib: 2.6.3
tslib: 2.7.0
'@smithy/eventstream-codec@3.1.5':
dependencies:
'@aws-crypto/crc32': 5.2.0
'@smithy/types': 3.4.2
'@smithy/util-hex-encoding': 3.0.0
tslib: 2.6.3
tslib: 2.7.0
'@smithy/eventstream-serde-browser@3.0.9':
dependencies:
@@ -19825,7 +19812,7 @@ snapshots:
dependencies:
'@smithy/eventstream-codec': 3.1.5
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@smithy/fetch-http-handler@3.2.8':
dependencies:
@@ -19862,11 +19849,11 @@ snapshots:
'@smithy/is-array-buffer@2.2.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@smithy/is-array-buffer@3.0.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@smithy/md5-js@3.0.6':
dependencies:
@@ -19930,7 +19917,7 @@ snapshots:
'@smithy/property-provider@3.1.6':
dependencies:
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@smithy/protocol-http@4.1.3':
dependencies:
@@ -19941,12 +19928,12 @@ snapshots:
dependencies:
'@smithy/types': 3.4.2
'@smithy/util-uri-escape': 3.0.0
tslib: 2.6.3
tslib: 2.7.0
'@smithy/querystring-parser@3.0.6':
dependencies:
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@smithy/service-error-classification@3.0.6':
dependencies:
@@ -19955,7 +19942,7 @@ snapshots:
'@smithy/shared-ini-file-loader@3.1.7':
dependencies:
'@smithy/types': 3.4.2
tslib: 2.6.3
tslib: 2.7.0
'@smithy/signature-v4@4.1.4':
dependencies:
@@ -20004,16 +19991,16 @@ snapshots:
'@smithy/util-buffer-from@2.2.0':
dependencies:
'@smithy/is-array-buffer': 2.2.0
tslib: 2.6.3
tslib: 2.7.0
'@smithy/util-buffer-from@3.0.0':
dependencies:
'@smithy/is-array-buffer': 3.0.0
tslib: 2.6.3
tslib: 2.7.0
'@smithy/util-config-provider@3.0.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@smithy/util-defaults-mode-browser@3.0.21':
dependencies:
@@ -20067,12 +20054,12 @@ snapshots:
'@smithy/util-uri-escape@3.0.0':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@smithy/util-utf8@2.3.0':
dependencies:
'@smithy/util-buffer-from': 2.2.0
tslib: 2.6.3
tslib: 2.7.0
'@smithy/util-utf8@3.0.0':
dependencies:
@@ -20425,11 +20412,11 @@ snapshots:
'@swc/helpers@0.5.11':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@swc/helpers@0.5.2':
dependencies:
tslib: 2.6.3
tslib: 2.7.0
'@swc/helpers@0.5.5':
dependencies:
@@ -21630,7 +21617,7 @@ snapshots:
aria-hidden@1.2.4:
dependencies:
tslib: 2.6.3
tslib: 2.7.0
aria-query@5.3.0:
dependencies:
@@ -21727,11 +21714,11 @@ snapshots:
ast-types@0.15.2:
dependencies:
tslib: 2.6.3
tslib: 2.7.0
ast-types@0.16.1:
dependencies:
tslib: 2.6.3
tslib: 2.7.0
astral-regex@1.0.0: {}
@@ -23833,7 +23820,7 @@ snapshots:
fast-unique-numbers@8.0.13:
dependencies:
'@babel/runtime': 7.24.7
tslib: 2.6.3
tslib: 2.7.0
fast-url-parser@1.1.3:
dependencies:
@@ -24349,7 +24336,7 @@ snapshots:
graphql-tag@2.12.6(graphql@15.8.0):
dependencies:
graphql: 15.8.0
tslib: 2.6.3
tslib: 2.7.0
graphql@15.8.0: {}
@@ -27819,7 +27806,7 @@ snapshots:
dependencies:
react: 18.3.1
react-style-singleton: 2.2.1(@types/react@18.2.47)(react@18.3.1)
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.2.47
@@ -27827,7 +27814,7 @@ snapshots:
dependencies:
react: 18.3.1
react-style-singleton: 2.2.1(@types/react@18.3.9)(react@18.3.1)
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.3.9
@@ -27836,7 +27823,7 @@ snapshots:
react: 18.3.1
react-remove-scroll-bar: 2.3.6(@types/react@18.3.9)(react@18.3.1)
react-style-singleton: 2.2.1(@types/react@18.3.9)(react@18.3.1)
tslib: 2.6.3
tslib: 2.7.0
use-callback-ref: 1.3.2(@types/react@18.3.9)(react@18.3.1)
use-sidecar: 1.1.2(@types/react@18.3.9)(react@18.3.1)
optionalDependencies:
@@ -27847,7 +27834,7 @@ snapshots:
react: 18.3.1
react-remove-scroll-bar: 2.3.6(@types/react@18.2.47)(react@18.3.1)
react-style-singleton: 2.2.1(@types/react@18.2.47)(react@18.3.1)
tslib: 2.6.3
tslib: 2.7.0
use-callback-ref: 1.3.2(@types/react@18.2.47)(react@18.3.1)
use-sidecar: 1.1.2(@types/react@18.2.47)(react@18.3.1)
optionalDependencies:
@@ -27858,7 +27845,7 @@ snapshots:
react: 18.3.1
react-remove-scroll-bar: 2.3.6(@types/react@18.3.9)(react@18.3.1)
react-style-singleton: 2.2.1(@types/react@18.3.9)(react@18.3.1)
tslib: 2.6.3
tslib: 2.7.0
use-callback-ref: 1.3.2(@types/react@18.3.9)(react@18.3.1)
use-sidecar: 1.1.2(@types/react@18.3.9)(react@18.3.1)
optionalDependencies:
@@ -27886,7 +27873,7 @@ snapshots:
get-nonce: 1.0.1
invariant: 2.2.4
react: 18.3.1
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.2.47
@@ -27895,7 +27882,7 @@ snapshots:
get-nonce: 1.0.1
invariant: 2.2.4
react: 18.3.1
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.3.9
@@ -27996,7 +27983,7 @@ snapshots:
ast-types: 0.15.2
esprima: 4.0.1
source-map: 0.6.1
tslib: 2.6.3
tslib: 2.7.0
recast@0.23.9:
dependencies:
@@ -28004,7 +27991,7 @@ snapshots:
esprima: 4.0.1
source-map: 0.6.1
tiny-invariant: 1.3.3
tslib: 2.6.3
tslib: 2.7.0
redent@3.0.0:
dependencies:
@@ -28324,7 +28311,7 @@ snapshots:
rxjs@7.8.1:
dependencies:
tslib: 2.6.3
tslib: 2.7.0
safe-array-concat@1.1.2:
dependencies:
@@ -29016,7 +29003,7 @@ snapshots:
synckit@0.9.0:
dependencies:
'@pkgr/core': 0.1.1
tslib: 2.6.3
tslib: 2.7.0
tabbable@6.2.0: {}
@@ -29699,14 +29686,14 @@ snapshots:
use-callback-ref@1.3.2(@types/react@18.2.47)(react@18.3.1):
dependencies:
react: 18.3.1
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.2.47
use-callback-ref@1.3.2(@types/react@18.3.9)(react@18.3.1):
dependencies:
react: 18.3.1
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.3.9
@@ -29714,7 +29701,7 @@ snapshots:
dependencies:
detect-node-es: 1.1.0
react: 18.3.1
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.2.47
@@ -29722,7 +29709,7 @@ snapshots:
dependencies:
detect-node-es: 1.1.0
react: 18.3.1
tslib: 2.6.3
tslib: 2.7.0
optionalDependencies:
'@types/react': 18.3.9
@@ -30119,18 +30106,18 @@ snapshots:
dependencies:
'@babel/runtime': 7.24.7
fast-unique-numbers: 8.0.13
tslib: 2.6.3
tslib: 2.7.0
worker-timers-worker: 7.0.71
worker-timers-worker@7.0.71:
dependencies:
'@babel/runtime': 7.24.7
tslib: 2.6.3
tslib: 2.7.0
worker-timers@7.1.8:
dependencies:
'@babel/runtime': 7.24.7
tslib: 2.6.3
tslib: 2.7.0
worker-timers-broker: 6.1.8
worker-timers-worker: 7.0.71