mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 12:27:44 +00:00
docs: add optional field indicators
This commit is contained in:
@@ -8,8 +8,14 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from "@/components/ui/table";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Key, Link } from "lucide-react";
|
import { CircleDot, Key, Link } from "lucide-react";
|
||||||
import { Label } from "../ui/label";
|
import { Label } from "../ui/label";
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipProvider,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "../ui/tooltip";
|
||||||
|
|
||||||
interface Field {
|
interface Field {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -17,6 +23,7 @@ interface Field {
|
|||||||
description: string;
|
description: string;
|
||||||
isPrimaryKey?: boolean;
|
isPrimaryKey?: boolean;
|
||||||
isForeignKey?: boolean;
|
isForeignKey?: boolean;
|
||||||
|
isOptional?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DatabaseTableProps {
|
interface DatabaseTableProps {
|
||||||
@@ -47,6 +54,9 @@ export default function DatabaseTable({ fields }: DatabaseTableProps) {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{field.isPrimaryKey && (
|
{field.isPrimaryKey && (
|
||||||
|
<TooltipProvider delayDuration={0}>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
<Badge
|
<Badge
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="mr-1 rounded-sm bg-amber-500"
|
className="mr-1 rounded-sm bg-amber-500"
|
||||||
@@ -54,16 +64,42 @@ export default function DatabaseTable({ fields }: DatabaseTableProps) {
|
|||||||
<Key className="w-3 h-3 mr-1" size={14} />
|
<Key className="w-3 h-3 mr-1" size={14} />
|
||||||
PK
|
PK
|
||||||
</Badge>
|
</Badge>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>Primary Key</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
)}
|
)}
|
||||||
{field.isForeignKey && (
|
{field.isForeignKey && (
|
||||||
<Badge className="rounded-sm" variant="secondary">
|
<TooltipProvider delayDuration={0}>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<Badge
|
||||||
|
variant="secondary"
|
||||||
|
className="mr-1 rounded-sm bg-blue-500"
|
||||||
|
>
|
||||||
<Link className="w-3 h-3 mr-1" size={14} />
|
<Link className="w-3 h-3 mr-1" size={14} />
|
||||||
FK
|
FK
|
||||||
</Badge>
|
</Badge>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>Foreign Key</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
)}
|
)}
|
||||||
{!field.isPrimaryKey && !field.isForeignKey && (
|
{!field.isPrimaryKey &&
|
||||||
|
!field.isForeignKey &&
|
||||||
|
!field.isOptional && (
|
||||||
<span className="text-muted text-center">-</span>
|
<span className="text-muted text-center">-</span>
|
||||||
)}
|
)}
|
||||||
|
{field.isOptional && (
|
||||||
|
<TooltipProvider delayDuration={0}>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<Badge variant="outline">?</Badge>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>Optional</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{field.description}</TableCell>
|
<TableCell>{field.description}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@@ -178,6 +178,12 @@ Table Name: `user`
|
|||||||
type: "string",
|
type: "string",
|
||||||
description: "User's email address for communication and login"
|
description: "User's email address for communication and login"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "image",
|
||||||
|
type: "string",
|
||||||
|
description: "User's image url",
|
||||||
|
isOptional: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "createdAt",
|
name: "createdAt",
|
||||||
type: "Date",
|
type: "Date",
|
||||||
@@ -217,12 +223,14 @@ Table Name: `session`
|
|||||||
{
|
{
|
||||||
name: "ipAddress",
|
name: "ipAddress",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The IP address of the device"
|
description: "The IP address of the device",
|
||||||
|
isOptional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "userAgent",
|
name: "userAgent",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The user agent information of the device"
|
description: "The user agent information of the device",
|
||||||
|
isOptional: true
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -259,21 +267,25 @@ Table Name: `account`
|
|||||||
name: "accessToken",
|
name: "accessToken",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The access token of the account. Returned by the provider",
|
description: "The access token of the account. Returned by the provider",
|
||||||
|
isOptional: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "refreshToken",
|
name: "refreshToken",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The refresh token of the account. Returned by the provider",
|
description: "The refresh token of the account. Returned by the provider",
|
||||||
|
isOptional: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "expiresAt",
|
name: "expiresAt",
|
||||||
type: "Date",
|
type: "Date",
|
||||||
description: "The time when the access token expires",
|
description: "The time when the access token expires",
|
||||||
|
isOptional: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "password",
|
name: "password",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The password of the account. Mainly used for email and password authentication",
|
description: "The password of the account. Mainly used for email and password authentication",
|
||||||
|
isOptional: true,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -282,9 +282,9 @@ The plugin requires 3 additional fields in the `user` table.
|
|||||||
|
|
||||||
<DatabaseTable
|
<DatabaseTable
|
||||||
fields={[
|
fields={[
|
||||||
{ name: "twoFactorEnabled", type: "boolean", description: "Whether two factor authentication is enabled for the user." },
|
{ name: "twoFactorEnabled", type: "boolean", description: "Whether two factor authentication is enabled for the user.", isOptional: true },
|
||||||
{ name: "twoFactorSecret", type: "string", description: "The secret key used to generate TOTP codes." },
|
{ name: "twoFactorSecret", type: "string", description: "The secret key used to generate TOTP codes.", isOptional: true },
|
||||||
{ name: "twoFactorBackupCodes", type: "string", description: "Encrypted backup codes for account recovery." },
|
{ name: "twoFactorBackupCodes", type: "string", description: "Encrypted backup codes for account recovery.", isOptional: true },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,6 @@ The anonymous plugin requires an additional field in the user table:
|
|||||||
|
|
||||||
<DatabaseTable
|
<DatabaseTable
|
||||||
fields={[
|
fields={[
|
||||||
{ name: "isAnonymous", type: "boolean", description: "Indicates whether the user is anonymous." },
|
{ name: "isAnonymous", type: "boolean", description: "Indicates whether the user is anonymous.", isOptional: true },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -525,12 +525,14 @@ Table Name: `organization`
|
|||||||
{
|
{
|
||||||
name: "logo",
|
name: "logo",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "The logo of the organization"
|
description: "The logo of the organization",
|
||||||
|
isOptional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "metadata",
|
name: "metadata",
|
||||||
type: "string",
|
type: "string",
|
||||||
description: "Additional metadata for the organization"
|
description: "Additional metadata for the organization",
|
||||||
|
isOptional: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "createdAt",
|
name: "createdAt",
|
||||||
|
|||||||
Reference in New Issue
Block a user