@vinetechke/next-error-logger 0.1.0-beta.1

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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +442 -0
  3. package/dist/adapters/drizzle.cjs +123 -0
  4. package/dist/adapters/drizzle.cjs.map +1 -0
  5. package/dist/adapters/drizzle.d.cts +76 -0
  6. package/dist/adapters/drizzle.d.ts +76 -0
  7. package/dist/adapters/drizzle.js +99 -0
  8. package/dist/adapters/drizzle.js.map +1 -0
  9. package/dist/adapters/prisma.cjs +120 -0
  10. package/dist/adapters/prisma.cjs.map +1 -0
  11. package/dist/adapters/prisma.d.cts +75 -0
  12. package/dist/adapters/prisma.d.ts +75 -0
  13. package/dist/adapters/prisma.js +96 -0
  14. package/dist/adapters/prisma.js.map +1 -0
  15. package/dist/adapters/sql.cjs +206 -0
  16. package/dist/adapters/sql.cjs.map +1 -0
  17. package/dist/adapters/sql.d.cts +111 -0
  18. package/dist/adapters/sql.d.ts +111 -0
  19. package/dist/adapters/sql.js +182 -0
  20. package/dist/adapters/sql.js.map +1 -0
  21. package/dist/api/index.cjs +257 -0
  22. package/dist/api/index.cjs.map +1 -0
  23. package/dist/api/index.d.cts +137 -0
  24. package/dist/api/index.d.ts +137 -0
  25. package/dist/api/index.js +231 -0
  26. package/dist/api/index.js.map +1 -0
  27. package/dist/auth/clerk.cjs +60 -0
  28. package/dist/auth/clerk.cjs.map +1 -0
  29. package/dist/auth/clerk.d.cts +83 -0
  30. package/dist/auth/clerk.d.ts +83 -0
  31. package/dist/auth/clerk.js +36 -0
  32. package/dist/auth/clerk.js.map +1 -0
  33. package/dist/auth/next-auth.cjs +50 -0
  34. package/dist/auth/next-auth.cjs.map +1 -0
  35. package/dist/auth/next-auth.d.cts +53 -0
  36. package/dist/auth/next-auth.d.ts +53 -0
  37. package/dist/auth/next-auth.js +26 -0
  38. package/dist/auth/next-auth.js.map +1 -0
  39. package/dist/components/index.cjs +1175 -0
  40. package/dist/components/index.cjs.map +1 -0
  41. package/dist/components/index.d.cts +141 -0
  42. package/dist/components/index.d.ts +141 -0
  43. package/dist/components/index.js +1147 -0
  44. package/dist/components/index.js.map +1 -0
  45. package/dist/index.cjs +241 -0
  46. package/dist/index.cjs.map +1 -0
  47. package/dist/index.d.cts +109 -0
  48. package/dist/index.d.ts +109 -0
  49. package/dist/index.js +212 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/schemas/drizzle.cjs +100 -0
  52. package/dist/schemas/drizzle.cjs.map +1 -0
  53. package/dist/schemas/drizzle.d.cts +32 -0
  54. package/dist/schemas/drizzle.d.ts +32 -0
  55. package/dist/schemas/drizzle.js +74 -0
  56. package/dist/schemas/drizzle.js.map +1 -0
  57. package/dist/types-C3x_Ry2e.d.cts +195 -0
  58. package/dist/types-C3x_Ry2e.d.ts +195 -0
  59. package/package.json +128 -0
  60. package/schemas/prisma.prisma +23 -0
  61. package/schemas/schema.sql +75 -0
