zitejs 0.9.85 → 0.9.88
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/dev/index.js +1 -2
- package/dist/cjs/sync/lib.d.ts +0 -7
- package/dist/cjs/sync/lib.js +1 -66
- package/dist/cjs/sync/lib.test.js +8 -46
- package/dist/esm/auth/index.d.ts +4 -0
- package/dist/esm/auth/index.js +7 -0
- package/dist/esm/dev/index.js +2 -3
- package/dist/esm/sync/lib.d.ts +0 -7
- package/dist/esm/sync/lib.js +1 -64
- package/dist/esm/sync/lib.test.js +9 -47
- 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/dev/index.js
CHANGED
|
@@ -67,8 +67,7 @@ function getDeclaredEnvVarNames(appDir) {
|
|
|
67
67
|
function regenerateAppTypedWrappers(appDir) {
|
|
68
68
|
const outDir = (0, path_1.join)("apps", appDir, ".zite");
|
|
69
69
|
(0, fs_2.mkdirSync)(outDir, { recursive: true });
|
|
70
|
-
|
|
71
|
-
(0, fs_2.writeFileSync)((0, path_1.join)(outDir, "auth.ts"), (0, lib_js_1.generateAuthWrapperTs)());
|
|
70
|
+
// user.ts and auth.ts no longer generated — User type is fixed in zitejs/auth
|
|
72
71
|
// Email integration: generate the Email client at .zite/integrations/email.ts.
|
|
73
72
|
// Resolved by the `zitejs/email` bundler/tsconfig alias (mirrors airtable's
|
|
74
73
|
// `zitejs/integrations`), so endpoint code uses `import { Email } from 'zitejs/email'`.
|
package/dist/cjs/sync/lib.d.ts
CHANGED
|
@@ -35,13 +35,6 @@ export type EndpointFileInfo = {
|
|
|
35
35
|
content?: string;
|
|
36
36
|
};
|
|
37
37
|
export declare function generateApiTs(endpointFiles: (string | EndpointFileInfo)[]): string | null;
|
|
38
|
-
export declare function generateUserTs(usersTableFields?: Array<{
|
|
39
|
-
name: string;
|
|
40
|
-
type: string;
|
|
41
|
-
}>): string;
|
|
42
|
-
export declare function generateAuthWrapperTs(opts?: {
|
|
43
|
-
includeUseAuthCompat?: boolean;
|
|
44
|
-
}): string;
|
|
45
38
|
export type AirtableLockField = {
|
|
46
39
|
id: string;
|
|
47
40
|
sdkName: string;
|
package/dist/cjs/sync/lib.js
CHANGED
|
@@ -5,8 +5,6 @@ exports.toCamelCase = toCamelCase;
|
|
|
5
5
|
exports.generateSchema = generateSchema;
|
|
6
6
|
exports.generateDbTs = generateDbTs;
|
|
7
7
|
exports.generateApiTs = generateApiTs;
|
|
8
|
-
exports.generateUserTs = generateUserTs;
|
|
9
|
-
exports.generateAuthWrapperTs = generateAuthWrapperTs;
|
|
10
8
|
exports.generateAirtableTs = generateAirtableTs;
|
|
11
9
|
exports.generateBackendWrapperTs = generateBackendWrapperTs;
|
|
12
10
|
exports.generateEmailSdk = generateEmailSdk;
|
|
@@ -459,69 +457,6 @@ function tsTypeForField(field) {
|
|
|
459
457
|
return FIELD_TYPE_MAP[field.type];
|
|
460
458
|
return "string";
|
|
461
459
|
}
|
|
462
|
-
function generateUserTs(usersTableFields) {
|
|
463
|
-
const lines = [
|
|
464
|
-
"// Auto-generated by zitejs generate. Do not edit manually.",
|
|
465
|
-
"",
|
|
466
|
-
];
|
|
467
|
-
if (usersTableFields && usersTableFields.length > 0) {
|
|
468
|
-
lines.push("export type User = {");
|
|
469
|
-
lines.push(" id: string;");
|
|
470
|
-
lines.push(" email: string;");
|
|
471
|
-
for (const field of usersTableFields) {
|
|
472
|
-
const lowerName = field.name.toLowerCase();
|
|
473
|
-
if (lowerName === "id" || lowerName === "email")
|
|
474
|
-
continue;
|
|
475
|
-
const fieldName = toCamelCase(field.name);
|
|
476
|
-
const tsType = tsTypeForField(field);
|
|
477
|
-
lines.push(` ${fieldName}: ${tsType};`);
|
|
478
|
-
}
|
|
479
|
-
lines.push(" [key: string]: unknown;");
|
|
480
|
-
lines.push("};");
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
lines.push("export type User = {");
|
|
484
|
-
lines.push(" id: string;");
|
|
485
|
-
lines.push(" email: string;");
|
|
486
|
-
lines.push(" firstName?: string;");
|
|
487
|
-
lines.push(" lastName?: string;");
|
|
488
|
-
lines.push(" [key: string]: unknown;");
|
|
489
|
-
lines.push("};");
|
|
490
|
-
}
|
|
491
|
-
lines.push("");
|
|
492
|
-
return lines.join("\n");
|
|
493
|
-
}
|
|
494
|
-
function generateAuthWrapperTs(opts) {
|
|
495
|
-
const lines = [
|
|
496
|
-
"// Auto-generated auth re-exports. Do not edit manually.",
|
|
497
|
-
"// The real auth logic lives in the zitejs npm package (zitejs/auth).",
|
|
498
|
-
"// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
|
|
499
|
-
"",
|
|
500
|
-
"export {",
|
|
501
|
-
" useSession,",
|
|
502
|
-
" signIn,",
|
|
503
|
-
" signOut,",
|
|
504
|
-
" signUp,",
|
|
505
|
-
" loginWithRedirect,",
|
|
506
|
-
" logout,",
|
|
507
|
-
" updateProfile,",
|
|
508
|
-
"} from 'zitejs/auth/base';",
|
|
509
|
-
"",
|
|
510
|
-
"export type {",
|
|
511
|
-
" User,",
|
|
512
|
-
" ZiteAppConfig,",
|
|
513
|
-
" ZiteAuthenticationConfig,",
|
|
514
|
-
" ZiteAuthMethods,",
|
|
515
|
-
" ZiteAuthPage,",
|
|
516
|
-
" ZiteAuthPageMessages,",
|
|
517
|
-
"} from 'zitejs/auth/base';",
|
|
518
|
-
"",
|
|
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");
|
|
524
|
-
}
|
|
525
460
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
526
461
|
// Writable fields
|
|
527
462
|
singleLineText: "string",
|
|
@@ -726,7 +661,7 @@ function generateBackendWrapperTs(envVarNames = []) {
|
|
|
726
661
|
"// Re-exports createEndpoint with context.user typed to the app User.",
|
|
727
662
|
"",
|
|
728
663
|
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext, ZiteSchedule, ZiteWebhook } from 'zitejs/backend/base';",
|
|
729
|
-
"import type { User } from '
|
|
664
|
+
"import type { User } from 'zitejs/auth';",
|
|
730
665
|
"",
|
|
731
666
|
"export type { ZiteSchedule, ZiteWebhook };",
|
|
732
667
|
"",
|
|
@@ -2,53 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const lib_js_1 = require("./lib.js");
|
|
5
|
-
(0, vitest_1.describe)('
|
|
6
|
-
const output = (0, lib_js_1.
|
|
7
|
-
(0, vitest_1.it)('imports from zitejs/auth
|
|
8
|
-
(0, vitest_1.expect)(output).toContain("from 'zitejs/auth
|
|
9
|
-
(0, vitest_1.expect)(output).not.toContain("from 'zitejs/auth';");
|
|
5
|
+
(0, vitest_1.describe)('generateBackendWrapperTs', () => {
|
|
6
|
+
const output = (0, lib_js_1.generateBackendWrapperTs)();
|
|
7
|
+
(0, vitest_1.it)('imports User from zitejs/auth', () => {
|
|
8
|
+
(0, vitest_1.expect)(output).toContain("from 'zitejs/auth'");
|
|
10
9
|
});
|
|
11
|
-
(0, vitest_1.it)('
|
|
12
|
-
|
|
13
|
-
'useSession',
|
|
14
|
-
'signIn',
|
|
15
|
-
'signOut',
|
|
16
|
-
'signUp',
|
|
17
|
-
'loginWithRedirect',
|
|
18
|
-
'logout',
|
|
19
|
-
]) {
|
|
20
|
-
(0, vitest_1.expect)(output).toContain(fn);
|
|
21
|
-
}
|
|
10
|
+
(0, vitest_1.it)('exports createEndpoint', () => {
|
|
11
|
+
(0, vitest_1.expect)(output).toContain('createEndpoint');
|
|
22
12
|
});
|
|
23
|
-
(0, vitest_1.it)('
|
|
24
|
-
|
|
25
|
-
'User',
|
|
26
|
-
'ZiteAppConfig',
|
|
27
|
-
'ZiteAuthenticationConfig',
|
|
28
|
-
'ZiteAuthMethods',
|
|
29
|
-
'ZiteAuthPage',
|
|
30
|
-
'ZiteAuthPageMessages',
|
|
31
|
-
]) {
|
|
32
|
-
(0, vitest_1.expect)(output).toContain(type);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
(0, vitest_1.it)('does not export useAuth by default', () => {
|
|
36
|
-
(0, vitest_1.expect)(output).not.toContain('useAuth');
|
|
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
|
-
});
|
|
13
|
+
(0, vitest_1.it)('exports ZiteError', () => {
|
|
14
|
+
(0, vitest_1.expect)(output).toContain('ZiteError');
|
|
53
15
|
});
|
|
54
16
|
});
|
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/dev/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { watch } from "fs";
|
|
|
2
2
|
import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { runSync } from "../sync/index.js";
|
|
5
|
-
import { generateDbTs, generateApiTs,
|
|
5
|
+
import { generateDbTs, generateApiTs, generateBackendWrapperTs, generateAirtableTs, generateEmailSdk, } from "../sync/lib.js";
|
|
6
6
|
const debounceTimers = new Map();
|
|
7
7
|
function debounce(key, fn, ms) {
|
|
8
8
|
const existing = debounceTimers.get(key);
|
|
@@ -63,8 +63,7 @@ function getDeclaredEnvVarNames(appDir) {
|
|
|
63
63
|
function regenerateAppTypedWrappers(appDir) {
|
|
64
64
|
const outDir = join("apps", appDir, ".zite");
|
|
65
65
|
mkdirSync(outDir, { recursive: true });
|
|
66
|
-
|
|
67
|
-
writeFileSync(join(outDir, "auth.ts"), generateAuthWrapperTs());
|
|
66
|
+
// user.ts and auth.ts no longer generated — User type is fixed in zitejs/auth
|
|
68
67
|
// Email integration: generate the Email client at .zite/integrations/email.ts.
|
|
69
68
|
// Resolved by the `zitejs/email` bundler/tsconfig alias (mirrors airtable's
|
|
70
69
|
// `zitejs/integrations`), so endpoint code uses `import { Email } from 'zitejs/email'`.
|
package/dist/esm/sync/lib.d.ts
CHANGED
|
@@ -35,13 +35,6 @@ export type EndpointFileInfo = {
|
|
|
35
35
|
content?: string;
|
|
36
36
|
};
|
|
37
37
|
export declare function generateApiTs(endpointFiles: (string | EndpointFileInfo)[]): string | null;
|
|
38
|
-
export declare function generateUserTs(usersTableFields?: Array<{
|
|
39
|
-
name: string;
|
|
40
|
-
type: string;
|
|
41
|
-
}>): string;
|
|
42
|
-
export declare function generateAuthWrapperTs(opts?: {
|
|
43
|
-
includeUseAuthCompat?: boolean;
|
|
44
|
-
}): string;
|
|
45
38
|
export type AirtableLockField = {
|
|
46
39
|
id: string;
|
|
47
40
|
sdkName: string;
|
package/dist/esm/sync/lib.js
CHANGED
|
@@ -447,69 +447,6 @@ function tsTypeForField(field) {
|
|
|
447
447
|
return FIELD_TYPE_MAP[field.type];
|
|
448
448
|
return "string";
|
|
449
449
|
}
|
|
450
|
-
export function generateUserTs(usersTableFields) {
|
|
451
|
-
const lines = [
|
|
452
|
-
"// Auto-generated by zitejs generate. Do not edit manually.",
|
|
453
|
-
"",
|
|
454
|
-
];
|
|
455
|
-
if (usersTableFields && usersTableFields.length > 0) {
|
|
456
|
-
lines.push("export type User = {");
|
|
457
|
-
lines.push(" id: string;");
|
|
458
|
-
lines.push(" email: string;");
|
|
459
|
-
for (const field of usersTableFields) {
|
|
460
|
-
const lowerName = field.name.toLowerCase();
|
|
461
|
-
if (lowerName === "id" || lowerName === "email")
|
|
462
|
-
continue;
|
|
463
|
-
const fieldName = toCamelCase(field.name);
|
|
464
|
-
const tsType = tsTypeForField(field);
|
|
465
|
-
lines.push(` ${fieldName}: ${tsType};`);
|
|
466
|
-
}
|
|
467
|
-
lines.push(" [key: string]: unknown;");
|
|
468
|
-
lines.push("};");
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
lines.push("export type User = {");
|
|
472
|
-
lines.push(" id: string;");
|
|
473
|
-
lines.push(" email: string;");
|
|
474
|
-
lines.push(" firstName?: string;");
|
|
475
|
-
lines.push(" lastName?: string;");
|
|
476
|
-
lines.push(" [key: string]: unknown;");
|
|
477
|
-
lines.push("};");
|
|
478
|
-
}
|
|
479
|
-
lines.push("");
|
|
480
|
-
return lines.join("\n");
|
|
481
|
-
}
|
|
482
|
-
export function generateAuthWrapperTs(opts) {
|
|
483
|
-
const lines = [
|
|
484
|
-
"// Auto-generated auth re-exports. Do not edit manually.",
|
|
485
|
-
"// The real auth logic lives in the zitejs npm package (zitejs/auth).",
|
|
486
|
-
"// Imports use zitejs/auth/base to avoid circular alias (zitejs/auth → this file).",
|
|
487
|
-
"",
|
|
488
|
-
"export {",
|
|
489
|
-
" useSession,",
|
|
490
|
-
" signIn,",
|
|
491
|
-
" signOut,",
|
|
492
|
-
" signUp,",
|
|
493
|
-
" loginWithRedirect,",
|
|
494
|
-
" logout,",
|
|
495
|
-
" updateProfile,",
|
|
496
|
-
"} from 'zitejs/auth/base';",
|
|
497
|
-
"",
|
|
498
|
-
"export type {",
|
|
499
|
-
" User,",
|
|
500
|
-
" ZiteAppConfig,",
|
|
501
|
-
" ZiteAuthenticationConfig,",
|
|
502
|
-
" ZiteAuthMethods,",
|
|
503
|
-
" ZiteAuthPage,",
|
|
504
|
-
" ZiteAuthPageMessages,",
|
|
505
|
-
"} from 'zitejs/auth/base';",
|
|
506
|
-
"",
|
|
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");
|
|
512
|
-
}
|
|
513
450
|
const AIRTABLE_FIELD_TYPE_MAP = {
|
|
514
451
|
// Writable fields
|
|
515
452
|
singleLineText: "string",
|
|
@@ -714,7 +651,7 @@ export function generateBackendWrapperTs(envVarNames = []) {
|
|
|
714
651
|
"// Re-exports createEndpoint with context.user typed to the app User.",
|
|
715
652
|
"",
|
|
716
653
|
"import type { ZiteRequestContext as _ZiteRequestContext, ZiteScheduledContext as _ZiteScheduledContext, ZiteSchedule, ZiteWebhook } from 'zitejs/backend/base';",
|
|
717
|
-
"import type { User } from '
|
|
654
|
+
"import type { User } from 'zitejs/auth';",
|
|
718
655
|
"",
|
|
719
656
|
"export type { ZiteSchedule, ZiteWebhook };",
|
|
720
657
|
"",
|
|
@@ -1,52 +1,14 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
describe('
|
|
4
|
-
const output =
|
|
5
|
-
it('imports from zitejs/auth
|
|
6
|
-
expect(output).toContain("from 'zitejs/auth
|
|
7
|
-
expect(output).not.toContain("from 'zitejs/auth';");
|
|
2
|
+
import { generateBackendWrapperTs } from './lib.js';
|
|
3
|
+
describe('generateBackendWrapperTs', () => {
|
|
4
|
+
const output = generateBackendWrapperTs();
|
|
5
|
+
it('imports User from zitejs/auth', () => {
|
|
6
|
+
expect(output).toContain("from 'zitejs/auth'");
|
|
8
7
|
});
|
|
9
|
-
it('
|
|
10
|
-
|
|
11
|
-
'useSession',
|
|
12
|
-
'signIn',
|
|
13
|
-
'signOut',
|
|
14
|
-
'signUp',
|
|
15
|
-
'loginWithRedirect',
|
|
16
|
-
'logout',
|
|
17
|
-
]) {
|
|
18
|
-
expect(output).toContain(fn);
|
|
19
|
-
}
|
|
8
|
+
it('exports createEndpoint', () => {
|
|
9
|
+
expect(output).toContain('createEndpoint');
|
|
20
10
|
});
|
|
21
|
-
it('
|
|
22
|
-
|
|
23
|
-
'User',
|
|
24
|
-
'ZiteAppConfig',
|
|
25
|
-
'ZiteAuthenticationConfig',
|
|
26
|
-
'ZiteAuthMethods',
|
|
27
|
-
'ZiteAuthPage',
|
|
28
|
-
'ZiteAuthPageMessages',
|
|
29
|
-
]) {
|
|
30
|
-
expect(output).toContain(type);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
it('does not export useAuth by default', () => {
|
|
34
|
-
expect(output).not.toContain('useAuth');
|
|
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
|
-
});
|
|
11
|
+
it('exports ZiteError', () => {
|
|
12
|
+
expect(output).toContain('ZiteError');
|
|
51
13
|
});
|
|
52
14
|
});
|