zitejs 0.9.85 → 0.9.86
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/dist/cjs/auth/index.d.ts +4 -0
- package/dist/cjs/auth/index.js +8 -0
- package/dist/cjs/sync/lib.d.ts +1 -3
- package/dist/cjs/sync/lib.js +4 -7
- package/dist/cjs/sync/lib.test.js +6 -17
- package/dist/esm/auth/index.d.ts +4 -0
- package/dist/esm/auth/index.js +7 -0
- package/dist/esm/sync/lib.d.ts +1 -3
- package/dist/esm/sync/lib.js +4 -7
- package/dist/esm/sync/lib.test.js +6 -17
- package/package.json +1 -1
package/dist/cjs/auth/index.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export declare const useSession: () => {
|
|
|
30
30
|
query?: import("better-auth/types").SessionQueryParams;
|
|
31
31
|
} | undefined) => Promise<void>;
|
|
32
32
|
};
|
|
33
|
+
export declare function useAuth(): {
|
|
34
|
+
user: User | null;
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
};
|
|
33
37
|
export declare const signIn: {
|
|
34
38
|
magicLink: <FetchOptions extends import("@better-auth/core").ClientFetchOption<Partial<{
|
|
35
39
|
email: string;
|
package/dist/cjs/auth/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signUp = exports.signOut = exports.signIn = exports.useSession = void 0;
|
|
4
|
+
exports.useAuth = useAuth;
|
|
4
5
|
exports.loginWithRedirect = loginWithRedirect;
|
|
5
6
|
exports.logout = logout;
|
|
6
7
|
exports.updateProfile = updateProfile;
|
|
@@ -19,6 +20,13 @@ const authClient = (0, react_1.createAuthClient)({
|
|
|
19
20
|
],
|
|
20
21
|
});
|
|
21
22
|
exports.useSession = authClient.useSession;
|
|
23
|
+
function useAuth() {
|
|
24
|
+
const { data, isPending } = (0, exports.useSession)();
|
|
25
|
+
return {
|
|
26
|
+
user: data?.user ?? null,
|
|
27
|
+
isLoading: isPending,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
22
30
|
exports.signIn = authClient.signIn;
|
|
23
31
|
exports.signOut = authClient.signOut;
|
|
24
32
|
exports.signUp = authClient.signUp;
|
package/dist/cjs/sync/lib.d.ts
CHANGED
|
@@ -39,9 +39,7 @@ export declare function generateUserTs(usersTableFields?: Array<{
|
|
|
39
39
|
name: string;
|
|
40
40
|
type: string;
|
|
41
41
|
}>): string;
|
|
42
|
-
export declare function generateAuthWrapperTs(
|
|
43
|
-
includeUseAuthCompat?: boolean;
|
|
44
|
-
}): string;
|
|
42
|
+
export declare function generateAuthWrapperTs(): string;
|
|
45
43
|
export type AirtableLockField = {
|
|
46
44
|
id: string;
|
|
47
45
|
sdkName: string;
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -491,13 +491,14 @@ function generateUserTs(usersTableFields) {
|
|
|
491
491
|
lines.push("");
|
|
492
492
|
return lines.join("\n");
|
|
493
493
|
}
|
|
494
|
-
function generateAuthWrapperTs(
|
|
495
|
-
|
|
494
|
+
function generateAuthWrapperTs() {
|
|
495
|
+
return [
|
|
496
496
|
"// Auto-generated auth re-exports. Do not edit manually.",
|
|
497
497
|
"// The real auth logic lives in the zitejs npm package (zitejs/auth).",
|
|
498
498
|
"// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
|
|
499
499
|
"",
|
|
500
500
|
"export {",
|
|
501
|
+
" useAuth,",
|
|
501
502
|
" useSession,",
|
|
502
503
|
" signIn,",
|
|
503
504
|
" signOut,",
|
|
@@ -516,11 +517,7 @@ function generateAuthWrapperTs(opts) {
|
|
|
516
517
|
" ZiteAuthPageMessages,",
|
|
517
518
|
"} from 'zitejs/auth/base';",
|
|
518
519
|
"",
|
|
519
|
-
];
|
|
520
|
-
if (opts?.includeUseAuthCompat) {
|
|
521
|
-
lines.push("// Backward-compat shim: maps the old useAuth() API to useSession().", "// The LLM can remove this by switching to useSession() directly.", "import { useSession as _useSession, loginWithRedirect as _loginWithRedirect, logout as _logout } from 'zitejs/auth/base';", "", "export function useAuth() {", " const { data, isPending } = _useSession();", " return {", " user: data?.user ?? null,", " isLoading: isPending,", " loginWithRedirect: _loginWithRedirect,", " logout: _logout,", " };", "}", "");
|
|
522
|
-
}
|
|
523
|
-
return lines.join("\n");
|
|
520
|
+
].join("\n");
|
|
524
521
|
}
|
|
525
522
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
526
523
|
// Writable fields
|
|
@@ -32,23 +32,12 @@ const lib_js_1 = require("./lib.js");
|
|
|
32
32
|
(0, vitest_1.expect)(output).toContain(type);
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
-
(0, vitest_1.it)('
|
|
36
|
-
(0, vitest_1.expect)(output).
|
|
35
|
+
(0, vitest_1.it)('always exports useAuth as primary API', () => {
|
|
36
|
+
(0, vitest_1.expect)(output).toContain('useAuth');
|
|
37
37
|
});
|
|
38
|
-
(0, vitest_1.
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
(0, vitest_1.it)('wraps useSession', () => {
|
|
44
|
-
(0, vitest_1.expect)(compatOutput).toContain('_useSession()');
|
|
45
|
-
(0, vitest_1.expect)(compatOutput).toContain('data?.user ?? null');
|
|
46
|
-
(0, vitest_1.expect)(compatOutput).toContain('isLoading: isPending');
|
|
47
|
-
});
|
|
48
|
-
(0, vitest_1.it)('still exports all standard functions', () => {
|
|
49
|
-
for (const fn of ['useSession', 'signIn', 'signOut', 'loginWithRedirect', 'logout']) {
|
|
50
|
-
(0, vitest_1.expect)(compatOutput).toContain(fn);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
38
|
+
(0, vitest_1.it)('exports all standard functions', () => {
|
|
39
|
+
for (const fn of ['useAuth', 'useSession', 'signIn', 'signOut', 'loginWithRedirect', 'logout']) {
|
|
40
|
+
(0, vitest_1.expect)(output).toContain(fn);
|
|
41
|
+
}
|
|
53
42
|
});
|
|
54
43
|
});
|
package/dist/esm/auth/index.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export declare const useSession: () => {
|
|
|
30
30
|
query?: import("better-auth").SessionQueryParams;
|
|
31
31
|
} | undefined) => Promise<void>;
|
|
32
32
|
};
|
|
33
|
+
export declare function useAuth(): {
|
|
34
|
+
user: User | null;
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
};
|
|
33
37
|
export declare const signIn: {
|
|
34
38
|
magicLink: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
35
39
|
email: string;
|
package/dist/esm/auth/index.js
CHANGED
|
@@ -13,6 +13,13 @@ const authClient = createAuthClient({
|
|
|
13
13
|
],
|
|
14
14
|
});
|
|
15
15
|
export const useSession = authClient.useSession;
|
|
16
|
+
export function useAuth() {
|
|
17
|
+
const { data, isPending } = useSession();
|
|
18
|
+
return {
|
|
19
|
+
user: data?.user ?? null,
|
|
20
|
+
isLoading: isPending,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
16
23
|
export const signIn = authClient.signIn;
|
|
17
24
|
export const signOut = authClient.signOut;
|
|
18
25
|
export const signUp = authClient.signUp;
|
package/dist/esm/sync/lib.d.ts
CHANGED
|
@@ -39,9 +39,7 @@ export declare function generateUserTs(usersTableFields?: Array<{
|
|
|
39
39
|
name: string;
|
|
40
40
|
type: string;
|
|
41
41
|
}>): string;
|
|
42
|
-
export declare function generateAuthWrapperTs(
|
|
43
|
-
includeUseAuthCompat?: boolean;
|
|
44
|
-
}): string;
|
|
42
|
+
export declare function generateAuthWrapperTs(): string;
|
|
45
43
|
export type AirtableLockField = {
|
|
46
44
|
id: string;
|
|
47
45
|
sdkName: string;
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -479,13 +479,14 @@ export function generateUserTs(usersTableFields) {
|
|
|
479
479
|
lines.push("");
|
|
480
480
|
return lines.join("\n");
|
|
481
481
|
}
|
|
482
|
-
export function generateAuthWrapperTs(
|
|
483
|
-
|
|
482
|
+
export function generateAuthWrapperTs() {
|
|
483
|
+
return [
|
|
484
484
|
"// Auto-generated auth re-exports. Do not edit manually.",
|
|
485
485
|
"// The real auth logic lives in the zitejs npm package (zitejs/auth).",
|
|
486
486
|
"// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
|
|
487
487
|
"",
|
|
488
488
|
"export {",
|
|
489
|
+
" useAuth,",
|
|
489
490
|
" useSession,",
|
|
490
491
|
" signIn,",
|
|
491
492
|
" signOut,",
|
|
@@ -504,11 +505,7 @@ export function generateAuthWrapperTs(opts) {
|
|
|
504
505
|
" ZiteAuthPageMessages,",
|
|
505
506
|
"} from 'zitejs/auth/base';",
|
|
506
507
|
"",
|
|
507
|
-
];
|
|
508
|
-
if (opts?.includeUseAuthCompat) {
|
|
509
|
-
lines.push("// Backward-compat shim: maps the old useAuth() API to useSession().", "// The LLM can remove this by switching to useSession() directly.", "import { useSession as _useSession, loginWithRedirect as _loginWithRedirect, logout as _logout } from 'zitejs/auth/base';", "", "export function useAuth() {", " const { data, isPending } = _useSession();", " return {", " user: data?.user ?? null,", " isLoading: isPending,", " loginWithRedirect: _loginWithRedirect,", " logout: _logout,", " };", "}", "");
|
|
510
|
-
}
|
|
511
|
-
return lines.join("\n");
|
|
508
|
+
].join("\n");
|
|
512
509
|
}
|
|
513
510
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
514
511
|
// Writable fields
|
|
@@ -30,23 +30,12 @@ describe('generateAuthWrapperTs', () => {
|
|
|
30
30
|
expect(output).toContain(type);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
it('
|
|
34
|
-
expect(output).
|
|
33
|
+
it('always exports useAuth as primary API', () => {
|
|
34
|
+
expect(output).toContain('useAuth');
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
it('wraps useSession', () => {
|
|
42
|
-
expect(compatOutput).toContain('_useSession()');
|
|
43
|
-
expect(compatOutput).toContain('data?.user ?? null');
|
|
44
|
-
expect(compatOutput).toContain('isLoading: isPending');
|
|
45
|
-
});
|
|
46
|
-
it('still exports all standard functions', () => {
|
|
47
|
-
for (const fn of ['useSession', 'signIn', 'signOut', 'loginWithRedirect', 'logout']) {
|
|
48
|
-
expect(compatOutput).toContain(fn);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
36
|
+
it('exports all standard functions', () => {
|
|
37
|
+
for (const fn of ['useAuth', 'useSession', 'signIn', 'signOut', 'loginWithRedirect', 'logout']) {
|
|
38
|
+
expect(output).toContain(fn);
|
|
39
|
+
}
|
|
51
40
|
});
|
|
52
41
|
});
|