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.

rename import to projectdomain

Andras Bacsai79091a517fd0
diff --git a/apps/designer/app/canvas/shared/sync/use-sync.ts b/apps/designer/app/canvas/shared/sync/use-sync.ts
index a2f3959a33..c86c38f217 100644
--- a/apps/designer/app/canvas/shared/sync/use-sync.ts
+++ b/apps/designer/app/canvas/shared/sync/use-sync.ts
@@ -1,9 +1,9 @@
import useInterval from "react-use/lib/useInterval";
import { sync } from "immerhin";
import { enqueue } from "./queue";
-import * as db from "@webstudio-is/project";
+import { project } from "@webstudio-is/project";
-export const useSync = ({ project }: { project: db.project.Project }) => {
+export const useSync = ({ project }: { project: project.Project }) => {
useInterval(() => {
const entries = sync();
if (entries.length === 0) return;
diff --git a/apps/designer/app/routes/rest/breakpoints.$projectId.ts b/apps/designer/app/routes/rest/breakpoints.$projectId.ts
index e5919884f5..50a7706e73 100644
--- a/apps/designer/app/routes/rest/breakpoints.$projectId.ts
+++ b/apps/designer/app/routes/rest/breakpoints.$projectId.ts
@@ -1,6 +1,6 @@
import type { LoaderFunction } from "@remix-run/node";
import { Breakpoint } from "@webstudio-is/react-sdk";
-import * as db from "@webstudio-is/project";
+import * as projectdomain from "@webstudio-is/project";
export type ErrorData = {
errors: string;
@@ -10,7 +10,7 @@ export const loader: LoaderFunction = async ({
params,
}): Promise<Array<Breakpoint> | ErrorData> => {
try {
- const project = await db.project.loadById(params.projectId);
+ const project = await projectdomain.project.loadById(params.projectId);
if (project === null) {
throw new Error(`Project ${params.projectId} not found`);
}
@@ -19,7 +19,7 @@ export const loader: LoaderFunction = async ({
`Project ${params.projectId} needs to be published first`
);
}
- const data = await db.breakpoints.load(project.prodTreeId);
+ const data = await projectdomain.breakpoints.load(project.prodTreeId);
if (data === null) {
throw new Error(
`Breakpoints not found for project ${params.projectId} and tree ID ${project.prodTreeId}`
diff --git a/apps/designer/app/routes/rest/pages.$projectId.ts b/apps/designer/app/routes/rest/pages.$projectId.ts
index 5acd1cfa05..ac5cff59c9 100644
--- a/apps/designer/app/routes/rest/pages.$projectId.ts
+++ b/apps/designer/app/routes/rest/pages.$projectId.ts
@@ -1,6 +1,6 @@
import type { LoaderFunction } from "@remix-run/node";
import type { Breakpoint } from "@webstudio-is/react-sdk";
-import * as db from "@webstudio-is/project";
+import * as projectdomain from "@webstudio-is/project";
export type ErrorData = {
errors: string;
@@ -10,7 +10,7 @@ export const loader: LoaderFunction = async ({
params,
}): Promise<Array<Breakpoint> | ErrorData> => {
try {
- const project = await db.project.loadById(params.projectId);
+ const project = await projectdomain.project.loadById(params.projectId);
if (project === null) {
throw new Error(`Project ${params.projectId} not found`);
}
@@ -19,7 +19,7 @@ export const loader: LoaderFunction = async ({
`Project ${params.projectId} needs to be published first`
);
}
- const data = await db.breakpoints.load(project.prodTreeId);
+ const data = await projectdomain.breakpoints.load(project.prodTreeId);
if (data === null) {
throw new Error(
`Breakpoints not found for project ${params.projectId} and tree ID ${project.prodTreeId}`
diff --git a/apps/designer/app/routes/rest/patch.ts b/apps/designer/app/routes/rest/patch.ts
index ec5bda589b..976d50abfb 100644
--- a/apps/designer/app/routes/rest/patch.ts
+++ b/apps/designer/app/routes/rest/patch.ts
@@ -1,13 +1,13 @@
import { type ActionFunction } from "@remix-run/node";
-import * as db from "@webstudio-is/project";
+import * as projectdomain from "@webstudio-is/project";
import { type SyncItem } from "immerhin";
import { type Tree } from "@webstudio-is/react-sdk";
import { type Project } from "@webstudio-is/prisma-client";
const updaters = {
- root: db.tree.patchRoot,
- props: db.props.patch,
- breakpoints: db.breakpoints.patch,
+ root: projectdomain.tree.patchRoot,
+ props: projectdomain.props.patch,
+ breakpoints: projectdomain.breakpoints.patch,
};
type UpdaterKey = keyof typeof updaters;
diff --git a/apps/designer/app/routes/rest/project/clone.$domain.ts b/apps/designer/app/routes/rest/project/clone.$domain.ts
index b76788aa60..5ef971f6c1 100644
--- a/apps/designer/app/routes/rest/project/clone.$domain.ts
+++ b/apps/designer/app/routes/rest/project/clone.$domain.ts
@@ -1,7 +1,7 @@
import { type LoaderFunction, redirect } from "@remix-run/node";
import type { User } from "@webstudio-is/prisma-client";
-import * as db from "@webstudio-is/project";
-import * as dba from "~/shared/db";
+import * as projectdomain from "@webstudio-is/project";
+import * as db from "~/shared/db";
import { ensureUserCookie } from "~/shared/session";
import config from "~/config";
import { authenticator } from "~/services/auth.server";
@@ -12,11 +12,11 @@ const ensureProject = async ({
}: {
userId: User["id"];
domain: string;
-}): Promise<db.project.Project> => {
- const projects = await db.project.loadManyByUserId(userId);
+}): Promise<projectdomain.project.Project> => {
+ const projects = await projectdomain.project.loadManyByUserId(userId);
if (projects.length !== 0) return projects[0];
- return await db.project.clone(domain, userId);
+ return await projectdomain.project.clone(domain, userId);
};
/**
@@ -32,7 +32,7 @@ export const loader: LoaderFunction = async ({ request, params }) => {
const user = await authenticator.isAuthenticated(request);
const { headers, userId: generatedUserId } = await ensureUserCookie(request);
try {
- const userId = await dba.user.ensureUser({
+ const userId = await db.user.ensureUser({
userId: user ? user.id : generatedUserId,
});
const project = await ensureProject({
diff --git a/apps/designer/app/routes/rest/props.$projectId.ts b/apps/designer/app/routes/rest/props.$projectId.ts
index 751cc6d199..c704e5bce6 100644
--- a/apps/designer/app/routes/rest/props.$projectId.ts
+++ b/apps/designer/app/routes/rest/props.$projectId.ts
@@ -1,6 +1,6 @@
import { type LoaderFunction } from "@remix-run/node";
import { type InstanceProps } from "@webstudio-is/react-sdk";
-import * as db from "@webstudio-is/project";
+import * as projectdomain from "@webstudio-is/project";
type ErrorData = {
errors: string;
};
@@ -9,8 +9,8 @@ export const loader: LoaderFunction = async ({
params,
}): Promise<Array<InstanceProps> | ErrorData> => {
try {
- const project = await db.project.loadById(params.projectId);
- return await db.props.loadByProject(project, "production");
+ const project = await projectdomain.project.loadById(params.projectId);
+ return await projectdomain.props.loadByProject(project, "production");
} catch (error) {
if (error instanceof Error) {
return {
diff --git a/apps/designer/app/routes/rest/tree.$projectId.ts b/apps/designer/app/routes/rest/tree.$projectId.ts
index e9d7960b7a..0f9835a324 100644
--- a/apps/designer/app/routes/rest/tree.$projectId.ts
+++ b/apps/designer/app/routes/rest/tree.$projectId.ts
@@ -1,6 +1,6 @@
import { type LoaderFunction } from "@remix-run/node";
import type { Tree } from "@webstudio-is/react-sdk";
-import * as db from "@webstudio-is/project";
+import * as projectdomain from "@webstudio-is/project";
export type ErrorData = {
errors: string;
};
@@ -9,8 +9,8 @@ export const loader: LoaderFunction = async ({
params,
}): Promise<Tree | null | ErrorData> => {
try {
- const project = await db.project.loadById(params.projectId);
- return await db.tree.loadByProject(project, "production");
+ const project = await projectdomain.project.loadById(params.projectId);
+ return await projectdomain.tree.loadByProject(project, "production");
} catch (error) {
if (error instanceof Error) {
return {
diff --git a/apps/designer/app/shared/db/canvas.server.ts b/apps/designer/app/shared/db/canvas.server.ts
index a1345f5536..927a020e67 100644
--- a/apps/designer/app/shared/db/canvas.server.ts
+++ b/apps/designer/app/shared/db/canvas.server.ts
@@ -1,21 +1,21 @@
import { type Data } from "@webstudio-is/react-sdk";
-import * as db from "@webstudio-is/project";
+import * as projectdomain from "@webstudio-is/project";
-export type CanvasData = Data & { project: db.project.Project };
+export type CanvasData = Data & { project: projectdomain.project.Project };
export type ErrorData = {
errors: string;
};
-const loadData = async (projectId: db.project.Project["id"]) => {
- const project = await db.project.loadById(projectId);
+const loadData = async (projectId: projectdomain.project.Project["id"]) => {
+ const project = await projectdomain.project.loadById(projectId);
if (project === null) throw new Error(`Project "${projectId}" not found`);
const [tree, props, breakpoints] = await Promise.all([
- db.tree.loadByProject(project, "development"),
- db.props.loadByProject(project, "development"),
- db.breakpoints.load(project.devTreeId),
+ projectdomain.tree.loadByProject(project, "development"),
+ projectdomain.props.loadByProject(project, "development"),
+ projectdomain.breakpoints.load(project.devTreeId),
]);
if (tree === null) {
@@ -39,7 +39,7 @@ const loadData = async (projectId: db.project.Project["id"]) => {
export const loadCanvasData = async ({
projectId,
}: {
- projectId: db.project.Project["id"];
+ projectId: projectdomain.project.Project["id"];
}): Promise<CanvasData | ErrorData> => {
return await loadData(projectId);
};
@@ -49,7 +49,7 @@ export type PreviewData = Data;
export const loadPreviewData = async ({
projectId,
}: {
- projectId: db.project.Project["id"];
+ projectId: projectdomain.project.Project["id"];
}): Promise<PreviewData | ErrorData> => {
const { tree, props, breakpoints } = await loadData(projectId);
return { tree, props, breakpoints };
diff --git a/apps/designer/app/shared/db/misc.server.ts b/apps/designer/app/shared/db/misc.server.ts
index cfb933b6b7..d3287cb4a2 100644
--- a/apps/designer/app/shared/db/misc.server.ts
+++ b/apps/designer/app/shared/db/misc.server.ts
@@ -1,4 +1,5 @@
-import * as db from "@webstudio-is/project";
+import * as projectdomain from "@webstudio-is/project";
+
/**
* Conceptually publishing is cloning all data that affects user site
* and referencing it under a new tree id.
@@ -17,17 +18,17 @@ export const publish = async ({
throw new Error("Domain required");
}
- const project = await db.project.loadById(projectId);
+ const project = await projectdomain.project.loadById(projectId);
if (project === null) {
throw new Error(`Project "${projectId}" not found`);
}
- const tree = await db.tree.clone(project.devTreeId);
- await db.props.clone({
+ const tree = await projectdomain.tree.clone(project.devTreeId);
+ await projectdomain.props.clone({
previousTreeId: project.devTreeId,
nextTreeId: tree.id,
});
- await db.breakpoints.clone({
+ await projectdomain.breakpoints.clone({
previousTreeId: project.devTreeId,
nextTreeId: tree.id,
});
@@ -35,7 +36,7 @@ export const publish = async ({
if (project.prodTreeId) {
prodTreeIdHistory.push(project.prodTreeId);
}
- const updatedProject = await db.project.update({
+ const updatedProject = await projectdomain.project.update({
id: projectId,
domain,
prodTreeId: tree.id,