zitejs 0.9.84 → 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.
@@ -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;
@@ -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;
@@ -30,6 +30,7 @@ const FIELD_TYPE_MAP = {
30
30
  datetime: "string | null",
31
31
  attachments: "Array<{ url: string; name?: string }>",
32
32
  linked_record: "string | string[]",
33
+ user: "string | string[]",
33
34
  lookup: "unknown",
34
35
  autonumber: "number",
35
36
  source: "string",
@@ -497,6 +498,7 @@ function generateAuthWrapperTs() {
497
498
  "// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
498
499
  "",
499
500
  "export {",
501
+ " useAuth,",
500
502
  " useSession,",
501
503
  " signIn,",
502
504
  " signOut,",
@@ -32,7 +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)('does not export the old useAuth function', () => {
36
- (0, vitest_1.expect)(output).not.toContain('useAuth');
35
+ (0, vitest_1.it)('always exports useAuth as primary API', () => {
36
+ (0, vitest_1.expect)(output).toContain('useAuth');
37
+ });
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
+ }
37
42
  });
38
43
  });
@@ -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;
@@ -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;
@@ -18,6 +18,7 @@ const FIELD_TYPE_MAP = {
18
18
  datetime: "string | null",
19
19
  attachments: "Array<{ url: string; name?: string }>",
20
20
  linked_record: "string | string[]",
21
+ user: "string | string[]",
21
22
  lookup: "unknown",
22
23
  autonumber: "number",
23
24
  source: "string",
@@ -485,6 +486,7 @@ export function generateAuthWrapperTs() {
485
486
  "// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
486
487
  "",
487
488
  "export {",
489
+ " useAuth,",
488
490
  " useSession,",
489
491
  " signIn,",
490
492
  " signOut,",
@@ -30,7 +30,12 @@ describe('generateAuthWrapperTs', () => {
30
30
  expect(output).toContain(type);
31
31
  }
32
32
  });
33
- it('does not export the old useAuth function', () => {
34
- expect(output).not.toContain('useAuth');
33
+ it('always exports useAuth as primary API', () => {
34
+ expect(output).toContain('useAuth');
35
+ });
36
+ it('exports all standard functions', () => {
37
+ for (const fn of ['useAuth', 'useSession', 'signIn', 'signOut', 'loginWithRedirect', 'logout']) {
38
+ expect(output).toContain(fn);
39
+ }
35
40
  });
36
41
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.84",
3
+ "version": "0.9.86",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",