zitejs 0.9.84 → 0.9.85

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.
@@ -39,7 +39,9 @@ export declare function generateUserTs(usersTableFields?: Array<{
39
39
  name: string;
40
40
  type: string;
41
41
  }>): string;
42
- export declare function generateAuthWrapperTs(): string;
42
+ export declare function generateAuthWrapperTs(opts?: {
43
+ includeUseAuthCompat?: boolean;
44
+ }): string;
43
45
  export type AirtableLockField = {
44
46
  id: string;
45
47
  sdkName: string;
@@ -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",
@@ -490,8 +491,8 @@ function generateUserTs(usersTableFields) {
490
491
  lines.push("");
491
492
  return lines.join("\n");
492
493
  }
493
- function generateAuthWrapperTs() {
494
- return [
494
+ function generateAuthWrapperTs(opts) {
495
+ const lines = [
495
496
  "// Auto-generated auth re-exports. Do not edit manually.",
496
497
  "// The real auth logic lives in the zitejs npm package (zitejs/auth).",
497
498
  "// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
@@ -515,7 +516,11 @@ function generateAuthWrapperTs() {
515
516
  " ZiteAuthPageMessages,",
516
517
  "} from 'zitejs/auth/base';",
517
518
  "",
518
- ].join("\n");
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");
519
524
  }
520
525
  const AIRTABLE_FIELD_TYPE_MAP = {
521
526
  // Writable fields
@@ -32,7 +32,23 @@ 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', () => {
35
+ (0, vitest_1.it)('does not export useAuth by default', () => {
36
36
  (0, vitest_1.expect)(output).not.toContain('useAuth');
37
37
  });
38
+ (0, vitest_1.describe)('with includeUseAuthCompat', () => {
39
+ const compatOutput = (0, lib_js_1.generateAuthWrapperTs)({ includeUseAuthCompat: true });
40
+ (0, vitest_1.it)('exports useAuth compat function', () => {
41
+ (0, vitest_1.expect)(compatOutput).toContain('export function useAuth()');
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
+ });
53
+ });
38
54
  });
@@ -39,7 +39,9 @@ export declare function generateUserTs(usersTableFields?: Array<{
39
39
  name: string;
40
40
  type: string;
41
41
  }>): string;
42
- export declare function generateAuthWrapperTs(): string;
42
+ export declare function generateAuthWrapperTs(opts?: {
43
+ includeUseAuthCompat?: boolean;
44
+ }): string;
43
45
  export type AirtableLockField = {
44
46
  id: string;
45
47
  sdkName: string;
@@ -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",
@@ -478,8 +479,8 @@ export function generateUserTs(usersTableFields) {
478
479
  lines.push("");
479
480
  return lines.join("\n");
480
481
  }
481
- export function generateAuthWrapperTs() {
482
- return [
482
+ export function generateAuthWrapperTs(opts) {
483
+ const lines = [
483
484
  "// Auto-generated auth re-exports. Do not edit manually.",
484
485
  "// The real auth logic lives in the zitejs npm package (zitejs/auth).",
485
486
  "// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
@@ -503,7 +504,11 @@ export function generateAuthWrapperTs() {
503
504
  " ZiteAuthPageMessages,",
504
505
  "} from 'zitejs/auth/base';",
505
506
  "",
506
- ].join("\n");
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");
507
512
  }
508
513
  const AIRTABLE_FIELD_TYPE_MAP = {
509
514
  // Writable fields
@@ -30,7 +30,23 @@ describe('generateAuthWrapperTs', () => {
30
30
  expect(output).toContain(type);
31
31
  }
32
32
  });
33
- it('does not export the old useAuth function', () => {
33
+ it('does not export useAuth by default', () => {
34
34
  expect(output).not.toContain('useAuth');
35
35
  });
36
+ describe('with includeUseAuthCompat', () => {
37
+ const compatOutput = generateAuthWrapperTs({ includeUseAuthCompat: true });
38
+ it('exports useAuth compat function', () => {
39
+ expect(compatOutput).toContain('export function useAuth()');
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
+ });
51
+ });
36
52
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.84",
3
+ "version": "0.9.85",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",