@@ -0,0 +1,53 @@
1
+ import { A as AuthAdapter } from '../types-C3x_Ry2e.cjs';
2
+
3
+ /**
4
+ * NextAuth session interface
5
+ */
6
+ interface NextAuthSession {
7
+ user?: {
8
+ id?: string;
9
+ email?: string | null;
10
+ name?: string | null;
11
+ } | null;
12
+ }
13
+ /**
14
+ * NextAuth auth function type
15
+ */
16
+ type NextAuthFn = () => Promise<NextAuthSession | null>;
17
+ /**
18
+ * Create a NextAuth authentication adapter
19
+ *
20
+ * Automatically captures user context from NextAuth sessions.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // With NextAuth v5 (Auth.js)
25
+ * import { createNextAuthAdapter } from '@vinetechke/next-error-logger/auth/next-auth'
26
+ * import { auth } from '@/auth' // Your NextAuth config
27
+ *
28
+ * const authAdapter = createNextAuthAdapter(auth)
29
+ *
30
+ * // Initialize logger
31
+ * initErrorLogger({
32
+ * adapter: createPrismaAdapter(prisma),
33
+ * authAdapter,
34
+ * })
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * // With NextAuth v4
40
+ * import { createNextAuthAdapter } from '@vinetechke/next-error-logger/auth/next-auth'
41
+ * import { getServerSession } from 'next-auth'
42
+ * import { authOptions } from '@/app/api/auth/[...nextauth]/route'
43
+ *
44
+ * const authAdapter = createNextAuthAdapter(async () => {
45
+ * return getServerSession(authOptions)
46
+ * })
47
+ * ```
48
+ *
49
+ * @param authFn - Your NextAuth auth() function or a wrapper that returns the session
50
+ */
51
+ declare function createNextAuthAdapter(authFn: NextAuthFn): AuthAdapter;
52
+
53
+ export { createNextAuthAdapter };
@@ -0,0 +1,53 @@
1
+ import { A as AuthAdapter } from '../types-C3x_Ry2e.js';
2
+
3
+ /**
4
+ * NextAuth session interface
5
+ */
6
+ interface NextAuthSession {
7
+ user?: {
8
+ id?: string;
9
+ email?: string | null;
10
+ name?: string | null;
11
+ } | null;
12
+ }
13
+ /**
14
+ * NextAuth auth function type
15
+ */
16
+ type NextAuthFn = () => Promise<NextAuthSession | null>;
17
+ /**
18
+ * Create a NextAuth authentication adapter
19
+ *
20
+ * Automatically captures user context from NextAuth sessions.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // With NextAuth v5 (Auth.js)
25
+ * import { createNextAuthAdapter } from '@vinetechke/next-error-logger/auth/next-auth'
26
+ * import { auth } from '@/auth' // Your NextAuth config
27
+ *
28
+ * const authAdapter = createNextAuthAdapter(auth)
29
+ *
30
+ * // Initialize logger
31
+ * initErrorLogger({
32
+ * adapter: createPrismaAdapter(prisma),
33
+ * authAdapter,
34
+ * })
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * // With NextAuth v4
40
+ * import { createNextAuthAdapter } from '@vinetechke/next-error-logger/auth/next-auth'
41
+ * import { getServerSession } from 'next-auth'
42
+ * import { authOptions } from '@/app/api/auth/[...nextauth]/route'
43
+ *
44
+ * const authAdapter = createNextAuthAdapter(async () => {
45
+ * return getServerSession(authOptions)
46
+ * })
47
+ * ```
48
+ *
49
+ * @param authFn - Your NextAuth auth() function or a wrapper that returns the session
50
+ */
51
+ declare function createNextAuthAdapter(authFn: NextAuthFn): AuthAdapter;
52
+
53
+ export { createNextAuthAdapter };
@@ -0,0 +1,26 @@
1
+ "use client";
2
+
3
+ // src/auth/next-auth.ts
4
+ function createNextAuthAdapter(authFn) {
5
+ return {
6
+ async getUser() {
7
+ try {
8
+ const session = await authFn();
9
+ if (!session?.user?.id) {
10
+ return null;
11
+ }
12
+ return {
13
+ id: session.user.id,
14
+ email: session.user.email || void 0,
15
+ name: session.user.name || void 0
16
+ };
17
+ } catch {
18
+ return null;
19
+ }
20
+ }
21
+ };
22
+ }
23
+ export {
24
+ createNextAuthAdapter
25
+ };
26
+ //# sourceMappingURL=next-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/next-auth.ts"],"sourcesContent":["import type { AuthAdapter } from '../types'\n\n/**\n * NextAuth session interface\n */\ninterface NextAuthSession {\n user?: {\n id?: string\n email?: string | null\n name?: string | null\n } | null\n}\n\n/**\n * NextAuth auth function type\n */\ntype NextAuthFn = () => Promise<NextAuthSession | null>\n\n/**\n * Create a NextAuth authentication adapter\n *\n * Automatically captures user context from NextAuth sessions.\n *\n * @example\n * ```ts\n * // With NextAuth v5 (Auth.js)\n * import { createNextAuthAdapter } from '@vinetechke/next-error-logger/auth/next-auth'\n * import { auth } from '@/auth' // Your NextAuth config\n *\n * const authAdapter = createNextAuthAdapter(auth)\n *\n * // Initialize logger\n * initErrorLogger({\n * adapter: createPrismaAdapter(prisma),\n * authAdapter,\n * })\n * ```\n *\n * @example\n * ```ts\n * // With NextAuth v4\n * import { createNextAuthAdapter } from '@vinetechke/next-error-logger/auth/next-auth'\n * import { getServerSession } from 'next-auth'\n * import { authOptions } from '@/app/api/auth/[...nextauth]/route'\n *\n * const authAdapter = createNextAuthAdapter(async () => {\n * return getServerSession(authOptions)\n * })\n * ```\n *\n * @param authFn - Your NextAuth auth() function or a wrapper that returns the session\n */\nexport function createNextAuthAdapter(authFn: NextAuthFn): AuthAdapter {\n return {\n async getUser() {\n try {\n const session = await authFn()\n\n if (!session?.user?.id) {\n return null\n }\n\n return {\n id: session.user.id,\n email: session.user.email || undefined,\n name: session.user.name || undefined,\n }\n } catch {\n // Silently fail - user context is optional\n return null\n }\n },\n }\n}\n"],"mappings":";;;AAoDO,SAAS,sBAAsB,QAAiC;AACnE,SAAO;AAAA,IACH,MAAM,UAAU;AACZ,UAAI;AACA,cAAM,UAAU,MAAM,OAAO;AAE7B,YAAI,CAAC,SAAS,MAAM,IAAI;AACpB,iBAAO;AAAA,QACX;AAEA,eAAO;AAAA,UACH,IAAI,QAAQ,KAAK;AAAA,UACjB,OAAO,QAAQ,KAAK,SAAS;AAAA,UAC7B,MAAM,QAAQ,KAAK,QAAQ;AAAA,QAC/B;AAAA,MACJ,QAAQ;AAEJ,eAAO;AAAA,MACX;AAAA,IACJ;AAAA,EACJ;AACJ;","names":[]}