@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.
- package/LICENSE +21 -0
- package/README.md +442 -0
- package/dist/adapters/drizzle.cjs +123 -0
- package/dist/adapters/drizzle.cjs.map +1 -0
- package/dist/adapters/drizzle.d.cts +76 -0
- package/dist/adapters/drizzle.d.ts +76 -0
- package/dist/adapters/drizzle.js +99 -0
- package/dist/adapters/drizzle.js.map +1 -0
- package/dist/adapters/prisma.cjs +120 -0
- package/dist/adapters/prisma.cjs.map +1 -0
- package/dist/adapters/prisma.d.cts +75 -0
- package/dist/adapters/prisma.d.ts +75 -0
- package/dist/adapters/prisma.js +96 -0
- package/dist/adapters/prisma.js.map +1 -0
- package/dist/adapters/sql.cjs +206 -0
- package/dist/adapters/sql.cjs.map +1 -0
- package/dist/adapters/sql.d.cts +111 -0
- package/dist/adapters/sql.d.ts +111 -0
- package/dist/adapters/sql.js +182 -0
- package/dist/adapters/sql.js.map +1 -0
- package/dist/api/index.cjs +257 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.d.cts +137 -0
- package/dist/api/index.d.ts +137 -0
- package/dist/api/index.js +231 -0
- package/dist/api/index.js.map +1 -0
- package/dist/auth/clerk.cjs +60 -0
- package/dist/auth/clerk.cjs.map +1 -0
- package/dist/auth/clerk.d.cts +83 -0
- package/dist/auth/clerk.d.ts +83 -0
- package/dist/auth/clerk.js +36 -0
- package/dist/auth/clerk.js.map +1 -0
- package/dist/auth/next-auth.cjs +50 -0
- package/dist/auth/next-auth.cjs.map +1 -0
- package/dist/auth/next-auth.d.cts +53 -0
- package/dist/auth/next-auth.d.ts +53 -0
- package/dist/auth/next-auth.js +26 -0
- package/dist/auth/next-auth.js.map +1 -0
- package/dist/components/index.cjs +1175 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +141 -0
- package/dist/components/index.d.ts +141 -0
- package/dist/components/index.js +1147 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.cjs +241 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/drizzle.cjs +100 -0
- package/dist/schemas/drizzle.cjs.map +1 -0
- package/dist/schemas/drizzle.d.cts +32 -0
- package/dist/schemas/drizzle.d.ts +32 -0
- package/dist/schemas/drizzle.js +74 -0
- package/dist/schemas/drizzle.js.map +1 -0
- package/dist/types-C3x_Ry2e.d.cts +195 -0
- package/dist/types-C3x_Ry2e.d.ts +195 -0
- package/package.json +128 -0
- package/schemas/prisma.prisma +23 -0
- 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":[]}
|