From 0f567fbdfd8210c800a2797a089c1e3d90c6cf43 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Thu, 19 Dec 2024 09:19:28 -0800 Subject: [PATCH 01/16] added typed sql --- apps/backend/package.json | 12 +-- apps/backend/prisma/schema.prisma | 2 +- .../prisma/sql/getUsersLastActiveAtMillis.sql | 4 + apps/backend/src/app/api/v1/users/crud.tsx | 10 +-- pnpm-lock.yaml | 76 +++++++++---------- 5 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 apps/backend/prisma/sql/getUsersLastActiveAtMillis.sql diff --git a/apps/backend/package.json b/apps/backend/package.json index e435875bf..6b1d70ab0 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -14,7 +14,7 @@ "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", "codegen-prisma": "pnpm run prisma generate", - "codegen-prisma:watch": "pnpm run prisma generate --watch", + "codegen-prisma:watch": "pnpm run prisma generate --sql --watch", "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", "psql-inner": "psql $STACK_DATABASE_CONNECTION_STRING", @@ -43,7 +43,7 @@ "@opentelemetry/sdk-trace-base": "^1.26.0", "@opentelemetry/sdk-trace-node": "^1.26.0", "@opentelemetry/semantic-conventions": "^1.27.0", - "@prisma/client": "^6.0.1", + "@prisma/client": "^6.1.0", "@prisma/extension-accelerate": "^1.2.1", "@prisma/instrumentation": "^5.19.1", "@sentry/nextjs": "^8.40.0", @@ -82,11 +82,11 @@ "@types/semver": "^7.5.8", "concurrently": "^8.2.2", "glob": "^10.4.1", - "prisma": "^6.0.1", + "import-in-the-middle": "^1.12.0", + "prisma": "^6.1.0", + "require-in-the-middle": "^7.4.0", "rimraf": "^5.0.5", "tsup": "^8.3.0", - "tsx": "^4.7.2", - "require-in-the-middle": "^7.4.0", - "import-in-the-middle": "^1.12.0" + "tsx": "^4.7.2" } } diff --git a/apps/backend/prisma/schema.prisma b/apps/backend/prisma/schema.prisma index 5f008a58d..ea3f3d1b8 100644 --- a/apps/backend/prisma/schema.prisma +++ b/apps/backend/prisma/schema.prisma @@ -3,7 +3,7 @@ generator client { provider = "prisma-client-js" - previewFeatures = ["tracing", "relationJoins"] + previewFeatures = ["typedSql", "relationJoins"] } datasource db { diff --git a/apps/backend/prisma/sql/getUsersLastActiveAtMillis.sql b/apps/backend/prisma/sql/getUsersLastActiveAtMillis.sql new file mode 100644 index 000000000..801bba449 --- /dev/null +++ b/apps/backend/prisma/sql/getUsersLastActiveAtMillis.sql @@ -0,0 +1,4 @@ +SELECT data->>'userId' as "userId", MAX("createdAt") as "lastActiveAt" +FROM "Event" +WHERE data->>'userId' = ANY($1) +GROUP BY data->>'userId' \ No newline at end of file diff --git a/apps/backend/src/app/api/v1/users/crud.tsx b/apps/backend/src/app/api/v1/users/crud.tsx index db79f2786..de3072009 100644 --- a/apps/backend/src/app/api/v1/users/crud.tsx +++ b/apps/backend/src/app/api/v1/users/crud.tsx @@ -5,6 +5,7 @@ import { prismaClient, retryTransaction } from "@/prisma-client"; import { createCrudHandlers } from "@/route-handlers/crud-handler"; import { runAsynchronouslyAndWaitUntil } from "@/utils/vercel"; import { BooleanTrue, Prisma } from "@prisma/client"; +import { getUsersLastActiveAtMillis as getUsersLastActiveAtMillisSql } from "@prisma/client/sql"; import { KnownErrors } from "@stackframe/stack-shared"; import { currentUserCrud } from "@stackframe/stack-shared/dist/interface/crud/current-user"; import { UsersCrud, usersCrud } from "@stackframe/stack-shared/dist/interface/crud/users"; @@ -228,16 +229,11 @@ export const getUsersLastActiveAtMillis = async (userIds: string[], fallbackTo: return []; } - const events = await prismaClient.$queryRaw>` - SELECT data->>'userId' as "userId", MAX("createdAt") as "lastActiveAt" - FROM "Event" - WHERE data->>'userId' = ANY(${Prisma.sql`ARRAY[${Prisma.join(userIds)}]`}) - GROUP BY data->>'userId' - `; + const events = await prismaClient.$queryRawTyped(getUsersLastActiveAtMillisSql(userIds)); return userIds.map((userId, index) => { const event = events.find(e => e.userId === userId); - return event ? event.lastActiveAt.getTime() : ( + return event && event.lastActiveAt ? event.lastActiveAt.getTime() : ( typeof fallbackTo[index] === "number" ? (fallbackTo[index] as number) : (fallbackTo[index] as Date).getTime() ); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7adfc83a..f33cc254f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -127,11 +127,11 @@ importers: specifier: ^1.27.0 version: 1.27.0 '@prisma/client': - specifier: ^6.0.1 - version: 6.0.1(prisma@6.0.1) + specifier: ^6.1.0 + version: 6.1.0(prisma@6.1.0) '@prisma/extension-accelerate': specifier: ^1.2.1 - version: 1.2.1(@prisma/client@6.0.1(prisma@6.0.1)) + version: 1.2.1(@prisma/client@6.1.0(prisma@6.1.0)) '@prisma/instrumentation': specifier: ^5.19.1 version: 5.20.0 @@ -242,8 +242,8 @@ importers: specifier: ^1.12.0 version: 1.12.0 prisma: - specifier: ^6.0.1 - version: 6.0.1 + specifier: ^6.1.0 + version: 6.1.0 require-in-the-middle: specifier: ^7.4.0 version: 7.4.0 @@ -3591,8 +3591,8 @@ packages: '@polka/url@1.0.0-next.25': resolution: {integrity: sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==} - '@prisma/client@6.0.1': - resolution: {integrity: sha512-60w7kL6bUxz7M6Gs/V+OWMhwy94FshpngVmOY05TmGD0Lhk+Ac0ZgtjlL6Wll9TD4G03t4Sq1wZekNVy+Xdlbg==} + '@prisma/client@6.1.0': + resolution: {integrity: sha512-AbQYc5+EJKm1Ydfq3KxwcGiy7wIbm4/QbjCKWWoNROtvy7d6a3gmAGkKjK0iUCzh+rHV8xDhD5Cge8ke/kiy5Q==} engines: {node: '>=18.18'} peerDependencies: prisma: '*' @@ -3600,14 +3600,14 @@ packages: prisma: optional: true - '@prisma/debug@6.0.1': - resolution: {integrity: sha512-jQylgSOf7ibTVxqBacnAlVGvek6fQxJIYCQOeX2KexsfypNzXjJQSS2o5s+Mjj2Np93iSOQUaw6TvPj8syhG4w==} + '@prisma/debug@6.1.0': + resolution: {integrity: sha512-0himsvcM4DGBTtvXkd2Tggv6sl2JyUYLzEGXXleFY+7Kp6rZeSS3hiTW9mwtUlXrwYbJP6pwlVNB7jYElrjWUg==} - '@prisma/engines-version@5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e': - resolution: {integrity: sha512-JmIds0Q2/vsOmnuTJYxY4LE+sajqjYKhLtdOT6y4imojqv5d/aeVEfbBGC74t8Be1uSp0OP8lxIj2OqoKbLsfQ==} + '@prisma/engines-version@6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959': + resolution: {integrity: sha512-PdJqmYM2Fd8K0weOOtQThWylwjsDlTig+8Pcg47/jszMuLL9iLIaygC3cjWJLda69siRW4STlCTMSgOjZzvKPQ==} - '@prisma/engines@6.0.1': - resolution: {integrity: sha512-4hxzI+YQIR2uuDyVsDooFZGu5AtixbvM2psp+iayDZ4hRrAHo/YwgA17N23UWq7G6gRu18NvuNMb48qjP3DPQw==} + '@prisma/engines@6.1.0': + resolution: {integrity: sha512-GnYJbCiep3Vyr1P/415ReYrgJUjP79fBNc1wCo7NP6Eia0CzL2Ot9vK7Infczv3oK7JLrCcawOSAxFxNFsAERQ==} '@prisma/extension-accelerate@1.2.1': resolution: {integrity: sha512-QicnMeyqL226ilT3vvRsFAqPeIdqHGKR4c25CoK5zZ1tNIv8egfgpD1gCKqOGmfAz0pIKQnMuJU3eNg9KItC7A==} @@ -3615,11 +3615,11 @@ packages: peerDependencies: '@prisma/client': '>=4.16.1' - '@prisma/fetch-engine@6.0.1': - resolution: {integrity: sha512-T36bWFVGeGYYSyYOj9d+O9G3sBC+pAyMC+jc45iSL63/Haq1GrYjQPgPMxrEj9m739taXrupoysRedQ+VyvM/Q==} + '@prisma/fetch-engine@6.1.0': + resolution: {integrity: sha512-asdFi7TvPlEZ8CzSZ/+Du5wZ27q6OJbRSXh+S8ISZguu+S9KtS/gP7NeXceZyb1Jv1SM1S5YfiCv+STDsG6rrg==} - '@prisma/get-platform@6.0.1': - resolution: {integrity: sha512-zspC9vlxAqx4E6epMPMLLBMED2VD8axDe8sPnquZ8GOsn6tiacWK0oxrGK4UAHYzYUVuMVUApJbdXB2dFpLhvg==} + '@prisma/get-platform@6.1.0': + resolution: {integrity: sha512-ia8bNjboBoHkmKGGaWtqtlgQOhCi7+f85aOkPJKgNwWvYrT6l78KgojLekE8zMhVk0R9lWcifV0Pf8l3/15V0Q==} '@prisma/instrumentation@5.19.1': resolution: {integrity: sha512-VLnzMQq7CWroL5AeaW0Py2huiNKeoMfCH3SUxstdzPrlWQi6UQ9UrfcbUkNHlVFqOMacqy8X/8YtE0kuKDpD9w==} @@ -9315,8 +9315,8 @@ packages: peerDependencies: react: '>=16.0.0' - prisma@6.0.1: - resolution: {integrity: sha512-CaMNFHkf+DDq8zq3X/JJsQ4Koy7dyWwwtOKibkT/Am9j/tDxcfbg7+lB1Dzhx18G/+RQCMgjPYB61bhRqteNBQ==} + prisma@6.1.0: + resolution: {integrity: sha512-aFI3Yi+ApUxkwCJJwyQSwpyzUX7YX3ihzuHNHOyv4GJg3X5tQsmRaJEnZ+ZyfHpMtnyahhmXVfbTZ+lS8ZtfKw==} engines: {node: '>=18.18'} hasBin: true @@ -13306,34 +13306,34 @@ snapshots: '@polka/url@1.0.0-next.25': {} - '@prisma/client@6.0.1(prisma@6.0.1)': + '@prisma/client@6.1.0(prisma@6.1.0)': optionalDependencies: - prisma: 6.0.1 + prisma: 6.1.0 - '@prisma/debug@6.0.1': {} + '@prisma/debug@6.1.0': {} - '@prisma/engines-version@5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e': {} + '@prisma/engines-version@6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959': {} - '@prisma/engines@6.0.1': + '@prisma/engines@6.1.0': dependencies: - '@prisma/debug': 6.0.1 - '@prisma/engines-version': 5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e - '@prisma/fetch-engine': 6.0.1 - '@prisma/get-platform': 6.0.1 + '@prisma/debug': 6.1.0 + '@prisma/engines-version': 6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959 + '@prisma/fetch-engine': 6.1.0 + '@prisma/get-platform': 6.1.0 - '@prisma/extension-accelerate@1.2.1(@prisma/client@6.0.1(prisma@6.0.1))': + '@prisma/extension-accelerate@1.2.1(@prisma/client@6.1.0(prisma@6.1.0))': dependencies: - '@prisma/client': 6.0.1(prisma@6.0.1) + '@prisma/client': 6.1.0(prisma@6.1.0) - '@prisma/fetch-engine@6.0.1': + '@prisma/fetch-engine@6.1.0': dependencies: - '@prisma/debug': 6.0.1 - '@prisma/engines-version': 5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e - '@prisma/get-platform': 6.0.1 + '@prisma/debug': 6.1.0 + '@prisma/engines-version': 6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959 + '@prisma/get-platform': 6.1.0 - '@prisma/get-platform@6.0.1': + '@prisma/get-platform@6.1.0': dependencies: - '@prisma/debug': 6.0.1 + '@prisma/debug': 6.1.0 '@prisma/instrumentation@5.19.1': dependencies: @@ -20337,9 +20337,9 @@ snapshots: clsx: 1.2.1 react: 18.3.1 - prisma@6.0.1: + prisma@6.1.0: dependencies: - '@prisma/engines': 6.0.1 + '@prisma/engines': 6.1.0 optionalDependencies: fsevents: 2.3.3 From 976a48813db6cd067e8e98832847bfed2031a60f Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Thu, 19 Dec 2024 20:57:46 -0800 Subject: [PATCH 02/16] improve user read --- apps/backend/src/app/api/v1/users/crud.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/backend/src/app/api/v1/users/crud.tsx b/apps/backend/src/app/api/v1/users/crud.tsx index de3072009..340c278da 100644 --- a/apps/backend/src/app/api/v1/users/crud.tsx +++ b/apps/backend/src/app/api/v1/users/crud.tsx @@ -273,11 +273,10 @@ export const usersCrudHandlers = createLazyProxy(() => createCrudHandlers(usersC query: yupString().optional().meta({ openapiField: { onlyShowInOperations: [ 'List' ], description: "A search query to filter the results by. This is a free-text search that is applied to the user's display name and primary email." }}), }), onRead: async ({ auth, params }) => { - const user = await getUser({ projectId: auth.project.id, userId: params.user_id }); - if (!user) { + if (!auth.user) { throw new KnownErrors.UserNotFound(); } - return user; + return auth.user; }, onList: async ({ auth, query }) => { const where = { From 22760df6ca37ebe0a52256003d480752d5172a71 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Thu, 19 Dec 2024 20:58:17 -0800 Subject: [PATCH 03/16] revert --- apps/backend/src/app/api/v1/users/crud.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/backend/src/app/api/v1/users/crud.tsx b/apps/backend/src/app/api/v1/users/crud.tsx index 340c278da..de3072009 100644 --- a/apps/backend/src/app/api/v1/users/crud.tsx +++ b/apps/backend/src/app/api/v1/users/crud.tsx @@ -273,10 +273,11 @@ export const usersCrudHandlers = createLazyProxy(() => createCrudHandlers(usersC query: yupString().optional().meta({ openapiField: { onlyShowInOperations: [ 'List' ], description: "A search query to filter the results by. This is a free-text search that is applied to the user's display name and primary email." }}), }), onRead: async ({ auth, params }) => { - if (!auth.user) { + const user = await getUser({ projectId: auth.project.id, userId: params.user_id }); + if (!user) { throw new KnownErrors.UserNotFound(); } - return auth.user; + return user; }, onList: async ({ auth, query }) => { const where = { From 289bab9ceb6111bf3ab31031bdcc843ade7252e7 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Fri, 20 Dec 2024 09:37:07 -0800 Subject: [PATCH 04/16] fixed codegen --- apps/backend/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index 15c5b5564..3391689fa 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -13,9 +13,9 @@ "self-host-seed-script": "tsup --config prisma/tsup.config.ts", "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", - "codegen-prisma": "pnpm run prisma generate", + "codegen-prisma": "pnpm run prisma generate --sql", "codegen-prisma:watch": "pnpm run prisma generate --sql --watch", - "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", + "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", "psql-inner": "psql $STACK_DATABASE_CONNECTION_STRING", "psql": "pnpm run with-env pnpm run psql-inner", From 4b9645bd4818f953d02942b1f12ff085a34e5990 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Fri, 20 Dec 2024 10:02:07 -0800 Subject: [PATCH 05/16] changed prisma version --- apps/backend/package.json | 2 +- pnpm-lock.yaml | 70 +++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index 3391689fa..d6f4a08ef 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -83,7 +83,7 @@ "concurrently": "^8.2.2", "glob": "^10.4.1", "import-in-the-middle": "^1.12.0", - "prisma": "^6.1.0", + "prisma": "^6.0.1", "require-in-the-middle": "^7.4.0", "rimraf": "^5.0.5", "tsup": "^8.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f33cc254f..1753982d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -128,10 +128,10 @@ importers: version: 1.27.0 '@prisma/client': specifier: ^6.1.0 - version: 6.1.0(prisma@6.1.0) + version: 6.1.0(prisma@6.0.1) '@prisma/extension-accelerate': specifier: ^1.2.1 - version: 1.2.1(@prisma/client@6.1.0(prisma@6.1.0)) + version: 1.2.1(@prisma/client@6.1.0(prisma@6.0.1)) '@prisma/instrumentation': specifier: ^5.19.1 version: 5.20.0 @@ -242,8 +242,8 @@ importers: specifier: ^1.12.0 version: 1.12.0 prisma: - specifier: ^6.1.0 - version: 6.1.0 + specifier: ^6.0.1 + version: 6.0.1 require-in-the-middle: specifier: ^7.4.0 version: 7.4.0 @@ -3600,14 +3600,14 @@ packages: prisma: optional: true - '@prisma/debug@6.1.0': - resolution: {integrity: sha512-0himsvcM4DGBTtvXkd2Tggv6sl2JyUYLzEGXXleFY+7Kp6rZeSS3hiTW9mwtUlXrwYbJP6pwlVNB7jYElrjWUg==} + '@prisma/debug@6.0.1': + resolution: {integrity: sha512-jQylgSOf7ibTVxqBacnAlVGvek6fQxJIYCQOeX2KexsfypNzXjJQSS2o5s+Mjj2Np93iSOQUaw6TvPj8syhG4w==} - '@prisma/engines-version@6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959': - resolution: {integrity: sha512-PdJqmYM2Fd8K0weOOtQThWylwjsDlTig+8Pcg47/jszMuLL9iLIaygC3cjWJLda69siRW4STlCTMSgOjZzvKPQ==} + '@prisma/engines-version@5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e': + resolution: {integrity: sha512-JmIds0Q2/vsOmnuTJYxY4LE+sajqjYKhLtdOT6y4imojqv5d/aeVEfbBGC74t8Be1uSp0OP8lxIj2OqoKbLsfQ==} - '@prisma/engines@6.1.0': - resolution: {integrity: sha512-GnYJbCiep3Vyr1P/415ReYrgJUjP79fBNc1wCo7NP6Eia0CzL2Ot9vK7Infczv3oK7JLrCcawOSAxFxNFsAERQ==} + '@prisma/engines@6.0.1': + resolution: {integrity: sha512-4hxzI+YQIR2uuDyVsDooFZGu5AtixbvM2psp+iayDZ4hRrAHo/YwgA17N23UWq7G6gRu18NvuNMb48qjP3DPQw==} '@prisma/extension-accelerate@1.2.1': resolution: {integrity: sha512-QicnMeyqL226ilT3vvRsFAqPeIdqHGKR4c25CoK5zZ1tNIv8egfgpD1gCKqOGmfAz0pIKQnMuJU3eNg9KItC7A==} @@ -3615,11 +3615,11 @@ packages: peerDependencies: '@prisma/client': '>=4.16.1' - '@prisma/fetch-engine@6.1.0': - resolution: {integrity: sha512-asdFi7TvPlEZ8CzSZ/+Du5wZ27q6OJbRSXh+S8ISZguu+S9KtS/gP7NeXceZyb1Jv1SM1S5YfiCv+STDsG6rrg==} + '@prisma/fetch-engine@6.0.1': + resolution: {integrity: sha512-T36bWFVGeGYYSyYOj9d+O9G3sBC+pAyMC+jc45iSL63/Haq1GrYjQPgPMxrEj9m739taXrupoysRedQ+VyvM/Q==} - '@prisma/get-platform@6.1.0': - resolution: {integrity: sha512-ia8bNjboBoHkmKGGaWtqtlgQOhCi7+f85aOkPJKgNwWvYrT6l78KgojLekE8zMhVk0R9lWcifV0Pf8l3/15V0Q==} + '@prisma/get-platform@6.0.1': + resolution: {integrity: sha512-zspC9vlxAqx4E6epMPMLLBMED2VD8axDe8sPnquZ8GOsn6tiacWK0oxrGK4UAHYzYUVuMVUApJbdXB2dFpLhvg==} '@prisma/instrumentation@5.19.1': resolution: {integrity: sha512-VLnzMQq7CWroL5AeaW0Py2huiNKeoMfCH3SUxstdzPrlWQi6UQ9UrfcbUkNHlVFqOMacqy8X/8YtE0kuKDpD9w==} @@ -9315,8 +9315,8 @@ packages: peerDependencies: react: '>=16.0.0' - prisma@6.1.0: - resolution: {integrity: sha512-aFI3Yi+ApUxkwCJJwyQSwpyzUX7YX3ihzuHNHOyv4GJg3X5tQsmRaJEnZ+ZyfHpMtnyahhmXVfbTZ+lS8ZtfKw==} + prisma@6.0.1: + resolution: {integrity: sha512-CaMNFHkf+DDq8zq3X/JJsQ4Koy7dyWwwtOKibkT/Am9j/tDxcfbg7+lB1Dzhx18G/+RQCMgjPYB61bhRqteNBQ==} engines: {node: '>=18.18'} hasBin: true @@ -13306,34 +13306,34 @@ snapshots: '@polka/url@1.0.0-next.25': {} - '@prisma/client@6.1.0(prisma@6.1.0)': + '@prisma/client@6.1.0(prisma@6.0.1)': optionalDependencies: - prisma: 6.1.0 + prisma: 6.0.1 - '@prisma/debug@6.1.0': {} + '@prisma/debug@6.0.1': {} - '@prisma/engines-version@6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959': {} + '@prisma/engines-version@5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e': {} - '@prisma/engines@6.1.0': + '@prisma/engines@6.0.1': dependencies: - '@prisma/debug': 6.1.0 - '@prisma/engines-version': 6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959 - '@prisma/fetch-engine': 6.1.0 - '@prisma/get-platform': 6.1.0 + '@prisma/debug': 6.0.1 + '@prisma/engines-version': 5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e + '@prisma/fetch-engine': 6.0.1 + '@prisma/get-platform': 6.0.1 - '@prisma/extension-accelerate@1.2.1(@prisma/client@6.1.0(prisma@6.1.0))': + '@prisma/extension-accelerate@1.2.1(@prisma/client@6.1.0(prisma@6.0.1))': dependencies: - '@prisma/client': 6.1.0(prisma@6.1.0) + '@prisma/client': 6.1.0(prisma@6.0.1) - '@prisma/fetch-engine@6.1.0': + '@prisma/fetch-engine@6.0.1': dependencies: - '@prisma/debug': 6.1.0 - '@prisma/engines-version': 6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959 - '@prisma/get-platform': 6.1.0 + '@prisma/debug': 6.0.1 + '@prisma/engines-version': 5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e + '@prisma/get-platform': 6.0.1 - '@prisma/get-platform@6.1.0': + '@prisma/get-platform@6.0.1': dependencies: - '@prisma/debug': 6.1.0 + '@prisma/debug': 6.0.1 '@prisma/instrumentation@5.19.1': dependencies: @@ -20337,9 +20337,9 @@ snapshots: clsx: 1.2.1 react: 18.3.1 - prisma@6.1.0: + prisma@6.0.1: dependencies: - '@prisma/engines': 6.1.0 + '@prisma/engines': 6.0.1 optionalDependencies: fsevents: 2.3.3 From 22a6b406d9d7150052444411ad7bf9c6b213362b Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 11:22:54 -0800 Subject: [PATCH 06/16] added pglite server --- .dockerignore | 3 +- .gitignore | 1 + apps/backend/package.json | 2 + apps/backend/scripts/run-pg-gateway.mjs | 50 +++++++++++++ pnpm-lock.yaml | 95 +++++++++++++++++++++++-- 5 files changed, 143 insertions(+), 8 deletions(-) create mode 100644 apps/backend/scripts/run-pg-gateway.mjs diff --git a/.dockerignore b/.dockerignore index 2eff84b4e..746c190da 100644 --- a/.dockerignore +++ b/.dockerignore @@ -57,6 +57,7 @@ packages/adapter-prisma/prisma/migrations db.sqlite packages/adapter-supabase/supabase/.branches packages/adapter-drizzle/.drizzle +pglite-data/ # Tests coverage @@ -136,4 +137,4 @@ node_modules deploy !deploy/docker/**/entrypoint.sh -docker-compose.yaml +docker-compose.yaml \ No newline at end of file diff --git a/.gitignore b/.gitignore index b6e934f7c..683d6f75e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ packages/adapter-prisma/prisma/migrations db.sqlite packages/adapter-supabase/supabase/.branches packages/adapter-drizzle/.drizzle +pglite-data/ # Tests coverage diff --git a/apps/backend/package.json b/apps/backend/package.json index d6f4a08ef..4cbeb43c8 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -30,6 +30,7 @@ "seed": "pnpm run with-env tsx prisma/seed.ts" }, "dependencies": { + "@electric-sql/pglite": "0.2.7", "@next/bundle-analyzer": "15.0.3", "@node-oauth/oauth2-server": "^5.1.0", "@opentelemetry/api": "^1.9.0", @@ -62,6 +63,7 @@ "openid-client": "^5.6.4", "oslo": "^1.2.1", "pg": "^8.11.3", + "pg-gateway": "0.3.0-beta.3", "posthog-node": "^4.1.0", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/apps/backend/scripts/run-pg-gateway.mjs b/apps/backend/scripts/run-pg-gateway.mjs new file mode 100644 index 000000000..e06ab4628 --- /dev/null +++ b/apps/backend/scripts/run-pg-gateway.mjs @@ -0,0 +1,50 @@ +import { PGlite } from '@electric-sql/pglite'; +import net from 'node:net'; +import { fromNodeSocket } from 'pg-gateway/node'; + +const db = new PGlite(); + +const server = net.createServer(async (socket) => { + let activeDb; + + console.info(`Client connected: ${socket.remoteAddress}:${socket.remotePort}`) + await fromNodeSocket(socket, { + serverVersion: '16.3', + + auth: { + // No password required + method: 'trust', + }, + + async onStartup({ clientParams }) { + console.info(`Connecting client to ${clientParams?.database}`) + // If the DB is the Prisma shadow DB, create a temp in-memory instance + if (clientParams?.database === 'prisma-shadow') { + activeDb = new PGlite() + } else { + activeDb = db + } + + // Wait for PGlite to be ready before further processing + await activeDb.waitReady + }, + + async onMessage(data, { isAuthenticated }) { + if (!isAuthenticated) { + // currently we have no authentication, but let's keep it for the future + return + } + + // Forward raw message to PGlite and send response to client + return await activeDb.execProtocolRaw(data) + }, + }) + + socket.on('end', () => { + console.info('Client disconnected') + }) +}) + +server.listen(5432, () => { + console.info('Server listening on port 5432') +}) \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1753982d9..60256dde6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -87,6 +87,9 @@ importers: apps/backend: dependencies: + '@electric-sql/pglite': + specifier: 0.2.7 + version: 0.2.7 '@next/bundle-analyzer': specifier: 15.0.3 version: 15.0.3 @@ -183,6 +186,9 @@ importers: pg: specifier: ^8.11.3 version: 8.12.0 + pg-gateway: + specifier: 0.3.0-beta.3 + version: 0.3.0-beta.3 posthog-node: specifier: ^4.1.0 version: 4.1.0 @@ -252,7 +258,7 @@ importers: version: 5.0.7 tsup: specifier: ^8.3.0 - version: 8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.3.3)(yaml@2.4.5) + version: 8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.7.2)(yaml@2.4.5) tsx: specifier: ^4.7.2 version: 4.15.5 @@ -765,6 +771,31 @@ importers: specifier: ^10.1.0 version: 10.1.0 + packages/pg-gateway: + dependencies: + pg-protocol: + specifier: ^1.6.1 + version: 1.6.1 + devDependencies: + '@electric-sql/pglite': + specifier: npm:@gregnr/pglite@0.2.0-dev.8 + version: '@gregnr/pglite@0.2.0-dev.8' + '@types/node': + specifier: ^20.14.11 + version: 20.17.6 + pg: + specifier: ^8.12.0 + version: 8.12.0 + tsup: + specifier: ^8.2.3 + version: 8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.16.2)(typescript@5.7.2)(yaml@2.6.0) + tsx: + specifier: ^4.16.2 + version: 4.16.2 + typescript: + specifier: ^5.5.3 + version: 5.7.2 + packages/stack: dependencies: '@hookform/resolvers': @@ -896,7 +927,7 @@ importers: version: 3.4.4 tsup: specifier: ^8.0.2 - version: 8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.3.3) + version: 8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.7.2) packages/stack-emails: dependencies: @@ -1531,6 +1562,9 @@ packages: resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} engines: {node: '>=10.0.0'} + '@electric-sql/pglite@0.2.7': + resolution: {integrity: sha512-8Il//XHTAtZ8VeQF+6P1UjsIoaAJyO4LwOMoXhSFaHpmkwKs63cUhHHNzLzUmcZvP/ZTmlT3+xTiWfU/EyoxwQ==} + '@emnapi/core@0.45.0': resolution: {integrity: sha512-DPWjcUDQkCeEM4VnljEOEcXdAD7pp8zSZsgOujk/LGIwCXWbXJngin+MO4zbH429lzeC3WbYLGjE2MaUOwzpyw==} @@ -2418,6 +2452,9 @@ packages: '@formatjs/intl-localematcher@0.5.4': resolution: {integrity: sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g==} + '@gregnr/pglite@0.2.0-dev.8': + resolution: {integrity: sha512-re5b8EOnQIq22us7aT/BnstyDDGk/M90FdDhxDufrPFAme+9TWpdTSQGFAyBq8BqjhL4O7WHB2M1KTKw02gmUw==} + '@gulpjs/to-absolute-glob@4.0.0': resolution: {integrity: sha512-kjotm7XJrJ6v+7knhPaRgaT6q8F8K2jiafwYdNHLzmV0uGLuZY43FK6smNSHUPrhq5kX2slCUy+RGG/xGqmIKA==} engines: {node: '>=10.13.0'} @@ -9116,6 +9153,9 @@ packages: pg-connection-string@2.6.4: resolution: {integrity: sha512-v+Z7W/0EO707aNMaAEfiGnGL9sxxumwLl2fJvCQtMn9Fxsg+lPpPkdcyBSv/KFgpGdYkMfn+EI1Or2EHjpgLCA==} + pg-gateway@0.3.0-beta.3: + resolution: {integrity: sha512-tzO/TSlFzgu6AJvn4clzZpDfCDyRjG/GnGYtdi1kgN+h+TmaD/1xDfqqVhcknPDx7qQaViq8JW7aQiazn3QaqQ==} + pg-int8@1.0.1: resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} engines: {node: '>=4.0.0'} @@ -10563,6 +10603,11 @@ packages: engines: {node: '>=14.17'} hasBin: true + typescript@5.7.2: + resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} + engines: {node: '>=14.17'} + hasBin: true + ufo@1.5.4: resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} @@ -11627,6 +11672,8 @@ snapshots: '@discoveryjs/json-ext@0.5.7': {} + '@electric-sql/pglite@0.2.7': {} + '@emnapi/core@0.45.0': dependencies: tslib: 2.8.1 @@ -12251,6 +12298,8 @@ snapshots: dependencies: tslib: 2.6.3 + '@gregnr/pglite@0.2.0-dev.8': {} + '@gulpjs/to-absolute-glob@4.0.0': dependencies: is-negated-glob: 1.0.0 @@ -18318,7 +18367,7 @@ snapshots: lilconfig: 3.1.2 rsvp: 4.8.5 sort-keys: 5.0.0 - typescript: 5.3.3 + typescript: 5.7.2 vinyl: 3.0.0 vinyl-fs: 4.0.0 transitivePeerDependencies: @@ -20119,6 +20168,8 @@ snapshots: pg-connection-string@2.6.4: {} + pg-gateway@0.3.0-beta.3: {} + pg-int8@1.0.1: {} pg-pool@3.6.2(pg@8.12.0): @@ -21802,7 +21853,7 @@ snapshots: tsscmp@1.0.6: {} - tsup@8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.3.3): + tsup@8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.7.2): dependencies: bundle-require: 4.2.1(esbuild@0.21.5) cac: 6.7.14 @@ -21821,12 +21872,12 @@ snapshots: optionalDependencies: '@swc/core': 1.3.101(@swc/helpers@0.5.13) postcss: 8.4.38 - typescript: 5.3.3 + typescript: 5.7.2 transitivePeerDependencies: - supports-color - ts-node - tsup@8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.3.3)(yaml@2.4.5): + tsup@8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.7.2)(yaml@2.4.5): dependencies: bundle-require: 5.0.0(esbuild@0.24.0) cac: 6.7.14 @@ -21847,7 +21898,7 @@ snapshots: optionalDependencies: '@swc/core': 1.3.101(@swc/helpers@0.5.13) postcss: 8.4.47 - typescript: 5.3.3 + typescript: 5.7.2 transitivePeerDependencies: - jiti - supports-color @@ -21882,6 +21933,34 @@ snapshots: - tsx - yaml + tsup@8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.16.2)(typescript@5.7.2)(yaml@2.6.0): + dependencies: + bundle-require: 5.0.0(esbuild@0.24.0) + cac: 6.7.14 + chokidar: 4.0.1 + consola: 3.2.3 + debug: 4.3.7 + esbuild: 0.24.0 + joycon: 3.1.1 + picocolors: 1.1.1 + postcss-load-config: 6.0.1(jiti@1.21.6)(postcss@8.4.47)(tsx@4.16.2)(yaml@2.6.0) + resolve-from: 5.0.0 + rollup: 4.24.4 + source-map: 0.8.0-beta.0 + sucrase: 3.35.0 + tinyexec: 0.3.1 + tinyglobby: 0.2.10 + tree-kill: 1.2.2 + optionalDependencies: + '@swc/core': 1.3.101(@swc/helpers@0.5.13) + postcss: 8.4.47 + typescript: 5.7.2 + transitivePeerDependencies: + - jiti + - supports-color + - tsx + - yaml + tsx@4.15.5: dependencies: esbuild: 0.21.5 @@ -21988,6 +22067,8 @@ snapshots: typescript@5.3.3: {} + typescript@5.7.2: {} + ufo@1.5.4: {} uglify-js@3.18.0: From a342d9876f3045f19e2a517eaa36ebec965db643 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 11:45:41 -0800 Subject: [PATCH 07/16] added codegen script --- apps/backend/package.json | 2 +- .../scripts/{run-pg-gateway.mjs => mock-postgres.mjs} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename apps/backend/scripts/{run-pg-gateway.mjs => mock-postgres.mjs} (93%) diff --git a/apps/backend/package.json b/apps/backend/package.json index 4cbeb43c8..db6c191ca 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -13,7 +13,7 @@ "self-host-seed-script": "tsup --config prisma/tsup.config.ts", "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", - "codegen-prisma": "pnpm run prisma generate --sql", + "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" && pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\"", "codegen-prisma:watch": "pnpm run prisma generate --sql --watch", "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", diff --git a/apps/backend/scripts/run-pg-gateway.mjs b/apps/backend/scripts/mock-postgres.mjs similarity index 93% rename from apps/backend/scripts/run-pg-gateway.mjs rename to apps/backend/scripts/mock-postgres.mjs index e06ab4628..8fbec72a6 100644 --- a/apps/backend/scripts/run-pg-gateway.mjs +++ b/apps/backend/scripts/mock-postgres.mjs @@ -45,6 +45,6 @@ const server = net.createServer(async (socket) => { }) }) -server.listen(5432, () => { - console.info('Server listening on port 5432') -}) \ No newline at end of file +server.listen(8118, () => { + console.info('Postgres server listening on port 8118') +}) From 18150a377d44ef896a9f8dc115a1a59d515c2e09 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 11:51:14 -0800 Subject: [PATCH 08/16] added watch --- apps/backend/package.json | 3 +- pnpm-lock.yaml | 71 +++++---------------------------------- 2 files changed, 10 insertions(+), 64 deletions(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index db6c191ca..f266f9c0a 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -14,7 +14,7 @@ "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" && pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\"", - "codegen-prisma:watch": "pnpm run prisma generate --sql --watch", + "codegen-prisma:watch": "pnpm run codegen-prisma && chokidar \"prisma/**/*\" -c \"pnpm run codegen-prisma\"", "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", "psql-inner": "psql $STACK_DATABASE_CONNECTION_STRING", @@ -55,6 +55,7 @@ "@vercel/functions": "^1.4.2", "@vercel/otel": "^1.10.0", "bcrypt": "^5.1.1", + "chokidar-cli": "^3.0.0", "dotenv-cli": "^7.3.0", "jose": "^5.2.2", "next": "15.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 60256dde6..e58c05e78 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -162,6 +162,9 @@ importers: bcrypt: specifier: ^5.1.1 version: 5.1.1 + chokidar-cli: + specifier: ^3.0.0 + version: 3.0.0 dotenv-cli: specifier: ^7.3.0 version: 7.4.1 @@ -771,31 +774,6 @@ importers: specifier: ^10.1.0 version: 10.1.0 - packages/pg-gateway: - dependencies: - pg-protocol: - specifier: ^1.6.1 - version: 1.6.1 - devDependencies: - '@electric-sql/pglite': - specifier: npm:@gregnr/pglite@0.2.0-dev.8 - version: '@gregnr/pglite@0.2.0-dev.8' - '@types/node': - specifier: ^20.14.11 - version: 20.17.6 - pg: - specifier: ^8.12.0 - version: 8.12.0 - tsup: - specifier: ^8.2.3 - version: 8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.16.2)(typescript@5.7.2)(yaml@2.6.0) - tsx: - specifier: ^4.16.2 - version: 4.16.2 - typescript: - specifier: ^5.5.3 - version: 5.7.2 - packages/stack: dependencies: '@hookform/resolvers': @@ -2452,9 +2430,6 @@ packages: '@formatjs/intl-localematcher@0.5.4': resolution: {integrity: sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g==} - '@gregnr/pglite@0.2.0-dev.8': - resolution: {integrity: sha512-re5b8EOnQIq22us7aT/BnstyDDGk/M90FdDhxDufrPFAme+9TWpdTSQGFAyBq8BqjhL4O7WHB2M1KTKw02gmUw==} - '@gulpjs/to-absolute-glob@4.0.0': resolution: {integrity: sha512-kjotm7XJrJ6v+7knhPaRgaT6q8F8K2jiafwYdNHLzmV0uGLuZY43FK6smNSHUPrhq5kX2slCUy+RGG/xGqmIKA==} engines: {node: '>=10.13.0'} @@ -6253,8 +6228,8 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} - chokidar@4.0.1: - resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==} + chokidar@4.0.3: + resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} engines: {node: '>= 14.16.0'} chownr@1.1.4: @@ -12298,8 +12273,6 @@ snapshots: dependencies: tslib: 2.6.3 - '@gregnr/pglite@0.2.0-dev.8': {} - '@gulpjs/to-absolute-glob@4.0.0': dependencies: is-negated-glob: 1.0.0 @@ -16453,7 +16426,7 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - chokidar@4.0.1: + chokidar@4.0.3: dependencies: readdirp: 4.0.2 @@ -21881,7 +21854,7 @@ snapshots: dependencies: bundle-require: 5.0.0(esbuild@0.24.0) cac: 6.7.14 - chokidar: 4.0.1 + chokidar: 4.0.3 consola: 3.2.3 debug: 4.3.7 esbuild: 0.24.0 @@ -21909,7 +21882,7 @@ snapshots: dependencies: bundle-require: 5.0.0(esbuild@0.24.0) cac: 6.7.14 - chokidar: 4.0.1 + chokidar: 4.0.3 consola: 3.2.3 debug: 4.3.7 esbuild: 0.24.0 @@ -21933,34 +21906,6 @@ snapshots: - tsx - yaml - tsup@8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.16.2)(typescript@5.7.2)(yaml@2.6.0): - dependencies: - bundle-require: 5.0.0(esbuild@0.24.0) - cac: 6.7.14 - chokidar: 4.0.1 - consola: 3.2.3 - debug: 4.3.7 - esbuild: 0.24.0 - joycon: 3.1.1 - picocolors: 1.1.1 - postcss-load-config: 6.0.1(jiti@1.21.6)(postcss@8.4.47)(tsx@4.16.2)(yaml@2.6.0) - resolve-from: 5.0.0 - rollup: 4.24.4 - source-map: 0.8.0-beta.0 - sucrase: 3.35.0 - tinyexec: 0.3.1 - tinyglobby: 0.2.10 - tree-kill: 1.2.2 - optionalDependencies: - '@swc/core': 1.3.101(@swc/helpers@0.5.13) - postcss: 8.4.47 - typescript: 5.7.2 - transitivePeerDependencies: - - jiti - - supports-color - - tsx - - yaml - tsx@4.15.5: dependencies: esbuild: 0.21.5 From 6e7d3f6970cbdfa10036d98cade5668ef7e761c0 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 13:36:26 -0800 Subject: [PATCH 09/16] added with env --- apps/backend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index f266f9c0a..b06a0f3d8 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -13,7 +13,7 @@ "self-host-seed-script": "tsup --config prisma/tsup.config.ts", "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", - "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" && pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\"", + "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" && pnpm run with-env prisma migrate reset --force && pnpm run with-env prisma generate --sql\"", "codegen-prisma:watch": "pnpm run codegen-prisma && chokidar \"prisma/**/*\" -c \"pnpm run codegen-prisma\"", "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", From 7e2d7316ef8536a0ce76cea484b8b42298dc212d Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 13:43:57 -0800 Subject: [PATCH 10/16] fixed codegen --- apps/backend/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index b06a0f3d8..b2fdf7c9a 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -13,7 +13,8 @@ "self-host-seed-script": "tsup --config prisma/tsup.config.ts", "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", - "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" && pnpm run with-env prisma migrate reset --force && pnpm run with-env prisma generate --sql\"", + "codegen-prisma:env": "export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=\\\"test_key\\\" STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=\\\"test_secret\\\" STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=\\\"test_admin\\\"", + "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && pnpm run codegen-prisma:env && pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\"", "codegen-prisma:watch": "pnpm run codegen-prisma && chokidar \"prisma/**/*\" -c \"pnpm run codegen-prisma\"", "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", From a2940bd4d49199734e6c83a0eb5966cadcc9de9d Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 13:46:16 -0800 Subject: [PATCH 11/16] fixed codegen --- apps/backend/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index b2fdf7c9a..cd7671249 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -13,8 +13,7 @@ "self-host-seed-script": "tsup --config prisma/tsup.config.ts", "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", - "codegen-prisma:env": "export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=\\\"test_key\\\" STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=\\\"test_secret\\\" STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=\\\"test_admin\\\"", - "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && pnpm run codegen-prisma:env && pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\"", + "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=\\\"test_key\\\" STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=\\\"test_secret\\\" STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=\\\"test_admin\\\" && pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\"", "codegen-prisma:watch": "pnpm run codegen-prisma && chokidar \"prisma/**/*\" -c \"pnpm run codegen-prisma\"", "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", From 16fc9612e7dc694d7a331d1055a0d0bfa6283567 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 14:27:36 -0800 Subject: [PATCH 12/16] fixed env --- apps/backend/package.json | 3 ++- pnpm-lock.yaml | 47 ++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index e79201913..7aa3859de 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -13,7 +13,7 @@ "build-self-host-seed-script": "tsup --config prisma/tsup.config.ts", "analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build", "start": "next start --port 8102", - "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"sleep 2 && export STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=\\\"test_key\\\" STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=\\\"test_secret\\\" STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=\\\"test_admin\\\" && pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\"", + "codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"node -e \\\"setTimeout(() => process.exit(0), 2000)\\\" && cross-env STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=\\\"test_key\\\" STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=\\\"test_secret\\\" STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=\\\"test_admin\\\" sh -c \\\"pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\\\"\"", "codegen-prisma:watch": "pnpm run codegen-prisma && chokidar \"prisma/**/*\" -c \"pnpm run codegen-prisma\"", "codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'", "codegen:watch": "concurrently -n \"prisma,docs\" -k \"pnpm run codegen-prisma:watch\" \"pnpm run watch-docs\"", @@ -85,6 +85,7 @@ "@types/react-dom": "^19.0.0", "@types/semver": "^7.5.8", "concurrently": "^8.2.2", + "cross-env": "^7.0.3", "glob": "^10.4.1", "import-in-the-middle": "^1.12.0", "prisma": "^6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 388be9872..6889e6f05 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -244,6 +244,9 @@ importers: concurrently: specifier: ^8.2.2 version: 8.2.2 + cross-env: + specifier: ^7.0.3 + version: 7.0.3 glob: specifier: ^10.4.1 version: 10.4.1 @@ -261,7 +264,7 @@ importers: version: 5.0.7 tsup: specifier: ^8.3.0 - version: 8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.7.2)(yaml@2.4.5) + version: 8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.3.3)(yaml@2.4.5) tsx: specifier: ^4.7.2 version: 4.15.5 @@ -920,7 +923,7 @@ importers: version: 3.4.4 tsup: specifier: ^8.0.2 - version: 8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.7.2) + version: 8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.3.3) packages/stack-emails: dependencies: @@ -6310,8 +6313,8 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} - chokidar@4.0.3: - resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} + chokidar@4.0.1: + resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==} engines: {node: '>= 14.16.0'} chownr@1.1.4: @@ -6556,6 +6559,11 @@ packages: resolution: {integrity: sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==} engines: {node: '>=10'} + cross-env@7.0.3: + resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} + engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} + hasBin: true + cross-fetch@4.0.0: resolution: {integrity: sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==} @@ -10860,11 +10868,6 @@ packages: engines: {node: '>=14.17'} hasBin: true - typescript@5.7.2: - resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} - engines: {node: '>=14.17'} - hasBin: true - ufo@1.5.4: resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} @@ -16781,7 +16784,7 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - chokidar@4.0.3: + chokidar@4.0.1: dependencies: readdirp: 4.0.2 @@ -17000,6 +17003,10 @@ snapshots: path-type: 4.0.0 yaml: 1.10.2 + cross-env@7.0.3: + dependencies: + cross-spawn: 7.0.5 + cross-fetch@4.0.0: dependencies: node-fetch: 2.7.0 @@ -18113,7 +18120,7 @@ snapshots: execa@5.1.1: dependencies: - cross-spawn: 7.0.3 + cross-spawn: 7.0.5 get-stream: 6.0.1 human-signals: 2.1.0 is-stream: 2.0.1 @@ -18227,7 +18234,7 @@ snapshots: foreground-child@3.2.1: dependencies: - cross-spawn: 7.0.3 + cross-spawn: 7.0.5 signal-exit: 4.1.0 foreground-child@3.3.0: @@ -18794,7 +18801,7 @@ snapshots: lilconfig: 3.1.2 rsvp: 4.8.5 sort-keys: 5.0.0 - typescript: 5.7.2 + typescript: 5.3.3 vinyl: 3.0.0 vinyl-fs: 4.0.0 transitivePeerDependencies: @@ -22404,7 +22411,7 @@ snapshots: tsscmp@1.0.6: {} - tsup@8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.7.2): + tsup@8.1.0(@swc/core@1.3.101)(postcss@8.4.38)(typescript@5.3.3): dependencies: bundle-require: 4.2.1(esbuild@0.21.5) cac: 6.7.14 @@ -22423,16 +22430,16 @@ snapshots: optionalDependencies: '@swc/core': 1.3.101(@swc/helpers@0.5.13) postcss: 8.4.38 - typescript: 5.7.2 + typescript: 5.3.3 transitivePeerDependencies: - supports-color - ts-node - tsup@8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.7.2)(yaml@2.4.5): + tsup@8.3.5(@swc/core@1.3.101)(jiti@1.21.6)(postcss@8.4.47)(tsx@4.15.5)(typescript@5.3.3)(yaml@2.4.5): dependencies: bundle-require: 5.0.0(esbuild@0.24.0) cac: 6.7.14 - chokidar: 4.0.3 + chokidar: 4.0.1 consola: 3.2.3 debug: 4.3.7 esbuild: 0.24.0 @@ -22449,7 +22456,7 @@ snapshots: optionalDependencies: '@swc/core': 1.3.101(@swc/helpers@0.5.13) postcss: 8.4.47 - typescript: 5.7.2 + typescript: 5.3.3 transitivePeerDependencies: - jiti - supports-color @@ -22460,7 +22467,7 @@ snapshots: dependencies: bundle-require: 5.0.0(esbuild@0.24.0) cac: 6.7.14 - chokidar: 4.0.3 + chokidar: 4.0.1 consola: 3.2.3 debug: 4.3.7 esbuild: 0.24.0 @@ -22590,8 +22597,6 @@ snapshots: typescript@5.3.3: {} - typescript@5.7.2: {} - ufo@1.5.4: {} uglify-js@3.18.0: From 7ef8c1e7716e2958c6c1e48f4c82d0edd329f5c7 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 14:38:54 -0800 Subject: [PATCH 13/16] prisma 6.0.1 --- apps/backend/package.json | 2 +- pnpm-lock.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/backend/package.json b/apps/backend/package.json index 7aa3859de..c2f89a5c3 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -88,7 +88,7 @@ "cross-env": "^7.0.3", "glob": "^10.4.1", "import-in-the-middle": "^1.12.0", - "prisma": "^6.0.1", + "prisma": "6.0.1", "require-in-the-middle": "^7.4.0", "rimraf": "^5.0.5", "tsup": "^8.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6889e6f05..68190ddeb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -254,7 +254,7 @@ importers: specifier: ^1.12.0 version: 1.12.0 prisma: - specifier: ^6.0.1 + specifier: 6.0.1 version: 6.0.1 require-in-the-middle: specifier: ^7.4.0 From 10e9b960d5b923e77000f3880a9934caa8aa1d8f Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 14:53:41 -0800 Subject: [PATCH 14/16] disabled sentry --- apps/backend/package.json | 2 +- apps/backend/sentry.client.config.ts | 78 ++++++++++++++-------------- apps/backend/src/instrumentation.ts | 51 ------------------ pnpm-lock.yaml | 70 ++++++++++++------------- 4 files changed, 75 insertions(+), 126 deletions(-) delete mode 100644 apps/backend/src/instrumentation.ts diff --git a/apps/backend/package.json b/apps/backend/package.json index c2f89a5c3..a1f452bd0 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -88,7 +88,7 @@ "cross-env": "^7.0.3", "glob": "^10.4.1", "import-in-the-middle": "^1.12.0", - "prisma": "6.0.1", + "prisma": "^6.1.0", "require-in-the-middle": "^7.4.0", "rimraf": "^5.0.5", "tsup": "^8.3.0", diff --git a/apps/backend/sentry.client.config.ts b/apps/backend/sentry.client.config.ts index cb8809cfb..b364e32e6 100644 --- a/apps/backend/sentry.client.config.ts +++ b/apps/backend/sentry.client.config.ts @@ -2,47 +2,47 @@ // The config you add here will be used whenever a users loads a page in their browser. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import * as Sentry from "@sentry/nextjs"; -import { getBrowserCompatibilityReport } from "@stackframe/stack-shared/dist/utils/browser-compat"; -import { sentryBaseConfig } from "@stackframe/stack-shared/dist/utils/sentry"; -import { nicify } from "@stackframe/stack-shared/dist/utils/strings"; +// import * as Sentry from "@sentry/nextjs"; +// import { getBrowserCompatibilityReport } from "@stackframe/stack-shared/dist/utils/browser-compat"; +// import { sentryBaseConfig } from "@stackframe/stack-shared/dist/utils/sentry"; +// import { nicify } from "@stackframe/stack-shared/dist/utils/strings"; -Sentry.init({ - ...sentryBaseConfig, +// Sentry.init({ +// ...sentryBaseConfig, - dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, +// dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - enabled: process.env.NODE_ENV !== "development" && !process.env.CI, +// enabled: process.env.NODE_ENV !== "development" && !process.env.CI, - // You can remove this option if you're not planning to use the Sentry Session Replay feature: - integrations: [ - Sentry.replayIntegration({ - // Additional Replay configuration goes in here, for example: - maskAllText: false, - blockAllMedia: false, - }), - ], +// // You can remove this option if you're not planning to use the Sentry Session Replay feature: +// integrations: [ +// Sentry.replayIntegration({ +// // Additional Replay configuration goes in here, for example: +// maskAllText: false, +// blockAllMedia: false, +// }), +// ], - // Add exception metadata to the event - beforeSend(event, hint) { - const error = hint.originalException; - let nicified; - try { - nicified = nicify(error, { maxDepth: 8 }); - } catch (e) { - nicified = `Error occurred during nicification: ${e}`; - } - if (error instanceof Error) { - event.extra = { - ...event.extra, - cause: error.cause, - errorProps: { - ...error, - }, - nicifiedError: nicified, - clientBrowserCompatibility: getBrowserCompatibilityReport(), - }; - } - return event; - }, -}); +// // Add exception metadata to the event +// beforeSend(event, hint) { +// const error = hint.originalException; +// let nicified; +// try { +// nicified = nicify(error, { maxDepth: 8 }); +// } catch (e) { +// nicified = `Error occurred during nicification: ${e}`; +// } +// if (error instanceof Error) { +// event.extra = { +// ...event.extra, +// cause: error.cause, +// errorProps: { +// ...error, +// }, +// nicifiedError: nicified, +// clientBrowserCompatibility: getBrowserCompatibilityReport(), +// }; +// } +// return event; +// }, +// }); diff --git a/apps/backend/src/instrumentation.ts b/apps/backend/src/instrumentation.ts deleted file mode 100644 index e8644c10f..000000000 --- a/apps/backend/src/instrumentation.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { PrismaInstrumentation } from "@prisma/instrumentation"; -import * as Sentry from "@sentry/nextjs"; -import { getEnvVariable, getNextRuntime, getNodeEnvironment } from "@stackframe/stack-shared/dist/utils/env"; -import { sentryBaseConfig } from "@stackframe/stack-shared/dist/utils/sentry"; -import { nicify } from "@stackframe/stack-shared/dist/utils/strings"; -import { registerOTel } from '@vercel/otel'; -import "./polyfills"; - -export function register() { - registerOTel({ - serviceName: 'stack-backend', - instrumentations: [new PrismaInstrumentation()], - }); - - if (getNextRuntime() === "nodejs") { - process.title = "stack-backend (nextjs)"; - } - - if (getNextRuntime() === "nodejs" || getNextRuntime() === "edge") { - Sentry.init({ - ...sentryBaseConfig, - - dsn: getEnvVariable("NEXT_PUBLIC_SENTRY_DSN", ""), - - enabled: getNodeEnvironment() !== "development" && !getEnvVariable("CI", ""), - - // Add exception metadata to the event - beforeSend(event, hint) { - const error = hint.originalException; - let nicified; - try { - nicified = nicify(error, { maxDepth: 8 }); - } catch (e) { - nicified = `Error occurred during nicification: ${e}`; - } - if (error instanceof Error) { - event.extra = { - ...event.extra, - cause: error.cause, - errorProps: { - ...error, - }, - nicifiedError: nicified, - }; - } - return event; - }, - }); - - } -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 68190ddeb..d43e4ba8d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -131,10 +131,10 @@ importers: version: 1.27.0 '@prisma/client': specifier: ^6.1.0 - version: 6.1.0(prisma@6.0.1) + version: 6.1.0(prisma@6.1.0) '@prisma/extension-accelerate': specifier: ^1.2.1 - version: 1.2.1(@prisma/client@6.1.0(prisma@6.0.1)) + version: 1.2.1(@prisma/client@6.1.0(prisma@6.1.0)) '@prisma/instrumentation': specifier: ^5.19.1 version: 5.20.0 @@ -254,8 +254,8 @@ importers: specifier: ^1.12.0 version: 1.12.0 prisma: - specifier: 6.0.1 - version: 6.0.1 + specifier: ^6.1.0 + version: 6.1.0 require-in-the-middle: specifier: ^7.4.0 version: 7.4.0 @@ -3633,14 +3633,14 @@ packages: prisma: optional: true - '@prisma/debug@6.0.1': - resolution: {integrity: sha512-jQylgSOf7ibTVxqBacnAlVGvek6fQxJIYCQOeX2KexsfypNzXjJQSS2o5s+Mjj2Np93iSOQUaw6TvPj8syhG4w==} + '@prisma/debug@6.1.0': + resolution: {integrity: sha512-0himsvcM4DGBTtvXkd2Tggv6sl2JyUYLzEGXXleFY+7Kp6rZeSS3hiTW9mwtUlXrwYbJP6pwlVNB7jYElrjWUg==} - '@prisma/engines-version@5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e': - resolution: {integrity: sha512-JmIds0Q2/vsOmnuTJYxY4LE+sajqjYKhLtdOT6y4imojqv5d/aeVEfbBGC74t8Be1uSp0OP8lxIj2OqoKbLsfQ==} + '@prisma/engines-version@6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959': + resolution: {integrity: sha512-PdJqmYM2Fd8K0weOOtQThWylwjsDlTig+8Pcg47/jszMuLL9iLIaygC3cjWJLda69siRW4STlCTMSgOjZzvKPQ==} - '@prisma/engines@6.0.1': - resolution: {integrity: sha512-4hxzI+YQIR2uuDyVsDooFZGu5AtixbvM2psp+iayDZ4hRrAHo/YwgA17N23UWq7G6gRu18NvuNMb48qjP3DPQw==} + '@prisma/engines@6.1.0': + resolution: {integrity: sha512-GnYJbCiep3Vyr1P/415ReYrgJUjP79fBNc1wCo7NP6Eia0CzL2Ot9vK7Infczv3oK7JLrCcawOSAxFxNFsAERQ==} '@prisma/extension-accelerate@1.2.1': resolution: {integrity: sha512-QicnMeyqL226ilT3vvRsFAqPeIdqHGKR4c25CoK5zZ1tNIv8egfgpD1gCKqOGmfAz0pIKQnMuJU3eNg9KItC7A==} @@ -3648,11 +3648,11 @@ packages: peerDependencies: '@prisma/client': '>=4.16.1' - '@prisma/fetch-engine@6.0.1': - resolution: {integrity: sha512-T36bWFVGeGYYSyYOj9d+O9G3sBC+pAyMC+jc45iSL63/Haq1GrYjQPgPMxrEj9m739taXrupoysRedQ+VyvM/Q==} + '@prisma/fetch-engine@6.1.0': + resolution: {integrity: sha512-asdFi7TvPlEZ8CzSZ/+Du5wZ27q6OJbRSXh+S8ISZguu+S9KtS/gP7NeXceZyb1Jv1SM1S5YfiCv+STDsG6rrg==} - '@prisma/get-platform@6.0.1': - resolution: {integrity: sha512-zspC9vlxAqx4E6epMPMLLBMED2VD8axDe8sPnquZ8GOsn6tiacWK0oxrGK4UAHYzYUVuMVUApJbdXB2dFpLhvg==} + '@prisma/get-platform@6.1.0': + resolution: {integrity: sha512-ia8bNjboBoHkmKGGaWtqtlgQOhCi7+f85aOkPJKgNwWvYrT6l78KgojLekE8zMhVk0R9lWcifV0Pf8l3/15V0Q==} '@prisma/instrumentation@5.19.1': resolution: {integrity: sha512-VLnzMQq7CWroL5AeaW0Py2huiNKeoMfCH3SUxstdzPrlWQi6UQ9UrfcbUkNHlVFqOMacqy8X/8YtE0kuKDpD9w==} @@ -9544,8 +9544,8 @@ packages: peerDependencies: react: '>=16.0.0' - prisma@6.0.1: - resolution: {integrity: sha512-CaMNFHkf+DDq8zq3X/JJsQ4Koy7dyWwwtOKibkT/Am9j/tDxcfbg7+lB1Dzhx18G/+RQCMgjPYB61bhRqteNBQ==} + prisma@6.1.0: + resolution: {integrity: sha512-aFI3Yi+ApUxkwCJJwyQSwpyzUX7YX3ihzuHNHOyv4GJg3X5tQsmRaJEnZ+ZyfHpMtnyahhmXVfbTZ+lS8ZtfKw==} engines: {node: '>=18.18'} hasBin: true @@ -13619,34 +13619,34 @@ snapshots: '@polka/url@1.0.0-next.25': {} - '@prisma/client@6.1.0(prisma@6.0.1)': + '@prisma/client@6.1.0(prisma@6.1.0)': optionalDependencies: - prisma: 6.0.1 + prisma: 6.1.0 - '@prisma/debug@6.0.1': {} + '@prisma/debug@6.1.0': {} - '@prisma/engines-version@5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e': {} + '@prisma/engines-version@6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959': {} - '@prisma/engines@6.0.1': + '@prisma/engines@6.1.0': dependencies: - '@prisma/debug': 6.0.1 - '@prisma/engines-version': 5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e - '@prisma/fetch-engine': 6.0.1 - '@prisma/get-platform': 6.0.1 + '@prisma/debug': 6.1.0 + '@prisma/engines-version': 6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959 + '@prisma/fetch-engine': 6.1.0 + '@prisma/get-platform': 6.1.0 - '@prisma/extension-accelerate@1.2.1(@prisma/client@6.1.0(prisma@6.0.1))': + '@prisma/extension-accelerate@1.2.1(@prisma/client@6.1.0(prisma@6.1.0))': dependencies: - '@prisma/client': 6.1.0(prisma@6.0.1) + '@prisma/client': 6.1.0(prisma@6.1.0) - '@prisma/fetch-engine@6.0.1': + '@prisma/fetch-engine@6.1.0': dependencies: - '@prisma/debug': 6.0.1 - '@prisma/engines-version': 5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e - '@prisma/get-platform': 6.0.1 + '@prisma/debug': 6.1.0 + '@prisma/engines-version': 6.1.0-21.11f085a2012c0f4778414c8db2651556ee0ef959 + '@prisma/get-platform': 6.1.0 - '@prisma/get-platform@6.0.1': + '@prisma/get-platform@6.1.0': dependencies: - '@prisma/debug': 6.0.1 + '@prisma/debug': 6.1.0 '@prisma/instrumentation@5.19.1': dependencies: @@ -20842,9 +20842,9 @@ snapshots: clsx: 1.2.1 react: 18.3.1 - prisma@6.0.1: + prisma@6.1.0: dependencies: - '@prisma/engines': 6.0.1 + '@prisma/engines': 6.1.0 optionalDependencies: fsevents: 2.3.3 From e200a87800427965b43478d49d3a9922a00fc6b2 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 23 Dec 2024 14:57:40 -0800 Subject: [PATCH 15/16] removed traces sample rate --- apps/backend/sentry.client.config.ts | 82 +++++++++++++++------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/apps/backend/sentry.client.config.ts b/apps/backend/sentry.client.config.ts index b364e32e6..cea55a3f4 100644 --- a/apps/backend/sentry.client.config.ts +++ b/apps/backend/sentry.client.config.ts @@ -2,47 +2,51 @@ // The config you add here will be used whenever a users loads a page in their browser. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -// import * as Sentry from "@sentry/nextjs"; -// import { getBrowserCompatibilityReport } from "@stackframe/stack-shared/dist/utils/browser-compat"; -// import { sentryBaseConfig } from "@stackframe/stack-shared/dist/utils/sentry"; -// import { nicify } from "@stackframe/stack-shared/dist/utils/strings"; +import * as Sentry from "@sentry/nextjs"; +import { getBrowserCompatibilityReport } from "@stackframe/stack-shared/dist/utils/browser-compat"; +import { sentryBaseConfig } from "@stackframe/stack-shared/dist/utils/sentry"; +import { nicify } from "@stackframe/stack-shared/dist/utils/strings"; -// Sentry.init({ -// ...sentryBaseConfig, +Sentry.init({ + ...sentryBaseConfig, -// dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, -// enabled: process.env.NODE_ENV !== "development" && !process.env.CI, + enabled: process.env.NODE_ENV !== "development" && !process.env.CI, -// // You can remove this option if you're not planning to use the Sentry Session Replay feature: -// integrations: [ -// Sentry.replayIntegration({ -// // Additional Replay configuration goes in here, for example: -// maskAllText: false, -// blockAllMedia: false, -// }), -// ], + // Sentry and Prisma are not compatible with the new tracing. https://github.com/prisma/prisma/issues/25885 + // TODO: Remove this once sentry fixes the issue. + tracesSampleRate: 0, -// // Add exception metadata to the event -// beforeSend(event, hint) { -// const error = hint.originalException; -// let nicified; -// try { -// nicified = nicify(error, { maxDepth: 8 }); -// } catch (e) { -// nicified = `Error occurred during nicification: ${e}`; -// } -// if (error instanceof Error) { -// event.extra = { -// ...event.extra, -// cause: error.cause, -// errorProps: { -// ...error, -// }, -// nicifiedError: nicified, -// clientBrowserCompatibility: getBrowserCompatibilityReport(), -// }; -// } -// return event; -// }, -// }); + // You can remove this option if you're not planning to use the Sentry Session Replay feature: + integrations: [ + Sentry.replayIntegration({ + // Additional Replay configuration goes in here, for example: + maskAllText: false, + blockAllMedia: false, + }), + ], + + // Add exception metadata to the event + beforeSend(event, hint) { + const error = hint.originalException; + let nicified; + try { + nicified = nicify(error, { maxDepth: 8 }); + } catch (e) { + nicified = `Error occurred during nicification: ${e}`; + } + if (error instanceof Error) { + event.extra = { + ...event.extra, + cause: error.cause, + errorProps: { + ...error, + }, + nicifiedError: nicified, + clientBrowserCompatibility: getBrowserCompatibilityReport(), + }; + } + return event; + }, +}); From 259a780c938242ff2812677d9990ac68b31c2a10 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Tue, 24 Dec 2024 11:05:22 -0800 Subject: [PATCH 16/16] removed pglite data --- .dockerignore | 3 +-- .gitignore | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 746c190da..2eff84b4e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -57,7 +57,6 @@ packages/adapter-prisma/prisma/migrations db.sqlite packages/adapter-supabase/supabase/.branches packages/adapter-drizzle/.drizzle -pglite-data/ # Tests coverage @@ -137,4 +136,4 @@ node_modules deploy !deploy/docker/**/entrypoint.sh -docker-compose.yaml \ No newline at end of file +docker-compose.yaml diff --git a/.gitignore b/.gitignore index 683d6f75e..b6e934f7c 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,6 @@ packages/adapter-prisma/prisma/migrations db.sqlite packages/adapter-supabase/supabase/.branches packages/adapter-drizzle/.drizzle -pglite-data/ # Tests coverage