docs: add optional field indicators

This commit is contained in:
Bereket Engida
2024-10-07 13:23:53 +03:00
parent 266a46fdab
commit 8e7dbcf14b
5 changed files with 72 additions and 22 deletions

View File

@@ -8,8 +8,14 @@ import {
TableRow,
} from "@/components/ui/table";
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 {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "../ui/tooltip";
interface Field {
name: string;
@@ -17,6 +23,7 @@ interface Field {
description: string;
isPrimaryKey?: boolean;
isForeignKey?: boolean;
isOptional?: boolean;
}
interface DatabaseTableProps {
@@ -47,22 +54,51 @@ export default function DatabaseTable({ fields }: DatabaseTableProps) {
</TableCell>
<TableCell>
{field.isPrimaryKey && (
<Badge
variant="secondary"
className="mr-1 rounded-sm bg-amber-500"
>
<Key className="w-3 h-3 mr-1" size={14} />
PK
</Badge>
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger>
<Badge
variant="secondary"
className="mr-1 rounded-sm bg-amber-500"
>
<Key className="w-3 h-3 mr-1" size={14} />
PK
</Badge>
</TooltipTrigger>
<TooltipContent>Primary Key</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
{field.isForeignKey && (
<Badge className="rounded-sm" variant="secondary">
<Link className="w-3 h-3 mr-1" size={14} />
FK
</Badge>
<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} />
FK
</Badge>
</TooltipTrigger>
<TooltipContent>Foreign Key</TooltipContent>
</Tooltip>
</TooltipProvider>
)}
{!field.isPrimaryKey && !field.isForeignKey && (
<span className="text-muted text-center">-</span>
{!field.isPrimaryKey &&
!field.isForeignKey &&
!field.isOptional && (
<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>{field.description}</TableCell>

View File

@@ -178,6 +178,12 @@ Table Name: `user`
type: "string",
description: "User's email address for communication and login"
},
{
name: "image",
type: "string",
description: "User's image url",
isOptional: true
},
{
name: "createdAt",
type: "Date",
@@ -217,12 +223,14 @@ Table Name: `session`
{
name: "ipAddress",
type: "string",
description: "The IP address of the device"
description: "The IP address of the device",
isOptional: true
},
{
name: "userAgent",
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",
type: "string",
description: "The access token of the account. Returned by the provider",
isOptional: true,
},
{
name: "refreshToken",
type: "string",
description: "The refresh token of the account. Returned by the provider",
isOptional: true,
},
{
name: "expiresAt",
type: "Date",
description: "The time when the access token expires",
isOptional: true,
},
{
name: "password",
type: "string",
description: "The password of the account. Mainly used for email and password authentication",
isOptional: true,
},
]}
/>

View File

@@ -282,9 +282,9 @@ The plugin requires 3 additional fields in the `user` table.
<DatabaseTable
fields={[
{ name: "twoFactorEnabled", type: "boolean", description: "Whether two factor authentication is enabled for the user." },
{ name: "twoFactorSecret", type: "string", description: "The secret key used to generate TOTP codes." },
{ name: "twoFactorBackupCodes", type: "string", description: "Encrypted backup codes for account recovery." },
{ 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.", isOptional: true },
{ name: "twoFactorBackupCodes", type: "string", description: "Encrypted backup codes for account recovery.", isOptional: true },
]}
/>

View File

@@ -106,6 +106,6 @@ The anonymous plugin requires an additional field in the user table:
<DatabaseTable
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 },
]}
/>

View File

@@ -525,12 +525,14 @@ Table Name: `organization`
{
name: "logo",
type: "string",
description: "The logo of the organization"
description: "The logo of the organization",
isOptional: true
},
{
name: "metadata",
type: "string",
description: "Additional metadata for the organization"
description: "Additional metadata for the organization",
isOptional: true
},
{
name: "createdAt",