-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WEB-1116] feat: pages realtime sync (#5057)
* init: live server for editor realtime sync * chore: authentication added * chore: updated logic to convert html to binary for old pages * chore: added description json on page update * chore: made all functions generic * chore: save description in json and html formats * refactor: document editor components * chore: uncomment ui package components * fix: without props extensions refactor * fix: merge conflicts resolved from preview * chore: init docker compose * chore: pages custom error codes * chore: add health check endpoint to the live server * chore: update without props extensions type * chore: better error handling * chore: update react-hook-form versions --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
- Loading branch information
1 parent
2c60967
commit f001bfa
Showing
61 changed files
with
3,177 additions
and
3,477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ERROR_CODES = { | ||
# issues | ||
"INVALID_ARCHIVE_STATE_GROUP": 4091, | ||
"INVALID_ISSUE_DATES": 4100, | ||
"INVALID_ISSUE_START_DATE": 4101, | ||
"INVALID_ISSUE_TARGET_DATE": 4102, | ||
# pages | ||
"PAGE_LOCKED": 4701, | ||
"PAGE_ARCHIVED": 4702, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
API_BASE_URL="http://api:8000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Use a Node.js base image | ||
FROM node:latest | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY ./channel/package*.json ./ | ||
|
||
# Install dependencies | ||
RUN yarn install | ||
|
||
# COPY ./plane/editor-core ./node_modules/@plane/editor-core | ||
|
||
# Install TypeScript | ||
RUN yarn add typescript | ||
|
||
# Copy the rest of the application | ||
COPY ./channel . | ||
|
||
# Compile TypeScript to JavaScript | ||
RUN npx tsc | ||
|
||
# Expose port 3003 | ||
EXPOSE 3003 | ||
|
||
# Start the Node.js server | ||
CMD ["node", "dist/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:18-alpine | ||
RUN apk add --no-cache libc6-compat | ||
# Set working directory | ||
WORKDIR /app | ||
|
||
|
||
COPY . . | ||
RUN yarn global add turbo | ||
RUN yarn install | ||
EXPOSE 3003 | ||
|
||
VOLUME [ "/app/node_modules", "/app/channel/node_modules"] | ||
CMD ["yarn","dev", "--filter=live"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "live", | ||
"version": "0.22.0", | ||
"description": "", | ||
"main": "./src/index.ts", | ||
"scripts": { | ||
"build": "tsup", | ||
"start": "node dist/index.js", | ||
"dev": "tsup --watch" | ||
}, | ||
"keywords": [], | ||
"type": "module", | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@hocuspocus/extension-database": "^2.11.3", | ||
"@hocuspocus/extension-logger": "^2.11.3", | ||
"@hocuspocus/server": "^2.11.3", | ||
"@plane/editor": "*", | ||
"@plane/types": "*", | ||
"@tiptap/core": "^2.4.0", | ||
"@tiptap/html": "^2.3.0", | ||
"axios": "^1.7.2", | ||
"dotenv": "^16.4.5", | ||
"express": "^4.19.2", | ||
"express-ws": "^5.0.2", | ||
"lodash": "^4.17.21", | ||
"y-prosemirror": "^1.2.9", | ||
"y-protocols": "^1.0.6", | ||
"yjs": "^13.6.14" | ||
}, | ||
"devDependencies": { | ||
"@types/dotenv": "^8.2.0", | ||
"@types/express": "^4.17.21", | ||
"@types/express-ws": "^3.0.4", | ||
"@types/node": "^20.14.9", | ||
"tsup": "^7.2.0", | ||
"nodemon": "^3.1.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ConnectionConfiguration } from "@hocuspocus/server"; | ||
// services | ||
import { UserService } from "./services/user.service.js"; | ||
// types | ||
import { TDocumentTypes } from "./types/common.js"; | ||
const userService = new UserService(); | ||
|
||
type Props = { | ||
connection: ConnectionConfiguration; | ||
cookie: string; | ||
params: URLSearchParams; | ||
token: string; | ||
}; | ||
|
||
export const handleAuthentication = async (props: Props) => { | ||
const { connection, cookie, params, token } = props; | ||
// params | ||
const workspaceSlug = params.get("workspaceSlug")?.toString(); | ||
const projectId = params.get("projectId")?.toString(); | ||
const documentType = params.get("documentType")?.toString() as | ||
| TDocumentTypes | ||
| undefined; | ||
// fetch current user info | ||
let response; | ||
try { | ||
response = await userService.currentUser(cookie); | ||
} catch (error) { | ||
console.error("Failed to fetch current user:", error); | ||
throw error; | ||
} | ||
if (response.id !== token) { | ||
throw Error("Authentication failed: Token doesn't match the current user."); | ||
} | ||
|
||
if (documentType === "project_page") { | ||
if (!workspaceSlug || !projectId) { | ||
throw Error( | ||
"Authentication failed: Incomplete query params. Either workspaceSlug or projectId is missing.", | ||
); | ||
} | ||
// fetch current user's roles | ||
const workspaceRoles = await userService.getUserAllProjectsRole( | ||
workspaceSlug, | ||
cookie, | ||
); | ||
const currentProjectRole = workspaceRoles[projectId]; | ||
// make the connection read only for roles lower than a member | ||
if (currentProjectRole < 15) { | ||
connection.readOnly = true; | ||
} | ||
} else { | ||
throw Error("Authentication failed: Invalid document type provided."); | ||
} | ||
|
||
return { | ||
user: { | ||
id: response.id, | ||
name: response.display_name, | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.