ta_data_mas 0.0.2
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/README.md +42 -0
- package/apps/api/.prettierrc +4 -0
- package/apps/api/README.md +98 -0
- package/apps/api/drizzle/0000_right_drax.sql +87 -0
- package/apps/api/drizzle/meta/0000_snapshot.json +588 -0
- package/apps/api/drizzle/meta/_journal.json +13 -0
- package/apps/api/drizzle.config.ts +12 -0
- package/apps/api/eslint.config.mjs +35 -0
- package/apps/api/nest-cli.json +8 -0
- package/apps/api/package.json +99 -0
- package/apps/api/src/app.controller.spec.ts +25 -0
- package/apps/api/src/app.controller.ts +9 -0
- package/apps/api/src/app.module.ts +37 -0
- package/apps/api/src/app.service.ts +8 -0
- package/apps/api/src/auth/auth.controller.ts +113 -0
- package/apps/api/src/auth/auth.module.ts +15 -0
- package/apps/api/src/auth/auth.service.ts +309 -0
- package/apps/api/src/auth/decorators/current-user-decorator.ts +10 -0
- package/apps/api/src/auth/decorators/require-org-role-decorator.ts +7 -0
- package/apps/api/src/auth/dto/login.dto.ts +10 -0
- package/apps/api/src/auth/dto/register.dto.ts +14 -0
- package/apps/api/src/auth/guards/jwt-auth-guard.ts +40 -0
- package/apps/api/src/auth/guards/org-role.guards.ts +60 -0
- package/apps/api/src/db/db.module.ts +9 -0
- package/apps/api/src/db/drizzle.service.ts +16 -0
- package/apps/api/src/db/schema/index.ts +6 -0
- package/apps/api/src/db/schema/organizations.ts +30 -0
- package/apps/api/src/db/schema/projects.ts +26 -0
- package/apps/api/src/db/schema/query-history.ts +16 -0
- package/apps/api/src/db/schema/storage-buckets.ts +17 -0
- package/apps/api/src/db/schema/storage-objects.ts +18 -0
- package/apps/api/src/db/schema/users.ts +14 -0
- package/apps/api/src/main.ts +51 -0
- package/apps/api/src/members/dto/invite-member-dto.ts +6 -0
- package/apps/api/src/members/dto/update-role.dto.ts +8 -0
- package/apps/api/src/members/invite.service.ts +147 -0
- package/apps/api/src/members/members.controller.ts +56 -0
- package/apps/api/src/members/members.module.ts +13 -0
- package/apps/api/src/members/members.service.ts +85 -0
- package/apps/api/src/orgs/dto/create-org.dto.ts +8 -0
- package/apps/api/src/orgs/orgs.controller.ts +27 -0
- package/apps/api/src/orgs/orgs.module.ts +12 -0
- package/apps/api/src/orgs/orgs.service.ts +86 -0
- package/apps/api/src/project-api/project-api.controller.ts +95 -0
- package/apps/api/src/project-api/project-api.module.ts +12 -0
- package/apps/api/src/project-api/project-api.service.ts +196 -0
- package/apps/api/src/project-api/project-key.guard.ts +45 -0
- package/apps/api/src/project-api/query-parser.ts +129 -0
- package/apps/api/src/project-auth/dto/magic-link.dto.ts +7 -0
- package/apps/api/src/project-auth/dto/signin.dto.ts +10 -0
- package/apps/api/src/project-auth/dto/signup.dto.ts +11 -0
- package/apps/api/src/project-auth/project-auth-dashboard.controller.ts +35 -0
- package/apps/api/src/project-auth/project-auth.controller.ts +111 -0
- package/apps/api/src/project-auth/project-auth.module.ts +13 -0
- package/apps/api/src/project-auth/project-auth.service.ts +440 -0
- package/apps/api/src/projects/dto/create-project.dto.ts +9 -0
- package/apps/api/src/projects/projects.controller.ts +34 -0
- package/apps/api/src/projects/projects.module.ts +12 -0
- package/apps/api/src/projects/projects.service.ts +136 -0
- package/apps/api/src/realtime/realtime-socket.type.ts +14 -0
- package/apps/api/src/realtime/realtime.controller.ts +63 -0
- package/apps/api/src/realtime/realtime.gateway.ts +150 -0
- package/apps/api/src/realtime/realtime.module.ts +14 -0
- package/apps/api/src/realtime/realtime.service.ts +101 -0
- package/apps/api/src/realtime/trigger.service.ts +95 -0
- package/apps/api/src/sql-editor/dto/execute-query.dto.ts +7 -0
- package/apps/api/src/sql-editor/sql-editor.controller.ts +28 -0
- package/apps/api/src/sql-editor/sql-editor.module.ts +12 -0
- package/apps/api/src/sql-editor/sql-editor.service.ts +154 -0
- package/apps/api/src/storage/project-storage.controller.ts +140 -0
- package/apps/api/src/storage/storage.controller.ts +118 -0
- package/apps/api/src/storage/storage.module.ts +15 -0
- package/apps/api/src/storage/storage.service.ts +191 -0
- package/apps/api/src/storage/uploadthing.ts +23 -0
- package/apps/api/src/table-editor/dto/alter-table.dto.ts +15 -0
- package/apps/api/src/table-editor/dto/create-table.dto.ts +54 -0
- package/apps/api/src/table-editor/table-editor.controller.ts +117 -0
- package/apps/api/src/table-editor/table-editor.module.ts +12 -0
- package/apps/api/src/table-editor/table-editor.service.ts +366 -0
- package/apps/api/test/app.e2e-spec.ts +29 -0
- package/apps/api/test/jest-e2e.json +9 -0
- package/apps/api/tsconfig.build.json +4 -0
- package/apps/api/tsconfig.json +25 -0
- package/apps/web/.env.example +12 -0
- package/apps/web/AGENTS.md +9 -0
- package/apps/web/CLAUDE.md +1 -0
- package/apps/web/README.md +36 -0
- package/apps/web/components.json +25 -0
- package/apps/web/eslint.config.mjs +18 -0
- package/apps/web/next.config.ts +11 -0
- package/apps/web/package.json +48 -0
- package/apps/web/postcss.config.mjs +7 -0
- package/apps/web/public/file.svg +1 -0
- package/apps/web/public/globe.svg +1 -0
- package/apps/web/public/logo.svg +4 -0
- package/apps/web/public/next.svg +1 -0
- package/apps/web/public/vercel.svg +1 -0
- package/apps/web/public/window.svg +1 -0
- package/apps/web/src/app/(dashboard)/layout.tsx +33 -0
- package/apps/web/src/app/(dashboard)/organizations/(list)/layout.tsx +7 -0
- package/apps/web/src/app/(dashboard)/organizations/(list)/new/page.tsx +26 -0
- package/apps/web/src/app/(dashboard)/organizations/(list)/page.tsx +44 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/api/page.tsx +13 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/layout.tsx +19 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/page.tsx +10 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/providers/page.tsx +19 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/url-configuration/page.tsx +24 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/auth/users/page.tsx +13 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/database/page.tsx +29 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/realtime/page.tsx +28 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/sql/page.tsx +21 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/[projectSlug]/storage/page.tsx +28 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/layout.tsx +20 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/projects/page.tsx +62 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/settings/members/page.tsx +28 -0
- package/apps/web/src/app/(dashboard)/organizations/[slug]/settings/page.tsx +10 -0
- package/apps/web/src/app/(dashboard)/settings/page.tsx +12 -0
- package/apps/web/src/app/dashboard/page.tsx +14 -0
- package/apps/web/src/app/favicon.ico +0 -0
- package/apps/web/src/app/globals.css +115 -0
- package/apps/web/src/app/layout.tsx +36 -0
- package/apps/web/src/app/login/page.tsx +199 -0
- package/apps/web/src/app/page.tsx +100 -0
- package/apps/web/src/app/register/page.tsx +218 -0
- package/apps/web/src/components/app-sidebar.tsx +301 -0
- package/apps/web/src/components/navbar.tsx +63 -0
- package/apps/web/src/components/topNav.tsx +68 -0
- package/apps/web/src/components/ui/avatar.tsx +112 -0
- package/apps/web/src/components/ui/badge.tsx +48 -0
- package/apps/web/src/components/ui/button.tsx +66 -0
- package/apps/web/src/components/ui/card.tsx +102 -0
- package/apps/web/src/components/ui/checkbox.tsx +32 -0
- package/apps/web/src/components/ui/dialog.tsx +168 -0
- package/apps/web/src/components/ui/dropdown-menu.tsx +269 -0
- package/apps/web/src/components/ui/field.tsx +238 -0
- package/apps/web/src/components/ui/input.tsx +19 -0
- package/apps/web/src/components/ui/label.tsx +24 -0
- package/apps/web/src/components/ui/resizable.tsx +50 -0
- package/apps/web/src/components/ui/scroll-area.tsx +55 -0
- package/apps/web/src/components/ui/select.tsx +192 -0
- package/apps/web/src/components/ui/separator.tsx +28 -0
- package/apps/web/src/components/ui/sheet.tsx +147 -0
- package/apps/web/src/components/ui/sidebar.tsx +703 -0
- package/apps/web/src/components/ui/skeleton.tsx +13 -0
- package/apps/web/src/components/ui/switch.tsx +33 -0
- package/apps/web/src/components/ui/table.tsx +116 -0
- package/apps/web/src/components/ui/tooltip.tsx +57 -0
- package/apps/web/src/features/api-docs/api-docs-client.tsx +227 -0
- package/apps/web/src/features/api-docs/api-docs-helpers.server.ts +86 -0
- package/apps/web/src/features/auth/action.ts +67 -0
- package/apps/web/src/features/auth/client.schema.ts +13 -0
- package/apps/web/src/features/auth/constants.ts +6 -0
- package/apps/web/src/features/auth/cookies.ts +86 -0
- package/apps/web/src/features/auth/server.schema.ts +11 -0
- package/apps/web/src/features/auth/sign-out.ts +17 -0
- package/apps/web/src/features/members/action.ts +66 -0
- package/apps/web/src/features/members/client.schema.ts +11 -0
- package/apps/web/src/features/members/constants.ts +8 -0
- package/apps/web/src/features/members/members-client.tsx +198 -0
- package/apps/web/src/features/members/members-helpers.server.ts +21 -0
- package/apps/web/src/features/members/server.schema.ts +19 -0
- package/apps/web/src/features/organization/action.ts +45 -0
- package/apps/web/src/features/organization/client.schema.ts +5 -0
- package/apps/web/src/features/organization/constants.tsx +3 -0
- package/apps/web/src/features/organization/create-org-form.tsx +66 -0
- package/apps/web/src/features/organization/organization-helpers.server.ts +35 -0
- package/apps/web/src/features/organization/server.schema.ts +10 -0
- package/apps/web/src/features/project-auth/project-auth-action.ts +78 -0
- package/apps/web/src/features/project-auth/project-auth-client.schema.ts +18 -0
- package/apps/web/src/features/project-auth/project-auth-constants.ts +8 -0
- package/apps/web/src/features/project-auth/project-auth-helpers.server.ts +39 -0
- package/apps/web/src/features/project-auth/project-auth-providers.tsx +222 -0
- package/apps/web/src/features/project-auth/project-auth-server.schema.ts +22 -0
- package/apps/web/src/features/project-auth/project-auth-shell.tsx +106 -0
- package/apps/web/src/features/project-auth/project-auth-url-config.tsx +151 -0
- package/apps/web/src/features/project-auth/project-auth-users.tsx +138 -0
- package/apps/web/src/features/projects/action.ts +46 -0
- package/apps/web/src/features/projects/client.schema.ts +9 -0
- package/apps/web/src/features/projects/constants.ts +6 -0
- package/apps/web/src/features/projects/create-project-modal.tsx +117 -0
- package/apps/web/src/features/projects/project-helpers.server.ts +38 -0
- package/apps/web/src/features/projects/server.schema.ts +10 -0
- package/apps/web/src/features/realtime/realtime-client.tsx +294 -0
- package/apps/web/src/features/realtime/realtime-helpers.server.ts +40 -0
- package/apps/web/src/features/sql-editor/sql-editor-client.tsx +324 -0
- package/apps/web/src/features/sql-editor/sql-editor-helpers.server.ts +22 -0
- package/apps/web/src/features/storage/storage-client.tsx +500 -0
- package/apps/web/src/features/storage/storage-helpers.server.ts +36 -0
- package/apps/web/src/features/table-editor/action.ts +97 -0
- package/apps/web/src/features/table-editor/add-column-dialog.tsx +184 -0
- package/apps/web/src/features/table-editor/client.schema.ts +36 -0
- package/apps/web/src/features/table-editor/create-table-drawer.tsx +542 -0
- package/apps/web/src/features/table-editor/server.schema.ts +41 -0
- package/apps/web/src/features/table-editor/table-editor-client.tsx +737 -0
- package/apps/web/src/features/table-editor/table-editor-helpers.server.ts +39 -0
- package/apps/web/src/hooks/use-mobile.ts +19 -0
- package/apps/web/src/lib/axios.ts +8 -0
- package/apps/web/src/lib/utils.ts +6 -0
- package/apps/web/src/proxy.ts +72 -0
- package/apps/web/src/server-utils/utils.ts +10 -0
- package/apps/web/tsconfig.json +34 -0
- package/package.json +22 -0
- package/packages/apiDatabase-js/package.json +39 -0
- package/packages/apiDatabase-js/src/auth/index.ts +121 -0
- package/packages/apiDatabase-js/src/client.ts +25 -0
- package/packages/apiDatabase-js/src/db/index.ts +15 -0
- package/packages/apiDatabase-js/src/db/query-builder.ts +194 -0
- package/packages/apiDatabase-js/src/index.ts +16 -0
- package/packages/apiDatabase-js/src/realtime/index.ts +84 -0
- package/packages/apiDatabase-js/src/storage/index.ts +130 -0
- package/packages/apiDatabase-js/tsconfig.json +13 -0
- package/packages/apiDatabase-js/tsdown.config.ts +20 -0
- package/packages/constants/package.json +6 -0
- package/packages/constants/src/index.ts +76 -0
- package/packages/tsconfig.json +13 -0
- package/packages/tsdown.config.ts +20 -0
- package/packages/types/package.json +6 -0
- package/packages/types/src/index.ts +254 -0
- package/pnpm-workspace.yaml +10 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Plus } from "lucide-react";
|
|
5
|
+
import { Button } from "@/components/ui/button";
|
|
6
|
+
import {
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogContent,
|
|
9
|
+
DialogDescription,
|
|
10
|
+
DialogHeader,
|
|
11
|
+
DialogTitle,
|
|
12
|
+
} from "@/components/ui/dialog";
|
|
13
|
+
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field";
|
|
14
|
+
import { Input } from "@/components/ui/input";
|
|
15
|
+
import {
|
|
16
|
+
Select,
|
|
17
|
+
SelectContent,
|
|
18
|
+
SelectItem,
|
|
19
|
+
SelectTrigger,
|
|
20
|
+
SelectValue,
|
|
21
|
+
} from "@/components/ui/select";
|
|
22
|
+
import { COLUMN_TYPES, TABLE_EDITOR_INTENT } from "@apiDatabase/constants";
|
|
23
|
+
import type { ColumnType } from "@apiDatabase/types";
|
|
24
|
+
import { tableEditorAction } from "@/features/table-editor/action";
|
|
25
|
+
import { cn } from "@/lib/utils";
|
|
26
|
+
|
|
27
|
+
interface AddColumnDialogProps {
|
|
28
|
+
orgSlug: string;
|
|
29
|
+
projectSlug: string;
|
|
30
|
+
tableName: string;
|
|
31
|
+
onAdded: () => void;
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function AddColumnDialog({
|
|
36
|
+
orgSlug,
|
|
37
|
+
projectSlug,
|
|
38
|
+
tableName,
|
|
39
|
+
onAdded,
|
|
40
|
+
className,
|
|
41
|
+
}: AddColumnDialogProps) {
|
|
42
|
+
const [open, setOpen] = useState(false);
|
|
43
|
+
const [name, setName] = useState("");
|
|
44
|
+
const [type, setType] = useState<ColumnType>("text");
|
|
45
|
+
const [defaultValue, setDefaultValue] = useState("");
|
|
46
|
+
const [error, setError] = useState<string | null>(null);
|
|
47
|
+
const [isPending, setIsPending] = useState(false);
|
|
48
|
+
|
|
49
|
+
const reset = () => {
|
|
50
|
+
setName("");
|
|
51
|
+
setType("text");
|
|
52
|
+
setDefaultValue("");
|
|
53
|
+
setError(null);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
setError(null);
|
|
59
|
+
setIsPending(true);
|
|
60
|
+
|
|
61
|
+
const formData = new FormData();
|
|
62
|
+
formData.set("intent", TABLE_EDITOR_INTENT.ADD_COLUMN);
|
|
63
|
+
formData.set("tableName", tableName);
|
|
64
|
+
formData.set("name", name);
|
|
65
|
+
formData.set("type", type);
|
|
66
|
+
if (defaultValue.trim()) formData.set("defaultValue", defaultValue.trim());
|
|
67
|
+
|
|
68
|
+
const result = await tableEditorAction(
|
|
69
|
+
{ orgSlug, projectSlug },
|
|
70
|
+
{},
|
|
71
|
+
formData,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
setIsPending(false);
|
|
75
|
+
|
|
76
|
+
if (result.error) {
|
|
77
|
+
setError(result.error);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setOpen(false);
|
|
82
|
+
reset();
|
|
83
|
+
onAdded();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<Button
|
|
89
|
+
type="button"
|
|
90
|
+
variant="ghost"
|
|
91
|
+
size="icon"
|
|
92
|
+
className={cn(
|
|
93
|
+
"h-8 w-8 shrink-0 text-muted-foreground hover:text-foreground",
|
|
94
|
+
className,
|
|
95
|
+
)}
|
|
96
|
+
onClick={() => setOpen(true)}
|
|
97
|
+
aria-label="Add column"
|
|
98
|
+
>
|
|
99
|
+
<Plus size={14} />
|
|
100
|
+
</Button>
|
|
101
|
+
|
|
102
|
+
<Dialog
|
|
103
|
+
open={open}
|
|
104
|
+
onOpenChange={(next) => {
|
|
105
|
+
setOpen(next);
|
|
106
|
+
if (!next) reset();
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<DialogContent className="sm:max-w-md">
|
|
110
|
+
<DialogHeader>
|
|
111
|
+
<DialogTitle>Add column to {tableName}</DialogTitle>
|
|
112
|
+
<DialogDescription>
|
|
113
|
+
Adds a new column to this table via{" "}
|
|
114
|
+
<span className="font-mono">ALTER TABLE ... ADD COLUMN</span>.
|
|
115
|
+
</DialogDescription>
|
|
116
|
+
</DialogHeader>
|
|
117
|
+
|
|
118
|
+
{error && <p className="text-sm text-destructive">{error}</p>}
|
|
119
|
+
|
|
120
|
+
<form onSubmit={(e) => void handleSubmit(e)} className="space-y-4">
|
|
121
|
+
<FieldGroup>
|
|
122
|
+
<Field>
|
|
123
|
+
<FieldLabel htmlFor="column-name">Name</FieldLabel>
|
|
124
|
+
<Input
|
|
125
|
+
id="column-name"
|
|
126
|
+
value={name}
|
|
127
|
+
onChange={(e) => setName(e.target.value)}
|
|
128
|
+
placeholder="column_name"
|
|
129
|
+
className="font-mono"
|
|
130
|
+
required
|
|
131
|
+
/>
|
|
132
|
+
</Field>
|
|
133
|
+
|
|
134
|
+
<Field>
|
|
135
|
+
<FieldLabel>Type</FieldLabel>
|
|
136
|
+
<Select
|
|
137
|
+
value={type}
|
|
138
|
+
onValueChange={(v) => setType(v as ColumnType)}
|
|
139
|
+
>
|
|
140
|
+
<SelectTrigger>
|
|
141
|
+
<SelectValue />
|
|
142
|
+
</SelectTrigger>
|
|
143
|
+
<SelectContent>
|
|
144
|
+
{COLUMN_TYPES.map((t) => (
|
|
145
|
+
<SelectItem key={t} value={t} className="font-mono">
|
|
146
|
+
{t}
|
|
147
|
+
</SelectItem>
|
|
148
|
+
))}
|
|
149
|
+
</SelectContent>
|
|
150
|
+
</Select>
|
|
151
|
+
</Field>
|
|
152
|
+
|
|
153
|
+
<Field>
|
|
154
|
+
<FieldLabel htmlFor="column-default">
|
|
155
|
+
Default (optional)
|
|
156
|
+
</FieldLabel>
|
|
157
|
+
<Input
|
|
158
|
+
id="column-default"
|
|
159
|
+
value={defaultValue}
|
|
160
|
+
onChange={(e) => setDefaultValue(e.target.value)}
|
|
161
|
+
placeholder="NULL"
|
|
162
|
+
className="font-mono"
|
|
163
|
+
/>
|
|
164
|
+
</Field>
|
|
165
|
+
</FieldGroup>
|
|
166
|
+
|
|
167
|
+
<div className="flex justify-end gap-2">
|
|
168
|
+
<Button
|
|
169
|
+
type="button"
|
|
170
|
+
variant="outline"
|
|
171
|
+
onClick={() => setOpen(false)}
|
|
172
|
+
>
|
|
173
|
+
Cancel
|
|
174
|
+
</Button>
|
|
175
|
+
<Button type="submit" disabled={isPending || !name.trim()}>
|
|
176
|
+
{isPending ? "Adding..." : "Add column"}
|
|
177
|
+
</Button>
|
|
178
|
+
</div>
|
|
179
|
+
</form>
|
|
180
|
+
</DialogContent>
|
|
181
|
+
</Dialog>
|
|
182
|
+
</>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { COLUMN_TYPES } from "@apiDatabase/constants";
|
|
3
|
+
import type { CreateTableInput } from "@apiDatabase/types";
|
|
4
|
+
|
|
5
|
+
export const createColumnSchema = z.object({
|
|
6
|
+
name: z.string().min(1, "Required"),
|
|
7
|
+
type: z.enum(COLUMN_TYPES),
|
|
8
|
+
isNullable: z.boolean(),
|
|
9
|
+
isPrimaryKey: z.boolean(),
|
|
10
|
+
defaultValue: z.string().optional(),
|
|
11
|
+
foreignKeyTable: z.string().optional(),
|
|
12
|
+
foreignKeyColumn: z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const createTableSchema = z.object({
|
|
16
|
+
name: z.string().min(1, "Table name is required"),
|
|
17
|
+
columns: z.array(createColumnSchema).min(1, "At least one column required"),
|
|
18
|
+
}) satisfies z.ZodType<CreateTableInput>;
|
|
19
|
+
|
|
20
|
+
export const fetchTableSchema = z.object({
|
|
21
|
+
tableName: z.string().min(1),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const deleteTableSchema = z.object({
|
|
25
|
+
tableName: z.string().min(1),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const addColumnSchema = z.object({
|
|
29
|
+
tableName: z.string().min(1),
|
|
30
|
+
name: z
|
|
31
|
+
.string()
|
|
32
|
+
.min(1, "Column name is required")
|
|
33
|
+
.regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/, "Invalid column name"),
|
|
34
|
+
type: z.enum(COLUMN_TYPES),
|
|
35
|
+
defaultValue: z.string().optional(),
|
|
36
|
+
});
|