Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

more code cleanup

Sara Vieira91cef3796dd2
diff --git a/apps/designer/app/designer/designer.tsx b/apps/designer/app/designer/designer.tsx
index 88f510de26..43b14a34b8 100644
--- a/apps/designer/app/designer/designer.tsx
+++ b/apps/designer/app/designer/designer.tsx
@@ -2,7 +2,7 @@ import { useCallback, useState } from "react";
import { DndProvider } from "react-dnd";
import { TouchBackend } from "react-dnd-touch-backend";
import { useSubscribe, usePublish } from "@webstudio-is/react-sdk";
-import { type Project, type AssetWithPath } from "@webstudio-is/prisma-client";
+import { type Project, type Asset } from "@webstudio-is/prisma-client";
import type { Config } from "~/config";
import type {
HoveredInstanceData,
@@ -173,7 +173,7 @@ const dndOptions = { enableMouseEvents: true };
type DesignerProps = {
config: Config;
project: Project;
- assets: Array<AssetWithPath>;
+ assets: Array<Asset>;
};
export const Designer = ({ config, project, assets }: DesignerProps) => {
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
index a4c8c4f44c..7771ac6268 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/asset-manager.tsx
@@ -3,9 +3,9 @@ import { Button, Flex, Grid, Heading } from "~/shared/design-system";
import { useRef } from "react";
import { Form, useSubmit } from "@remix-run/react";
import { Image } from "~/shared/design-system/components/image";
-import { AssetWithPath } from "@webstudio-is/prisma-client";
+import { Asset } from "@webstudio-is/prisma-client";
-export const TabContent = ({ assets }: { assets: Array<AssetWithPath> }) => {
+export const TabContent = ({ assets }: { assets: Array<Asset> }) => {
const inputRef = useRef<HTMLInputElement | null>(null);
const submit = useSubmit();
diff --git a/apps/designer/app/designer/features/sidebar-left/sidebar-left.tsx b/apps/designer/app/designer/features/sidebar-left/sidebar-left.tsx
index 8879a7fe92..65b9cd96b8 100644
--- a/apps/designer/app/designer/features/sidebar-left/sidebar-left.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/sidebar-left.tsx
@@ -1,6 +1,6 @@
import { useState, useCallback } from "react";
import { useSubscribe, type Publish } from "@webstudio-is/react-sdk";
-import type { AssetWithPath } from "@webstudio-is/prisma-client";
+import type { Asset } from "@webstudio-is/prisma-client";
import {
Box,
SidebarTabs,
@@ -28,7 +28,7 @@ const none = { TabContent: () => null };
type SidebarLeftProps = {
onDragChange: (isDragging: boolean) => void;
publish: Publish;
- assets: Array<AssetWithPath>;
+ assets: Array<Asset>;
};
export const SidebarLeft = ({
diff --git a/apps/designer/app/routes/designer/$id.tsx b/apps/designer/app/routes/designer/$id.tsx
index 556f337973..50f6f2e296 100644
--- a/apps/designer/app/routes/designer/$id.tsx
+++ b/apps/designer/app/routes/designer/$id.tsx
@@ -1,6 +1,6 @@
import { useActionData, useLoaderData } from "@remix-run/react";
import { ActionFunction, LoaderFunction } from "@remix-run/node";
-import type { Project, AssetWithPath } from "@webstudio-is/prisma-client";
+import type { Project, Asset } from "@webstudio-is/prisma-client";
import { Designer, links } from "~/designer";
import * as db from "~/shared/db";
import config from "~/config";
@@ -26,7 +26,7 @@ export const loader: LoaderFunction = async ({ params }) => {
type Data = {
config: typeof config;
project: Project;
- assets: AssetWithPath[];
+ assets: Asset[];
};
type Error = {
diff --git a/packages/asset-uploader/src/db/load.ts b/packages/asset-uploader/src/db/load.ts
index 5d1874c8f2..25cfa43872 100644
--- a/packages/asset-uploader/src/db/load.ts
+++ b/packages/asset-uploader/src/db/load.ts
@@ -1,9 +1,9 @@
-import { prisma, Project, AssetWithPath } from "@webstudio-is/prisma-client";
+import { prisma, Project, Asset } from "@webstudio-is/prisma-client";
import { getAssetPath } from "../helpers/get-asset-path";
export const loadByProject = async (
projectId?: Project["id"]
-): Promise<AssetWithPath[]> => {
+): Promise<Asset[]> => {
if (typeof projectId !== "string") {
throw new Error("Tree ID required");
}
diff --git a/packages/asset-uploader/src/helpers/get-asset-path.ts b/packages/asset-uploader/src/helpers/get-asset-path.ts
index 1bca6686db..9a69969b63 100644
--- a/packages/asset-uploader/src/helpers/get-asset-path.ts
+++ b/packages/asset-uploader/src/helpers/get-asset-path.ts
@@ -1,11 +1,11 @@
-import { Asset, Location } from "@webstudio-is/prisma-client";
+import { DbAsset, Location } from "@webstudio-is/prisma-client";
import { fsEnvVariables, s3EnvVariables } from "../schema";
import path from "path";
const s3Envs = s3EnvVariables.safeParse(process.env);
const fsEnvs = fsEnvVariables.parse(process.env);
-export const getAssetPath = (asset: Asset) => {
+export const getAssetPath = (asset: DbAsset) => {
if (asset.location === Location.FS) {
return path.join("/", fsEnvs.FILE_UPLOAD_PATH, asset.name);
}
diff --git a/packages/prisma-client/src/types.ts b/packages/prisma-client/src/types.ts
index 482ebaaee9..a6cf5d409c 100644
--- a/packages/prisma-client/src/types.ts
+++ b/packages/prisma-client/src/types.ts
@@ -1,10 +1,6 @@
-import { Asset } from "@prisma/client";
+import { type Asset as DbAsset } from "@prisma/client";
export { Location } from "@prisma/client";
-export type {
- InstanceProps,
- Project,
- User,
- Breakpoints,
- Asset,
-} from "@prisma/client";
-export type AssetWithPath = Asset & { path: string };
+export type { InstanceProps, Project, User, Breakpoints } from "@prisma/client";
+
+export type Asset = DbAsset & { path: string };
+export { DbAsset };