mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
ui fixes
This commit is contained in:
@@ -25,8 +25,6 @@ export default async function RoutePage(props: PageParams<{}>) {
|
|||||||
orderBy: (fields) => desc(fields.createdAt),
|
orderBy: (fields) => desc(fields.createdAt),
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(agents);
|
|
||||||
|
|
||||||
|
|
||||||
if (!agents) {
|
if (!agents) {
|
||||||
notFound();
|
notFound();
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ export async function POST(
|
|||||||
const agentId = (await params).agentId
|
const agentId = (await params).agentId
|
||||||
const body: BodyResultRestore = await request.json();
|
const body: BodyResultRestore = await request.json();
|
||||||
|
|
||||||
console.log(body)
|
|
||||||
|
|
||||||
if (!isUuidv4(body.generatedId)) {
|
if (!isUuidv4(body.generatedId)) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ export async function POST(
|
|||||||
|
|
||||||
if (!isUuidv4(agentId)) {
|
if (!isUuidv4(agentId)) {
|
||||||
message = "agentId is not a valid uuid"
|
message = "agentId is not a valid uuid"
|
||||||
console.log(message)
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{error: "agentId is not a valid uuid"},
|
{error: "agentId is not a valid uuid"},
|
||||||
{status: 500}
|
{status: 500}
|
||||||
@@ -54,7 +53,6 @@ export async function POST(
|
|||||||
|
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
message = "Agent not found"
|
message = "Agent not found"
|
||||||
console.log(message)
|
|
||||||
return NextResponse.json({error: message}, {status: 404})
|
return NextResponse.json({error: message}, {status: 404})
|
||||||
}
|
}
|
||||||
const databasesResponse = await handleDatabases(body, agent, lastContact)
|
const databasesResponse = await handleDatabases(body, agent, lastContact)
|
||||||
@@ -77,7 +75,6 @@ export async function POST(
|
|||||||
},
|
},
|
||||||
databases: databasesResponse
|
databases: databasesResponse
|
||||||
}
|
}
|
||||||
console.log(response)
|
|
||||||
|
|
||||||
return Response.json(response)
|
return Response.json(response)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+1
-13
@@ -19,7 +19,6 @@ export async function GET(request: Request) {
|
|||||||
new ReadableStream({
|
new ReadableStream({
|
||||||
start(controller) {
|
start(controller) {
|
||||||
console.log('Stream started');
|
console.log('Stream started');
|
||||||
|
|
||||||
const handleModification = (data: any) => {
|
const handleModification = (data: any) => {
|
||||||
console.log('Modification event triggered:', data);
|
console.log('Modification event triggered:', data);
|
||||||
controller.enqueue(`event: modification\n`);
|
controller.enqueue(`event: modification\n`);
|
||||||
@@ -45,15 +44,4 @@ export async function GET(request: Request) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// export async function POST(request: Request) {
|
|
||||||
// console.log('POST request received');
|
|
||||||
// const data = await request.json();
|
|
||||||
// console.log('Data received:', data);
|
|
||||||
//
|
|
||||||
// // Emit the event to all connected clients
|
|
||||||
// eventEmitter.emit('modification', data);
|
|
||||||
//
|
|
||||||
// return new Response('Event sent', {status: 200});
|
|
||||||
// }
|
|
||||||
@@ -63,7 +63,6 @@ export const LoginForm = (props: loginFormProps) => {
|
|||||||
toast.success("Login success");
|
toast.success("Login success");
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.log(error);
|
|
||||||
toast.error(error.error.message);
|
toast.error(error.error.message);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ export const resetPasswordAction = action
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = await (await auth.$context).internalAdapter.findUserById(verification.value);
|
const user = await (await auth.$context).internalAdapter.findUserById(verification.value);
|
||||||
console.log(user)
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -39,28 +38,6 @@ export const resetPasswordAction = action
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const hashedPassword = await (await auth.$context).password.hash(parsedInput.schema.password);
|
|
||||||
console.log(hashedPassword)
|
|
||||||
console.log("ok")
|
|
||||||
// await (await auth.$context).internalAdapter.updatePassword(user.id, hashedPassword);
|
|
||||||
console.log("ici")
|
|
||||||
// await (await auth.$context).internalAdapter.deleteSessions(user.id);
|
|
||||||
// console.log("ici2")
|
|
||||||
// await (await auth.$context).internalAdapter.deleteVerificationValue(verification.id);
|
|
||||||
// console.log("ici3");
|
|
||||||
//
|
|
||||||
// (await auth.$context).internalAdapter.updateUser(user.id, {
|
|
||||||
// lastChangedPasswordAt: new Date(),
|
|
||||||
// });
|
|
||||||
|
|
||||||
// await auth.api.resetPassword({
|
|
||||||
// headers: await headers(),
|
|
||||||
// body: {
|
|
||||||
// newPassword: parsedInput.schema.password,
|
|
||||||
// token: parsedInput.token,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
await (
|
await (
|
||||||
await auth.$context
|
await auth.$context
|
||||||
).internalAdapter.updateUser(user.id, {
|
).internalAdapter.updateUser(user.id, {
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ export const ResetPasswordForm = (props: ResetPasswordFormProps) => {
|
|||||||
setTimeout(() => router.push("/"), 1400);
|
setTimeout(() => router.push("/"), 1400);
|
||||||
},
|
},
|
||||||
onError: (error: BetterAuthError) => {
|
onError: (error: BetterAuthError) => {
|
||||||
console.log(error)
|
|
||||||
toast.error("An error occurred while resetting password");
|
toast.error("An error occurred while resetting password");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export const RegisterForm = (props: registerFormProps) => {
|
|||||||
router.push(`/login`);
|
router.push(`/login`);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.log(error);
|
|
||||||
toast.error(error.error.message);
|
toast.error(error.error.message);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {Form, FormControl, FormField, FormItem, FormLabel, useZodForm} from "@/c
|
|||||||
import {PasswordStrengthInput} from "@/components/ui/password-input-indicator";
|
import {PasswordStrengthInput} from "@/components/ui/password-input-indicator";
|
||||||
import {ResetPasswordSchema, ResetPasswordType} from "@/components/wrappers/auth/reset-password/reset-password-schema";
|
import {ResetPasswordSchema, ResetPasswordType} from "@/components/wrappers/auth/reset-password/reset-password-schema";
|
||||||
import {PasswordInput} from "@/components/ui/password-input";
|
import {PasswordInput} from "@/components/ui/password-input";
|
||||||
import {Card, CardContent, CardHeader} from "@/components/ui/card";
|
import {CardContent, CardHeader} from "@/components/ui/card";
|
||||||
import {ButtonWithLoading} from "@/components/wrappers/common/button/button-with-loading";
|
import {ButtonWithLoading} from "@/components/wrappers/common/button/button-with-loading";
|
||||||
import {authClient} from "@/lib/auth/auth-client";
|
import {authClient} from "@/lib/auth/auth-client";
|
||||||
import {toast} from "sonner";
|
import {toast} from "sonner";
|
||||||
@@ -31,7 +31,6 @@ export const ResetPasswordForm = ({token}: ResetPasswordFormProps) => {
|
|||||||
token,
|
token,
|
||||||
}, {
|
}, {
|
||||||
onSuccess: (response) => {
|
onSuccess: (response) => {
|
||||||
console.log(response);
|
|
||||||
toast.success("Password changed successfully.");
|
toast.success("Password changed successfully.");
|
||||||
setTimeout(() => router.push("/"), 1000);
|
setTimeout(() => router.push("/"), 1000);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ export const ConnectionCircle = ({date}: ConnectionCircleProps) => {
|
|||||||
const timestamp = date.getTime();
|
const timestamp = date.getTime();
|
||||||
const interval_seconds = (now - timestamp) / 1000;
|
const interval_seconds = (now - timestamp) / 1000;
|
||||||
|
|
||||||
console.log({now, timestamp, interval_seconds});
|
|
||||||
|
|
||||||
if (interval_seconds < 55) {
|
if (interval_seconds < 55) {
|
||||||
style = "bg-green-400 border-green-600";
|
style = "bg-green-400 border-green-600";
|
||||||
} else if (interval_seconds <= 60) {
|
} else if (interval_seconds <= 60) {
|
||||||
@@ -25,7 +23,5 @@ export const ConnectionCircle = ({date}: ConnectionCircleProps) => {
|
|||||||
console.warn("Invalid date passed to ConnectionCircle:", date);
|
console.warn("Invalid date passed to ConnectionCircle:", date);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(style);
|
|
||||||
|
|
||||||
return <div className={cn("w-5 h-5 rounded-full border-4", style)}/>;
|
return <div className={cn("w-5 h-5 rounded-full border-4", style)}/>;
|
||||||
};
|
};
|
||||||
|
|||||||
-4
@@ -29,10 +29,6 @@ export const NotifierChannelOrganisationForm = ({
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
||||||
console.log("defaultValues", defaultValues);
|
|
||||||
console.log("organizations", organizations);
|
|
||||||
|
|
||||||
const defaultOrganizationIds = defaultValues?.organizations?.map(organization => organization.organizationId) ?? []
|
const defaultOrganizationIds = defaultValues?.organizations?.map(organization => organization.organizationId) ?? []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-3
@@ -34,13 +34,11 @@ export const OrganizationAddMemberForm = ({onSuccessAction, users, organization}
|
|||||||
|
|
||||||
const mutationAddMemberOrganisation = useMutation({
|
const mutationAddMemberOrganisation = useMutation({
|
||||||
mutationFn: async (data: AddMemberSchemaType) => {
|
mutationFn: async (data: AddMemberSchemaType) => {
|
||||||
console.log(data);
|
|
||||||
const result = await addMemberOrganizationAction({
|
const result = await addMemberOrganizationAction({
|
||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
organizationId: organization.id,
|
organizationId: organization.id,
|
||||||
role: "member",
|
role: "member",
|
||||||
});
|
});
|
||||||
console.log(result);
|
|
||||||
toast.success("Member successfully added!");
|
toast.success("Member successfully added!");
|
||||||
router.refresh();
|
router.refresh();
|
||||||
onSuccessAction?.();
|
onSuccessAction?.();
|
||||||
@@ -71,7 +69,6 @@ export const OrganizationAddMemberForm = ({onSuccessAction, users, organization}
|
|||||||
placeholder="Enter a user email"
|
placeholder="Enter a user email"
|
||||||
entries={filteredUsers}
|
entries={filteredUsers}
|
||||||
onSelect={(entySelected: any) => {
|
onSelect={(entySelected: any) => {
|
||||||
console.log("Form selection:", entySelected);
|
|
||||||
field.onChange(entySelected.value);
|
field.onChange(entySelected.value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
-2
@@ -35,13 +35,11 @@ export const OrganizationDeleteMemberModal = ({ member, open, onOpenChangeAction
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
onSuccess: async (response) => {
|
onSuccess: async (response) => {
|
||||||
console.log(response);
|
|
||||||
toast.success("Member successfully deleted!");
|
toast.success("Member successfully deleted!");
|
||||||
onOpenChangeAction(false);
|
onOpenChangeAction(false);
|
||||||
router.refresh();
|
router.refresh();
|
||||||
},
|
},
|
||||||
onError: async (error) => {
|
onError: async (error) => {
|
||||||
console.log(error);
|
|
||||||
toast.error("An error occurred while deleting member!");
|
toast.error("An error occurred while deleting member!");
|
||||||
onOpenChangeAction(false);
|
onOpenChangeAction(false);
|
||||||
},
|
},
|
||||||
|
|||||||
-1
@@ -49,7 +49,6 @@ export const OrganizationMemberChangeRoleModal = (props: OrganizationMemberChang
|
|||||||
router.refresh();
|
router.refresh();
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.log(error);
|
|
||||||
toast.error("An error occurred while updating member");
|
toast.error("An error occurred while updating member");
|
||||||
onOpenChangeAction(false);
|
onOpenChangeAction(false);
|
||||||
},
|
},
|
||||||
|
|||||||
-2
@@ -28,11 +28,9 @@ export const StorageS3Form = (props: S3FormProps) => {
|
|||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: async (values: S3FormType) => {
|
mutationFn: async (values: S3FormType) => {
|
||||||
console.log(values);
|
|
||||||
const updateS3Settings = await updateS3SettingsAction({ name: "system", data: values });
|
const updateS3Settings = await updateS3SettingsAction({ name: "system", data: values });
|
||||||
const data = updateS3Settings?.data?.data;
|
const data = updateS3Settings?.data?.data;
|
||||||
if (updateS3Settings?.serverError || !data) {
|
if (updateS3Settings?.serverError || !data) {
|
||||||
console.log(updateS3Settings?.serverError);
|
|
||||||
toast.error(updateS3Settings?.serverError);
|
toast.error(updateS3Settings?.serverError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export const AdminUserEditForm = ({ onSuccess, defaultValues }: AdminUserEditFor
|
|||||||
...data,
|
...data,
|
||||||
id: defaultValues?.id || "",
|
id: defaultValues?.id || "",
|
||||||
});
|
});
|
||||||
console.log(result)
|
|
||||||
const inner = result?.data;
|
const inner = result?.data;
|
||||||
if (inner?.success) {
|
if (inner?.success) {
|
||||||
toast.success("User Successfully updated");
|
toast.success("User Successfully updated");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {Server} from "lucide-react";
|
|||||||
import {formatDateLastContact} from "@/utils/date-formatting";
|
import {formatDateLastContact} from "@/utils/date-formatting";
|
||||||
import {AgentCardKey} from "@/components/wrappers/dashboard/agent/agent-card-key/agent-card-key";
|
import {AgentCardKey} from "@/components/wrappers/dashboard/agent/agent-card-key/agent-card-key";
|
||||||
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
|
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
|
||||||
import {DatabaseCard} from "@/components/wrappers/dashboard/projects/project-card/project-database-card";
|
import {AgentDatabaseCard} from "@/components/wrappers/dashboard/agent/agent-database-card";
|
||||||
import {AgentWithDatabases} from "@/db/schema/08_agent";
|
import {AgentWithDatabases} from "@/db/schema/08_agent";
|
||||||
import {eventUpdate} from "@/types/events";
|
import {eventUpdate} from "@/types/events";
|
||||||
import {useAutoRefresh} from "@/hooks/use-auto-refresh";
|
import {useAutoRefresh} from "@/hooks/use-auto-refresh";
|
||||||
@@ -72,7 +72,7 @@ export const AgentContentPage = ({edgeKey, agent}: AgentContentPageProps) => {
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
<CardsWithPagination cardsPerPage={4} numberOfColumns={2} data={agent.databases}
|
<CardsWithPagination cardsPerPage={4} numberOfColumns={2} data={agent.databases}
|
||||||
cardItem={DatabaseCard}/>
|
cardItem={AgentDatabaseCard}/>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import {Database} from "@/db/schema/07_database";
|
||||||
|
import {DatabaseCard} from "@/components/wrappers/dashboard/projects/project-card/project-database-card";
|
||||||
|
|
||||||
|
export type agentDatabaseCardProps = {
|
||||||
|
data: Database;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AgentDatabaseCard = (props: agentDatabaseCardProps) => {
|
||||||
|
const {data: database} = props;
|
||||||
|
|
||||||
|
return <DatabaseCard data={database}/>;
|
||||||
|
|
||||||
|
//todo: à remettre quand on aura fait l'impersonation des admins
|
||||||
|
/* if (!database.projectId) {
|
||||||
|
return <DatabaseCard data={database}/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link className="group block transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl"
|
||||||
|
href={`/dashboard/projects/${database.projectId}/database/${database.id}`}>
|
||||||
|
<DatabaseCard data={database}/>
|
||||||
|
</Link>
|
||||||
|
);*/
|
||||||
|
};
|
||||||
@@ -47,7 +47,6 @@ export const AgentForm = (props: agentFormProps) => {
|
|||||||
|
|
||||||
const data = createAgent?.data?.data;
|
const data = createAgent?.data?.data;
|
||||||
if (createAgent?.serverError || !data) {
|
if (createAgent?.serverError || !data) {
|
||||||
console.log(createAgent?.serverError);
|
|
||||||
toast.error(createAgent?.serverError);
|
toast.error(createAgent?.serverError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -20,15 +20,6 @@ export const NotifierTestChannelButton = ({notificationChannel, organizationId}:
|
|||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
|
|
||||||
// const payload: EventPayload = {
|
|
||||||
// title: 'Database Down',
|
|
||||||
// message: 'Primary DB instance is unreachable',
|
|
||||||
// level: 'critical',
|
|
||||||
// data: {host: 'db-prod-01', error: 'connection timeout'},
|
|
||||||
// };
|
|
||||||
|
|
||||||
console.log("organizationId ici", organizationId);
|
|
||||||
|
|
||||||
const payload: EventPayload = {
|
const payload: EventPayload = {
|
||||||
title: 'Test Channel',
|
title: 'Test Channel',
|
||||||
message: `We are testing channel ${notificationChannel.name}`,
|
message: `We are testing channel ${notificationChannel.name}`,
|
||||||
|
|||||||
@@ -296,9 +296,7 @@ export const AlertPolicyForm = ({database, notificationChannels, organizationId,
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-1.5">
|
<div className="flex flex-col gap-1.5">
|
||||||
<Label className="text-[10px] font-bold text-transparent uppercase tracking-widest select-none">
|
|
||||||
Actions
|
|
||||||
</Label>
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export function CreateOrganizationModal({
|
|||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: async (values: OrganizationSchema) => {
|
mutationFn: async (values: OrganizationSchema) => {
|
||||||
console.log(values);
|
|
||||||
|
|
||||||
const result = await createOrganizationAction(values);
|
const result = await createOrganizationAction(values);
|
||||||
|
|
||||||
@@ -73,7 +72,6 @@ export function CreateOrganizationModal({
|
|||||||
form={form}
|
form={form}
|
||||||
className="flex flex-col gap-4"
|
className="flex flex-col gap-4"
|
||||||
onSubmit={async (values) => {
|
onSubmit={async (values) => {
|
||||||
console.log(values);
|
|
||||||
await mutation.mutateAsync(values);
|
await mutation.mutateAsync(values);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export const AvatarWithUpload = (props: AvatarWithUploadProps) => {
|
|||||||
const data = uploadImage?.data?.data;
|
const data = uploadImage?.data?.data;
|
||||||
|
|
||||||
if (uploadImage?.serverError || !data) {
|
if (uploadImage?.serverError || !data) {
|
||||||
console.log(uploadImage?.serverError);
|
|
||||||
toast.error(uploadImage?.serverError);
|
toast.error(uploadImage?.serverError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -34,7 +33,6 @@ export const AvatarWithUpload = (props: AvatarWithUploadProps) => {
|
|||||||
const dataUser = updateUser?.data?.data;
|
const dataUser = updateUser?.data?.data;
|
||||||
|
|
||||||
if (updateUser?.serverError || !dataUser) {
|
if (updateUser?.serverError || !dataUser) {
|
||||||
console.log(updateUser?.serverError);
|
|
||||||
toast.error(updateUser?.serverError);
|
toast.error(updateUser?.serverError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ export function ProfileAccount({user}: ProfileAccountProps) {
|
|||||||
router.refresh();
|
router.refresh();
|
||||||
},
|
},
|
||||||
onError: (error: BetterAuthError) => {
|
onError: (error: BetterAuthError) => {
|
||||||
console.log(error)
|
|
||||||
if (error.code === "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL") {
|
if (error.code === "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL") {
|
||||||
toast.error("User already exists, use another email address!");
|
toast.error("User already exists, use another email address!");
|
||||||
emailForm.reset({email: user.email});
|
emailForm.reset({email: user.email});
|
||||||
|
|||||||
-2
@@ -21,8 +21,6 @@ export const deleteProjectAction = userAction.schema(z.string()).action(async ({
|
|||||||
|
|
||||||
|
|
||||||
const databasesToRemove = databasesUpdated.map((db) => db.id);
|
const databasesToRemove = databasesUpdated.map((db) => db.id);
|
||||||
console.log(databasesUpdated);
|
|
||||||
console.log(databasesToRemove);
|
|
||||||
|
|
||||||
await db.delete(drizzleDb.schemas.retentionPolicy)
|
await db.delete(drizzleDb.schemas.retentionPolicy)
|
||||||
.where(inArray(drizzleDb.schemas.retentionPolicy.databaseId, databasesToRemove)).execute();
|
.where(inArray(drizzleDb.schemas.retentionPolicy.databaseId, databasesToRemove)).execute();
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ export const DatabaseBackupList = (props: DatabaseBackupListProps) => {
|
|||||||
<DropdownMenuContent align="start">
|
<DropdownMenuContent align="start">
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
console.log("Deleting rows:", rows)
|
|
||||||
await mutationDeleteBackups.mutateAsync(rows)
|
await mutationDeleteBackups.mutateAsync(rows)
|
||||||
}}
|
}}
|
||||||
className="text-red-600 focus:text-red-700"
|
className="text-red-600 focus:text-red-700"
|
||||||
|
|||||||
@@ -20,18 +20,18 @@ export const ProjectCard = (props: projectCardProps) => {
|
|||||||
href={`/dashboard/projects/${project.id}`}
|
href={`/dashboard/projects/${project.id}`}
|
||||||
className="group block transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl"
|
className="group block transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl"
|
||||||
>
|
>
|
||||||
<Card className="relative h-full flex flex-col p-5 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden">
|
<Card className="relative h-full flex flex-col p-4 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden gap-0">
|
||||||
<div className="flex items-start justify-between mb-4">
|
<div className="flex items-start justify-between mb-2">
|
||||||
<div className="flex items-center justify-center w-12 h-12 rounded-2xl bg-primary/10 text-primary group-hover:bg-primary group-hover:text-primary-foreground transition-all duration-300 shadow-inner">
|
<div className="flex items-center justify-center w-12 h-12 rounded-xl bg-primary/10 text-primary group-hover:bg-primary group-hover:text-primary-foreground transition-all duration-300 shadow-inner">
|
||||||
<Folder className="w-6 h-6" />
|
<Folder className="w-8 h-8" />
|
||||||
</div>
|
</div>
|
||||||
<Badge className="text-xs font-medium px-2 py-1 rounded-lg bg-secondary/50 text-foreground">{dbCount} {dbCount === 1 ? "Database" : "Databases"}
|
<Badge className="text-[10px] font-medium px-2 py-1 rounded-lg bg-secondary/50 text-foreground">{dbCount} {dbCount === 1 ? "Database" : "Databases"}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-1.5 flex-1">
|
<div className="flex flex-col gap-2 flex-1">
|
||||||
<h3 className="text-xl font-black text-foreground group-hover:text-primary transition-colors line-clamp-1">
|
<h3 className="text-lg font-black text-foreground group-hover:text-primary transition-colors line-clamp-1 tracking-tight">
|
||||||
{project.name}
|
{project.name}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
|
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
|
||||||
@@ -39,11 +39,11 @@ export const ProjectCard = (props: projectCardProps) => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-6 flex items-center justify-between pt-4 border-t border-border/50">
|
<div className="mt-4 flex items-center justify-between pt-3 border-t border-border/50">
|
||||||
<span className="text-[10px] font-bold uppercase tracking-widest text-primary opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-x-[-10px] group-hover:translate-x-0">View Project</span>
|
<span className="text-[10px] font-bold uppercase tracking-widest text-primary opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-x-[-10px] group-hover:translate-x-0">View Project</span>
|
||||||
<div className="flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors">
|
<div className="flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors">
|
||||||
<span className="text-[10px] font-bold uppercase tracking-widest group-hover:hidden">Details</span>
|
<span className="text-[10px] font-bold uppercase tracking-widest group-hover:hidden">Details</span>
|
||||||
<ChevronRight className="w-4 h-4 group-hover:translate-x-1 transition-transform" />
|
<ChevronRight className="w-3.5 h-3.5 group-hover:translate-x-1 transition-transform" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -43,61 +43,61 @@ export const DatabaseCard = (props: databaseCardProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="relative h-full flex flex-col p-6 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden">
|
<Card className="relative h-full flex flex-col p-4 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-lg overflow-hidden gap-0">
|
||||||
<div className="flex items-start justify-between mb-6">
|
<div className="flex items-start justify-between mb-2">
|
||||||
<div className="relative w-16 h-16 p-3 bg-background rounded-2xl border border-border/50 shadow-sm flex items-center justify-center group-hover:border-primary/30 transition-all duration-300 group-hover:scale-105">
|
<div className="relative w-12 h-12 p-2 bg-background rounded-xl border border-border/50 shadow-sm flex items-center justify-center group-hover:border-primary/30 transition-all duration-300 group-hover:scale-105">
|
||||||
<Image
|
<Image
|
||||||
src={`/images/${database.dbms}.png`}
|
src={`/images/${database.dbms}.png`}
|
||||||
alt={`${database.dbms} icon`}
|
alt={`${database.dbms} icon`}
|
||||||
width={48}
|
width={32}
|
||||||
height={48}
|
height={32}
|
||||||
className="object-contain w-full h-full"
|
className="object-contain w-full h-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col items-end gap-3">
|
<div className="flex flex-col items-end gap-3">
|
||||||
<div className="scale-125 origin-right">
|
<div className="scale-100 origin-right">
|
||||||
<ConnectionCircle date={database.lastContact}/>
|
<ConnectionCircle date={database.lastContact}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-4 flex-1">
|
<div className="flex flex-col gap-2 flex-1">
|
||||||
<h3 className="text-xl font-black text-foreground group-hover:text-primary transition-colors truncate tracking-tight">
|
<h3 className="text-lg font-black text-foreground group-hover:text-primary transition-colors truncate tracking-tight">
|
||||||
{database.name}
|
{database.name}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-2">
|
||||||
<div className="flex items-center gap-2.5 text-muted-foreground group-hover:text-foreground transition-colors">
|
<div className="flex items-center gap-2 text-muted-foreground group-hover:text-foreground transition-colors">
|
||||||
<div className="p-1.5 bg-muted/50 rounded-lg">
|
<div className="p-1 bg-muted/50 rounded-lg">
|
||||||
<Fingerprint className="w-4 h-4" />
|
<Fingerprint className="w-3.5 h-3.5" />
|
||||||
</div>
|
</div>
|
||||||
<span className="font-mono text-xs font-bold truncate">
|
<span className="font-mono text-[10px] font-bold truncate">
|
||||||
{database.agentDatabaseId}
|
{database.agentDatabaseId}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
onClick={handleCopy}
|
onClick={handleCopy}
|
||||||
className="ml-1 p-1 hover:bg-muted rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 z-10"
|
className="ml-1 p-0.5 hover:bg-muted rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 z-10"
|
||||||
title="Copy ID"
|
title="Copy ID"
|
||||||
>
|
>
|
||||||
{isCopied ? <Check className="w-3 h-3 text-green-500" /> : <Copy className="w-3 h-3" />}
|
{isCopied ? <Check className="w-2.5 h-2.5 text-green-500" /> : <Copy className="w-2.5 h-2.5" />}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2.5 text-muted-foreground group-hover:text-foreground transition-colors">
|
<div className="flex items-center gap-2 text-muted-foreground group-hover:text-foreground transition-colors">
|
||||||
<div className="p-1.5 bg-muted/50 rounded-lg">
|
<div className="p-1 bg-muted/50 rounded-lg">
|
||||||
<Activity className="w-4 h-4" />
|
<Activity className="w-3.5 h-3.5" />
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs font-bold uppercase tracking-tight">
|
<span className="text-[10px] font-bold uppercase tracking-tight">
|
||||||
{formatDateLastContact(database.lastContact)}
|
{formatDateLastContact(database.lastContact)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-8 flex items-center justify-between pt-4 border-t border-border/50">
|
<div className="mt-4 flex items-center justify-between pt-3 border-t border-border/50">
|
||||||
<span className="text-[10px] font-black uppercase tracking-widest text-primary opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-x-[-10px] group-hover:translate-x-0">Open Explorer</span>
|
<span className="text-[10px] font-black uppercase tracking-widest text-primary opacity-0 group-hover:opacity-100 transition-all duration-300 transform translate-x-[-10px] group-hover:translate-x-0">Open</span>
|
||||||
<div className="flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors">
|
<div className="flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors">
|
||||||
<span className="text-[10px] font-bold uppercase tracking-widest group-hover:hidden">Details</span>
|
<span className="text-[10px] font-bold uppercase tracking-widest group-hover:hidden">Details</span>
|
||||||
<ChevronRight className="w-4 h-4 group-hover:translate-x-1 transition-transform" />
|
<ChevronRight className="w-3.5 h-3.5 group-hover:translate-x-1 transition-transform" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ export const createProjectAction = userAction
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
actionError: {
|
actionError: {
|
||||||
|
|||||||
@@ -66,10 +66,8 @@ export function backupColumns(
|
|||||||
header: "Reference",
|
header: "Reference",
|
||||||
cell: ({row}) => {
|
cell: ({row}) => {
|
||||||
const fileName = row.original.file
|
const fileName = row.original.file
|
||||||
console.log(row.original)
|
|
||||||
const reference = row.original.id
|
const reference = row.original.id
|
||||||
const isImported = isImportedFilename(`${fileName}`)
|
const isImported = isImportedFilename(`${fileName}`)
|
||||||
console.log(isImported)
|
|
||||||
return isImported ? `${reference} (imported)` : `${reference}`
|
return isImported ? `${reference} (imported)` : `${reference}`
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -77,7 +75,6 @@ export function backupColumns(
|
|||||||
accessorKey: "fileSize",
|
accessorKey: "fileSize",
|
||||||
header: "Size",
|
header: "Size",
|
||||||
cell: ({row}) => {
|
cell: ({row}) => {
|
||||||
console.log(row.original.fileSize)
|
|
||||||
return formatBytes(row.getValue("fileSize"))
|
return formatBytes(row.getValue("fileSize"))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -163,7 +160,6 @@ export function backupColumns(
|
|||||||
} else if (settings.storage == "s3") {
|
} else if (settings.storage == "s3") {
|
||||||
data = await getFileUrlPreSignedS3Action(`backups/${database.project?.slug}/${fileName}`);
|
data = await getFileUrlPreSignedS3Action(`backups/${database.project?.slug}/${fileName}`);
|
||||||
}
|
}
|
||||||
console.log(data)
|
|
||||||
if (data?.data?.success) {
|
if (data?.data?.success) {
|
||||||
url = data.data.value ?? "";
|
url = data.data.value ?? "";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export async function dispatchNotification(
|
|||||||
success: false,
|
success: false,
|
||||||
channelId: channelId || "",
|
channelId: channelId || "",
|
||||||
provider: null,
|
provider: null,
|
||||||
error: "Channel not active¬",
|
error: "Channel not active",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +1,64 @@
|
|||||||
import {DatabaseWith} from "@/db/schema/07_database";
|
import { DatabaseWith } from "@/db/schema/07_database";
|
||||||
import {EventKind, EventPayload} from "@/features/notifications/types";
|
import { EventKind, EventPayload } from "@/features/notifications/types";
|
||||||
import {dispatchNotification} from "@/features/notifications/dispatch";
|
import { dispatchNotification } from "@/features/notifications/dispatch";
|
||||||
|
|
||||||
|
|
||||||
export async function sendNotificationsBackupRestore(database: DatabaseWith, event: EventKind) {
|
export async function sendNotificationsBackupRestore(database: DatabaseWith, event: EventKind) {
|
||||||
|
if (!database.alertPolicies || database.alertPolicies.length === 0) {
|
||||||
if (database.alertPolicies && database.alertPolicies.length > 0) {
|
return [];
|
||||||
for (const alertPolicy of database.alertPolicies) {
|
|
||||||
if (alertPolicy.enabled) {
|
|
||||||
|
|
||||||
const eventKinds = alertPolicy.eventKinds
|
|
||||||
|
|
||||||
if (eventKinds.includes(event)) {
|
|
||||||
|
|
||||||
const date = new Date()
|
|
||||||
|
|
||||||
let level: "info" | "critical" = "info";
|
|
||||||
let message = "";
|
|
||||||
let error: string | null = null;
|
|
||||||
|
|
||||||
switch (event) {
|
|
||||||
case "error_backup":
|
|
||||||
case "error_restore":
|
|
||||||
level = "critical";
|
|
||||||
message = `An error occurred during ${event.includes("backup") ? "backup" : "restore"} on ${date.toISOString()}.`;
|
|
||||||
error = "Check database connection or agent";
|
|
||||||
break;
|
|
||||||
case "success_backup":
|
|
||||||
case "success_restore":
|
|
||||||
level = "info";
|
|
||||||
message = `${event.includes("backup") ? "Backup" : "Restore"} completed successfully at ${date.toISOString()}.`;
|
|
||||||
break;
|
|
||||||
case "weekly_report":
|
|
||||||
level = "info";
|
|
||||||
message = `Weekly report generated at ${date.toISOString()}.`;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const titleMap: Record<EventKind, string> = {
|
|
||||||
error_backup: `Backup Notification`,
|
|
||||||
error_restore: `Restore Notification`,
|
|
||||||
success_backup: `Backup Notification`,
|
|
||||||
success_restore: `Restore Notification`,
|
|
||||||
weekly_report: `Weekly Report Notification`,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const payload: EventPayload = {
|
|
||||||
title: titleMap[event],
|
|
||||||
message,
|
|
||||||
level: level,
|
|
||||||
event: event,
|
|
||||||
data: {
|
|
||||||
host: database.name,
|
|
||||||
id: database.id,
|
|
||||||
agentDatabaseId: database.agentDatabaseId,
|
|
||||||
error,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return await dispatchNotification(payload, alertPolicy.id, undefined, undefined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const activePolicies = database.alertPolicies.filter(policy =>
|
||||||
|
policy.enabled && policy.eventKinds.includes(event)
|
||||||
|
);
|
||||||
|
|
||||||
|
const promises = activePolicies.map(alertPolicy => {
|
||||||
|
const date = new Date();
|
||||||
|
let level: "info" | "critical" = "info";
|
||||||
|
let message = "";
|
||||||
|
let error: string | null = null;
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case "error_backup":
|
||||||
|
case "error_restore":
|
||||||
|
level = "critical";
|
||||||
|
message = `An error occurred during ${event.includes("backup") ? "backup" : "restore"} on ${date.toISOString()}.`;
|
||||||
|
error = "Check database connection or agent";
|
||||||
|
break;
|
||||||
|
case "success_backup":
|
||||||
|
case "success_restore":
|
||||||
|
level = "info";
|
||||||
|
message = `${event.includes("backup") ? "Backup" : "Restore"} completed successfully at ${date.toISOString()}.`;
|
||||||
|
break;
|
||||||
|
case "weekly_report":
|
||||||
|
level = "info";
|
||||||
|
message = `Weekly report generated at ${date.toISOString()}.`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const titleMap: Record<EventKind, string> = {
|
||||||
|
error_backup: `Backup Notification`,
|
||||||
|
error_restore: `Restore Notification`,
|
||||||
|
success_backup: `Backup Notification`,
|
||||||
|
success_restore: `Restore Notification`,
|
||||||
|
weekly_report: `Weekly Report Notification`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const payload: EventPayload = {
|
||||||
|
title: titleMap[event],
|
||||||
|
message,
|
||||||
|
level: level,
|
||||||
|
event: event,
|
||||||
|
data: {
|
||||||
|
host: database.name,
|
||||||
|
id: database.id,
|
||||||
|
agentDatabaseId: database.agentDatabaseId,
|
||||||
|
error,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return dispatchNotification(payload, alertPolicy.id, undefined, undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return Promise.all(promises);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,6 @@ async function uploadLocal(fileName: string, buffer: any) {
|
|||||||
await mkdir(path.join(process.cwd(), localDir), {recursive: true});
|
await mkdir(path.join(process.cwd(), localDir), {recursive: true});
|
||||||
return await writeFile(path.join(process.cwd(), localDir + fileName), buffer);
|
return await writeFile(path.join(process.cwd(), localDir + fileName), buffer);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error occured ", error);
|
|
||||||
throw new Error("An error occured while importing image");
|
throw new Error("An error occured while importing image");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,15 +45,12 @@ export function useAutoRefresh(options: UseAutoRefreshOptions) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
payload = JSON.parse(event.data);
|
payload = JSON.parse(event.data);
|
||||||
} catch {
|
} catch {}
|
||||||
// keep raw payload
|
|
||||||
}
|
|
||||||
|
|
||||||
const shouldRefresh =
|
const shouldRefresh =
|
||||||
options.sse?.shouldRefresh?.(payload) ?? true;
|
options.sse?.shouldRefresh?.(payload) ?? true;
|
||||||
|
|
||||||
if (shouldRefresh) {
|
if (shouldRefresh) {
|
||||||
console.log("Received event source", eventSource);
|
|
||||||
router.refresh();
|
router.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+4
-15
@@ -46,11 +46,7 @@ export const auth = betterAuth({
|
|||||||
{}
|
{}
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
|
||||||
onPasswordReset: async ({user}, request) => {
|
|
||||||
console.log(`Password for user ${user.email} has been reset.`);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
emailVerification: {
|
emailVerification: {
|
||||||
async sendVerificationEmail({user, token, url}) {
|
async sendVerificationEmail({user, token, url}) {
|
||||||
@@ -176,13 +172,12 @@ export const auth = betterAuth({
|
|||||||
const role = userCount === 0 ? "owner" : "admin";
|
const role = userCount === 0 ? "owner" : "admin";
|
||||||
|
|
||||||
|
|
||||||
const defaultOrgSlug = "default"; // change this if your default org has a different slug
|
const defaultOrgSlug = "default";
|
||||||
const defaultOrg = await db.query.organization.findFirst({
|
const defaultOrg = await db.query.organization.findFirst({
|
||||||
where: eq(drizzleDb.schemas.organization.slug, defaultOrgSlug),
|
where: eq(drizzleDb.schemas.organization.slug, defaultOrgSlug),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (defaultOrg) {
|
if (defaultOrg) {
|
||||||
console.log(user)
|
|
||||||
await db.insert(drizzleDb.schemas.member).values({
|
await db.insert(drizzleDb.schemas.member).values({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
organizationId: defaultOrg.id,
|
organizationId: defaultOrg.id,
|
||||||
@@ -295,7 +290,6 @@ export const auth = betterAuth({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("sessionId", session.id);
|
|
||||||
|
|
||||||
const [aa] = await db
|
const [aa] = await db
|
||||||
.update(drizzleUser.session)
|
.update(drizzleUser.session)
|
||||||
@@ -303,7 +297,6 @@ export const auth = betterAuth({
|
|||||||
.where(eq(drizzleUser.session.id, session.id))
|
.where(eq(drizzleUser.session.id, session.id))
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
console.log("aaaaa", aa);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...session,
|
...session,
|
||||||
@@ -516,9 +509,7 @@ export const checkSlugOrganization = async (slug: string) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
} catch (e) {
|
} catch {}
|
||||||
console.log("err", e);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getActiveMember = async () => {
|
export const getActiveMember = async () => {
|
||||||
@@ -542,7 +533,5 @@ export const setActiveOrganization = async (slug: string) => {
|
|||||||
organizationSlug: slug,
|
organizationSlug: slug,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch {}
|
||||||
console.log("error", e);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export const retentionCleanTask = async () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log(databases);
|
|
||||||
|
|
||||||
for (const db of databases) {
|
for (const db of databases) {
|
||||||
if (!db.retentionPolicy) continue; // no policy = skip
|
if (!db.retentionPolicy) continue; // no policy = skip
|
||||||
@@ -34,7 +33,6 @@ export async function enforceRetention(
|
|||||||
databaseId: string,
|
databaseId: string,
|
||||||
policy: typeof retentionPolicy.$inferSelect
|
policy: typeof retentionPolicy.$inferSelect
|
||||||
) {
|
) {
|
||||||
console.log(`EnforceRetention: ${policy}`);
|
|
||||||
|
|
||||||
switch (policy.type) {
|
switch (policy.type) {
|
||||||
case "count":
|
case "count":
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ export async function generateEdgeKey(serverUrl: string, agentId: string): Promi
|
|||||||
agentId,
|
agentId,
|
||||||
publicKey
|
publicKey
|
||||||
};
|
};
|
||||||
console.log(edgeKeyData);
|
|
||||||
const edgeKeyJson = JSON.stringify(edgeKeyData);
|
const edgeKeyJson = JSON.stringify(edgeKeyData);
|
||||||
const edgeKeyBuffer = Buffer.from(edgeKeyJson, 'utf-8');
|
const edgeKeyBuffer = Buffer.from(edgeKeyJson, 'utf-8');
|
||||||
return edgeKeyBuffer.toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
return edgeKeyBuffer.toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
||||||
|
|||||||
@@ -171,22 +171,18 @@ export async function createPresignedUrlToUpload({
|
|||||||
return await s3Client.presignedPutObject(bucketName, fileName, expiry);
|
return await s3Client.presignedPutObject(bucketName, fileName, expiry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to create a bucket and make it public
|
|
||||||
export async function createPublicBucket({bucketName}: { bucketName: string }) {
|
export async function createPublicBucket({bucketName}: { bucketName: string }) {
|
||||||
const s3Client = await getS3Client();
|
const s3Client = await getS3Client();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if the bucket already exists
|
|
||||||
const exists = await s3Client.bucketExists(bucketName);
|
const exists = await s3Client.bucketExists(bucketName);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
// Create the bucket
|
await s3Client.makeBucket(bucketName);
|
||||||
await s3Client.makeBucket(bucketName); // Change region if needed
|
|
||||||
console.log(`Bucket ${bucketName} created successfully.`);
|
console.log(`Bucket ${bucketName} created successfully.`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Bucket ${bucketName} already exists.`);
|
console.log(`Bucket ${bucketName} already exists.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define a bucket policy for public access
|
|
||||||
const policy = {
|
const policy = {
|
||||||
Version: "2012-10-17",
|
Version: "2012-10-17",
|
||||||
Statement: [
|
Statement: [
|
||||||
@@ -199,7 +195,6 @@ export async function createPublicBucket({bucketName}: { bucketName: string }) {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the policy to the bucket
|
|
||||||
await s3Client.setBucketPolicy(bucketName, JSON.stringify(policy));
|
await s3Client.setBucketPolicy(bucketName, JSON.stringify(policy));
|
||||||
console.log(`Bucket ${bucketName} is now public.`);
|
console.log(`Bucket ${bucketName} is now public.`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -242,7 +237,6 @@ export async function createPresignedUrlToDownload({
|
|||||||
bucketName,
|
bucketName,
|
||||||
fileName,
|
fileName,
|
||||||
errorMessage: err?.message,
|
errorMessage: err?.message,
|
||||||
// stack: err?.stack,
|
|
||||||
});
|
});
|
||||||
throw {error: err.message ?? "Unknown error"};
|
throw {error: err.message ?? "Unknown error"};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user