@proofkit/cli 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/LICENSE.md +21 -0
- package/README.md +19 -0
- package/dist/acorn-AKFTBDM6.js +15 -0
- package/dist/angular-BOQ6FHSU.js +2 -0
- package/dist/babel-ZTOORN7K.js +15 -0
- package/dist/chunk-4LISTI44.js +1 -0
- package/dist/estree-KOJPX4S6.js +36 -0
- package/dist/flow-RCI44GYZ.js +19 -0
- package/dist/glimmer-GV5EF5E4.js +30 -0
- package/dist/graphql-YXQNPQWM.js +29 -0
- package/dist/html-ZAJTRROK.js +22 -0
- package/dist/index.js +300 -0
- package/dist/markdown-Q75DTQI7.js +63 -0
- package/dist/meriyah-32K7GBV5.js +4 -0
- package/dist/postcss-WWYO4PGL.js +54 -0
- package/dist/typescript-M6N7JDNQ.js +20 -0
- package/dist/yaml-LY7PNAYV.js +161 -0
- package/index.d.ts +19 -0
- package/package.json +122 -0
- package/template/extras/_cursor/conditional-rules/nextjs-framework.mdc +51 -0
- package/template/extras/_cursor/conditional-rules/npm.mdc +60 -0
- package/template/extras/_cursor/conditional-rules/pnpm.mdc +65 -0
- package/template/extras/_cursor/conditional-rules/yarn.mdc +60 -0
- package/template/extras/_cursor/rules/cursor-rules.mdc +88 -0
- package/template/extras/_cursor/rules/filemaker-api.mdc +176 -0
- package/template/extras/_cursor/rules/troubleshooting-patterns.mdc +240 -0
- package/template/extras/_cursor/rules/ui-components.mdc +57 -0
- package/template/extras/config/_eslint.js +27 -0
- package/template/extras/config/_prettier.config.js +6 -0
- package/template/extras/config/drizzle-config-mysql.ts +12 -0
- package/template/extras/config/drizzle-config-postgres.ts +12 -0
- package/template/extras/config/drizzle-config-sqlite.ts +12 -0
- package/template/extras/config/fmschema.config.mjs +9 -0
- package/template/extras/config/get-query-client.ts +6 -0
- package/template/extras/config/postcss.config.cjs +7 -0
- package/template/extras/config/query-provider-vite.tsx +19 -0
- package/template/extras/config/query-provider.tsx +21 -0
- package/template/extras/emailProviders/none/email.tsx +24 -0
- package/template/extras/emailProviders/plunk/email.tsx +26 -0
- package/template/extras/emailProviders/plunk/service.ts +4 -0
- package/template/extras/emailProviders/resend/email.tsx +23 -0
- package/template/extras/emailProviders/resend/service.ts +4 -0
- package/template/extras/fmaddon-auth/app/(main)/auth/profile/actions.ts +93 -0
- package/template/extras/fmaddon-auth/app/(main)/auth/profile/page.tsx +27 -0
- package/template/extras/fmaddon-auth/app/(main)/auth/profile/profile-form.tsx +56 -0
- package/template/extras/fmaddon-auth/app/(main)/auth/profile/reset-password-form.tsx +110 -0
- package/template/extras/fmaddon-auth/app/(main)/auth/profile/schema.ts +19 -0
- package/template/extras/fmaddon-auth/app/auth/forgot-password/actions.ts +37 -0
- package/template/extras/fmaddon-auth/app/auth/forgot-password/forgot-form.tsx +41 -0
- package/template/extras/fmaddon-auth/app/auth/forgot-password/page.tsx +21 -0
- package/template/extras/fmaddon-auth/app/auth/forgot-password/schema.ts +5 -0
- package/template/extras/fmaddon-auth/app/auth/login/actions.ts +34 -0
- package/template/extras/fmaddon-auth/app/auth/login/login-form.tsx +64 -0
- package/template/extras/fmaddon-auth/app/auth/login/page.tsx +26 -0
- package/template/extras/fmaddon-auth/app/auth/login/schema.ts +6 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/actions.ts +50 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/page.tsx +32 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/reset-password-form.tsx +59 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/schema.ts +14 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/verify-email/actions.ts +45 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/verify-email/page.tsx +32 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/verify-email/schema.ts +5 -0
- package/template/extras/fmaddon-auth/app/auth/reset-password/verify-email/verify-email-form.tsx +48 -0
- package/template/extras/fmaddon-auth/app/auth/signup/actions.ts +49 -0
- package/template/extras/fmaddon-auth/app/auth/signup/page.tsx +26 -0
- package/template/extras/fmaddon-auth/app/auth/signup/schema.ts +12 -0
- package/template/extras/fmaddon-auth/app/auth/signup/signup-form.tsx +67 -0
- package/template/extras/fmaddon-auth/app/auth/verify-email/actions.ts +110 -0
- package/template/extras/fmaddon-auth/app/auth/verify-email/email-verification-form.tsx +45 -0
- package/template/extras/fmaddon-auth/app/auth/verify-email/page.tsx +38 -0
- package/template/extras/fmaddon-auth/app/auth/verify-email/resend-button.tsx +35 -0
- package/template/extras/fmaddon-auth/app/auth/verify-email/schema.ts +5 -0
- package/template/extras/fmaddon-auth/components/auth/actions.ts +16 -0
- package/template/extras/fmaddon-auth/components/auth/protect.tsx +17 -0
- package/template/extras/fmaddon-auth/components/auth/redirect.tsx +26 -0
- package/template/extras/fmaddon-auth/components/auth/use-user.ts +59 -0
- package/template/extras/fmaddon-auth/components/auth/user-menu.tsx +51 -0
- package/template/extras/fmaddon-auth/emails/auth-code.tsx +156 -0
- package/template/extras/fmaddon-auth/middleware.ts +45 -0
- package/template/extras/fmaddon-auth/server/auth/utils/email-verification.ts +136 -0
- package/template/extras/fmaddon-auth/server/auth/utils/encryption.ts +51 -0
- package/template/extras/fmaddon-auth/server/auth/utils/index.ts +16 -0
- package/template/extras/fmaddon-auth/server/auth/utils/password-reset.ts +152 -0
- package/template/extras/fmaddon-auth/server/auth/utils/password.ts +67 -0
- package/template/extras/fmaddon-auth/server/auth/utils/redirect.ts +8 -0
- package/template/extras/fmaddon-auth/server/auth/utils/session.ts +192 -0
- package/template/extras/fmaddon-auth/server/auth/utils/user.ts +147 -0
- package/template/extras/prisma/schema/base-planetscale.prisma +24 -0
- package/template/extras/prisma/schema/base.prisma +20 -0
- package/template/extras/prisma/schema/with-auth-planetscale.prisma +77 -0
- package/template/extras/prisma/schema/with-auth.prisma +74 -0
- package/template/extras/src/app/_components/post-tw.tsx +50 -0
- package/template/extras/src/app/_components/post.tsx +54 -0
- package/template/extras/src/app/api/auth/[...nextauth]/route.ts +4 -0
- package/template/extras/src/app/api/trpc/[trpc]/route.ts +34 -0
- package/template/extras/src/app/clerk-auth/layout.tsx +10 -0
- package/template/extras/src/app/clerk-auth/signin/[[...sign-in]]/page.tsx +5 -0
- package/template/extras/src/app/clerk-auth/signup/[[...sign-up]]/page.tsx +5 -0
- package/template/extras/src/app/layout/base.tsx +34 -0
- package/template/extras/src/app/layout/main-shell.tsx +37 -0
- package/template/extras/src/app/layout/with-trpc-tw.tsx +24 -0
- package/template/extras/src/app/layout/with-trpc.tsx +24 -0
- package/template/extras/src/app/layout/with-tw.tsx +20 -0
- package/template/extras/src/app/next-auth/layout.tsx +22 -0
- package/template/extras/src/app/next-auth/signin/page.tsx +82 -0
- package/template/extras/src/app/next-auth/signup/action.ts +24 -0
- package/template/extras/src/app/next-auth/signup/page.tsx +40 -0
- package/template/extras/src/app/next-auth/signup/validation.ts +12 -0
- package/template/extras/src/app/page/base.tsx +6 -0
- package/template/extras/src/app/page/with-auth-trpc-tw.tsx +67 -0
- package/template/extras/src/app/page/with-auth-trpc.tsx +68 -0
- package/template/extras/src/app/page/with-trpc-tw.tsx +53 -0
- package/template/extras/src/app/page/with-trpc.tsx +54 -0
- package/template/extras/src/app/page/with-tw.tsx +37 -0
- package/template/extras/src/components/clerk-auth/clerk-provider.tsx +18 -0
- package/template/extras/src/components/clerk-auth/user-menu-mobile.tsx +36 -0
- package/template/extras/src/components/clerk-auth/user-menu.tsx +24 -0
- package/template/extras/src/components/next-auth/next-auth-provider.tsx +14 -0
- package/template/extras/src/components/next-auth/user-menu-mobile.tsx +31 -0
- package/template/extras/src/components/next-auth/user-menu.tsx +38 -0
- package/template/extras/src/env/with-auth.ts +31 -0
- package/template/extras/src/env/with-clerk.ts +20 -0
- package/template/extras/src/index.module.css +177 -0
- package/template/extras/src/middleware/clerk.ts +20 -0
- package/template/extras/src/middleware/next-auth.ts +5 -0
- package/template/extras/src/pages/_app/base.tsx +14 -0
- package/template/extras/src/pages/_app/with-auth-trpc-tw.tsx +23 -0
- package/template/extras/src/pages/_app/with-auth-trpc.tsx +23 -0
- package/template/extras/src/pages/_app/with-auth-tw.tsx +21 -0
- package/template/extras/src/pages/_app/with-auth.tsx +21 -0
- package/template/extras/src/pages/_app/with-trpc-tw.tsx +16 -0
- package/template/extras/src/pages/_app/with-trpc.tsx +16 -0
- package/template/extras/src/pages/_app/with-tw.tsx +14 -0
- package/template/extras/src/pages/api/auth/[...nextauth].ts +5 -0
- package/template/extras/src/pages/api/trpc/[trpc].ts +19 -0
- package/template/extras/src/pages/index/base.tsx +47 -0
- package/template/extras/src/pages/index/with-auth-trpc-tw.tsx +80 -0
- package/template/extras/src/pages/index/with-auth-trpc.tsx +81 -0
- package/template/extras/src/pages/index/with-trpc-tw.tsx +52 -0
- package/template/extras/src/pages/index/with-trpc.tsx +53 -0
- package/template/extras/src/pages/index/with-tw.tsx +45 -0
- package/template/extras/src/server/api/root.ts +23 -0
- package/template/extras/src/server/api/routers/post/base.ts +40 -0
- package/template/extras/src/server/api/routers/post/with-auth-drizzle.ts +39 -0
- package/template/extras/src/server/api/routers/post/with-auth-prisma.ts +41 -0
- package/template/extras/src/server/api/routers/post/with-auth.ts +37 -0
- package/template/extras/src/server/api/routers/post/with-drizzle.ts +30 -0
- package/template/extras/src/server/api/routers/post/with-prisma.ts +31 -0
- package/template/extras/src/server/api/trpc-app/base.ts +103 -0
- package/template/extras/src/server/api/trpc-app/with-auth-db.ts +133 -0
- package/template/extras/src/server/api/trpc-app/with-auth.ts +130 -0
- package/template/extras/src/server/api/trpc-app/with-db.ts +106 -0
- package/template/extras/src/server/api/trpc-pages/base.ts +122 -0
- package/template/extras/src/server/api/trpc-pages/with-auth-db.ts +160 -0
- package/template/extras/src/server/api/trpc-pages/with-auth.ts +158 -0
- package/template/extras/src/server/api/trpc-pages/with-db.ts +125 -0
- package/template/extras/src/server/data/users.ts +23 -0
- package/template/extras/src/server/db/db-prisma-planetscale.ts +22 -0
- package/template/extras/src/server/db/db-prisma.ts +17 -0
- package/template/extras/src/server/db/index-drizzle/with-mysql.ts +18 -0
- package/template/extras/src/server/db/index-drizzle/with-planetscale.ts +7 -0
- package/template/extras/src/server/db/index-drizzle/with-postgres.ts +18 -0
- package/template/extras/src/server/db/index-drizzle/with-sqlite.ts +19 -0
- package/template/extras/src/server/db/schema-drizzle/base-mysql.ts +34 -0
- package/template/extras/src/server/db/schema-drizzle/base-planetscale.ts +34 -0
- package/template/extras/src/server/db/schema-drizzle/base-postgres.ts +36 -0
- package/template/extras/src/server/db/schema-drizzle/base-sqlite.ts +30 -0
- package/template/extras/src/server/db/schema-drizzle/with-auth-mysql.ts +123 -0
- package/template/extras/src/server/db/schema-drizzle/with-auth-planetscale.ts +117 -0
- package/template/extras/src/server/db/schema-drizzle/with-auth-postgres.ts +130 -0
- package/template/extras/src/server/db/schema-drizzle/with-auth-sqlite.ts +116 -0
- package/template/extras/src/server/next-auth/base.ts +111 -0
- package/template/extras/src/server/next-auth/password.ts +13 -0
- package/template/extras/src/server/next-auth/with-drizzle.ts +83 -0
- package/template/extras/src/server/next-auth/with-prisma.ts +72 -0
- package/template/extras/src/trpc/query-client.ts +25 -0
- package/template/extras/src/trpc/react.tsx +76 -0
- package/template/extras/src/trpc/server.ts +30 -0
- package/template/extras/src/utils/api.ts +68 -0
- package/template/extras/start-database/mysql.sh +54 -0
- package/template/extras/start-database/postgres.sh +55 -0
- package/template/fm-addon/ProofKitAuth/de.xml +518 -0
- package/template/fm-addon/ProofKitAuth/en.xml +518 -0
- package/template/fm-addon/ProofKitAuth/es.xml +518 -0
- package/template/fm-addon/ProofKitAuth/fr.xml +518 -0
- package/template/fm-addon/ProofKitAuth/icon.png +0 -0
- package/template/fm-addon/ProofKitAuth/icon@2x.png +0 -0
- package/template/fm-addon/ProofKitAuth/info.json +11 -0
- package/template/fm-addon/ProofKitAuth/info_de.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_en.json +8 -0
- package/template/fm-addon/ProofKitAuth/info_es.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_fr.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_it.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_ja.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_ko.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_nl.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_pt.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_sv.json +18 -0
- package/template/fm-addon/ProofKitAuth/info_zh.json +18 -0
- package/template/fm-addon/ProofKitAuth/it.xml +518 -0
- package/template/fm-addon/ProofKitAuth/ja.xml +518 -0
- package/template/fm-addon/ProofKitAuth/ko.xml +518 -0
- package/template/fm-addon/ProofKitAuth/nl.xml +518 -0
- package/template/fm-addon/ProofKitAuth/preview.png +0 -0
- package/template/fm-addon/ProofKitAuth/pt.xml +518 -0
- package/template/fm-addon/ProofKitAuth/sv.xml +518 -0
- package/template/fm-addon/ProofKitAuth/template.xml +0 -0
- package/template/fm-addon/ProofKitAuth/zh.xml +518 -0
- package/template/fm-addon/ProofKitWV/de.xml +896 -0
- package/template/fm-addon/ProofKitWV/en.xml +896 -0
- package/template/fm-addon/ProofKitWV/es.xml +896 -0
- package/template/fm-addon/ProofKitWV/fr.xml +896 -0
- package/template/fm-addon/ProofKitWV/icon.png +0 -0
- package/template/fm-addon/ProofKitWV/icon@2x.png +0 -0
- package/template/fm-addon/ProofKitWV/info.json +11 -0
- package/template/fm-addon/ProofKitWV/info_de.json +18 -0
- package/template/fm-addon/ProofKitWV/info_en.json +11 -0
- package/template/fm-addon/ProofKitWV/info_es.json +18 -0
- package/template/fm-addon/ProofKitWV/info_fr.json +18 -0
- package/template/fm-addon/ProofKitWV/info_it.json +18 -0
- package/template/fm-addon/ProofKitWV/info_ja.json +18 -0
- package/template/fm-addon/ProofKitWV/info_ko.json +18 -0
- package/template/fm-addon/ProofKitWV/info_nl.json +18 -0
- package/template/fm-addon/ProofKitWV/info_pt.json +18 -0
- package/template/fm-addon/ProofKitWV/info_sv.json +18 -0
- package/template/fm-addon/ProofKitWV/info_zh.json +18 -0
- package/template/fm-addon/ProofKitWV/it.xml +896 -0
- package/template/fm-addon/ProofKitWV/ja.xml +896 -0
- package/template/fm-addon/ProofKitWV/ko.xml +896 -0
- package/template/fm-addon/ProofKitWV/nl.xml +896 -0
- package/template/fm-addon/ProofKitWV/preview.png +0 -0
- package/template/fm-addon/ProofKitWV/pt.xml +896 -0
- package/template/fm-addon/ProofKitWV/records_de.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_en.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_es.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_fr.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_it.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_ja.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_ko.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_nl.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_pt.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_sv.xml +0 -0
- package/template/fm-addon/ProofKitWV/records_zh.xml +0 -0
- package/template/fm-addon/ProofKitWV/sv.xml +896 -0
- package/template/fm-addon/ProofKitWV/template.xml +0 -0
- package/template/fm-addon/ProofKitWV/zh.xml +896 -0
- package/template/nextjs/README.md +27 -0
- package/template/nextjs/_gitignore +37 -0
- package/template/nextjs/next.config.ts +12 -0
- package/template/nextjs/package.json +50 -0
- package/template/nextjs/postcss.config.cjs +14 -0
- package/template/nextjs/proofkit.json +1 -0
- package/template/nextjs/public/favicon.ico +0 -0
- package/template/nextjs/public/proofkit.png +0 -0
- package/template/nextjs/src/app/(main)/layout.tsx +6 -0
- package/template/nextjs/src/app/(main)/page.tsx +90 -0
- package/template/nextjs/src/app/layout.tsx +39 -0
- package/template/nextjs/src/app/navigation.tsx +12 -0
- package/template/nextjs/src/components/AppLogo.tsx +6 -0
- package/template/nextjs/src/components/AppShell/internal/AppShell.tsx +21 -0
- package/template/nextjs/src/components/AppShell/internal/Header.module.css +40 -0
- package/template/nextjs/src/components/AppShell/internal/Header.tsx +34 -0
- package/template/nextjs/src/components/AppShell/internal/HeaderMobileMenu.tsx +27 -0
- package/template/nextjs/src/components/AppShell/internal/HeaderNavLink.tsx +31 -0
- package/template/nextjs/src/components/AppShell/internal/config.ts +1 -0
- package/template/nextjs/src/components/AppShell/slot-header-center.tsx +13 -0
- package/template/nextjs/src/components/AppShell/slot-header-left.tsx +23 -0
- package/template/nextjs/src/components/AppShell/slot-header-mobile-content.tsx +43 -0
- package/template/nextjs/src/components/AppShell/slot-header-right.tsx +26 -0
- package/template/nextjs/src/config/env.ts +13 -0
- package/template/nextjs/src/config/theme/globals.css +1 -0
- package/template/nextjs/src/config/theme/mantine-theme.ts +22 -0
- package/template/nextjs/src/server/safe-action.ts +3 -0
- package/template/nextjs/src/utils/notification-helpers.ts +32 -0
- package/template/nextjs/tsconfig.json +40 -0
- package/template/pages/nextjs/blank/page.tsx +5 -0
- package/template/pages/nextjs/table/page.tsx +17 -0
- package/template/pages/nextjs/table/table.tsx +18 -0
- package/template/pages/nextjs/table-edit/actions.ts +23 -0
- package/template/pages/nextjs/table-edit/page.tsx +28 -0
- package/template/pages/nextjs/table-edit/schema.ts +4 -0
- package/template/pages/nextjs/table-edit/table.tsx +43 -0
- package/template/pages/nextjs/table-infinite/actions.ts +62 -0
- package/template/pages/nextjs/table-infinite/page.tsx +11 -0
- package/template/pages/nextjs/table-infinite/query.ts +44 -0
- package/template/pages/nextjs/table-infinite/table.tsx +107 -0
- package/template/pages/nextjs/table-infinite-edit/actions.ts +84 -0
- package/template/pages/nextjs/table-infinite-edit/page.tsx +23 -0
- package/template/pages/nextjs/table-infinite-edit/query.ts +81 -0
- package/template/pages/nextjs/table-infinite-edit/schema.ts +4 -0
- package/template/pages/nextjs/table-infinite-edit/table.tsx +130 -0
- package/template/pages/vite-wv/blank/index.tsx +0 -0
- package/template/pages/vite-wv/table/index.tsx +34 -0
- package/template/pages/vite-wv/table-edit/index.tsx +72 -0
- package/template/vite-wv/.vscode/settings.json +11 -0
- package/template/vite-wv/_gitignore +18 -0
- package/template/vite-wv/index.html +13 -0
- package/template/vite-wv/package.json +52 -0
- package/template/vite-wv/pnpm-lock.yaml +2294 -0
- package/template/vite-wv/postcss.config.cjs +14 -0
- package/template/vite-wv/proofkit.json +1 -0
- package/template/vite-wv/scripts/launch-fm.sh +3 -0
- package/template/vite-wv/scripts/upload.js +21 -0
- package/template/vite-wv/src/components/AppLogo.tsx +5 -0
- package/template/vite-wv/src/components/full-screen-loader.tsx +9 -0
- package/template/vite-wv/src/config/env.ts +16 -0
- package/template/vite-wv/src/config/theme/globals.css +1 -0
- package/template/vite-wv/src/config/theme/mantine-theme.ts +22 -0
- package/template/vite-wv/src/main.tsx +42 -0
- package/template/vite-wv/src/routeTree.gen.ts +111 -0
- package/template/vite-wv/src/routes/__root.tsx +21 -0
- package/template/vite-wv/src/routes/index.tsx +63 -0
- package/template/vite-wv/src/routes/secondary.tsx +28 -0
- package/template/vite-wv/src/utils/notification-helpers.ts +32 -0
- package/template/vite-wv/tsconfig.json +14 -0
- package/template/vite-wv/vite.config.ts +18 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: |
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# Troubleshooting and Maintenance Patterns
|
|
7
|
+
|
|
8
|
+
This rule documents common issues, error patterns, and their solutions in the project.
|
|
9
|
+
|
|
10
|
+
<rule>
|
|
11
|
+
name: troubleshooting_patterns
|
|
12
|
+
description: Documents common runtime errors, type errors, and solutions. All data operations MUST use FileMaker Data API exclusively.
|
|
13
|
+
filters:
|
|
14
|
+
- type: file_extension
|
|
15
|
+
pattern: "\\.(ts|tsx)$"
|
|
16
|
+
- type: content
|
|
17
|
+
pattern: "(Error|error|ZodError|TypeError|ValidationError|@proofkit/fmdapi)"
|
|
18
|
+
|
|
19
|
+
initial_debugging_steps:
|
|
20
|
+
priority: "ALWAYS run `{package-manager} typegen` first for any data-related issues"
|
|
21
|
+
steps:
|
|
22
|
+
- "Run `{package-manager} typegen` to ensure types match FileMaker schema"
|
|
23
|
+
- "Check if error persists after typegen"
|
|
24
|
+
- "If error persists, check console for exact error messages"
|
|
25
|
+
- "Look for patterns in the troubleshooting guide below"
|
|
26
|
+
common_console_errors:
|
|
27
|
+
zod_errors:
|
|
28
|
+
pattern: "ZodError: [path] invalid_type..."
|
|
29
|
+
likely_cause: "Field name mismatch or missing field"
|
|
30
|
+
example: "ZodError: nameFirst expected string, got undefined"
|
|
31
|
+
solution: "Run typegen first, then check field names in FileMaker schema"
|
|
32
|
+
type_errors:
|
|
33
|
+
pattern: "TypeError: Cannot read property 'X' of undefined"
|
|
34
|
+
likely_cause: "Accessing field before data is loaded or field name mismatch"
|
|
35
|
+
solution: "Run typegen first, then add null checks or loading states"
|
|
36
|
+
network_errors:
|
|
37
|
+
pattern: "Failed to fetch" or "Network error"
|
|
38
|
+
likely_cause: "FileMaker connection issues"
|
|
39
|
+
solution: "Run typegen first, then check FileMaker server status and credentials"
|
|
40
|
+
|
|
41
|
+
data_source_validation:
|
|
42
|
+
requirement: "All data operations must use FileMaker Data API exclusively"
|
|
43
|
+
first_step_for_data_issues: "ALWAYS run `{package-manager} typegen` first"
|
|
44
|
+
common_mistakes:
|
|
45
|
+
- "Attempting to use SQL queries"
|
|
46
|
+
- "Adding direct database connections"
|
|
47
|
+
- "Using local storage for persistent data"
|
|
48
|
+
- "Implementing alternative data stores"
|
|
49
|
+
- "Skipping typegen after FileMaker schema changes"
|
|
50
|
+
- "Using incorrect field names from old schema"
|
|
51
|
+
correct_approach:
|
|
52
|
+
- "Run typegen first"
|
|
53
|
+
- "Use @proofkit/fmdapi for all data operations"
|
|
54
|
+
- "Follow FileMaker layout and field conventions"
|
|
55
|
+
- "Use layout.create, layout.find, layout.get, layout.update, layout.delete"
|
|
56
|
+
- "Use layout.maybeFindFirst for optional records"
|
|
57
|
+
|
|
58
|
+
error_patterns:
|
|
59
|
+
field_name_mismatches:
|
|
60
|
+
symptoms:
|
|
61
|
+
- "ZodError: invalid_type at path [fieldName]"
|
|
62
|
+
- "Property 'X' does not exist on type 'Y'"
|
|
63
|
+
- "TypeScript errors about missing properties"
|
|
64
|
+
common_examples:
|
|
65
|
+
- "nameFirst vs firstName"
|
|
66
|
+
- "lastName vs nameLast"
|
|
67
|
+
- "postalCode vs postal_code"
|
|
68
|
+
- "phoneNumber vs phone"
|
|
69
|
+
cause: "Mismatch between component field names and FileMaker schema"
|
|
70
|
+
solution:
|
|
71
|
+
steps:
|
|
72
|
+
- "Run `{package-manager} typegen` to update types"
|
|
73
|
+
- "Look at generated types in src/config/schemas/filemaker/"
|
|
74
|
+
- "Update component field names to match schema"
|
|
75
|
+
- "Check console for exact field name in error"
|
|
76
|
+
files_to_check:
|
|
77
|
+
- "src/config/schemas/filemaker/*.ts"
|
|
78
|
+
- "Component files using the fields"
|
|
79
|
+
|
|
80
|
+
zod_validation_errors:
|
|
81
|
+
symptoms:
|
|
82
|
+
- "Runtime ZodError: invalid_type"
|
|
83
|
+
- "Zod schema validation failed"
|
|
84
|
+
- "Property not found in schema"
|
|
85
|
+
- "Unexpected field in response"
|
|
86
|
+
cause: "FileMaker database schema changes not reflected in TypeScript types"
|
|
87
|
+
solution:
|
|
88
|
+
steps:
|
|
89
|
+
- "Run `{package-manager} typegen` to regenerate types from FileMaker schema"
|
|
90
|
+
- "Run `{package-manager} tsc` to identify type mismatches"
|
|
91
|
+
- "Check console for exact error message"
|
|
92
|
+
- "Update affected components and server actions"
|
|
93
|
+
commands:
|
|
94
|
+
- "{package-manager} typegen"
|
|
95
|
+
- "{package-manager} tsc"
|
|
96
|
+
files_to_check:
|
|
97
|
+
- "src/server/actions/*"
|
|
98
|
+
- "src/server/schema/*"
|
|
99
|
+
- "fmschema.config.mjs"
|
|
100
|
+
|
|
101
|
+
filemaker_connection:
|
|
102
|
+
symptoms:
|
|
103
|
+
- "ETIMEDOUT connecting to FileMaker"
|
|
104
|
+
- "Invalid FileMaker credentials"
|
|
105
|
+
- "Session token expired"
|
|
106
|
+
- "Layout not found"
|
|
107
|
+
- "Field not found in layout"
|
|
108
|
+
- "Invalid find criteria"
|
|
109
|
+
- "No data appearing or queries returning empty"
|
|
110
|
+
cause: "FileMaker connection, authentication, or query issues"
|
|
111
|
+
solution:
|
|
112
|
+
steps:
|
|
113
|
+
- "Run `{package-manager} typegen` to ensure schema is up to date"
|
|
114
|
+
- "Check FileMaker Server status"
|
|
115
|
+
- "Validate credentials and permissions"
|
|
116
|
+
- "Note: As an AI, you cannot directly check environment variables - always ask the user to verify them if this is determined to be the issue"
|
|
117
|
+
- "Verify layout names and field access"
|
|
118
|
+
- "Check FileMaker query syntax"
|
|
119
|
+
files_to_check:
|
|
120
|
+
- "src/server/lib/fm.ts"
|
|
121
|
+
- "fmschema.config.mjs"
|
|
122
|
+
|
|
123
|
+
data_access_errors:
|
|
124
|
+
symptoms:
|
|
125
|
+
- "Invalid operation on FileMaker record"
|
|
126
|
+
- "Record not found"
|
|
127
|
+
- "Insufficient permissions"
|
|
128
|
+
- "Invalid find request"
|
|
129
|
+
cause: "Incorrect FileMaker Data API usage or permissions"
|
|
130
|
+
solution:
|
|
131
|
+
steps:
|
|
132
|
+
- "Run `{package-manager} typegen` to ensure schema is up to date"
|
|
133
|
+
- "Verify FileMaker layout privileges"
|
|
134
|
+
- "Check record existence before operations"
|
|
135
|
+
- "Validate find criteria format"
|
|
136
|
+
- "Use proper FM API methods"
|
|
137
|
+
files_to_check:
|
|
138
|
+
- "src/server/actions/*"
|
|
139
|
+
- "src/server/lib/fm.ts"
|
|
140
|
+
|
|
141
|
+
type_errors:
|
|
142
|
+
symptoms:
|
|
143
|
+
- "Type ... is not assignable to type ..."
|
|
144
|
+
- "Property ... does not exist on type ..."
|
|
145
|
+
- "Argument of type ... is not assignable"
|
|
146
|
+
cause: "Mismatch between FileMaker schema and TypeScript types"
|
|
147
|
+
solution:
|
|
148
|
+
steps:
|
|
149
|
+
- "Run `{package-manager} typegen` to regenerate types"
|
|
150
|
+
- "Run `{package-manager} tsc` to identify type mismatches"
|
|
151
|
+
- "Update type definitions if needed"
|
|
152
|
+
- "Check for null/undefined handling"
|
|
153
|
+
commands:
|
|
154
|
+
- "{package-manager} typegen && {package-manager} tsc"
|
|
155
|
+
|
|
156
|
+
data_sync_issues:
|
|
157
|
+
symptoms:
|
|
158
|
+
- "Missing fields in table"
|
|
159
|
+
- "Unexpected null values"
|
|
160
|
+
- "Fields showing as blank"
|
|
161
|
+
- "Type mismatches between FM and frontend"
|
|
162
|
+
first_step: "ALWAYS run `{package-manager} typegen` first"
|
|
163
|
+
cause: "Mismatch between FileMaker schema and TypeScript types, or outdated type definitions"
|
|
164
|
+
solution:
|
|
165
|
+
steps:
|
|
166
|
+
- "Run `{package-manager} typegen` to regenerate types from FileMaker schema"
|
|
167
|
+
- "Check for any type errors in the console"
|
|
168
|
+
- "Verify field names match exactly between FM and generated types"
|
|
169
|
+
- "Update components if field names have changed"
|
|
170
|
+
commands:
|
|
171
|
+
- "{package-manager} typegen"
|
|
172
|
+
- "{package-manager} tsc"
|
|
173
|
+
files_to_check:
|
|
174
|
+
- "src/config/schemas/filemaker/*.ts"
|
|
175
|
+
- "fmschema.config.mjs"
|
|
176
|
+
|
|
177
|
+
maintenance_tasks:
|
|
178
|
+
schema_sync:
|
|
179
|
+
description: "Keep FileMaker schema and TypeScript types in sync"
|
|
180
|
+
frequency: "After any FileMaker schema changes"
|
|
181
|
+
steps:
|
|
182
|
+
- "Run typegen to update types"
|
|
183
|
+
- "Run TypeScript compiler"
|
|
184
|
+
- "Update affected components"
|
|
185
|
+
impact: "Prevents runtime errors and type mismatches"
|
|
186
|
+
|
|
187
|
+
type_checking:
|
|
188
|
+
description: "Regular type checking for early error detection"
|
|
189
|
+
frequency: "Before deployments and after schema changes"
|
|
190
|
+
commands:
|
|
191
|
+
- "{package-manager} tsc --noEmit"
|
|
192
|
+
impact: "Catches type errors before runtime"
|
|
193
|
+
|
|
194
|
+
keywords:
|
|
195
|
+
errors:
|
|
196
|
+
- "ZodError"
|
|
197
|
+
- "TypeError"
|
|
198
|
+
- "ValidationError"
|
|
199
|
+
- "Schema mismatch"
|
|
200
|
+
- "Type mismatch"
|
|
201
|
+
- "Runtime error"
|
|
202
|
+
- "Database schema"
|
|
203
|
+
- "Type generation"
|
|
204
|
+
- "FileMaker fields"
|
|
205
|
+
- "Missing property"
|
|
206
|
+
- "Invalid type"
|
|
207
|
+
- "Layout not found"
|
|
208
|
+
- "Field not found"
|
|
209
|
+
- "Invalid find request"
|
|
210
|
+
solutions:
|
|
211
|
+
- "typegen"
|
|
212
|
+
- "tsc"
|
|
213
|
+
- "type checking"
|
|
214
|
+
- "schema update"
|
|
215
|
+
- "validation fix"
|
|
216
|
+
- "error handling"
|
|
217
|
+
- "FM API methods"
|
|
218
|
+
- "FileMaker layout"
|
|
219
|
+
operations:
|
|
220
|
+
- "layout.create"
|
|
221
|
+
- "layout.find"
|
|
222
|
+
- "layout.get"
|
|
223
|
+
- "layout.update"
|
|
224
|
+
- "layout.delete"
|
|
225
|
+
- "layout.maybeFindFirst"
|
|
226
|
+
- "recordId"
|
|
227
|
+
- "fieldData"
|
|
228
|
+
- "query parameters"
|
|
229
|
+
- "sort options"
|
|
230
|
+
data_source:
|
|
231
|
+
- "FileMaker only"
|
|
232
|
+
- "No SQL"
|
|
233
|
+
- "FM Data API"
|
|
234
|
+
- "Exclusive data source"
|
|
235
|
+
- "@proofkit/fmdapi"
|
|
236
|
+
|
|
237
|
+
metadata:
|
|
238
|
+
priority: high
|
|
239
|
+
version: 1.0
|
|
240
|
+
</rule>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# UI Components and Styling
|
|
7
|
+
|
|
8
|
+
This rule documents the UI component library and styling conventions used in the project.
|
|
9
|
+
|
|
10
|
+
<rule>
|
|
11
|
+
name: ui_components
|
|
12
|
+
description: Documents UI component library usage and styling conventions
|
|
13
|
+
filters:
|
|
14
|
+
- type: file_extension
|
|
15
|
+
pattern: "\\.(ts|tsx)$"
|
|
16
|
+
- type: directory
|
|
17
|
+
pattern: "src/components/"
|
|
18
|
+
- type: content
|
|
19
|
+
pattern: "@mantine/"
|
|
20
|
+
|
|
21
|
+
conventions:
|
|
22
|
+
component_library:
|
|
23
|
+
- Mantine v7 as primary UI framework
|
|
24
|
+
- Tabler icons for iconography
|
|
25
|
+
- Mantine React Table for data grids
|
|
26
|
+
- Custom components extend Mantine base
|
|
27
|
+
|
|
28
|
+
styling:
|
|
29
|
+
- PostCSS for processing
|
|
30
|
+
- Mantine theme customization
|
|
31
|
+
- CSS modules for component styles
|
|
32
|
+
- CSS variables for theming
|
|
33
|
+
|
|
34
|
+
components:
|
|
35
|
+
- Atomic design principles
|
|
36
|
+
- Consistent prop interfaces
|
|
37
|
+
- Accessibility first
|
|
38
|
+
- Responsive design patterns
|
|
39
|
+
|
|
40
|
+
forms:
|
|
41
|
+
- React Hook Form for form state
|
|
42
|
+
- Zod for validation schemas
|
|
43
|
+
- Mantine form components
|
|
44
|
+
- Custom form layouts
|
|
45
|
+
|
|
46
|
+
dependencies:
|
|
47
|
+
mantine_core: "^7.17.0"
|
|
48
|
+
mantine_hooks: "^7.17.0"
|
|
49
|
+
mantine_dates: "^7.17.0"
|
|
50
|
+
mantine_notifications: "^7.17.0"
|
|
51
|
+
react_hook_form: "^7.54.2"
|
|
52
|
+
zod: "^3.24.2"
|
|
53
|
+
|
|
54
|
+
metadata:
|
|
55
|
+
priority: high
|
|
56
|
+
version: 1.0
|
|
57
|
+
</rule>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @type {import("eslint").Linter.Config} */
|
|
2
|
+
export const _initialConfig = {
|
|
3
|
+
parser: "@typescript-eslint/parser",
|
|
4
|
+
parserOptions: { project: true },
|
|
5
|
+
plugins: ["@typescript-eslint"],
|
|
6
|
+
extends: [
|
|
7
|
+
"next/core-web-vitals",
|
|
8
|
+
"plugin:@typescript-eslint/recommended-type-checked",
|
|
9
|
+
"plugin:@typescript-eslint/stylistic-type-checked",
|
|
10
|
+
],
|
|
11
|
+
rules: {
|
|
12
|
+
"@typescript-eslint/array-type": "off",
|
|
13
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
14
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
15
|
+
"warn",
|
|
16
|
+
{ prefer: "type-imports", fixStyle: "inline-type-imports" },
|
|
17
|
+
],
|
|
18
|
+
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
|
|
19
|
+
"@typescript-eslint/require-await": "off",
|
|
20
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
21
|
+
"@typescript-eslint/no-misused-promises": [
|
|
22
|
+
"error",
|
|
23
|
+
{ checksVoidReturn: { attributes: false } },
|
|
24
|
+
],
|
|
25
|
+
"@typescript-eslint/no-floating-promises": "warn",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Config } from "drizzle-kit";
|
|
2
|
+
|
|
3
|
+
import { env } from "~/env";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
schema: "./src/server/db/schema.ts",
|
|
7
|
+
dialect: "mysql",
|
|
8
|
+
dbCredentials: {
|
|
9
|
+
url: env.DATABASE_URL,
|
|
10
|
+
},
|
|
11
|
+
tablesFilter: ["project1_*"],
|
|
12
|
+
} satisfies Config;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Config } from "drizzle-kit";
|
|
2
|
+
|
|
3
|
+
import { env } from "~/env";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
schema: "./src/server/db/schema.ts",
|
|
7
|
+
dialect: "postgresql",
|
|
8
|
+
dbCredentials: {
|
|
9
|
+
url: env.DATABASE_URL,
|
|
10
|
+
},
|
|
11
|
+
tablesFilter: ["project1_*"],
|
|
12
|
+
} satisfies Config;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Config } from "drizzle-kit";
|
|
2
|
+
|
|
3
|
+
import { env } from "~/env";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
schema: "./src/server/db/schema.ts",
|
|
7
|
+
dialect: "sqlite",
|
|
8
|
+
dbCredentials: {
|
|
9
|
+
url: env.DATABASE_URL,
|
|
10
|
+
},
|
|
11
|
+
tablesFilter: ["project1_*"],
|
|
12
|
+
} satisfies Config;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @type {import("@proofkit/fmdapi/dist/utils/typegen/types.d.ts").GenerateSchemaOptions} */
|
|
2
|
+
export const config = {
|
|
3
|
+
clientSuffix: "Layout",
|
|
4
|
+
schemas: [
|
|
5
|
+
// add your layouts and name schemas here
|
|
6
|
+
],
|
|
7
|
+
clearOldFiles: true,
|
|
8
|
+
path: "./src/config/schemas/filemaker",
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
4
|
+
|
|
5
|
+
const queryClient = new QueryClient();
|
|
6
|
+
|
|
7
|
+
export default function QueryProvider({
|
|
8
|
+
children,
|
|
9
|
+
}: {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}) {
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<QueryClientProvider client={queryClient}>
|
|
15
|
+
{children}
|
|
16
|
+
<ReactQueryDevtools />
|
|
17
|
+
</QueryClientProvider>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
4
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
5
|
+
|
|
6
|
+
import getQueryClient from "./get-query-client";
|
|
7
|
+
|
|
8
|
+
export default function QueryProvider({
|
|
9
|
+
children,
|
|
10
|
+
}: {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}) {
|
|
13
|
+
const queryClient = getQueryClient();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<QueryClientProvider client={queryClient}>
|
|
17
|
+
{children}
|
|
18
|
+
<ReactQueryDevtools />
|
|
19
|
+
</QueryClientProvider>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { render } from "@react-email/render";
|
|
2
|
+
import { AuthCodeEmail } from "@/emails/auth-code";
|
|
3
|
+
|
|
4
|
+
export async function sendEmail({
|
|
5
|
+
to,
|
|
6
|
+
code,
|
|
7
|
+
type,
|
|
8
|
+
}: {
|
|
9
|
+
to: string;
|
|
10
|
+
code: string;
|
|
11
|
+
type: "verification" | "password-reset";
|
|
12
|
+
}) {
|
|
13
|
+
// this is the HTML body of the email to be send
|
|
14
|
+
const body = await render(
|
|
15
|
+
<AuthCodeEmail validationCode={code} type={type} />
|
|
16
|
+
);
|
|
17
|
+
const subject = type === "verification" ? "Verify Your Email" : "Reset Your Password"
|
|
18
|
+
|
|
19
|
+
// TODO: Customize this function to actually send the email to your users
|
|
20
|
+
// Learn more: https://proofkit.dev/auth/fm-addon
|
|
21
|
+
console.warn("TODO: Customize this function to actually send to your users");
|
|
22
|
+
console.log(`To ${to}: Your ${type} code is ${code}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { render } from "@react-email/render";
|
|
2
|
+
import { AuthCodeEmail } from "@/emails/auth-code";
|
|
3
|
+
import { plunk } from "../services/plunk";
|
|
4
|
+
|
|
5
|
+
export async function sendEmail({
|
|
6
|
+
to,
|
|
7
|
+
code,
|
|
8
|
+
type,
|
|
9
|
+
}: {
|
|
10
|
+
to: string;
|
|
11
|
+
code: string;
|
|
12
|
+
type: "verification" | "password-reset";
|
|
13
|
+
}) {
|
|
14
|
+
// this is the HTML body of the email to be send
|
|
15
|
+
const body = await render(
|
|
16
|
+
<AuthCodeEmail validationCode={code} type={type} />
|
|
17
|
+
);
|
|
18
|
+
const subject = type === "verification" ? "Verify Your Email" : "Reset Your Password"
|
|
19
|
+
|
|
20
|
+
await plunk.emails.send({
|
|
21
|
+
to,
|
|
22
|
+
subject,
|
|
23
|
+
body,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AuthCodeEmail } from "@/emails/auth-code";
|
|
2
|
+
import { resend } from "../services/resend";
|
|
3
|
+
|
|
4
|
+
export async function sendEmail({
|
|
5
|
+
to,
|
|
6
|
+
code,
|
|
7
|
+
type,
|
|
8
|
+
}: {
|
|
9
|
+
to: string;
|
|
10
|
+
code: string;
|
|
11
|
+
type: "verification" | "password-reset";
|
|
12
|
+
}) {
|
|
13
|
+
const subject =
|
|
14
|
+
type === "verification" ? "Verify Your Email" : "Reset Your Password";
|
|
15
|
+
|
|
16
|
+
await resend.emails.send({
|
|
17
|
+
// TODO: Change this to our own email after verifying your domain with Resend
|
|
18
|
+
from: "ProofKit <onboarding@resend.dev>",
|
|
19
|
+
to,
|
|
20
|
+
subject,
|
|
21
|
+
react: <AuthCodeEmail validationCode={code} type={type} />,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { actionClient } from "@/server/safe-action";
|
|
3
|
+
import { updateEmailSchema, updatePasswordSchema } from "./schema";
|
|
4
|
+
import {
|
|
5
|
+
createSession,
|
|
6
|
+
generateSessionToken,
|
|
7
|
+
getCurrentSession,
|
|
8
|
+
invalidateUserSessions,
|
|
9
|
+
setSessionTokenCookie,
|
|
10
|
+
} from "@/server/auth/utils/session";
|
|
11
|
+
import {
|
|
12
|
+
checkEmailAvailability,
|
|
13
|
+
updateUserPassword,
|
|
14
|
+
validateLogin,
|
|
15
|
+
} from "@/server/auth/utils/user";
|
|
16
|
+
import {
|
|
17
|
+
createEmailVerificationRequest,
|
|
18
|
+
sendVerificationEmail,
|
|
19
|
+
setEmailVerificationRequestCookie,
|
|
20
|
+
} from "@/server/auth/utils/email-verification";
|
|
21
|
+
import { redirect } from "next/navigation";
|
|
22
|
+
import { verifyPasswordHash } from "@/server/auth/utils/password";
|
|
23
|
+
import { verifyPasswordStrength } from "@/server/auth/utils/password";
|
|
24
|
+
|
|
25
|
+
export const updateEmailAction = actionClient
|
|
26
|
+
.schema(updateEmailSchema)
|
|
27
|
+
.action(async ({ parsedInput }) => {
|
|
28
|
+
const { session, user } = await getCurrentSession();
|
|
29
|
+
if (session === null) {
|
|
30
|
+
return {
|
|
31
|
+
message: "Not authenticated",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { email } = parsedInput;
|
|
36
|
+
|
|
37
|
+
const emailAvailable = await checkEmailAvailability(email);
|
|
38
|
+
if (!emailAvailable) {
|
|
39
|
+
return {
|
|
40
|
+
error: "This email is already used",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const verificationRequest = await createEmailVerificationRequest(
|
|
45
|
+
user.id,
|
|
46
|
+
email
|
|
47
|
+
);
|
|
48
|
+
await sendVerificationEmail(
|
|
49
|
+
verificationRequest.email,
|
|
50
|
+
verificationRequest.code
|
|
51
|
+
);
|
|
52
|
+
await setEmailVerificationRequestCookie(verificationRequest);
|
|
53
|
+
return redirect("/auth/verify-email");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const updatePasswordAction = actionClient
|
|
57
|
+
.schema(updatePasswordSchema)
|
|
58
|
+
.action(async ({ parsedInput }) => {
|
|
59
|
+
const { confirmNewPassword, currentPassword, newPassword } = parsedInput;
|
|
60
|
+
|
|
61
|
+
const { session, user } = await getCurrentSession();
|
|
62
|
+
if (session === null) {
|
|
63
|
+
return {
|
|
64
|
+
error: "Not authenticated",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const strongPassword = await verifyPasswordStrength(newPassword);
|
|
69
|
+
if (!strongPassword) {
|
|
70
|
+
return {
|
|
71
|
+
error: "Weak password",
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const validPassword = Boolean(
|
|
76
|
+
await validateLogin(user.email, currentPassword)
|
|
77
|
+
);
|
|
78
|
+
if (!validPassword) {
|
|
79
|
+
return {
|
|
80
|
+
error: "Incorrect password",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await invalidateUserSessions(user.id);
|
|
85
|
+
await updateUserPassword(user.id, newPassword);
|
|
86
|
+
|
|
87
|
+
const sessionToken = generateSessionToken();
|
|
88
|
+
const newSession = await createSession(sessionToken, user.id);
|
|
89
|
+
await setSessionTokenCookie(sessionToken, newSession.expiresAt);
|
|
90
|
+
return {
|
|
91
|
+
message: "Password updated",
|
|
92
|
+
};
|
|
93
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getCurrentSession } from "@/server/auth/utils/session";
|
|
2
|
+
import { Anchor, Container, Paper, Stack, Text, Title } from "@mantine/core";
|
|
3
|
+
import { redirect } from "next/navigation";
|
|
4
|
+
import UpdateEmailForm from "./profile-form";
|
|
5
|
+
import UpdatePasswordForm from "./reset-password-form";
|
|
6
|
+
// import EmailVerificationForm from "./email-verification-form";
|
|
7
|
+
|
|
8
|
+
export default async function Page() {
|
|
9
|
+
const { user } = await getCurrentSession();
|
|
10
|
+
|
|
11
|
+
if (user === null) {
|
|
12
|
+
return redirect("/auth/login");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Container size={420} my={40}>
|
|
17
|
+
<Title ta="center">Profile Details</Title>
|
|
18
|
+
|
|
19
|
+
<Paper withBorder shadow="md" p={30} mt={30} radius="md">
|
|
20
|
+
<Stack>
|
|
21
|
+
<UpdateEmailForm currentEmail={user.email} />
|
|
22
|
+
<UpdatePasswordForm />
|
|
23
|
+
</Stack>
|
|
24
|
+
</Paper>
|
|
25
|
+
</Container>
|
|
26
|
+
);
|
|
27
|
+
}
|