diff --git a/package.json b/package.json index 45eae4f..dc1ce76 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,9 @@ "@tanstack/react-router-ssr-query": "^1.131.7", "@tanstack/react-start": "^1.132.0", "@tanstack/router-plugin": "^1.132.0", - "better-auth": "^1.4.7", + "better-auth": "^1.4.10", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", - "i18next": "^25.7.3", "next-themes": "^0.4.6", "prisma": "^7.1.0", "radix-ui": "^1.4.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d77308..bc0ce56 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,17 +54,14 @@ importers: specifier: ^1.132.0 version: 1.143.4(@tanstack/react-router@1.143.4(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(vite@7.3.0(@types/node@22.19.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)) better-auth: - specifier: ^1.4.7 - version: 1.4.9(@prisma/client@7.2.0(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@tanstack/react-start@1.143.4(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@7.3.0(@types/node@22.19.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)))(mysql2@3.15.3)(pg@8.16.3)(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.10)(vitest@3.2.4(@types/node@22.19.3)(jiti@2.6.1)(jsdom@27.3.0)(lightningcss@1.30.2)(msw@2.12.4(@types/node@22.19.3)(typescript@5.9.3))(tsx@4.21.0)) + specifier: ^1.4.10 + version: 1.4.10(@prisma/client@7.2.0(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@tanstack/react-start@1.143.4(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@7.3.0(@types/node@22.19.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)))(mysql2@3.15.3)(pg@8.16.3)(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.10)(vitest@3.2.4(@types/node@22.19.3)(jiti@2.6.1)(jsdom@27.3.0)(lightningcss@1.30.2)(msw@2.12.4(@types/node@22.19.3)(typescript@5.9.3))(tsx@4.21.0)) class-variance-authority: specifier: ^0.7.1 version: 0.7.1 clsx: specifier: ^2.1.1 version: 2.1.1 - i18next: - specifier: ^25.7.3 - version: 25.7.3(typescript@5.9.3) next-themes: specifier: ^0.4.6 version: 0.4.6(react-dom@19.2.3(react@19.2.3))(react@19.2.3) @@ -342,8 +339,8 @@ packages: '@types/react': optional: true - '@better-auth/core@1.4.9': - resolution: {integrity: sha512-JT2q4NDkQzN22KclUEoZ7qU6tl9HUTfK1ctg2oWlT87SEagkwJcnrUwS9VznL+u9ziOIfY27P0f7/jSnmvLcoQ==} + '@better-auth/core@1.4.10': + resolution: {integrity: sha512-AThrfb6CpG80wqkanfrbN2/fGOYzhGladHFf3JhaWt/3/Vtf4h084T6PJLrDE7M/vCCGYvDI1DkvP3P1OB2HAg==} peerDependencies: '@better-auth/utils': 0.3.0 '@better-fetch/fetch': 1.1.21 @@ -352,10 +349,10 @@ packages: kysely: ^0.28.5 nanostores: ^1.0.1 - '@better-auth/telemetry@1.4.9': - resolution: {integrity: sha512-Tthy1/Gmx+pYlbvRQPBTKfVei8+pJwvH1NZp+5SbhwA6K2EXIaoonx/K6N/AXYs2aKUpyR4/gzqDesDjL7zd6A==} + '@better-auth/telemetry@1.4.10': + resolution: {integrity: sha512-Dq4XJX6EKsUu0h3jpRagX739p/VMOTcnJYWRrLtDYkqtZFg+sFiFsSWVcfapZoWpRSUGYX9iKwl6nDHn6Ju2oQ==} peerDependencies: - '@better-auth/core': 1.4.9 + '@better-auth/core': 1.4.10 '@better-auth/utils@0.3.0': resolution: {integrity: sha512-W+Adw6ZA6mgvnSnhOki270rwJ42t4XzSK6YWGF//BbVXL6SwCLWfyzBc1lN2m/4RM28KubdBKQ4X5VMoLRNPQw==} @@ -2435,8 +2432,8 @@ packages: resolution: {integrity: sha512-Sg0xJUNDU1sJNGdfGWhVHX0kkZ+HWcvmVymJbj6NSgZZmW/8S9Y2HQ5euytnIgakgxN6papOAWiwDo1ctFDcoQ==} hasBin: true - better-auth@1.4.9: - resolution: {integrity: sha512-usSdjuyTzZwIvM8fjF8YGhPncxV3MAg3dHUO9uPUnf0yklXUSYISiH1+imk6/Z+UBqsscyyPRnbIyjyK97p7YA==} + better-auth@1.4.10: + resolution: {integrity: sha512-0kqwEBJLe8eyFzbUspRG/htOriCf9uMLlnpe34dlIJGdmDfPuQISd4shShvUrvIVhPxsY1dSTXdXPLpqISYOYg==} peerDependencies: '@lynx-js/react': '*' '@prisma/client': ^5.0.0 || ^6.0.0 || ^7.0.0 @@ -3320,14 +3317,6 @@ packages: resolution: {integrity: sha512-eKCa6bwnJhvxj14kZk5NCPc6Hb6BdsU9DZcOnmQKSnO1VKrfV0zCvtttPZUsBvjmNDn8rpcJfpwSYnHBjc95MQ==} engines: {node: '>=18.18.0'} - i18next@25.7.3: - resolution: {integrity: sha512-2XaT+HpYGuc2uTExq9TVRhLsso+Dxym6PWaKpn36wfBmTI779OQ7iP/XaZHzrnGyzU4SHpFrTYLKfVyBfAhVNA==} - peerDependencies: - typescript: ^5 - peerDependenciesMeta: - typescript: - optional: true - iconv-lite@0.6.3: resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} engines: {node: '>=0.10.0'} @@ -5119,7 +5108,7 @@ snapshots: optionalDependencies: '@types/react': 19.2.7 - '@better-auth/core@1.4.9(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0)': + '@better-auth/core@1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0)': dependencies: '@better-auth/utils': 0.3.0 '@better-fetch/fetch': 1.1.21 @@ -5130,9 +5119,9 @@ snapshots: nanostores: 1.1.0 zod: 4.2.1 - '@better-auth/telemetry@1.4.9(@better-auth/core@1.4.9(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0))': + '@better-auth/telemetry@1.4.10(@better-auth/core@1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0))': dependencies: - '@better-auth/core': 1.4.9(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0) + '@better-auth/core': 1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0) '@better-auth/utils': 0.3.0 '@better-fetch/fetch': 1.1.21 @@ -7340,10 +7329,10 @@ snapshots: baseline-browser-mapping@2.9.11: {} - better-auth@1.4.9(@prisma/client@7.2.0(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@tanstack/react-start@1.143.4(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@7.3.0(@types/node@22.19.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)))(mysql2@3.15.3)(pg@8.16.3)(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.10)(vitest@3.2.4(@types/node@22.19.3)(jiti@2.6.1)(jsdom@27.3.0)(lightningcss@1.30.2)(msw@2.12.4(@types/node@22.19.3)(typescript@5.9.3))(tsx@4.21.0)): + better-auth@1.4.10(@prisma/client@7.2.0(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(typescript@5.9.3))(@tanstack/react-start@1.143.4(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@7.3.0(@types/node@22.19.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)))(mysql2@3.15.3)(pg@8.16.3)(prisma@7.2.0(@types/react@19.2.7)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(typescript@5.9.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.10)(vitest@3.2.4(@types/node@22.19.3)(jiti@2.6.1)(jsdom@27.3.0)(lightningcss@1.30.2)(msw@2.12.4(@types/node@22.19.3)(typescript@5.9.3))(tsx@4.21.0)): dependencies: - '@better-auth/core': 1.4.9(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0) - '@better-auth/telemetry': 1.4.9(@better-auth/core@1.4.9(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0)) + '@better-auth/core': 1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0) + '@better-auth/telemetry': 1.4.10(@better-auth/core@1.4.10(@better-auth/utils@0.3.0)(@better-fetch/fetch@1.1.21)(better-call@1.1.7(zod@4.2.1))(jose@6.1.3)(kysely@0.28.9)(nanostores@1.1.0)) '@better-auth/utils': 0.3.0 '@better-fetch/fetch': 1.1.21 '@noble/ciphers': 2.1.1 @@ -8249,12 +8238,6 @@ snapshots: human-signals@8.0.1: {} - i18next@25.7.3(typescript@5.9.3): - dependencies: - '@babel/runtime': 7.28.4 - optionalDependencies: - typescript: 5.9.3 - iconv-lite@0.6.3: dependencies: safer-buffer: 2.1.2 diff --git a/prisma/migrations/20260108130508_audit/migration.sql b/prisma/migrations/20260108130508_audit/migration.sql new file mode 100644 index 0000000..3fea8ab --- /dev/null +++ b/prisma/migrations/20260108130508_audit/migration.sql @@ -0,0 +1,16 @@ +-- CreateTable +CREATE TABLE "audit" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "action" TEXT NOT NULL, + "tableName" TEXT NOT NULL, + "recordId" TEXT NOT NULL, + "oldValue" TEXT, + "newValue" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "audit_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "audit" ADD CONSTRAINT "audit_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index eb0b813..585f92e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -18,6 +18,7 @@ model User { updatedAt DateTime @updatedAt sessions Session[] accounts Account[] + audit Audit[] role String? banned Boolean? @default(false) @@ -142,3 +143,18 @@ model Setting { @@map("setting") } + +model Audit { + id String @id @default(uuid()) + userId String + action String + tableName String + recordId String + oldValue String? + newValue String? + createdAt DateTime @default(now()) + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@map("audit") +} diff --git a/project.inlang/settings.json b/project.inlang/settings.json index 05729a3..89c8bd3 100644 --- a/project.inlang/settings.json +++ b/project.inlang/settings.json @@ -4,13 +4,9 @@ "locales": ["en", "vi"], "modules": [ "https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js", - "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js", - "https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@latest/dist/index.js" + "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js" ], "plugin.inlang.messageFormat": { "pathPattern": "./messages/{locale}.json" - }, - "plugin.inlang.i18next": { - "pathPattern": "./messages/{locale}.json" } } diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 35efaa1..3e1ac3f 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -73,17 +73,6 @@ export default function Header() { )} - {/* setIsOpen(false)} - className="flex-1 flex items-center gap-3 p-3 rounded-lg hover:bg-gray-800 transition-colors mb-2" - activeProps={{ - className: - 'flex-1 flex items-center gap-3 p-3 rounded-lg bg-cyan-600 hover:bg-cyan-700 transition-colors mb-2', - }} - > - Start - SSR Demos - */} ); } diff --git a/src/components/form/change-password-form.tsx b/src/components/form/change-password-form.tsx index 2fcc96e..05061ce 100644 --- a/src/components/form/change-password-form.tsx +++ b/src/components/form/change-password-form.tsx @@ -2,7 +2,6 @@ import { authClient } from '@/lib/auth-client'; import { m } from '@/paraglide/messages'; import { KeyIcon } from '@phosphor-icons/react'; import { useForm } from '@tanstack/react-form'; -import i18next from 'i18next'; import { toast } from 'sonner'; import z from 'zod'; import { Button } from '../ui/button'; @@ -72,9 +71,14 @@ const ChangePasswordForm = () => { }, onError: (ctx) => { console.log(ctx.error.code); - toast.error(i18next.t(`backend_${ctx.error.code}` as any), { - richColors: true, - }); + toast.error( + ( + m[`backend_${ctx.error.code}` as keyof typeof m] as () => string + )(), + { + richColors: true, + }, + ); }, }, ); diff --git a/src/components/form/profile-form.tsx b/src/components/form/profile-form.tsx index 83df190..61f6642 100644 --- a/src/components/form/profile-form.tsx +++ b/src/components/form/profile-form.tsx @@ -1,11 +1,9 @@ import { authClient } from '@/lib/auth-client'; import { m } from '@/paraglide/messages'; -import { uploadProfileImage } from '@/service/profile.api'; import { ProfileInput, profileUpdateSchema } from '@/service/profile.schema'; import { UserCircleIcon } from '@phosphor-icons/react'; import { useForm } from '@tanstack/react-form'; import { useQueryClient } from '@tanstack/react-query'; -import i18next from 'i18next'; import { useRef } from 'react'; import { toast } from 'sonner'; import { useAuth } from '../auth/auth-provider'; @@ -37,21 +35,9 @@ const ProfileForm = () => { }, onSubmit: async ({ value }) => { try { - let imageKey; - if (value.image) { - // upload image - const formData = new FormData(); - formData.set('file', value.image); - const { imageKey: uploadedKey } = await uploadProfileImage({ - data: formData, - }); - imageKey = uploadedKey; - } - await authClient.updateUser( { name: value.name, - image: imageKey, }, { onSuccess: () => { @@ -67,9 +53,16 @@ const ProfileForm = () => { }); }, onError: (ctx) => { - toast.error(i18next.t(`backend.${ctx.error.code}` as any), { - richColors: true, - }); + toast.error( + ( + m[ + `backend_${ctx.error.code}` as keyof typeof m + ] as () => string + )(), + { + richColors: true, + }, + ); }, }, ); diff --git a/src/components/form/settings-form.tsx b/src/components/form/settings-form.tsx index 8e05e37..ba2cd93 100644 --- a/src/components/form/settings-form.tsx +++ b/src/components/form/settings-form.tsx @@ -27,10 +27,7 @@ const SettingsForm = () => { const updateMutation = useMutation({ mutationFn: updateAdminSettings, onSuccess: () => { - // setLocale(variables.data.site_language as Locale); - queryClient.invalidateQueries({ - queryKey: [...settingQueries.all, 'list'], - }); + queryClient.invalidateQueries(settingQueries.listAdmin()); toast.success(m.settings_messages_update_success(), { richColors: true, }); diff --git a/src/components/form/signin-form.tsx b/src/components/form/signin-form.tsx index eb11f36..724f22c 100644 --- a/src/components/form/signin-form.tsx +++ b/src/components/form/signin-form.tsx @@ -3,7 +3,6 @@ import { m } from '@/paraglide/messages'; import { useForm } from '@tanstack/react-form'; import { useQueryClient } from '@tanstack/react-query'; import { createLink, useNavigate } from '@tanstack/react-router'; -import i18next from 'i18next'; import { toast } from 'sonner'; import z from 'zod'; import { Button } from '../ui/button'; @@ -14,7 +13,7 @@ import { Input } from '../ui/input'; const SignInFormSchema = z.object({ email: z .string() - .nonempty(m.common_is_required({ field: m.login_page_form_email })) + .nonempty(m.common_is_required({ field: m.login_page_form_email() })) .email(m.login_page_messages_email_invalid()), password: z.string().nonempty( m.common_is_required({ @@ -52,9 +51,14 @@ const SignInForm = () => { }); }, onError: (ctx) => { - toast.error(i18next.t(`backend.${ctx.error.code}` as any), { - richColors: true, - }); + toast.error( + ( + m[`backend_${ctx.error.code}` as keyof typeof m] as () => string + )(), + { + richColors: true, + }, + ); }, }, ); diff --git a/src/components/sidebar/nav-user.tsx b/src/components/sidebar/nav-user.tsx index f8ceafe..b677b1e 100644 --- a/src/components/sidebar/nav-user.tsx +++ b/src/components/sidebar/nav-user.tsx @@ -9,7 +9,6 @@ import { } from '@phosphor-icons/react'; import { useQueryClient } from '@tanstack/react-query'; import { createLink, Link, useNavigate } from '@tanstack/react-router'; -import i18next from 'i18next'; import { toast } from 'sonner'; import { useAuth } from '../auth/auth-provider'; import AvatarUser from '../avatar/AvatarUser'; @@ -49,9 +48,14 @@ const NavUser = () => { }); }, onError: (ctx) => { - toast.error(i18next.t(`backend_${ctx.error.code}` as any), { - richColors: true, - }); + toast.error( + ( + m[`backend_${ctx.error.code}` as keyof typeof m] as () => string + )(), + { + richColors: true, + }, + ); }, }, }); diff --git a/src/data/demo.punk-songs.ts b/src/data/demo.punk-songs.ts deleted file mode 100644 index bc6086d..0000000 --- a/src/data/demo.punk-songs.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createServerFn } from '@tanstack/react-start' - -export const getPunkSongs = createServerFn({ - method: 'GET', -}).handler(async () => [ - { id: 1, name: 'Teenage Dirtbag', artist: 'Wheatus' }, - { id: 2, name: 'Smells Like Teen Spirit', artist: 'Nirvana' }, - { id: 3, name: 'The Middle', artist: 'Jimmy Eat World' }, - { id: 4, name: 'My Own Worst Enemy', artist: 'Lit' }, - { id: 5, name: 'Fat Lip', artist: 'Sum 41' }, - { id: 6, name: 'All the Small Things', artist: 'blink-182' }, - { id: 7, name: 'Beverly Hills', artist: 'Weezer' }, -]) diff --git a/src/generated/prisma/browser.ts b/src/generated/prisma/browser.ts index 18a1bea..3cf601e 100644 --- a/src/generated/prisma/browser.ts +++ b/src/generated/prisma/browser.ts @@ -57,3 +57,8 @@ export type Invitation = Prisma.InvitationModel * */ export type Setting = Prisma.SettingModel +/** + * Model Audit + * + */ +export type Audit = Prisma.AuditModel diff --git a/src/generated/prisma/client.ts b/src/generated/prisma/client.ts index e50536b..fe60bf9 100644 --- a/src/generated/prisma/client.ts +++ b/src/generated/prisma/client.ts @@ -79,3 +79,8 @@ export type Invitation = Prisma.InvitationModel * */ export type Setting = Prisma.SettingModel +/** + * Model Audit + * + */ +export type Audit = Prisma.AuditModel diff --git a/src/generated/prisma/internal/class.ts b/src/generated/prisma/internal/class.ts index 9fc3068..e9cc59f 100644 --- a/src/generated/prisma/internal/class.ts +++ b/src/generated/prisma/internal/class.ts @@ -20,7 +20,7 @@ const config: runtime.GetPrismaClientConfig = { "clientVersion": "7.2.0", "engineVersion": "0c8ef2ce45c83248ab3df073180d5eda9e8be7a3", "activeProvider": "postgresql", - "inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../src/generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\nmodel User {\n id String @id @default(uuid())\n name String\n email String\n emailVerified Boolean @default(false)\n image String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n sessions Session[]\n accounts Account[]\n\n role String?\n banned Boolean? @default(false)\n banReason String?\n banExpires DateTime?\n\n members Member[]\n invitations Invitation[]\n\n @@unique([email])\n @@map(\"user\")\n}\n\nmodel Session {\n id String @id @default(uuid())\n expiresAt DateTime\n token String\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n ipAddress String?\n userAgent String?\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n\n impersonatedBy String?\n\n activeOrganizationId String?\n\n @@unique([token])\n @@index([userId])\n @@map(\"session\")\n}\n\nmodel Account {\n id String @id @default(uuid())\n accountId String\n providerId String\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n accessToken String?\n refreshToken String?\n idToken String?\n accessTokenExpiresAt DateTime?\n refreshTokenExpiresAt DateTime?\n scope String?\n password String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([userId])\n @@map(\"account\")\n}\n\nmodel Verification {\n id String @id @default(uuid())\n identifier String\n value String\n expiresAt DateTime\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([identifier])\n @@map(\"verification\")\n}\n\nmodel Organization {\n id String @id @default(uuid())\n name String\n slug String\n logo String?\n createdAt DateTime\n metadata String?\n members Member[]\n invitations Invitation[]\n\n color String? @default(\"#000000\")\n\n @@unique([slug])\n @@map(\"organization\")\n}\n\nmodel Member {\n id String @id @default(uuid())\n organizationId String\n organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n role String @default(\"member\")\n createdAt DateTime\n\n @@index([organizationId])\n @@index([userId])\n @@map(\"member\")\n}\n\nmodel Invitation {\n id String @id @default(uuid())\n organizationId String\n organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)\n email String\n role String?\n status String @default(\"pending\")\n expiresAt DateTime\n createdAt DateTime @default(now())\n inviterId String\n user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)\n\n @@index([organizationId])\n @@index([email])\n @@map(\"invitation\")\n}\n\nmodel Setting {\n id String @id @default(uuid())\n key String @unique\n value String\n description String\n relation String @default(\"admin\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@map(\"setting\")\n}\n", + "inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../src/generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\nmodel User {\n id String @id @default(uuid())\n name String\n email String\n emailVerified Boolean @default(false)\n image String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n sessions Session[]\n accounts Account[]\n audit Audit[]\n\n role String?\n banned Boolean? @default(false)\n banReason String?\n banExpires DateTime?\n\n members Member[]\n invitations Invitation[]\n\n @@unique([email])\n @@map(\"user\")\n}\n\nmodel Session {\n id String @id @default(uuid())\n expiresAt DateTime\n token String\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n ipAddress String?\n userAgent String?\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n\n impersonatedBy String?\n\n activeOrganizationId String?\n\n @@unique([token])\n @@index([userId])\n @@map(\"session\")\n}\n\nmodel Account {\n id String @id @default(uuid())\n accountId String\n providerId String\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n accessToken String?\n refreshToken String?\n idToken String?\n accessTokenExpiresAt DateTime?\n refreshTokenExpiresAt DateTime?\n scope String?\n password String?\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([userId])\n @@map(\"account\")\n}\n\nmodel Verification {\n id String @id @default(uuid())\n identifier String\n value String\n expiresAt DateTime\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@index([identifier])\n @@map(\"verification\")\n}\n\nmodel Organization {\n id String @id @default(uuid())\n name String\n slug String\n logo String?\n createdAt DateTime\n metadata String?\n members Member[]\n invitations Invitation[]\n\n color String? @default(\"#000000\")\n\n @@unique([slug])\n @@map(\"organization\")\n}\n\nmodel Member {\n id String @id @default(uuid())\n organizationId String\n organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)\n userId String\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n role String @default(\"member\")\n createdAt DateTime\n\n @@index([organizationId])\n @@index([userId])\n @@map(\"member\")\n}\n\nmodel Invitation {\n id String @id @default(uuid())\n organizationId String\n organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)\n email String\n role String?\n status String @default(\"pending\")\n expiresAt DateTime\n createdAt DateTime @default(now())\n inviterId String\n user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)\n\n @@index([organizationId])\n @@index([email])\n @@map(\"invitation\")\n}\n\nmodel Setting {\n id String @id @default(uuid())\n key String @unique\n value String\n description String\n relation String @default(\"admin\")\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@map(\"setting\")\n}\n\nmodel Audit {\n id String @id @default(uuid())\n userId String\n action String\n tableName String\n recordId String\n oldValue String?\n newValue String?\n createdAt DateTime @default(now())\n\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n\n @@map(\"audit\")\n}\n", "runtimeDataModel": { "models": {}, "enums": {}, @@ -28,7 +28,7 @@ const config: runtime.GetPrismaClientConfig = { } } -config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"emailVerified\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"image\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"sessions\",\"kind\":\"object\",\"type\":\"Session\",\"relationName\":\"SessionToUser\"},{\"name\":\"accounts\",\"kind\":\"object\",\"type\":\"Account\",\"relationName\":\"AccountToUser\"},{\"name\":\"role\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"banned\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"banReason\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"banExpires\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"members\",\"kind\":\"object\",\"type\":\"Member\",\"relationName\":\"MemberToUser\"},{\"name\":\"invitations\",\"kind\":\"object\",\"type\":\"Invitation\",\"relationName\":\"InvitationToUser\"}],\"dbName\":\"user\"},\"Session\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"token\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"ipAddress\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userAgent\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"SessionToUser\"},{\"name\":\"impersonatedBy\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"activeOrganizationId\",\"kind\":\"scalar\",\"type\":\"String\"}],\"dbName\":\"session\"},\"Account\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"accountId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"providerId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"AccountToUser\"},{\"name\":\"accessToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"refreshToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"idToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"accessTokenExpiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"refreshTokenExpiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"scope\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"account\"},\"Verification\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"identifier\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"value\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"verification\"},\"Organization\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"slug\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"logo\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"metadata\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"members\",\"kind\":\"object\",\"type\":\"Member\",\"relationName\":\"MemberToOrganization\"},{\"name\":\"invitations\",\"kind\":\"object\",\"type\":\"Invitation\",\"relationName\":\"InvitationToOrganization\"},{\"name\":\"color\",\"kind\":\"scalar\",\"type\":\"String\"}],\"dbName\":\"organization\"},\"Member\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organizationId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organization\",\"kind\":\"object\",\"type\":\"Organization\",\"relationName\":\"MemberToOrganization\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"MemberToUser\"},{\"name\":\"role\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"member\"},\"Invitation\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organizationId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organization\",\"kind\":\"object\",\"type\":\"Organization\",\"relationName\":\"InvitationToOrganization\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"role\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"status\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"inviterId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"InvitationToUser\"}],\"dbName\":\"invitation\"},\"Setting\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"key\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"value\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"relation\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"setting\"}},\"enums\":{},\"types\":{}}") +config.runtimeDataModel = JSON.parse("{\"models\":{\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"emailVerified\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"image\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"sessions\",\"kind\":\"object\",\"type\":\"Session\",\"relationName\":\"SessionToUser\"},{\"name\":\"accounts\",\"kind\":\"object\",\"type\":\"Account\",\"relationName\":\"AccountToUser\"},{\"name\":\"audit\",\"kind\":\"object\",\"type\":\"Audit\",\"relationName\":\"AuditToUser\"},{\"name\":\"role\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"banned\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"banReason\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"banExpires\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"members\",\"kind\":\"object\",\"type\":\"Member\",\"relationName\":\"MemberToUser\"},{\"name\":\"invitations\",\"kind\":\"object\",\"type\":\"Invitation\",\"relationName\":\"InvitationToUser\"}],\"dbName\":\"user\"},\"Session\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"token\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"ipAddress\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userAgent\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"SessionToUser\"},{\"name\":\"impersonatedBy\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"activeOrganizationId\",\"kind\":\"scalar\",\"type\":\"String\"}],\"dbName\":\"session\"},\"Account\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"accountId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"providerId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"AccountToUser\"},{\"name\":\"accessToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"refreshToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"idToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"accessTokenExpiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"refreshTokenExpiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"scope\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"account\"},\"Verification\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"identifier\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"value\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"verification\"},\"Organization\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"slug\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"logo\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"metadata\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"members\",\"kind\":\"object\",\"type\":\"Member\",\"relationName\":\"MemberToOrganization\"},{\"name\":\"invitations\",\"kind\":\"object\",\"type\":\"Invitation\",\"relationName\":\"InvitationToOrganization\"},{\"name\":\"color\",\"kind\":\"scalar\",\"type\":\"String\"}],\"dbName\":\"organization\"},\"Member\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organizationId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organization\",\"kind\":\"object\",\"type\":\"Organization\",\"relationName\":\"MemberToOrganization\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"MemberToUser\"},{\"name\":\"role\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"member\"},\"Invitation\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organizationId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"organization\",\"kind\":\"object\",\"type\":\"Organization\",\"relationName\":\"InvitationToOrganization\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"role\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"status\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expiresAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"inviterId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"InvitationToUser\"}],\"dbName\":\"invitation\"},\"Setting\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"key\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"value\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"relation\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"setting\"},\"Audit\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"action\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"tableName\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"recordId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"oldValue\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"newValue\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"AuditToUser\"}],\"dbName\":\"audit\"}},\"enums\":{},\"types\":{}}") async function decodeBase64AsWasm(wasmBase64: string): Promise { const { Buffer } = await import('node:buffer') @@ -253,6 +253,16 @@ export interface PrismaClient< * ``` */ get setting(): Prisma.SettingDelegate; + + /** + * `prisma.audit`: Exposes CRUD operations for the **Audit** model. + * Example usage: + * ```ts + * // Fetch zero or more Audits + * const audits = await prisma.audit.findMany() + * ``` + */ + get audit(): Prisma.AuditDelegate; } export function getPrismaClientClass(): PrismaClientConstructor { diff --git a/src/generated/prisma/internal/prismaNamespace.ts b/src/generated/prisma/internal/prismaNamespace.ts index 3225233..75881c6 100644 --- a/src/generated/prisma/internal/prismaNamespace.ts +++ b/src/generated/prisma/internal/prismaNamespace.ts @@ -391,7 +391,8 @@ export const ModelName = { Organization: 'Organization', Member: 'Member', Invitation: 'Invitation', - Setting: 'Setting' + Setting: 'Setting', + Audit: 'Audit' } as const export type ModelName = (typeof ModelName)[keyof typeof ModelName] @@ -407,7 +408,7 @@ export type TypeMap + fields: Prisma.AuditFieldRefs + operations: { + findUnique: { + args: Prisma.AuditFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.AuditFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.AuditFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.AuditFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.AuditFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.AuditCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.AuditCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.AuditCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.AuditDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.AuditUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.AuditDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.AuditUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.AuditUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.AuditUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.AuditAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.AuditGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.AuditCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } } } & { other: { @@ -1157,6 +1232,20 @@ export const SettingScalarFieldEnum = { export type SettingScalarFieldEnum = (typeof SettingScalarFieldEnum)[keyof typeof SettingScalarFieldEnum] +export const AuditScalarFieldEnum = { + id: 'id', + userId: 'userId', + action: 'action', + tableName: 'tableName', + recordId: 'recordId', + oldValue: 'oldValue', + newValue: 'newValue', + createdAt: 'createdAt' +} as const + +export type AuditScalarFieldEnum = (typeof AuditScalarFieldEnum)[keyof typeof AuditScalarFieldEnum] + + export const SortOrder = { asc: 'asc', desc: 'desc' @@ -1338,6 +1427,7 @@ export type GlobalOmitConfig = { member?: Prisma.MemberOmit invitation?: Prisma.InvitationOmit setting?: Prisma.SettingOmit + audit?: Prisma.AuditOmit } /* Types for Logging */ diff --git a/src/generated/prisma/internal/prismaNamespaceBrowser.ts b/src/generated/prisma/internal/prismaNamespaceBrowser.ts index c6cc879..c765336 100644 --- a/src/generated/prisma/internal/prismaNamespaceBrowser.ts +++ b/src/generated/prisma/internal/prismaNamespaceBrowser.ts @@ -58,7 +58,8 @@ export const ModelName = { Organization: 'Organization', Member: 'Member', Invitation: 'Invitation', - Setting: 'Setting' + Setting: 'Setting', + Audit: 'Audit' } as const export type ModelName = (typeof ModelName)[keyof typeof ModelName] @@ -192,6 +193,20 @@ export const SettingScalarFieldEnum = { export type SettingScalarFieldEnum = (typeof SettingScalarFieldEnum)[keyof typeof SettingScalarFieldEnum] +export const AuditScalarFieldEnum = { + id: 'id', + userId: 'userId', + action: 'action', + tableName: 'tableName', + recordId: 'recordId', + oldValue: 'oldValue', + newValue: 'newValue', + createdAt: 'createdAt' +} as const + +export type AuditScalarFieldEnum = (typeof AuditScalarFieldEnum)[keyof typeof AuditScalarFieldEnum] + + export const SortOrder = { asc: 'asc', desc: 'desc' diff --git a/src/generated/prisma/models.ts b/src/generated/prisma/models.ts index 3613539..d7fa0ad 100644 --- a/src/generated/prisma/models.ts +++ b/src/generated/prisma/models.ts @@ -16,4 +16,5 @@ export type * from './models/Organization.ts' export type * from './models/Member.ts' export type * from './models/Invitation.ts' export type * from './models/Setting.ts' +export type * from './models/Audit.ts' export type * from './commonInputTypes.ts' \ No newline at end of file diff --git a/src/generated/prisma/models/Audit.ts b/src/generated/prisma/models/Audit.ts new file mode 100644 index 0000000..9fc0317 --- /dev/null +++ b/src/generated/prisma/models/Audit.ts @@ -0,0 +1,1445 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `Audit` model and its related types. + * + * 🟢 You can import this file directly. + */ +import type * as runtime from "@prisma/client/runtime/client" +import type * as $Enums from "../enums.ts" +import type * as Prisma from "../internal/prismaNamespace.ts" + +/** + * Model Audit + * + */ +export type AuditModel = runtime.Types.Result.DefaultSelection + +export type AggregateAudit = { + _count: AuditCountAggregateOutputType | null + _min: AuditMinAggregateOutputType | null + _max: AuditMaxAggregateOutputType | null +} + +export type AuditMinAggregateOutputType = { + id: string | null + userId: string | null + action: string | null + tableName: string | null + recordId: string | null + oldValue: string | null + newValue: string | null + createdAt: Date | null +} + +export type AuditMaxAggregateOutputType = { + id: string | null + userId: string | null + action: string | null + tableName: string | null + recordId: string | null + oldValue: string | null + newValue: string | null + createdAt: Date | null +} + +export type AuditCountAggregateOutputType = { + id: number + userId: number + action: number + tableName: number + recordId: number + oldValue: number + newValue: number + createdAt: number + _all: number +} + + +export type AuditMinAggregateInputType = { + id?: true + userId?: true + action?: true + tableName?: true + recordId?: true + oldValue?: true + newValue?: true + createdAt?: true +} + +export type AuditMaxAggregateInputType = { + id?: true + userId?: true + action?: true + tableName?: true + recordId?: true + oldValue?: true + newValue?: true + createdAt?: true +} + +export type AuditCountAggregateInputType = { + id?: true + userId?: true + action?: true + tableName?: true + recordId?: true + oldValue?: true + newValue?: true + createdAt?: true + _all?: true +} + +export type AuditAggregateArgs = { + /** + * Filter which Audit to aggregate. + */ + where?: Prisma.AuditWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Audits to fetch. + */ + orderBy?: Prisma.AuditOrderByWithRelationInput | Prisma.AuditOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.AuditWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Audits from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Audits. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned Audits + **/ + _count?: true | AuditCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: AuditMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: AuditMaxAggregateInputType +} + +export type GetAuditAggregateType = { + [P in keyof T & keyof AggregateAudit]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type AuditGroupByArgs = { + where?: Prisma.AuditWhereInput + orderBy?: Prisma.AuditOrderByWithAggregationInput | Prisma.AuditOrderByWithAggregationInput[] + by: Prisma.AuditScalarFieldEnum[] | Prisma.AuditScalarFieldEnum + having?: Prisma.AuditScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: AuditCountAggregateInputType | true + _min?: AuditMinAggregateInputType + _max?: AuditMaxAggregateInputType +} + +export type AuditGroupByOutputType = { + id: string + userId: string + action: string + tableName: string + recordId: string + oldValue: string | null + newValue: string | null + createdAt: Date + _count: AuditCountAggregateOutputType | null + _min: AuditMinAggregateOutputType | null + _max: AuditMaxAggregateOutputType | null +} + +type GetAuditGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof AuditGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type AuditWhereInput = { + AND?: Prisma.AuditWhereInput | Prisma.AuditWhereInput[] + OR?: Prisma.AuditWhereInput[] + NOT?: Prisma.AuditWhereInput | Prisma.AuditWhereInput[] + id?: Prisma.StringFilter<"Audit"> | string + userId?: Prisma.StringFilter<"Audit"> | string + action?: Prisma.StringFilter<"Audit"> | string + tableName?: Prisma.StringFilter<"Audit"> | string + recordId?: Prisma.StringFilter<"Audit"> | string + oldValue?: Prisma.StringNullableFilter<"Audit"> | string | null + newValue?: Prisma.StringNullableFilter<"Audit"> | string | null + createdAt?: Prisma.DateTimeFilter<"Audit"> | Date | string + user?: Prisma.XOR +} + +export type AuditOrderByWithRelationInput = { + id?: Prisma.SortOrder + userId?: Prisma.SortOrder + action?: Prisma.SortOrder + tableName?: Prisma.SortOrder + recordId?: Prisma.SortOrder + oldValue?: Prisma.SortOrderInput | Prisma.SortOrder + newValue?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + user?: Prisma.UserOrderByWithRelationInput +} + +export type AuditWhereUniqueInput = Prisma.AtLeast<{ + id?: string + AND?: Prisma.AuditWhereInput | Prisma.AuditWhereInput[] + OR?: Prisma.AuditWhereInput[] + NOT?: Prisma.AuditWhereInput | Prisma.AuditWhereInput[] + userId?: Prisma.StringFilter<"Audit"> | string + action?: Prisma.StringFilter<"Audit"> | string + tableName?: Prisma.StringFilter<"Audit"> | string + recordId?: Prisma.StringFilter<"Audit"> | string + oldValue?: Prisma.StringNullableFilter<"Audit"> | string | null + newValue?: Prisma.StringNullableFilter<"Audit"> | string | null + createdAt?: Prisma.DateTimeFilter<"Audit"> | Date | string + user?: Prisma.XOR +}, "id"> + +export type AuditOrderByWithAggregationInput = { + id?: Prisma.SortOrder + userId?: Prisma.SortOrder + action?: Prisma.SortOrder + tableName?: Prisma.SortOrder + recordId?: Prisma.SortOrder + oldValue?: Prisma.SortOrderInput | Prisma.SortOrder + newValue?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + _count?: Prisma.AuditCountOrderByAggregateInput + _max?: Prisma.AuditMaxOrderByAggregateInput + _min?: Prisma.AuditMinOrderByAggregateInput +} + +export type AuditScalarWhereWithAggregatesInput = { + AND?: Prisma.AuditScalarWhereWithAggregatesInput | Prisma.AuditScalarWhereWithAggregatesInput[] + OR?: Prisma.AuditScalarWhereWithAggregatesInput[] + NOT?: Prisma.AuditScalarWhereWithAggregatesInput | Prisma.AuditScalarWhereWithAggregatesInput[] + id?: Prisma.StringWithAggregatesFilter<"Audit"> | string + userId?: Prisma.StringWithAggregatesFilter<"Audit"> | string + action?: Prisma.StringWithAggregatesFilter<"Audit"> | string + tableName?: Prisma.StringWithAggregatesFilter<"Audit"> | string + recordId?: Prisma.StringWithAggregatesFilter<"Audit"> | string + oldValue?: Prisma.StringNullableWithAggregatesFilter<"Audit"> | string | null + newValue?: Prisma.StringNullableWithAggregatesFilter<"Audit"> | string | null + createdAt?: Prisma.DateTimeWithAggregatesFilter<"Audit"> | Date | string +} + +export type AuditCreateInput = { + id?: string + action: string + tableName: string + recordId: string + oldValue?: string | null + newValue?: string | null + createdAt?: Date | string + user: Prisma.UserCreateNestedOneWithoutAuditInput +} + +export type AuditUncheckedCreateInput = { + id?: string + userId: string + action: string + tableName: string + recordId: string + oldValue?: string | null + newValue?: string | null + createdAt?: Date | string +} + +export type AuditUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + action?: Prisma.StringFieldUpdateOperationsInput | string + tableName?: Prisma.StringFieldUpdateOperationsInput | string + recordId?: Prisma.StringFieldUpdateOperationsInput | string + oldValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + newValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + user?: Prisma.UserUpdateOneRequiredWithoutAuditNestedInput +} + +export type AuditUncheckedUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + userId?: Prisma.StringFieldUpdateOperationsInput | string + action?: Prisma.StringFieldUpdateOperationsInput | string + tableName?: Prisma.StringFieldUpdateOperationsInput | string + recordId?: Prisma.StringFieldUpdateOperationsInput | string + oldValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + newValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AuditCreateManyInput = { + id?: string + userId: string + action: string + tableName: string + recordId: string + oldValue?: string | null + newValue?: string | null + createdAt?: Date | string +} + +export type AuditUpdateManyMutationInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + action?: Prisma.StringFieldUpdateOperationsInput | string + tableName?: Prisma.StringFieldUpdateOperationsInput | string + recordId?: Prisma.StringFieldUpdateOperationsInput | string + oldValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + newValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AuditUncheckedUpdateManyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + userId?: Prisma.StringFieldUpdateOperationsInput | string + action?: Prisma.StringFieldUpdateOperationsInput | string + tableName?: Prisma.StringFieldUpdateOperationsInput | string + recordId?: Prisma.StringFieldUpdateOperationsInput | string + oldValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + newValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AuditListRelationFilter = { + every?: Prisma.AuditWhereInput + some?: Prisma.AuditWhereInput + none?: Prisma.AuditWhereInput +} + +export type AuditOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type AuditCountOrderByAggregateInput = { + id?: Prisma.SortOrder + userId?: Prisma.SortOrder + action?: Prisma.SortOrder + tableName?: Prisma.SortOrder + recordId?: Prisma.SortOrder + oldValue?: Prisma.SortOrder + newValue?: Prisma.SortOrder + createdAt?: Prisma.SortOrder +} + +export type AuditMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + userId?: Prisma.SortOrder + action?: Prisma.SortOrder + tableName?: Prisma.SortOrder + recordId?: Prisma.SortOrder + oldValue?: Prisma.SortOrder + newValue?: Prisma.SortOrder + createdAt?: Prisma.SortOrder +} + +export type AuditMinOrderByAggregateInput = { + id?: Prisma.SortOrder + userId?: Prisma.SortOrder + action?: Prisma.SortOrder + tableName?: Prisma.SortOrder + recordId?: Prisma.SortOrder + oldValue?: Prisma.SortOrder + newValue?: Prisma.SortOrder + createdAt?: Prisma.SortOrder +} + +export type AuditCreateNestedManyWithoutUserInput = { + create?: Prisma.XOR | Prisma.AuditCreateWithoutUserInput[] | Prisma.AuditUncheckedCreateWithoutUserInput[] + connectOrCreate?: Prisma.AuditCreateOrConnectWithoutUserInput | Prisma.AuditCreateOrConnectWithoutUserInput[] + createMany?: Prisma.AuditCreateManyUserInputEnvelope + connect?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] +} + +export type AuditUncheckedCreateNestedManyWithoutUserInput = { + create?: Prisma.XOR | Prisma.AuditCreateWithoutUserInput[] | Prisma.AuditUncheckedCreateWithoutUserInput[] + connectOrCreate?: Prisma.AuditCreateOrConnectWithoutUserInput | Prisma.AuditCreateOrConnectWithoutUserInput[] + createMany?: Prisma.AuditCreateManyUserInputEnvelope + connect?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] +} + +export type AuditUpdateManyWithoutUserNestedInput = { + create?: Prisma.XOR | Prisma.AuditCreateWithoutUserInput[] | Prisma.AuditUncheckedCreateWithoutUserInput[] + connectOrCreate?: Prisma.AuditCreateOrConnectWithoutUserInput | Prisma.AuditCreateOrConnectWithoutUserInput[] + upsert?: Prisma.AuditUpsertWithWhereUniqueWithoutUserInput | Prisma.AuditUpsertWithWhereUniqueWithoutUserInput[] + createMany?: Prisma.AuditCreateManyUserInputEnvelope + set?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + disconnect?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + delete?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + connect?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + update?: Prisma.AuditUpdateWithWhereUniqueWithoutUserInput | Prisma.AuditUpdateWithWhereUniqueWithoutUserInput[] + updateMany?: Prisma.AuditUpdateManyWithWhereWithoutUserInput | Prisma.AuditUpdateManyWithWhereWithoutUserInput[] + deleteMany?: Prisma.AuditScalarWhereInput | Prisma.AuditScalarWhereInput[] +} + +export type AuditUncheckedUpdateManyWithoutUserNestedInput = { + create?: Prisma.XOR | Prisma.AuditCreateWithoutUserInput[] | Prisma.AuditUncheckedCreateWithoutUserInput[] + connectOrCreate?: Prisma.AuditCreateOrConnectWithoutUserInput | Prisma.AuditCreateOrConnectWithoutUserInput[] + upsert?: Prisma.AuditUpsertWithWhereUniqueWithoutUserInput | Prisma.AuditUpsertWithWhereUniqueWithoutUserInput[] + createMany?: Prisma.AuditCreateManyUserInputEnvelope + set?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + disconnect?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + delete?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + connect?: Prisma.AuditWhereUniqueInput | Prisma.AuditWhereUniqueInput[] + update?: Prisma.AuditUpdateWithWhereUniqueWithoutUserInput | Prisma.AuditUpdateWithWhereUniqueWithoutUserInput[] + updateMany?: Prisma.AuditUpdateManyWithWhereWithoutUserInput | Prisma.AuditUpdateManyWithWhereWithoutUserInput[] + deleteMany?: Prisma.AuditScalarWhereInput | Prisma.AuditScalarWhereInput[] +} + +export type AuditCreateWithoutUserInput = { + id?: string + action: string + tableName: string + recordId: string + oldValue?: string | null + newValue?: string | null + createdAt?: Date | string +} + +export type AuditUncheckedCreateWithoutUserInput = { + id?: string + action: string + tableName: string + recordId: string + oldValue?: string | null + newValue?: string | null + createdAt?: Date | string +} + +export type AuditCreateOrConnectWithoutUserInput = { + where: Prisma.AuditWhereUniqueInput + create: Prisma.XOR +} + +export type AuditCreateManyUserInputEnvelope = { + data: Prisma.AuditCreateManyUserInput | Prisma.AuditCreateManyUserInput[] + skipDuplicates?: boolean +} + +export type AuditUpsertWithWhereUniqueWithoutUserInput = { + where: Prisma.AuditWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type AuditUpdateWithWhereUniqueWithoutUserInput = { + where: Prisma.AuditWhereUniqueInput + data: Prisma.XOR +} + +export type AuditUpdateManyWithWhereWithoutUserInput = { + where: Prisma.AuditScalarWhereInput + data: Prisma.XOR +} + +export type AuditScalarWhereInput = { + AND?: Prisma.AuditScalarWhereInput | Prisma.AuditScalarWhereInput[] + OR?: Prisma.AuditScalarWhereInput[] + NOT?: Prisma.AuditScalarWhereInput | Prisma.AuditScalarWhereInput[] + id?: Prisma.StringFilter<"Audit"> | string + userId?: Prisma.StringFilter<"Audit"> | string + action?: Prisma.StringFilter<"Audit"> | string + tableName?: Prisma.StringFilter<"Audit"> | string + recordId?: Prisma.StringFilter<"Audit"> | string + oldValue?: Prisma.StringNullableFilter<"Audit"> | string | null + newValue?: Prisma.StringNullableFilter<"Audit"> | string | null + createdAt?: Prisma.DateTimeFilter<"Audit"> | Date | string +} + +export type AuditCreateManyUserInput = { + id?: string + action: string + tableName: string + recordId: string + oldValue?: string | null + newValue?: string | null + createdAt?: Date | string +} + +export type AuditUpdateWithoutUserInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + action?: Prisma.StringFieldUpdateOperationsInput | string + tableName?: Prisma.StringFieldUpdateOperationsInput | string + recordId?: Prisma.StringFieldUpdateOperationsInput | string + oldValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + newValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AuditUncheckedUpdateWithoutUserInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + action?: Prisma.StringFieldUpdateOperationsInput | string + tableName?: Prisma.StringFieldUpdateOperationsInput | string + recordId?: Prisma.StringFieldUpdateOperationsInput | string + oldValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + newValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AuditUncheckedUpdateManyWithoutUserInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + action?: Prisma.StringFieldUpdateOperationsInput | string + tableName?: Prisma.StringFieldUpdateOperationsInput | string + recordId?: Prisma.StringFieldUpdateOperationsInput | string + oldValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + newValue?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + + + +export type AuditSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + userId?: boolean + action?: boolean + tableName?: boolean + recordId?: boolean + oldValue?: boolean + newValue?: boolean + createdAt?: boolean + user?: boolean | Prisma.UserDefaultArgs +}, ExtArgs["result"]["audit"]> + +export type AuditSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + userId?: boolean + action?: boolean + tableName?: boolean + recordId?: boolean + oldValue?: boolean + newValue?: boolean + createdAt?: boolean + user?: boolean | Prisma.UserDefaultArgs +}, ExtArgs["result"]["audit"]> + +export type AuditSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + userId?: boolean + action?: boolean + tableName?: boolean + recordId?: boolean + oldValue?: boolean + newValue?: boolean + createdAt?: boolean + user?: boolean | Prisma.UserDefaultArgs +}, ExtArgs["result"]["audit"]> + +export type AuditSelectScalar = { + id?: boolean + userId?: boolean + action?: boolean + tableName?: boolean + recordId?: boolean + oldValue?: boolean + newValue?: boolean + createdAt?: boolean +} + +export type AuditOmit = runtime.Types.Extensions.GetOmit<"id" | "userId" | "action" | "tableName" | "recordId" | "oldValue" | "newValue" | "createdAt", ExtArgs["result"]["audit"]> +export type AuditInclude = { + user?: boolean | Prisma.UserDefaultArgs +} +export type AuditIncludeCreateManyAndReturn = { + user?: boolean | Prisma.UserDefaultArgs +} +export type AuditIncludeUpdateManyAndReturn = { + user?: boolean | Prisma.UserDefaultArgs +} + +export type $AuditPayload = { + name: "Audit" + objects: { + user: Prisma.$UserPayload + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: string + userId: string + action: string + tableName: string + recordId: string + oldValue: string | null + newValue: string | null + createdAt: Date + }, ExtArgs["result"]["audit"]> + composites: {} +} + +export type AuditGetPayload = runtime.Types.Result.GetResult + +export type AuditCountArgs = + Omit & { + select?: AuditCountAggregateInputType | true + } + +export interface AuditDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['Audit'], meta: { name: 'Audit' } } + /** + * Find zero or one Audit that matches the filter. + * @param {AuditFindUniqueArgs} args - Arguments to find a Audit + * @example + * // Get one Audit + * const audit = await prisma.audit.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one Audit that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {AuditFindUniqueOrThrowArgs} args - Arguments to find a Audit + * @example + * // Get one Audit + * const audit = await prisma.audit.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Audit that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AuditFindFirstArgs} args - Arguments to find a Audit + * @example + * // Get one Audit + * const audit = await prisma.audit.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Audit that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AuditFindFirstOrThrowArgs} args - Arguments to find a Audit + * @example + * // Get one Audit + * const audit = await prisma.audit.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more Audits that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AuditFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all Audits + * const audits = await prisma.audit.findMany() + * + * // Get first 10 Audits + * const audits = await prisma.audit.findMany({ take: 10 }) + * + * // Only select the `id` + * const auditWithIdOnly = await prisma.audit.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a Audit. + * @param {AuditCreateArgs} args - Arguments to create a Audit. + * @example + * // Create one Audit + * const Audit = await prisma.audit.create({ + * data: { + * // ... data to create a Audit + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many Audits. + * @param {AuditCreateManyArgs} args - Arguments to create many Audits. + * @example + * // Create many Audits + * const audit = await prisma.audit.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many Audits and returns the data saved in the database. + * @param {AuditCreateManyAndReturnArgs} args - Arguments to create many Audits. + * @example + * // Create many Audits + * const audit = await prisma.audit.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many Audits and only return the `id` + * const auditWithIdOnly = await prisma.audit.createManyAndReturn({ + * select: { id: true }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + createManyAndReturn(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "createManyAndReturn", GlobalOmitOptions>> + + /** + * Delete a Audit. + * @param {AuditDeleteArgs} args - Arguments to delete one Audit. + * @example + * // Delete one Audit + * const Audit = await prisma.audit.delete({ + * where: { + * // ... filter to delete one Audit + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one Audit. + * @param {AuditUpdateArgs} args - Arguments to update one Audit. + * @example + * // Update one Audit + * const audit = await prisma.audit.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more Audits. + * @param {AuditDeleteManyArgs} args - Arguments to filter Audits to delete. + * @example + * // Delete a few Audits + * const { count } = await prisma.audit.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Audits. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AuditUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many Audits + * const audit = await prisma.audit.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Audits and returns the data updated in the database. + * @param {AuditUpdateManyAndReturnArgs} args - Arguments to update many Audits. + * @example + * // Update many Audits + * const audit = await prisma.audit.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more Audits and only return the `id` + * const auditWithIdOnly = await prisma.audit.updateManyAndReturn({ + * select: { id: true }, + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + updateManyAndReturn(args: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "updateManyAndReturn", GlobalOmitOptions>> + + /** + * Create or update one Audit. + * @param {AuditUpsertArgs} args - Arguments to update or create a Audit. + * @example + * // Update or create a Audit + * const audit = await prisma.audit.upsert({ + * create: { + * // ... data to create a Audit + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the Audit we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__AuditClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of Audits. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AuditCountArgs} args - Arguments to filter Audits to count. + * @example + * // Count the number of Audits + * const count = await prisma.audit.count({ + * where: { + * // ... the filter for the Audits we want to count + * } + * }) + **/ + count( + args?: Prisma.Subset, + ): Prisma.PrismaPromise< + T extends runtime.Types.Utils.Record<'select', any> + ? T['select'] extends true + ? number + : Prisma.GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a Audit. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AuditAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Prisma.Subset): Prisma.PrismaPromise> + + /** + * Group by Audit. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AuditGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends AuditGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: AuditGroupByArgs['orderBy'] } + : { orderBy?: AuditGroupByArgs['orderBy'] }, + OrderFields extends Prisma.ExcludeUnderscoreKeys>>, + ByFields extends Prisma.MaybeTupleToUnion, + ByValid extends Prisma.Has, + HavingFields extends Prisma.GetHavingFields, + HavingValid extends Prisma.Has, + ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, + InputErrors extends ByEmpty extends Prisma.True + ? `Error: "by" must not be empty.` + : HavingValid extends Prisma.False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: Prisma.SubsetIntersection & InputErrors): {} extends InputErrors ? GetAuditGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the Audit model + */ +readonly fields: AuditFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for Audit. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ +export interface Prisma__AuditClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + user = {}>(args?: Prisma.Subset>): Prisma.Prisma__UserClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): runtime.Types.Utils.JsPromise +} + + + + +/** + * Fields of the Audit model + */ +export interface AuditFieldRefs { + readonly id: Prisma.FieldRef<"Audit", 'String'> + readonly userId: Prisma.FieldRef<"Audit", 'String'> + readonly action: Prisma.FieldRef<"Audit", 'String'> + readonly tableName: Prisma.FieldRef<"Audit", 'String'> + readonly recordId: Prisma.FieldRef<"Audit", 'String'> + readonly oldValue: Prisma.FieldRef<"Audit", 'String'> + readonly newValue: Prisma.FieldRef<"Audit", 'String'> + readonly createdAt: Prisma.FieldRef<"Audit", 'DateTime'> +} + + +// Custom InputTypes +/** + * Audit findUnique + */ +export type AuditFindUniqueArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * Filter, which Audit to fetch. + */ + where: Prisma.AuditWhereUniqueInput +} + +/** + * Audit findUniqueOrThrow + */ +export type AuditFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * Filter, which Audit to fetch. + */ + where: Prisma.AuditWhereUniqueInput +} + +/** + * Audit findFirst + */ +export type AuditFindFirstArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * Filter, which Audit to fetch. + */ + where?: Prisma.AuditWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Audits to fetch. + */ + orderBy?: Prisma.AuditOrderByWithRelationInput | Prisma.AuditOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Audits. + */ + cursor?: Prisma.AuditWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Audits from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Audits. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Audits. + */ + distinct?: Prisma.AuditScalarFieldEnum | Prisma.AuditScalarFieldEnum[] +} + +/** + * Audit findFirstOrThrow + */ +export type AuditFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * Filter, which Audit to fetch. + */ + where?: Prisma.AuditWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Audits to fetch. + */ + orderBy?: Prisma.AuditOrderByWithRelationInput | Prisma.AuditOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Audits. + */ + cursor?: Prisma.AuditWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Audits from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Audits. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Audits. + */ + distinct?: Prisma.AuditScalarFieldEnum | Prisma.AuditScalarFieldEnum[] +} + +/** + * Audit findMany + */ +export type AuditFindManyArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * Filter, which Audits to fetch. + */ + where?: Prisma.AuditWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Audits to fetch. + */ + orderBy?: Prisma.AuditOrderByWithRelationInput | Prisma.AuditOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing Audits. + */ + cursor?: Prisma.AuditWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Audits from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Audits. + */ + skip?: number + distinct?: Prisma.AuditScalarFieldEnum | Prisma.AuditScalarFieldEnum[] +} + +/** + * Audit create + */ +export type AuditCreateArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * The data needed to create a Audit. + */ + data: Prisma.XOR +} + +/** + * Audit createMany + */ +export type AuditCreateManyArgs = { + /** + * The data used to create many Audits. + */ + data: Prisma.AuditCreateManyInput | Prisma.AuditCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * Audit createManyAndReturn + */ +export type AuditCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelectCreateManyAndReturn | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * The data used to create many Audits. + */ + data: Prisma.AuditCreateManyInput | Prisma.AuditCreateManyInput[] + skipDuplicates?: boolean + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditIncludeCreateManyAndReturn | null +} + +/** + * Audit update + */ +export type AuditUpdateArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * The data needed to update a Audit. + */ + data: Prisma.XOR + /** + * Choose, which Audit to update. + */ + where: Prisma.AuditWhereUniqueInput +} + +/** + * Audit updateMany + */ +export type AuditUpdateManyArgs = { + /** + * The data used to update Audits. + */ + data: Prisma.XOR + /** + * Filter which Audits to update + */ + where?: Prisma.AuditWhereInput + /** + * Limit how many Audits to update. + */ + limit?: number +} + +/** + * Audit updateManyAndReturn + */ +export type AuditUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * The data used to update Audits. + */ + data: Prisma.XOR + /** + * Filter which Audits to update + */ + where?: Prisma.AuditWhereInput + /** + * Limit how many Audits to update. + */ + limit?: number + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditIncludeUpdateManyAndReturn | null +} + +/** + * Audit upsert + */ +export type AuditUpsertArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * The filter to search for the Audit to update in case it exists. + */ + where: Prisma.AuditWhereUniqueInput + /** + * In case the Audit found by the `where` argument doesn't exist, create a new Audit with this data. + */ + create: Prisma.XOR + /** + * In case the Audit was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * Audit delete + */ +export type AuditDeleteArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + /** + * Filter which Audit to delete. + */ + where: Prisma.AuditWhereUniqueInput +} + +/** + * Audit deleteMany + */ +export type AuditDeleteManyArgs = { + /** + * Filter which Audits to delete + */ + where?: Prisma.AuditWhereInput + /** + * Limit how many Audits to delete. + */ + limit?: number +} + +/** + * Audit without action + */ +export type AuditDefaultArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null +} diff --git a/src/generated/prisma/models/User.ts b/src/generated/prisma/models/User.ts index 7044a8e..2dda63a 100644 --- a/src/generated/prisma/models/User.ts +++ b/src/generated/prisma/models/User.ts @@ -232,6 +232,7 @@ export type UserWhereInput = { banExpires?: Prisma.DateTimeNullableFilter<"User"> | Date | string | null sessions?: Prisma.SessionListRelationFilter accounts?: Prisma.AccountListRelationFilter + audit?: Prisma.AuditListRelationFilter members?: Prisma.MemberListRelationFilter invitations?: Prisma.InvitationListRelationFilter } @@ -250,6 +251,7 @@ export type UserOrderByWithRelationInput = { banExpires?: Prisma.SortOrderInput | Prisma.SortOrder sessions?: Prisma.SessionOrderByRelationAggregateInput accounts?: Prisma.AccountOrderByRelationAggregateInput + audit?: Prisma.AuditOrderByRelationAggregateInput members?: Prisma.MemberOrderByRelationAggregateInput invitations?: Prisma.InvitationOrderByRelationAggregateInput } @@ -271,6 +273,7 @@ export type UserWhereUniqueInput = Prisma.AtLeast<{ banExpires?: Prisma.DateTimeNullableFilter<"User"> | Date | string | null sessions?: Prisma.SessionListRelationFilter accounts?: Prisma.AccountListRelationFilter + audit?: Prisma.AuditListRelationFilter members?: Prisma.MemberListRelationFilter invitations?: Prisma.InvitationListRelationFilter }, "id" | "email"> @@ -323,6 +326,7 @@ export type UserCreateInput = { banExpires?: Date | string | null sessions?: Prisma.SessionCreateNestedManyWithoutUserInput accounts?: Prisma.AccountCreateNestedManyWithoutUserInput + audit?: Prisma.AuditCreateNestedManyWithoutUserInput members?: Prisma.MemberCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationCreateNestedManyWithoutUserInput } @@ -341,6 +345,7 @@ export type UserUncheckedCreateInput = { banExpires?: Date | string | null sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput + audit?: Prisma.AuditUncheckedCreateNestedManyWithoutUserInput members?: Prisma.MemberUncheckedCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationUncheckedCreateNestedManyWithoutUserInput } @@ -359,6 +364,7 @@ export type UserUpdateInput = { banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUpdateManyWithoutUserNestedInput members?: Prisma.MemberUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUpdateManyWithoutUserNestedInput } @@ -377,6 +383,7 @@ export type UserUncheckedUpdateInput = { banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUncheckedUpdateManyWithoutUserNestedInput members?: Prisma.MemberUncheckedUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUncheckedUpdateManyWithoutUserNestedInput } @@ -550,6 +557,20 @@ export type UserUpdateOneRequiredWithoutInvitationsNestedInput = { update?: Prisma.XOR, Prisma.UserUncheckedUpdateWithoutInvitationsInput> } +export type UserCreateNestedOneWithoutAuditInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.UserCreateOrConnectWithoutAuditInput + connect?: Prisma.UserWhereUniqueInput +} + +export type UserUpdateOneRequiredWithoutAuditNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.UserCreateOrConnectWithoutAuditInput + upsert?: Prisma.UserUpsertWithoutAuditInput + connect?: Prisma.UserWhereUniqueInput + update?: Prisma.XOR, Prisma.UserUncheckedUpdateWithoutAuditInput> +} + export type UserCreateWithoutSessionsInput = { id?: string name: string @@ -563,6 +584,7 @@ export type UserCreateWithoutSessionsInput = { banReason?: string | null banExpires?: Date | string | null accounts?: Prisma.AccountCreateNestedManyWithoutUserInput + audit?: Prisma.AuditCreateNestedManyWithoutUserInput members?: Prisma.MemberCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationCreateNestedManyWithoutUserInput } @@ -580,6 +602,7 @@ export type UserUncheckedCreateWithoutSessionsInput = { banReason?: string | null banExpires?: Date | string | null accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput + audit?: Prisma.AuditUncheckedCreateNestedManyWithoutUserInput members?: Prisma.MemberUncheckedCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationUncheckedCreateNestedManyWithoutUserInput } @@ -613,6 +636,7 @@ export type UserUpdateWithoutSessionsInput = { banReason?: Prisma.NullableStringFieldUpdateOperationsInput | string | null banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUpdateManyWithoutUserNestedInput members?: Prisma.MemberUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUpdateManyWithoutUserNestedInput } @@ -630,6 +654,7 @@ export type UserUncheckedUpdateWithoutSessionsInput = { banReason?: Prisma.NullableStringFieldUpdateOperationsInput | string | null banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUncheckedUpdateManyWithoutUserNestedInput members?: Prisma.MemberUncheckedUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUncheckedUpdateManyWithoutUserNestedInput } @@ -647,6 +672,7 @@ export type UserCreateWithoutAccountsInput = { banReason?: string | null banExpires?: Date | string | null sessions?: Prisma.SessionCreateNestedManyWithoutUserInput + audit?: Prisma.AuditCreateNestedManyWithoutUserInput members?: Prisma.MemberCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationCreateNestedManyWithoutUserInput } @@ -664,6 +690,7 @@ export type UserUncheckedCreateWithoutAccountsInput = { banReason?: string | null banExpires?: Date | string | null sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput + audit?: Prisma.AuditUncheckedCreateNestedManyWithoutUserInput members?: Prisma.MemberUncheckedCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationUncheckedCreateNestedManyWithoutUserInput } @@ -697,6 +724,7 @@ export type UserUpdateWithoutAccountsInput = { banReason?: Prisma.NullableStringFieldUpdateOperationsInput | string | null banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUpdateManyWithoutUserNestedInput members?: Prisma.MemberUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUpdateManyWithoutUserNestedInput } @@ -714,6 +742,7 @@ export type UserUncheckedUpdateWithoutAccountsInput = { banReason?: Prisma.NullableStringFieldUpdateOperationsInput | string | null banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUncheckedUpdateManyWithoutUserNestedInput members?: Prisma.MemberUncheckedUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUncheckedUpdateManyWithoutUserNestedInput } @@ -732,6 +761,7 @@ export type UserCreateWithoutMembersInput = { banExpires?: Date | string | null sessions?: Prisma.SessionCreateNestedManyWithoutUserInput accounts?: Prisma.AccountCreateNestedManyWithoutUserInput + audit?: Prisma.AuditCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationCreateNestedManyWithoutUserInput } @@ -749,6 +779,7 @@ export type UserUncheckedCreateWithoutMembersInput = { banExpires?: Date | string | null sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput + audit?: Prisma.AuditUncheckedCreateNestedManyWithoutUserInput invitations?: Prisma.InvitationUncheckedCreateNestedManyWithoutUserInput } @@ -782,6 +813,7 @@ export type UserUpdateWithoutMembersInput = { banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUpdateManyWithoutUserNestedInput } @@ -799,6 +831,7 @@ export type UserUncheckedUpdateWithoutMembersInput = { banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUncheckedUpdateManyWithoutUserNestedInput invitations?: Prisma.InvitationUncheckedUpdateManyWithoutUserNestedInput } @@ -816,6 +849,7 @@ export type UserCreateWithoutInvitationsInput = { banExpires?: Date | string | null sessions?: Prisma.SessionCreateNestedManyWithoutUserInput accounts?: Prisma.AccountCreateNestedManyWithoutUserInput + audit?: Prisma.AuditCreateNestedManyWithoutUserInput members?: Prisma.MemberCreateNestedManyWithoutUserInput } @@ -833,6 +867,7 @@ export type UserUncheckedCreateWithoutInvitationsInput = { banExpires?: Date | string | null sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput + audit?: Prisma.AuditUncheckedCreateNestedManyWithoutUserInput members?: Prisma.MemberUncheckedCreateNestedManyWithoutUserInput } @@ -866,6 +901,7 @@ export type UserUpdateWithoutInvitationsInput = { banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUpdateManyWithoutUserNestedInput members?: Prisma.MemberUpdateManyWithoutUserNestedInput } @@ -883,9 +919,98 @@ export type UserUncheckedUpdateWithoutInvitationsInput = { banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput + audit?: Prisma.AuditUncheckedUpdateManyWithoutUserNestedInput members?: Prisma.MemberUncheckedUpdateManyWithoutUserNestedInput } +export type UserCreateWithoutAuditInput = { + id?: string + name: string + email: string + emailVerified?: boolean + image?: string | null + createdAt?: Date | string + updatedAt?: Date | string + role?: string | null + banned?: boolean | null + banReason?: string | null + banExpires?: Date | string | null + sessions?: Prisma.SessionCreateNestedManyWithoutUserInput + accounts?: Prisma.AccountCreateNestedManyWithoutUserInput + members?: Prisma.MemberCreateNestedManyWithoutUserInput + invitations?: Prisma.InvitationCreateNestedManyWithoutUserInput +} + +export type UserUncheckedCreateWithoutAuditInput = { + id?: string + name: string + email: string + emailVerified?: boolean + image?: string | null + createdAt?: Date | string + updatedAt?: Date | string + role?: string | null + banned?: boolean | null + banReason?: string | null + banExpires?: Date | string | null + sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput + accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput + members?: Prisma.MemberUncheckedCreateNestedManyWithoutUserInput + invitations?: Prisma.InvitationUncheckedCreateNestedManyWithoutUserInput +} + +export type UserCreateOrConnectWithoutAuditInput = { + where: Prisma.UserWhereUniqueInput + create: Prisma.XOR +} + +export type UserUpsertWithoutAuditInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.UserWhereInput +} + +export type UserUpdateToOneWithWhereWithoutAuditInput = { + where?: Prisma.UserWhereInput + data: Prisma.XOR +} + +export type UserUpdateWithoutAuditInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.StringFieldUpdateOperationsInput | string + emailVerified?: Prisma.BoolFieldUpdateOperationsInput | boolean + image?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + role?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + banned?: Prisma.NullableBoolFieldUpdateOperationsInput | boolean | null + banReason?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput + accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput + members?: Prisma.MemberUpdateManyWithoutUserNestedInput + invitations?: Prisma.InvitationUpdateManyWithoutUserNestedInput +} + +export type UserUncheckedUpdateWithoutAuditInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.StringFieldUpdateOperationsInput | string + emailVerified?: Prisma.BoolFieldUpdateOperationsInput | boolean + image?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + role?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + banned?: Prisma.NullableBoolFieldUpdateOperationsInput | boolean | null + banReason?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + banExpires?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput + accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput + members?: Prisma.MemberUncheckedUpdateManyWithoutUserNestedInput + invitations?: Prisma.InvitationUncheckedUpdateManyWithoutUserNestedInput +} + /** * Count Type UserCountOutputType @@ -894,6 +1019,7 @@ export type UserUncheckedUpdateWithoutInvitationsInput = { export type UserCountOutputType = { sessions: number accounts: number + audit: number members: number invitations: number } @@ -901,6 +1027,7 @@ export type UserCountOutputType = { export type UserCountOutputTypeSelect = { sessions?: boolean | UserCountOutputTypeCountSessionsArgs accounts?: boolean | UserCountOutputTypeCountAccountsArgs + audit?: boolean | UserCountOutputTypeCountAuditArgs members?: boolean | UserCountOutputTypeCountMembersArgs invitations?: boolean | UserCountOutputTypeCountInvitationsArgs } @@ -929,6 +1056,13 @@ export type UserCountOutputTypeCountAccountsArgs = { + where?: Prisma.AuditWhereInput +} + /** * UserCountOutputType without action */ @@ -958,6 +1092,7 @@ export type UserSelect accounts?: boolean | Prisma.User$accountsArgs + audit?: boolean | Prisma.User$auditArgs members?: boolean | Prisma.User$membersArgs invitations?: boolean | Prisma.User$invitationsArgs _count?: boolean | Prisma.UserCountOutputTypeDefaultArgs @@ -1009,6 +1144,7 @@ export type UserOmit = { sessions?: boolean | Prisma.User$sessionsArgs accounts?: boolean | Prisma.User$accountsArgs + audit?: boolean | Prisma.User$auditArgs members?: boolean | Prisma.User$membersArgs invitations?: boolean | Prisma.User$invitationsArgs _count?: boolean | Prisma.UserCountOutputTypeDefaultArgs @@ -1021,6 +1157,7 @@ export type $UserPayload[] accounts: Prisma.$AccountPayload[] + audit: Prisma.$AuditPayload[] members: Prisma.$MemberPayload[] invitations: Prisma.$InvitationPayload[] } @@ -1432,6 +1569,7 @@ export interface Prisma__UserClient = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> accounts = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + audit = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> members = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> invitations = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> /** @@ -1909,6 +2047,30 @@ export type User$accountsArgs = { + /** + * Select specific fields to fetch from the Audit + */ + select?: Prisma.AuditSelect | null + /** + * Omit specific fields from the Audit + */ + omit?: Prisma.AuditOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AuditInclude | null + where?: Prisma.AuditWhereInput + orderBy?: Prisma.AuditOrderByWithRelationInput | Prisma.AuditOrderByWithRelationInput[] + cursor?: Prisma.AuditWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.AuditScalarFieldEnum | Prisma.AuditScalarFieldEnum[] +} + /** * User.members */ diff --git a/src/lib/auth.ts b/src/lib/auth.ts index c557f2b..0bf48a7 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -8,6 +8,7 @@ import { owner, } from '@/lib/auth/organization-permissions'; import { ac, admin, user } from '@/lib/auth/permissions'; +import { createAuditLog } from '@/service/audit.api'; import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import { admin as adminPlugin, organization } from 'better-auth/plugins'; @@ -67,6 +68,73 @@ export const auth = betterAuth({ }); }, }, + update: { + before: async (user, ctx) => { + if (ctx?.context.session && ctx?.path === '/update-user') { + const newUser = JSON.parse(JSON.stringify(user)); + const keys = Object.keys(newUser); + const oldUser = Object.fromEntries( + Object.entries(ctx?.context.session?.user).filter(([key]) => + keys.includes(key), + ), + ); + await createAuditLog({ + action: 'update', + tableName: 'user', + recordId: ctx?.context.session?.user.id, + oldValue: JSON.stringify(oldUser), + newValue: JSON.stringify(newUser), + userId: ctx?.context.session?.user.id, + }); + } + }, + }, + }, + account: { + update: { + after: async (account, context) => { + if (context?.path === '/change-password') { + await createAuditLog({ + action: 'change_password', + tableName: 'account', + recordId: account.id, + oldValue: 'Change Password', + newValue: 'Change Password', + userId: account.userId, + }); + } + }, + }, + }, + session: { + create: { + after: async (session, context) => { + if (context?.path.includes('/sign-in')) { + await createAuditLog({ + action: 'sign_in', + tableName: 'session', + recordId: session.id, + oldValue: '', + newValue: JSON.stringify(session), + userId: session.userId, + }); + } + }, + }, + delete: { + after: async (session, context) => { + if (context?.path === '/sign-out') { + await createAuditLog({ + action: 'sign_out', + tableName: 'session', + recordId: session.id, + oldValue: JSON.stringify(session), + newValue: '', + userId: session.userId, + }); + } + }, + }, }, }, }); diff --git a/src/lib/auth/session.ts b/src/lib/auth/session.ts index 991357b..2f2fd4f 100644 --- a/src/lib/auth/session.ts +++ b/src/lib/auth/session.ts @@ -1,7 +1,6 @@ import { createServerFn } from '@tanstack/react-start'; import { getRequestHeaders } from '@tanstack/react-start/server'; import { auth } from '../auth'; -import { authClient } from '../auth-client'; export type Session = typeof auth.$Infer.Session; @@ -12,8 +11,3 @@ export const getSession = createServerFn({ method: 'GET' }).handler( return session; }, ); - -export const sessionPush = () => { - const session = authClient.getSession(); - return session; -}; diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 6264f1b..e062a08 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -14,7 +14,7 @@ import { Route as appIndexRouteImport } from './routes/(app)/index' import { Route as authSignUpRouteImport } from './routes/(auth)/sign-up' import { Route as authSignInRouteImport } from './routes/(auth)/sign-in' import { Route as appauthRouteRouteImport } from './routes/(app)/(auth)/route' -import { Route as ApiAuthSplatRouteImport } from './routes/api/auth.$' +import { Route as ApiAuthSplatRouteImport } from './routes/api.auth.$' import { Route as appauthSettingsRouteImport } from './routes/(app)/(auth)/settings' import { Route as appauthDashboardRouteImport } from './routes/(app)/(auth)/dashboard' import { Route as appauthAccountRouteRouteImport } from './routes/(app)/(auth)/account/route' diff --git a/src/routes/(app)/(auth)/route.tsx b/src/routes/(app)/(auth)/route.tsx index 832c820..4d47497 100644 --- a/src/routes/(app)/(auth)/route.tsx +++ b/src/routes/(app)/(auth)/route.tsx @@ -1,11 +1,11 @@ -import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'; +import { createFileRoute, Outlet } from '@tanstack/react-router'; export const Route = createFileRoute('/(app)/(auth)')({ - beforeLoad: async ({ context }) => { - if (!context.userSession) { - throw redirect({ to: '/sign-in' }); - } - }, + // beforeLoad: async ({ context }) => { + // if (!context.userSession) { + // throw redirect({ to: '/sign-in' }); + // } + // }, component: RouteComponent, }); diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 12bb13a..0daae9e 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -1,7 +1,6 @@ import NotFound from '@/components/NotFound'; import { Toaster } from '@/components/ui/sonner'; import { getLocale } from '@/paraglide/runtime'; -import { sessionQueries } from '@/service/queries'; import { CheckIcon, InfoIcon, @@ -20,43 +19,41 @@ import React from 'react'; import TanStackQueryDevtools from '../integrations/tanstack-query/devtools'; import appCss from '../styles.css?url'; -interface MyRouterContext { - queryClient: QueryClient; -} - -export const Route = createRootRouteWithContext()({ - beforeLoad: async ({ context }) => { - const userSession = await context.queryClient.fetchQuery( - sessionQueries.user(), - ); - return { userSession }; +export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()( + { + // beforeLoad: async ({ context }) => { + // const userSession = await context.queryClient.fetchQuery( + // sessionQueries.user(), + // ); + // return { userSession }; + // }, + head: () => ({ + meta: [ + { + charSet: 'utf-8', + }, + { + name: 'viewport', + content: 'width=device-width, initial-scale=1', + }, + { + title: 'Fuware', + }, + { + description: 'Fuware is a platform for managing your business.', + }, + ], + links: [ + { + rel: 'stylesheet', + href: appCss, + }, + ], + }), + shellComponent: RootDocument, + notFoundComponent: () => , }, - head: () => ({ - meta: [ - { - charSet: 'utf-8', - }, - { - name: 'viewport', - content: 'width=device-width, initial-scale=1', - }, - { - title: 'Fuware', - }, - { - description: 'Fuware is a platform for managing your business.', - }, - ], - links: [ - { - rel: 'stylesheet', - href: appCss, - }, - ], - }), - shellComponent: RootDocument, - notFoundComponent: () => , -}); +); function RootDocument({ children }: { children: React.ReactNode }) { return ( @@ -79,20 +76,20 @@ function RootDocument({ children }: { children: React.ReactNode }) { warning: , }} /> - - , - }, - TanStackQueryDevtools, - ]} - /> - + {/* */} + , + }, + TanStackQueryDevtools, + ]} + /> + {/* */} diff --git a/src/routes/api/auth.$.ts b/src/routes/api.auth.$.ts similarity index 100% rename from src/routes/api/auth.$.ts rename to src/routes/api.auth.$.ts diff --git a/src/service/audit.api.ts b/src/service/audit.api.ts new file mode 100644 index 0000000..95f1f7b --- /dev/null +++ b/src/service/audit.api.ts @@ -0,0 +1,15 @@ +import { prisma } from '@/db'; +import { Audit } from '@/generated/prisma/client'; + +export async function createAuditLog(data: Omit) { + try { + await prisma.audit.create({ + data: { + ...data, + }, + }); + } catch (error) { + console.log(error); + throw error; + } +} diff --git a/src/service/profile.api.ts b/src/service/profile.api.ts index d496c80..e69de29 100644 --- a/src/service/profile.api.ts +++ b/src/service/profile.api.ts @@ -1,17 +0,0 @@ -import { authMiddleware } from '@/lib/middleware'; -import { saveFile } from '@/utils/disk-storage'; -import { createServerFn } from '@tanstack/react-start'; -import z from 'zod'; - -export const uploadProfileImage = createServerFn({ method: 'POST' }) - .middleware([authMiddleware]) - .inputValidator(z.instanceof(FormData)) - .handler(async ({ data: formData }) => { - const uuid = crypto.randomUUID(); - const file = formData.get('file') as File; - if (!(file instanceof File)) throw new Error('File not found'); - const imageKey = `${uuid}.${file.type.split('/')[1]}`; - const buffer = Buffer.from(await file.arrayBuffer()); - await saveFile(imageKey, buffer); - return { imageKey }; - }); diff --git a/src/service/queries.ts b/src/service/queries.ts index 54bb7d5..6cb1b49 100644 --- a/src/service/queries.ts +++ b/src/service/queries.ts @@ -1,5 +1,4 @@ import { getSession } from '@/lib/auth/session'; -// import { sessionPush } from '@/lib/auth/session'; import { queryOptions } from '@tanstack/react-query'; import { getAdminSettings, getUserSettings } from './setting.api'; @@ -9,7 +8,6 @@ export const sessionQueries = { queryOptions({ queryKey: [...sessionQueries.all, 'session'], queryFn: () => getSession(), - // queryFn: () => sessionPush(), staleTime: 1000 * 60 * 20, retry: false, }), diff --git a/src/service/setting.api.ts b/src/service/setting.api.ts index 679654f..153c6ab 100644 --- a/src/service/setting.api.ts +++ b/src/service/setting.api.ts @@ -3,7 +3,6 @@ import { Setting } from '@/generated/prisma/client'; import { authMiddleware } from '@/lib/middleware'; import { createServerFn } from '@tanstack/react-start'; import { settingSchema, userSettingSchema } from './setting.schema'; -// import { settingSchema } from './setting.schema'; type AdminSettingReturn = { [key: string]: Setting; @@ -13,6 +12,7 @@ type AdminSettingReturn = { export const getAdminSettings = createServerFn({ method: 'GET' }) .middleware([authMiddleware]) .handler(async () => { + console.log('first'); const settings = await prisma.setting.findMany({ where: { relation: 'admin', @@ -48,6 +48,17 @@ export const updateAdminSettings = createServerFn({ method: 'POST' }) await prisma.$transaction(updates); + // console.log(updates); + + // await createAuditLog({ + // action: 'update', + // tableName: 'setting', + // recordId: '', + // oldValue: '', + // newValue: JSON.stringify(data), + // userId: '', + // }); + return { success: true }; }); @@ -93,6 +104,15 @@ export const updateUserSettings = createServerFn({ method: 'POST' }) }, }); + // await createAuditLog({ + // action: 'update', + // tableName: 'setting', + // recordId: '', + // oldValue: '', + // newValue: '', + // userId: '', + // }); + return { success: true }; } catch (error) { throw error; diff --git a/src/utils/disk-storage.ts b/src/utils/disk-storage.ts deleted file mode 100644 index 6ae31fc..0000000 --- a/src/utils/disk-storage.ts +++ /dev/null @@ -1,26 +0,0 @@ -import fs, { writeFile } from 'fs/promises'; -import path from 'path'; - -const uploadDir = './data/avatar'; - -export async function saveFile(key: string, file: Buffer | File) { - if (!uploadDir) { - throw new Error('Upload directory not found'); - } - - const fileBuffer = - file instanceof File ? Buffer.from(await file.arrayBuffer()) : file; - - const filePath = path.join(uploadDir, key); - - try { - await fs.mkdir(uploadDir, { recursive: true }); - await writeFile(filePath, fileBuffer); - return key; - } catch (error) { - console.error(`Error saving file: ${key}`, error); - throw new Error( - `Failed to save file: ${error instanceof Error ? error.message : 'Unknown error'}`, - ); - } -} diff --git a/src/utils/help.ts b/src/utils/help.ts new file mode 100644 index 0000000..a9c5db9 --- /dev/null +++ b/src/utils/help.ts @@ -0,0 +1,9 @@ +export function jsonSupport(jsonSTR: string) { + try { + const data = JSON.parse(jsonSTR); + + return JSON.stringify(data, undefined, 2); + } catch { + return jsonSTR; + } +}