Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Add a core package to be reused by desktop and server

Hakan Shehu8a5409ad2906
diff --git a/apps/desktop/.eslintrc.cjs b/apps/desktop/.eslintrc.cjs
index 63c97794..0af598b9 100644
--- a/apps/desktop/.eslintrc.cjs
+++ b/apps/desktop/.eslintrc.cjs
@@ -4,6 +4,6 @@ module.exports = {
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'@electron-toolkit/eslint-config-ts/recommended',
- '@electron-toolkit/eslint-config-prettier'
- ]
-}
+ '@electron-toolkit/eslint-config-prettier',
+ ],
+};
diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.ts
index aa2fd445..b7d593fa 100644
--- a/apps/desktop/electron.vite.config.ts
+++ b/apps/desktop/electron.vite.config.ts
@@ -4,7 +4,11 @@ import react from '@vitejs/plugin-react';
export default defineConfig({
main: {
- plugins: [externalizeDepsPlugin()],
+ plugins: [
+ externalizeDepsPlugin({
+ exclude: ['@colanode/core'],
+ }),
+ ],
resolve: {
alias: {
'@/main': resolve('src/main'),
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index daa06480..9873c107 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -20,9 +20,9 @@
"build:linux": "electron-vite build && electron-builder --linux"
},
"dependencies": {
+ "@colanode/core": "workspace:*",
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
- "electron-updater": "^6.1.7",
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-alert-dialog": "^1.1.2",
"@radix-ui/react-checkbox": "^1.1.2",
@@ -78,7 +78,7 @@
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"date-fns": "^3.6.0",
- "diff": "^7.0.0",
+ "electron-updater": "^6.1.7",
"form-data": "^4.0.1",
"fractional-indexing-jittered": "^0.9.1",
"is-hotkey": "^0.2.0",
@@ -104,27 +104,9 @@
"tailwindcss-animate": "^1.0.7",
"ts-pattern": "^5.5.0",
"ulid": "^2.3.0",
- "ws": "^8.18.0",
- "yjs": "^13.6.20",
- "zod": "^3.23.8"
+ "ws": "^8.18.0"
},
"devDependencies": {
- "@electron-toolkit/eslint-config-prettier": "^2.0.0",
- "@electron-toolkit/eslint-config-ts": "^2.0.0",
- "@electron-toolkit/tsconfig": "^1.0.1",
- "@types/node": "^20.14.8",
- "@types/react": "^18.3.3",
- "@types/react-dom": "^18.3.0",
- "@vitejs/plugin-react": "^4.3.1",
- "electron": "^31.0.2",
- "electron-builder": "^24.13.3",
- "electron-vite": "^2.3.0",
- "eslint": "^8.57.0",
- "eslint-plugin-react": "^7.34.3",
- "prettier": "^3.3.2",
- "react": "^18.3.1",
- "react-dom": "^18.3.1",
- "vite": "^5.3.1",
"@electron-forge/cli": "^7.5.0",
"@electron-forge/maker-deb": "^7.5.0",
"@electron-forge/maker-rpm": "^7.5.0",
@@ -133,22 +115,38 @@
"@electron-forge/plugin-auto-unpack-natives": "^7.5.0",
"@electron-forge/plugin-fuses": "^7.5.0",
"@electron-forge/plugin-vite": "^7.5.0",
+ "@electron-toolkit/eslint-config-prettier": "^2.0.0",
+ "@electron-toolkit/eslint-config-ts": "^2.0.0",
+ "@electron-toolkit/tsconfig": "^1.0.1",
"@electron/fuses": "^1.8.0",
"@types/better-sqlite3": "^7.6.11",
"@types/diff": "^5.2.3",
"@types/is-hotkey": "^0.1.10",
"@types/lodash": "^4.17.12",
"@types/mime-types": "^2.1.4",
+ "@types/node": "^20.14.8",
+ "@types/react": "^18.3.3",
+ "@types/react-dom": "^18.3.0",
"@types/react-window": "^1.8.8",
"@types/ws": "^8.5.12",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
+ "@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.20",
+ "electron": "^31.0.2",
+ "electron-builder": "^24.13.3",
+ "electron-vite": "^2.3.0",
+ "eslint": "^8.57.0",
"eslint-plugin-import": "^2.31.0",
+ "eslint-plugin-react": "^7.34.3",
"node-abi": "^3.71.0",
"postcss": "^8.4.47",
+ "prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.8",
+ "react": "^18.3.1",
+ "react-dom": "^18.3.1",
"tailwindcss": "^3.4.14",
- "ts-node": "^10.9.2"
+ "ts-node": "^10.9.2",
+ "vite": "^5.3.1"
}
}
diff --git a/apps/desktop/src/lib/databases.ts b/apps/desktop/src/lib/databases.ts
index 56374962..ae343524 100644
--- a/apps/desktop/src/lib/databases.ts
+++ b/apps/desktop/src/lib/databases.ts
@@ -5,7 +5,7 @@ import {
ViewFilterAttributes,
ViewFieldAttributes,
RecordNode,
-} from '@/registry';
+} from '@colanode/core';
import { compareString, isStringArray } from '@/lib/utils';
import { generateNodeIndex } from './nodes';
@@ -576,9 +576,9 @@ const recordMatchesBooleanFilter = (
};
const recordMatchesCollaboratorFilter = (
- record: RecordNode,
- filter: ViewFieldFilterAttributes,
- field: FieldAttributes
+ _: RecordNode,
+ __: ViewFieldFilterAttributes,
+ ___: FieldAttributes
) => {
return false;
};
@@ -739,9 +739,9 @@ const recordMatchesEmailFilter = (
};
const recordMatchesFileFilter = (
- record: RecordNode,
- filter: ViewFieldFilterAttributes,
- field: FieldAttributes
+ _: RecordNode,
+ __: ViewFieldFilterAttributes,
+ ___: FieldAttributes
) => {
return false;
};
diff --git a/apps/desktop/src/lib/editor.ts b/apps/desktop/src/lib/editor.ts
index d9395d0e..7034f568 100644
--- a/apps/desktop/src/lib/editor.ts
+++ b/apps/desktop/src/lib/editor.ts
@@ -3,7 +3,7 @@ import { generateId, getIdTypeFromNode } from '@/lib/id';
import { generateNodeIndex } from '@/lib/nodes';
import { compareString } from '@/lib/utils';
import { JSONContent } from '@tiptap/core';
-import { Block, BlockLeaf } from '@/registry';
+import { Block, BlockLeaf } from '@colanode/core';
const leafBlockTypes = new Set([
EditorNodeTypes.Paragraph,
@@ -17,7 +17,7 @@ const leafBlockTypes = new Set([
export const mapContentsToBlocks = (
parentId: string,
contents: JSONContent[],
- blocksMap: Map<string, Block>,
+ blocksMap: Map<string, Block>
): Block[] => {
const blocks: Block[] = [];
mapAndPushContentsToBlocks(contents, parentId, blocks, blocksMap);
@@ -29,7 +29,7 @@ const mapAndPushContentsToBlocks = (
contents: JSONContent[] | null | undefined,
parentId: string,
blocks: Block[],
- blocksMap: Map<string, Block>,
+ blocksMap: Map<string, Block>
): void => {
if (!contents) {
return;
@@ -43,7 +43,7 @@ const mapAndPushContentToBlock = (
content: JSONContent,
parentId: string,
blocks: Block[],
- blocksMap: Map<string, Block>,
+ blocksMap: Map<string, Block>
): void => {
if (!content.type) {
throw new Error('Invalid content type');
@@ -77,7 +77,7 @@ const mapAndPushContentToBlock = (
const mapContentsToBlockLeafs = (
type: string,
- contents?: JSONContent[],
+ contents?: JSONContent[]
): BlockLeaf[] | null => {
if (!leafBlockTypes.has(type) || contents == null || contents.length === 0) {
return null;
@@ -106,7 +106,7 @@ const mapContentsToBlockLeafs = (
export const mapBlocksToContents = (
parentId: string,
- blocks: Block[],
+ blocks: Block[]
): JSONContent[] => {
const contents: JSONContent[] = [];
const children = blocks
@@ -134,7 +134,7 @@ const mapBlockToContent = (block: Block, blocks: Block[]): JSONContent => {
};
const mapBlockLeafsToContents = (
- leafs: BlockLeaf[] | null,
+ leafs: BlockLeaf[] | null
): JSONContent[] | undefined => {
if (leafs == null) {
return undefined;
diff --git a/apps/desktop/src/lib/nodes.ts b/apps/desktop/src/lib/nodes.ts
index 2551f086..86cbd151 100644
--- a/apps/desktop/src/lib/nodes.ts
+++ b/apps/desktop/src/lib/nodes.ts
@@ -1,11 +1,9 @@
-import { SelectNode } from '@/main/data/workspace/schema';
-import { Node } from '@/registry';
import { generateKeyBetween } from 'fractional-indexing-jittered';
import { NodeTypes } from '@/lib/constants';
export const generateNodeIndex = (
previous?: string | null,
- next?: string | null,
+ next?: string | null
) => {
const lower = previous === undefined ? null : previous;
const upper = next === undefined ? null : next;
@@ -13,24 +11,6 @@ export const generateNodeIndex = (
return generateKeyBetween(lower, upper);
};
-export const mapNode = (row: SelectNode): Node => {
- return {
- id: row.id,
- type: row.type as any,
- index: row.index,
- parentId: row.parent_id,
- attributes: JSON.parse(row.attributes),
- createdAt: row.created_at,
- createdBy: row.created_by,
- updatedAt: row.updated_at,
- updatedBy: row.updated_by,
- versionId: row.version_id,
- serverCreatedAt: row.server_created_at,
- serverUpdatedAt: row.server_updated_at,
- serverVersionId: row.server_version_id,
- };
-};
-
export const getDefaultNodeIcon = (type: string) => {
switch (type) {
case NodeTypes.Channel:
diff --git a/apps/desktop/src/lib/servers.ts b/apps/desktop/src/lib/servers.ts
deleted file mode 100644
index 9dbec835..00000000
--- a/apps/desktop/src/lib/servers.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { SelectServer } from '@/main/data/app/schema';
-import { ServerAttributes } from '@/types/servers';
-
-export const buildSynapseUrl = (server: SelectServer, deviceId: string) => {
- const attributes = JSON.parse(server.attributes) as ServerAttributes;
- const protocol = attributes?.insecure ? 'ws' : 'wss';
- return `${protocol}://${server.domain}/v1/synapse?device_id=${deviceId}`;
-};
diff --git a/apps/desktop/src/main/file-manager.ts b/apps/desktop/src/main/file-manager.ts
index dbd9872a..086c172f 100644
--- a/apps/desktop/src/main/file-manager.ts
+++ b/apps/desktop/src/main/file-manager.ts
@@ -13,7 +13,7 @@ import { databaseManager } from './data/database-manager';
import { httpClient } from '@/lib/http-client';
import { mediator } from '@/main/mediator';
import { getWorkspaceFilesDirectoryPath } from '@/main/utils';
-import { FileAttributes } from '@/registry';
+import { FileAttributes } from '@colanode/core';
class FileManager {
public async handleFileRequest(request: Request): Promise<Response> {
@@ -39,7 +39,7 @@ class FileManager {
filePath: string,
fileId: string,
fileExtension: string,
- userId: string,
+ userId: string
): void {
const filesDir = getWorkspaceFilesDirectoryPath(userId);
@@ -49,7 +49,7 @@ class FileManager {
const destinationFilePath = path.join(
filesDir,
- `${fileId}${fileExtension}`,
+ `${fileId}${fileExtension}`
);
fs.copyFileSync(filePath, destinationFilePath);
}
@@ -88,10 +88,10 @@ class FileManager {
}
public async checkForUploads(
- credentials: WorkspaceCredentials,
+ credentials: WorkspaceCredentials
): Promise<void> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- credentials.userId,
+ credentials.userId
);
const uploads = await workspaceDatabase
@@ -133,7 +133,7 @@ class FileManager {
const attributes: FileAttributes = JSON.parse(file.attributes);
const filePath = path.join(
filesDir,
- `${upload.node_id}${attributes.extension}`,
+ `${upload.node_id}${attributes.extension}`
);
if (!fs.existsSync(filePath)) {
@@ -153,7 +153,7 @@ class FileManager {
serverDomain: credentials.serverDomain,
serverAttributes: credentials.serverAttributes,
token: credentials.token,
- },
+ }
);
const presignedUrl = data.url;
@@ -189,10 +189,10 @@ class FileManager {
}
public async checkForDownloads(
- credentials: WorkspaceCredentials,
+ credentials: WorkspaceCredentials
): Promise<void> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- credentials.userId,
+ credentials.userId
);
const downloads = await workspaceDatabase
@@ -229,7 +229,7 @@ class FileManager {
const attributes: FileAttributes = JSON.parse(file.attributes);
const filePath = path.join(
filesDir,
- `${download.node_id}${attributes.extension}`,
+ `${download.node_id}${attributes.extension}`
);
if (fs.existsSync(filePath)) {
@@ -251,7 +251,7 @@ class FileManager {
serverDomain: credentials.serverDomain,
serverAttributes: credentials.serverAttributes,
token: credentials.token,
- },
+ }
);
const presignedUrl = data.url;
diff --git a/apps/desktop/src/main/handlers/mutations/account-update.ts b/apps/desktop/src/main/handlers/mutations/account-update.ts
index b10362a4..175d206f 100644
--- a/apps/desktop/src/main/handlers/mutations/account-update.ts
+++ b/apps/desktop/src/main/handlers/mutations/account-update.ts
@@ -1,6 +1,6 @@
import { databaseManager } from '@/main/data/database-manager';
import { httpClient } from '@/lib/http-client';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { AccountUpdateOutput } from '@/types/accounts';
import { AccountUpdateMutationInput } from '@/operations/mutations/account-update';
@@ -8,7 +8,7 @@ export class AccountUpdateMutationHandler
implements MutationHandler<AccountUpdateMutationInput>
{
async handleMutation(
- input: AccountUpdateMutationInput,
+ input: AccountUpdateMutationInput
): Promise<MutationResult<AccountUpdateMutationInput>> {
const account = await databaseManager.appDatabase
.selectFrom('accounts')
@@ -40,7 +40,7 @@ export class AccountUpdateMutationHandler
serverDomain: server.domain,
serverAttributes: server.attributes,
token: account.token,
- },
+ }
);
await databaseManager.appDatabase
diff --git a/apps/desktop/src/main/handlers/mutations/avatar-upload.ts b/apps/desktop/src/main/handlers/mutations/avatar-upload.ts
index e3240f16..1ec482be 100644
--- a/apps/desktop/src/main/handlers/mutations/avatar-upload.ts
+++ b/apps/desktop/src/main/handlers/mutations/avatar-upload.ts
@@ -1,7 +1,7 @@
import fs from 'fs';
import FormData from 'form-data';
import { databaseManager } from '@/main/data/database-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { AvatarUploadMutationInput } from '@/operations/mutations/avatar-upload';
import { httpClient } from '@/lib/http-client';
@@ -13,7 +13,7 @@ export class AvatarUploadMutationHandler
implements MutationHandler<AvatarUploadMutationInput>
{
async handleMutation(
- input: AvatarUploadMutationInput,
+ input: AvatarUploadMutationInput
): Promise<MutationResult<AvatarUploadMutationInput>> {
const credentials = await databaseManager.appDatabase
.selectFrom('accounts')
@@ -45,7 +45,7 @@ export class AvatarUploadMutationHandler
serverAttributes: credentials.attributes,
token: credentials.token,
headers: formData.getHeaders(),
- },
+ }
);
return {
diff --git a/apps/desktop/src/main/handlers/mutations/channel-create.ts b/apps/desktop/src/main/handlers/mutations/channel-create.ts
index c2244f87..1216875c 100644
--- a/apps/desktop/src/main/handlers/mutations/channel-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/channel-create.ts
@@ -1,19 +1,19 @@
import { databaseManager } from '@/main/data/database-manager';
import { generateId, IdType } from '@/lib/id';
import { generateNodeIndex } from '@/lib/nodes';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { ChannelCreateMutationInput } from '@/operations/mutations/channel-create';
-import { ChannelAttributes } from '@/registry';
+import { ChannelAttributes } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
export class ChannelCreateMutationHandler
implements MutationHandler<ChannelCreateMutationInput>
{
async handleMutation(
- input: ChannelCreateMutationInput,
+ input: ChannelCreateMutationInput
): Promise<MutationResult<ChannelCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const maxIndexResult = await workspaceDatabase
diff --git a/apps/desktop/src/main/handlers/mutations/chat-create.ts b/apps/desktop/src/main/handlers/mutations/chat-create.ts
index a1d59ff4..03851295 100644
--- a/apps/desktop/src/main/handlers/mutations/chat-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/chat-create.ts
@@ -1,10 +1,10 @@
import { databaseManager } from '@/main/data/database-manager';
import { NodeRole, NodeTypes } from '@/lib/constants';
import { generateId, IdType } from '@/lib/id';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { ChatCreateMutationInput } from '@/operations/mutations/chat-create';
import { sql } from 'kysely';
-import { ChatAttributes } from '@/registry';
+import { ChatAttributes } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
interface ChatRow {
@@ -15,10 +15,10 @@ export class ChatCreateMutationHandler
implements MutationHandler<ChatCreateMutationInput>
{
public async handleMutation(
- input: ChatCreateMutationInput,
+ input: ChatCreateMutationInput
): Promise<MutationResult<ChatCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const query = sql<ChatRow>`
diff --git a/apps/desktop/src/main/handlers/mutations/database-create.ts b/apps/desktop/src/main/handlers/mutations/database-create.ts
index da3b973a..2f98dfd5 100644
--- a/apps/desktop/src/main/handlers/mutations/database-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/database-create.ts
@@ -1,8 +1,8 @@
import { generateId, IdType } from '@/lib/id';
import { generateNodeIndex } from '@/lib/nodes';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { DatabaseCreateMutationInput } from '@/operations/mutations/database-create';
-import { DatabaseAttributes } from '@/registry';
+import { DatabaseAttributes } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
import { databaseManager } from '@/main/data/database-manager';
@@ -10,10 +10,10 @@ export class DatabaseCreateMutationHandler
implements MutationHandler<DatabaseCreateMutationInput>
{
async handleMutation(
- input: DatabaseCreateMutationInput,
+ input: DatabaseCreateMutationInput
): Promise<MutationResult<DatabaseCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const databaseId = generateId(IdType.Database);
diff --git a/apps/desktop/src/main/handlers/mutations/document-save.ts b/apps/desktop/src/main/handlers/mutations/document-save.ts
index 6e43c07b..de688d2e 100644
--- a/apps/desktop/src/main/handlers/mutations/document-save.ts
+++ b/apps/desktop/src/main/handlers/mutations/document-save.ts
@@ -1,14 +1,14 @@
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { DocumentSaveMutationInput } from '@/operations/mutations/document-save';
import { mapContentsToBlocks } from '@/lib/editor';
-import { Block } from '@/registry';
+import { Block } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
export class DocumentSaveMutationHandler
implements MutationHandler<DocumentSaveMutationInput>
{
async handleMutation(
- input: DocumentSaveMutationInput,
+ input: DocumentSaveMutationInput
): Promise<MutationResult<DocumentSaveMutationInput>> {
await nodeManager.updateNode(
input.userId,
@@ -28,7 +28,7 @@ export class DocumentSaveMutationHandler
const blocks = mapContentsToBlocks(
input.documentId,
input.content.content ?? [],
- blocksMap,
+ blocksMap
);
attributes.content = blocks.reduce(
@@ -36,11 +36,11 @@ export class DocumentSaveMutationHandler
acc[block.id] = block;
return acc;
},
- {} as Record<string, Block>,
+ {} as Record<string, Block>
);
return attributes;
- },
+ }
);
return {
diff --git a/apps/desktop/src/main/handlers/mutations/email-login.ts b/apps/desktop/src/main/handlers/mutations/email-login.ts
index bc4c7d0d..b6a2eccd 100644
--- a/apps/desktop/src/main/handlers/mutations/email-login.ts
+++ b/apps/desktop/src/main/handlers/mutations/email-login.ts
@@ -1,18 +1,14 @@
import { LoginOutput } from '@/types/accounts';
import { databaseManager } from '@/main/data/database-manager';
import { EmailLoginMutationInput } from '@/operations/mutations/email-login';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
import { httpClient } from '@/lib/http-client';
export class EmailLoginMutationHandler
implements MutationHandler<EmailLoginMutationInput>
{
async handleMutation(
- input: EmailLoginMutationInput,
+ input: EmailLoginMutationInput
): Promise<MutationResult<EmailLoginMutationInput>> {
const server = await databaseManager.appDatabase
.selectFrom('servers')
@@ -37,7 +33,7 @@ export class EmailLoginMutationHandler
{
serverDomain: server.domain,
serverAttributes: server.attributes,
- },
+ }
);
const changedTables: MutationChange[] = [];
@@ -77,7 +73,7 @@ export class EmailLoginMutationHandler
description: workspace.description,
user_id: workspace.user.id,
version_id: workspace.versionId,
- })),
+ }))
)
.execute();
@@ -89,7 +85,7 @@ export class EmailLoginMutationHandler
for (const workspace of data.workspaces) {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- workspace.user.id,
+ workspace.user.id
);
const user = workspace.user.node;
diff --git a/apps/desktop/src/main/handlers/mutations/email-register.ts b/apps/desktop/src/main/handlers/mutations/email-register.ts
index ccc6fed3..73f441b2 100644
--- a/apps/desktop/src/main/handlers/mutations/email-register.ts
+++ b/apps/desktop/src/main/handlers/mutations/email-register.ts
@@ -2,17 +2,13 @@ import { LoginOutput } from '@/types/accounts';
import { databaseManager } from '@/main/data/database-manager';
import { httpClient } from '@/lib/http-client';
import { EmailRegisterMutationInput } from '@/operations/mutations/email-register';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
export class EmailRegisterMutationHandler
implements MutationHandler<EmailRegisterMutationInput>
{
handleMutation = async (
- input: EmailRegisterMutationInput,
+ input: EmailRegisterMutationInput
): Promise<MutationResult<EmailRegisterMutationInput>> => {
const server = await databaseManager.appDatabase
.selectFrom('servers')
@@ -38,7 +34,7 @@ export class EmailRegisterMutationHandler
{
serverDomain: server.domain,
serverAttributes: server.attributes,
- },
+ }
);
const changedTables: MutationChange[] = [];
@@ -78,7 +74,7 @@ export class EmailRegisterMutationHandler
description: workspace.description,
user_id: workspace.user.id,
version_id: workspace.versionId,
- })),
+ }))
)
.execute();
@@ -90,7 +86,7 @@ export class EmailRegisterMutationHandler
for (const workspace of data.workspaces) {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- workspace.user.id,
+ workspace.user.id
);
const user = workspace.user.node;
diff --git a/apps/desktop/src/main/handlers/mutations/field-create.ts b/apps/desktop/src/main/handlers/mutations/field-create.ts
index 03179af6..82d421cf 100644
--- a/apps/desktop/src/main/handlers/mutations/field-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/field-create.ts
@@ -1,7 +1,7 @@
import { generateId, IdType } from '@/lib/id';
import { generateNodeIndex } from '@/lib/nodes';
import { compareString } from '@/lib/utils';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { FieldCreateMutationInput } from '@/operations/mutations/field-create';
import { nodeManager } from '@/main/node-manager';
@@ -9,7 +9,7 @@ export class FieldCreateMutationHandler
implements MutationHandler<FieldCreateMutationInput>
{
async handleMutation(
- input: FieldCreateMutationInput,
+ input: FieldCreateMutationInput
): Promise<MutationResult<FieldCreateMutationInput>> {
const fieldId = generateId(IdType.Field);
await nodeManager.updateNode(
@@ -34,7 +34,7 @@ export class FieldCreateMutationHandler
};
return attributes;
- },
+ }
);
return {
diff --git a/apps/desktop/src/main/handlers/mutations/file-create.ts b/apps/desktop/src/main/handlers/mutations/file-create.ts
index 10d3b20c..f5753e24 100644
--- a/apps/desktop/src/main/handlers/mutations/file-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/file-create.ts
@@ -1,18 +1,18 @@
import { databaseManager } from '@/main/data/database-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { generateId, IdType } from '@/lib/id';
import { FileCreateMutationInput } from '@/operations/mutations/file-create';
import { fileManager } from '@/main/file-manager';
-import { FileAttributes } from '@/registry';
+import { FileAttributes } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
export class FileCreateMutationHandler
implements MutationHandler<FileCreateMutationInput>
{
async handleMutation(
- input: FileCreateMutationInput,
+ input: FileCreateMutationInput
): Promise<MutationResult<FileCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const metadata = fileManager.getFileMetadata(input.filePath);
@@ -25,7 +25,7 @@ export class FileCreateMutationHandler
input.filePath,
id,
metadata.extension,
- input.userId,
+ input.userId
);
const attributes: FileAttributes = {
diff --git a/apps/desktop/src/main/handlers/mutations/file-download.ts b/apps/desktop/src/main/handlers/mutations/file-download.ts
index 1a926a63..16c8a47d 100644
--- a/apps/desktop/src/main/handlers/mutations/file-download.ts
+++ b/apps/desktop/src/main/handlers/mutations/file-download.ts
@@ -1,15 +1,15 @@
import { databaseManager } from '@/main/data/database-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { FileDownloadMutationInput } from '@/operations/mutations/file-download';
export class FileDownloadMutationHandler
implements MutationHandler<FileDownloadMutationInput>
{
async handleMutation(
- input: FileDownloadMutationInput,
+ input: FileDownloadMutationInput
): Promise<MutationResult<FileDownloadMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const node = await workspaceDatabase
diff --git a/apps/desktop/src/main/handlers/mutations/folder-create.ts b/apps/desktop/src/main/handlers/mutations/folder-create.ts
index 0fcae96c..cb0a8b91 100644
--- a/apps/desktop/src/main/handlers/mutations/folder-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/folder-create.ts
@@ -1,7 +1,7 @@
import { generateId, IdType } from '@/lib/id';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { FolderCreateMutationInput } from '@/operations/mutations/folder-create';
-import { FolderAttributes } from '@/registry';
+import { FolderAttributes } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
import { databaseManager } from '@/main/data/database-manager';
@@ -9,10 +9,10 @@ export class FolderCreateMutationHandler
implements MutationHandler<FolderCreateMutationInput>
{
async handleMutation(
- input: FolderCreateMutationInput,
+ input: FolderCreateMutationInput
): Promise<MutationResult<FolderCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const attributes: FolderAttributes = {
diff --git a/apps/desktop/src/main/handlers/mutations/index.ts b/apps/desktop/src/main/handlers/mutations/index.ts
index 66c70d2e..5f3b9270 100644
--- a/apps/desktop/src/main/handlers/mutations/index.ts
+++ b/apps/desktop/src/main/handlers/mutations/index.ts
@@ -1,4 +1,5 @@
-import { MutationHandler, MutationMap } from '@/operations/mutations';
+import { MutationMap } from '@/operations/mutations';
+import { MutationHandler } from '@/main/types';
import { EmailLoginMutationHandler } from '@/main/handlers/mutations/email-login';
import { EmailRegisterMutationHandler } from '@/main/handlers/mutations/email-register';
import { ViewCreateMutationHandler } from '@/main/handlers/mutations/view-create';
diff --git a/apps/desktop/src/main/handlers/mutations/logout.ts b/apps/desktop/src/main/handlers/mutations/logout.ts
index db223f3c..78128207 100644
--- a/apps/desktop/src/main/handlers/mutations/logout.ts
+++ b/apps/desktop/src/main/handlers/mutations/logout.ts
@@ -1,7 +1,7 @@
import fs from 'fs';
import { databaseManager } from '@/main/data/database-manager';
import { LogoutMutationInput } from '@/operations/mutations/logout';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import {
getAccountAvatarsDirectoryPath,
getWorkspaceDirectoryPath,
@@ -11,7 +11,7 @@ export class LogoutMutationHandler
implements MutationHandler<LogoutMutationInput>
{
async handleMutation(
- input: LogoutMutationInput,
+ input: LogoutMutationInput
): Promise<MutationResult<LogoutMutationInput>> {
const account = await databaseManager.appDatabase
.selectFrom('accounts')
diff --git a/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.ts b/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.ts
index 17a3457b..69973470 100644
--- a/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.ts
+++ b/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.ts
@@ -1,6 +1,6 @@
import { generateId, IdType } from '@/lib/id';
import { databaseManager } from '@/main/data/database-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { MarkNodeAsSeenMutationInput } from '@/operations/mutations/mark-node-as-seen';
import { LocalUserNodeChangeData } from '@/types/sync';
@@ -8,10 +8,10 @@ export class MarkNodeAsSeenMutationHandler
implements MutationHandler<MarkNodeAsSeenMutationInput>
{
async handleMutation(
- input: MarkNodeAsSeenMutationInput,
+ input: MarkNodeAsSeenMutationInput
): Promise<MutationResult<MarkNodeAsSeenMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const changeData: LocalUserNodeChangeData = {
diff --git a/apps/desktop/src/main/handlers/mutations/message-create.ts b/apps/desktop/src/main/handlers/mutations/message-create.ts
index d8f71765..5d1abd47 100644
--- a/apps/desktop/src/main/handlers/mutations/message-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/message-create.ts
@@ -2,27 +2,27 @@ import * as Y from 'yjs';
import { databaseManager } from '@/main/data/database-manager';
import { EditorNodeTypes, NodeTypes } from '@/lib/constants';
import { generateId, IdType } from '@/lib/id';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
import { MessageCreateMutationInput } from '@/operations/mutations/message-create';
import { mapContentsToBlocks } from '@/lib/editor';
import { fileManager } from '@/main/file-manager';
import { CreateDownload, CreateUpload } from '@/main/data/workspace/schema';
-import { NodeAttributes } from '@/registry';
-import { Block, FileAttributes, MessageAttributes } from '@/registry';
+import {
+ NodeAttributes,
+ Block,
+ FileAttributes,
+ MessageAttributes,
+} from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
export class MessageCreateMutationHandler
implements MutationHandler<MessageCreateMutationInput>
{
async handleMutation(
- input: MessageCreateMutationInput,
+ input: MessageCreateMutationInput
): Promise<MutationResult<MessageCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const nodeAttributes: NodeAttributes[] = [];
@@ -34,7 +34,7 @@ export class MessageCreateMutationHandler
const blocks = mapContentsToBlocks(
messageId,
input.content.content ?? [],
- new Map(),
+ new Map()
);
// check if there are nested nodes (files, pages, folders etc.)
@@ -56,7 +56,7 @@ export class MessageCreateMutationHandler
path,
fileId,
metadata.extension,
- input.userId,
+ input.userId
);
const fileDoc = new Y.Doc({
@@ -110,7 +110,7 @@ export class MessageCreateMutationHandler
acc[block.id] = block;
return acc;
},
- {} as Record<string, Block>,
+ {} as Record<string, Block>
),
reactions: {},
};
@@ -123,7 +123,7 @@ export class MessageCreateMutationHandler
trx,
input.userId,
messageId,
- nodeAttribute,
+ nodeAttribute
);
}
diff --git a/apps/desktop/src/main/handlers/mutations/node-attribute-delete.ts b/apps/desktop/src/main/handlers/mutations/node-attribute-delete.ts
index 8da46114..ba9539c9 100644
--- a/apps/desktop/src/main/handlers/mutations/node-attribute-delete.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-attribute-delete.ts
@@ -1,4 +1,4 @@
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { NodeAttributeDeleteMutationInput } from '@/operations/mutations/node-attribute-delete';
import { nodeManager } from '@/main/node-manager';
import { unset } from 'lodash';
@@ -7,7 +7,7 @@ export class NodeAttributeDeleteMutationHandler
implements MutationHandler<NodeAttributeDeleteMutationInput>
{
async handleMutation(
- input: NodeAttributeDeleteMutationInput,
+ input: NodeAttributeDeleteMutationInput
): Promise<MutationResult<NodeAttributeDeleteMutationInput>> {
await nodeManager.updateNode(input.userId, input.nodeId, (attributes) => {
unset(attributes, input.path);
diff --git a/apps/desktop/src/main/handlers/mutations/node-attribute-set.ts b/apps/desktop/src/main/handlers/mutations/node-attribute-set.ts
index af09e2f0..f2c84b43 100644
--- a/apps/desktop/src/main/handlers/mutations/node-attribute-set.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-attribute-set.ts
@@ -1,4 +1,4 @@
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { NodeAttributeSetMutationInput } from '@/operations/mutations/node-attribute-set';
import { nodeManager } from '@/main/node-manager';
import { set } from 'lodash';
@@ -7,7 +7,7 @@ export class NodeAttributeSetMutationHandler
implements MutationHandler<NodeAttributeSetMutationInput>
{
async handleMutation(
- input: NodeAttributeSetMutationInput,
+ input: NodeAttributeSetMutationInput
): Promise<MutationResult<NodeAttributeSetMutationInput>> {
await nodeManager.updateNode(input.userId, input.nodeId, (attributes) => {
set(attributes, input.path, input.value);
diff --git a/apps/desktop/src/main/handlers/mutations/node-collaborator-create.ts b/apps/desktop/src/main/handlers/mutations/node-collaborator-create.ts
index 4243247c..c907b67c 100644
--- a/apps/desktop/src/main/handlers/mutations/node-collaborator-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-collaborator-create.ts
@@ -1,4 +1,4 @@
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { NodeCollaboratorCreateMutationInput } from '@/operations/mutations/node-collaborator-create';
import { nodeManager } from '@/main/node-manager';
import { set } from 'lodash';
@@ -7,7 +7,7 @@ export class NodeCollaboratorCreateMutationHandler
implements MutationHandler<NodeCollaboratorCreateMutationInput>
{
async handleMutation(
- input: NodeCollaboratorCreateMutationInput,
+ input: NodeCollaboratorCreateMutationInput
): Promise<MutationResult<NodeCollaboratorCreateMutationInput>> {
await nodeManager.updateNode(input.userId, input.nodeId, (attributes) => {
for (const collaboratorId of input.collaboratorIds) {
diff --git a/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.ts b/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.ts
index 8339ed8f..e33e5d83 100644
--- a/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.ts
@@ -1,5 +1,5 @@
import { nodeManager } from '@/main/node-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { NodeCollaboratorDeleteMutationInput } from '@/operations/mutations/node-collaborator-delete';
import { unset } from 'lodash';
@@ -7,7 +7,7 @@ export class NodeCollaboratorDeleteMutationHandler
implements MutationHandler<NodeCollaboratorDeleteMutationInput>
{
async handleMutation(
- input: NodeCollaboratorDeleteMutationInput,
+ input: NodeCollaboratorDeleteMutationInput
): Promise<MutationResult<NodeCollaboratorDeleteMutationInput>> {
await nodeManager.updateNode(input.userId, input.nodeId, (attributes) => {
unset(attributes, `collaborators.${input.collaboratorId}`);
diff --git a/apps/desktop/src/main/handlers/mutations/node-collaborator-update.ts b/apps/desktop/src/main/handlers/mutations/node-collaborator-update.ts
index 2b8777f5..ef1f3a18 100644
--- a/apps/desktop/src/main/handlers/mutations/node-collaborator-update.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-collaborator-update.ts
@@ -1,5 +1,5 @@
import { nodeManager } from '@/main/node-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { NodeCollaboratorUpdateMutationInput } from '@/operations/mutations/node-collaborator-update';
import { set } from 'lodash';
@@ -7,7 +7,7 @@ export class NodeCollaboratorUpdateMutationHandler
implements MutationHandler<NodeCollaboratorUpdateMutationInput>
{
async handleMutation(
- input: NodeCollaboratorUpdateMutationInput,
+ input: NodeCollaboratorUpdateMutationInput
): Promise<MutationResult<NodeCollaboratorUpdateMutationInput>> {
await nodeManager.updateNode(input.userId, input.nodeId, (attributes) => {
set(attributes, `collaborators.${input.collaboratorId}`, input.role);
diff --git a/apps/desktop/src/main/handlers/mutations/node-delete.ts b/apps/desktop/src/main/handlers/mutations/node-delete.ts
index 64e0345a..3dbea9bc 100644
--- a/apps/desktop/src/main/handlers/mutations/node-delete.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-delete.ts
@@ -1,11 +1,7 @@
import { NodeTypes } from '@/lib/constants';
import { databaseManager } from '@/main/data/database-manager';
import { fileManager } from '@/main/file-manager';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
import { NodeDeleteMutationInput } from '@/operations/mutations/node-delete';
import { LocalDeleteNodeChangeData } from '@/types/sync';
@@ -13,10 +9,10 @@ export class NodeDeleteMutationHandler
implements MutationHandler<NodeDeleteMutationInput>
{
async handleMutation(
- input: NodeDeleteMutationInput,
+ input: NodeDeleteMutationInput
): Promise<MutationResult<NodeDeleteMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const node = await workspaceDatabase
diff --git a/apps/desktop/src/main/handlers/mutations/node-reaction-create.ts b/apps/desktop/src/main/handlers/mutations/node-reaction-create.ts
index 60d8fba0..c971b218 100644
--- a/apps/desktop/src/main/handlers/mutations/node-reaction-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-reaction-create.ts
@@ -1,12 +1,12 @@
import { nodeManager } from '@/main/node-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { NodeReactionCreateMutationInput } from '@/operations/mutations/node-reaction-create';
export class NodeReactionCreateMutationHandler
implements MutationHandler<NodeReactionCreateMutationInput>
{
async handleMutation(
- input: NodeReactionCreateMutationInput,
+ input: NodeReactionCreateMutationInput
): Promise<MutationResult<NodeReactionCreateMutationInput>> {
await nodeManager.updateNode(input.userId, input.nodeId, (attributes) => {
if (attributes.type !== 'message') {
diff --git a/apps/desktop/src/main/handlers/mutations/node-reaction-delete.ts b/apps/desktop/src/main/handlers/mutations/node-reaction-delete.ts
index 43a5f014..0462a025 100644
--- a/apps/desktop/src/main/handlers/mutations/node-reaction-delete.ts
+++ b/apps/desktop/src/main/handlers/mutations/node-reaction-delete.ts
@@ -1,12 +1,12 @@
import { nodeManager } from '@/main/node-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { NodeReactionDeleteMutationInput } from '@/operations/mutations/node-reaction-delete';
export class NodeReactionDeleteMutationHandler
implements MutationHandler<NodeReactionDeleteMutationInput>
{
async handleMutation(
- input: NodeReactionDeleteMutationInput,
+ input: NodeReactionDeleteMutationInput
): Promise<MutationResult<NodeReactionDeleteMutationInput>> {
await nodeManager.updateNode(input.userId, input.nodeId, (attributes) => {
if (attributes.type !== 'message') {
diff --git a/apps/desktop/src/main/handlers/mutations/page-create.ts b/apps/desktop/src/main/handlers/mutations/page-create.ts
index 8fdb39c3..64f0d3c3 100644
--- a/apps/desktop/src/main/handlers/mutations/page-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/page-create.ts
@@ -1,18 +1,18 @@
import { databaseManager } from '@/main/data/database-manager';
import { generateId, IdType } from '@/lib/id';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { PageCreateMutationInput } from '@/operations/mutations/page-create';
-import { PageAttributes } from '@/registry';
+import { PageAttributes } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
export class PageCreateMutationHandler
implements MutationHandler<PageCreateMutationInput>
{
async handleMutation(
- input: PageCreateMutationInput,
+ input: PageCreateMutationInput
): Promise<MutationResult<PageCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const id = generateId(IdType.Page);
diff --git a/apps/desktop/src/main/handlers/mutations/record-create.ts b/apps/desktop/src/main/handlers/mutations/record-create.ts
index b1f30800..19a3e873 100644
--- a/apps/desktop/src/main/handlers/mutations/record-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/record-create.ts
@@ -1,18 +1,18 @@
import { databaseManager } from '@/main/data/database-manager';
import { generateId, IdType } from '@/lib/id';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { RecordCreateMutationInput } from '@/operations/mutations/record-create';
-import { RecordAttributes } from '@/registry';
+import { RecordAttributes } from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
export class RecordCreateMutationHandler
implements MutationHandler<RecordCreateMutationInput>
{
async handleMutation(
- input: RecordCreateMutationInput,
+ input: RecordCreateMutationInput
): Promise<MutationResult<RecordCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const id = generateId(IdType.Record);
diff --git a/apps/desktop/src/main/handlers/mutations/select-option-create.ts b/apps/desktop/src/main/handlers/mutations/select-option-create.ts
index 82df1929..885afe26 100644
--- a/apps/desktop/src/main/handlers/mutations/select-option-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/select-option-create.ts
@@ -1,6 +1,6 @@
import { generateId, IdType } from '@/lib/id';
import { generateNodeIndex } from '@/lib/nodes';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { SelectOptionCreateMutationInput } from '@/operations/mutations/select-option-create';
import { compareString } from '@/lib/utils';
import { nodeManager } from '@/main/node-manager';
@@ -9,7 +9,7 @@ export class SelectOptionCreateMutationHandler
implements MutationHandler<SelectOptionCreateMutationInput>
{
async handleMutation(
- input: SelectOptionCreateMutationInput,
+ input: SelectOptionCreateMutationInput
): Promise<MutationResult<SelectOptionCreateMutationInput>> {
const id = generateId(IdType.SelectOption);
await nodeManager.updateNode(
@@ -48,7 +48,7 @@ export class SelectOptionCreateMutationHandler
};
return attributes;
- },
+ }
);
return {
diff --git a/apps/desktop/src/main/handlers/mutations/server-create.ts b/apps/desktop/src/main/handlers/mutations/server-create.ts
index b6cc4a51..4c95adf0 100644
--- a/apps/desktop/src/main/handlers/mutations/server-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/server-create.ts
@@ -1,6 +1,6 @@
import axios from 'axios';
import { databaseManager } from '@/main/data/database-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { ServerCreateMutationInput } from '@/operations/mutations/server-create';
import { ServerConfig } from '@/types/servers';
@@ -8,10 +8,10 @@ export class ServerCreateMutationHandler
implements MutationHandler<ServerCreateMutationInput>
{
async handleMutation(
- input: ServerCreateMutationInput,
+ input: ServerCreateMutationInput
): Promise<MutationResult<ServerCreateMutationInput>> {
const { data } = await axios.get<ServerConfig>(
- `http://${input.domain}/v1/config`,
+ `http://${input.domain}/v1/config`
);
await databaseManager.appDatabase
diff --git a/apps/desktop/src/main/handlers/mutations/server-node-delete.ts b/apps/desktop/src/main/handlers/mutations/server-node-delete.ts
index 08effa17..3da839cf 100644
--- a/apps/desktop/src/main/handlers/mutations/server-node-delete.ts
+++ b/apps/desktop/src/main/handlers/mutations/server-node-delete.ts
@@ -1,17 +1,13 @@
import { databaseManager } from '@/main/data/database-manager';
import { socketManager } from '@/main/sockets/socket-manager';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
import { ServerNodeDeleteMutationInput } from '@/operations/mutations/server-node-delete';
export class ServerNodeDeleteMutationHandler
implements MutationHandler<ServerNodeDeleteMutationInput>
{
public async handleMutation(
- input: ServerNodeDeleteMutationInput,
+ input: ServerNodeDeleteMutationInput
): Promise<MutationResult<ServerNodeDeleteMutationInput>> {
const changes: MutationChange[] = [];
@@ -22,7 +18,7 @@ export class ServerNodeDeleteMutationHandler
eb.and([
eb('account_id', '=', input.accountId),
eb('workspace_id', '=', input.workspaceId),
- ]),
+ ])
)
.executeTakeFirst();
diff --git a/apps/desktop/src/main/handlers/mutations/server-node-sync.ts b/apps/desktop/src/main/handlers/mutations/server-node-sync.ts
index c8afb04f..1267ce12 100644
--- a/apps/desktop/src/main/handlers/mutations/server-node-sync.ts
+++ b/apps/desktop/src/main/handlers/mutations/server-node-sync.ts
@@ -1,7 +1,7 @@
import { databaseManager } from '@/main/data/database-manager';
import { socketManager } from '@/main/sockets/socket-manager';
import { hasInsertChanges, hasUpdateChanges } from '@/main/utils';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { ServerNodeSyncMutationInput } from '@/operations/mutations/server-node-sync';
import { toUint8Array } from 'js-base64';
import * as Y from 'yjs';
@@ -10,7 +10,7 @@ export class ServerNodeSyncMutationHandler
implements MutationHandler<ServerNodeSyncMutationInput>
{
public async handleMutation(
- input: ServerNodeSyncMutationInput,
+ input: ServerNodeSyncMutationInput
): Promise<MutationResult<ServerNodeSyncMutationInput>> {
const workspace = await databaseManager.appDatabase
.selectFrom('workspaces')
@@ -19,7 +19,7 @@ export class ServerNodeSyncMutationHandler
eb.and([
eb('account_id', '=', input.accountId),
eb('workspace_id', '=', input.workspaceId),
- ]),
+ ])
)
.executeTakeFirst();
diff --git a/apps/desktop/src/main/handlers/mutations/server-user-node-sync.ts b/apps/desktop/src/main/handlers/mutations/server-user-node-sync.ts
index 7530362f..7ebc4d07 100644
--- a/apps/desktop/src/main/handlers/mutations/server-user-node-sync.ts
+++ b/apps/desktop/src/main/handlers/mutations/server-user-node-sync.ts
@@ -1,13 +1,13 @@
import { databaseManager } from '@/main/data/database-manager';
import { socketManager } from '@/main/sockets/socket-manager';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { ServerUserNodeSyncMutationInput } from '@/operations/mutations/server-user-node-sync';
export class ServerUserNodeSyncMutationHandler
implements MutationHandler<ServerUserNodeSyncMutationInput>
{
public async handleMutation(
- input: ServerUserNodeSyncMutationInput,
+ input: ServerUserNodeSyncMutationInput
): Promise<MutationResult<ServerUserNodeSyncMutationInput>> {
const workspace = await databaseManager.appDatabase
.selectFrom('workspaces')
@@ -16,7 +16,7 @@ export class ServerUserNodeSyncMutationHandler
eb.and([
eb('account_id', '=', input.accountId),
eb('workspace_id', '=', input.workspaceId),
- ]),
+ ])
)
.executeTakeFirst();
@@ -51,7 +51,7 @@ export class ServerUserNodeSyncMutationHandler
mentions_count: input.mentionsCount,
updated_at: input.updatedAt,
version_id: input.versionId,
- }),
+ })
)
.execute();
diff --git a/apps/desktop/src/main/handlers/mutations/space-create.ts b/apps/desktop/src/main/handlers/mutations/space-create.ts
index 7f5ccf33..5011e24c 100644
--- a/apps/desktop/src/main/handlers/mutations/space-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/space-create.ts
@@ -1,20 +1,24 @@
import { databaseManager } from '@/main/data/database-manager';
import { generateId, IdType } from '@/lib/id';
import { generateNodeIndex } from '@/lib/nodes';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { SpaceCreateMutationInput } from '@/operations/mutations/space-create';
import { NodeRole } from '@/lib/constants';
-import { ChannelAttributes, PageAttributes, SpaceAttributes } from '@/registry';
+import {
+ ChannelAttributes,
+ PageAttributes,
+ SpaceAttributes,
+} from '@colanode/core';
import { nodeManager } from '@/main/node-manager';
export class SpaceCreateMutationHandler
implements MutationHandler<SpaceCreateMutationInput>
{
async handleMutation(
- input: SpaceCreateMutationInput,
+ input: SpaceCreateMutationInput
): Promise<MutationResult<SpaceCreateMutationInput>> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const spaceId = generateId(IdType.Space);
@@ -53,7 +57,7 @@ export class SpaceCreateMutationHandler
trx,
input.userId,
channelId,
- channelAttributes,
+ channelAttributes
);
});
diff --git a/apps/desktop/src/main/handlers/mutations/space-update.ts b/apps/desktop/src/main/handlers/mutations/space-update.ts
index fb4bc249..de10273b 100644
--- a/apps/desktop/src/main/handlers/mutations/space-update.ts
+++ b/apps/desktop/src/main/handlers/mutations/space-update.ts
@@ -1,4 +1,4 @@
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { SpaceUpdateMutationInput } from '@/operations/mutations/space-update';
import { nodeManager } from '@/main/node-manager';
@@ -6,7 +6,7 @@ export class SpaceUpdateMutationHandler
implements MutationHandler<SpaceUpdateMutationInput>
{
async handleMutation(
- input: SpaceUpdateMutationInput,
+ input: SpaceUpdateMutationInput
): Promise<MutationResult<SpaceUpdateMutationInput>> {
await nodeManager.updateNode(input.userId, input.id, (attributes) => {
if (attributes.type !== 'space') {
diff --git a/apps/desktop/src/main/handlers/mutations/view-create.ts b/apps/desktop/src/main/handlers/mutations/view-create.ts
index 54b64e37..5757cfc0 100644
--- a/apps/desktop/src/main/handlers/mutations/view-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/view-create.ts
@@ -1,5 +1,5 @@
import { generateId, IdType } from '@/lib/id';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { ViewCreateMutationInput } from '@/operations/mutations/view-create';
import { compareString } from '@/lib/utils';
import { generateNodeIndex } from '@/lib/nodes';
@@ -9,7 +9,7 @@ export class ViewCreateMutationHandler
implements MutationHandler<ViewCreateMutationInput>
{
async handleMutation(
- input: ViewCreateMutationInput,
+ input: ViewCreateMutationInput
): Promise<MutationResult<ViewCreateMutationInput>> {
const id = generateId(IdType.View);
await nodeManager.updateNode(
@@ -37,7 +37,7 @@ export class ViewCreateMutationHandler
};
return attributes;
- },
+ }
);
return {
diff --git a/apps/desktop/src/main/handlers/mutations/view-delete.ts b/apps/desktop/src/main/handlers/mutations/view-delete.ts
index d197b62b..9088c233 100644
--- a/apps/desktop/src/main/handlers/mutations/view-delete.ts
+++ b/apps/desktop/src/main/handlers/mutations/view-delete.ts
@@ -1,4 +1,4 @@
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { nodeManager } from '@/main/node-manager';
import { ViewDeleteMutationInput } from '@/operations/mutations/view-delete';
@@ -6,7 +6,7 @@ export class ViewDeleteMutationHandler
implements MutationHandler<ViewDeleteMutationInput>
{
async handleMutation(
- input: ViewDeleteMutationInput,
+ input: ViewDeleteMutationInput
): Promise<MutationResult<ViewDeleteMutationInput>> {
await nodeManager.updateNode(
input.userId,
@@ -18,7 +18,7 @@ export class ViewDeleteMutationHandler
delete attributes.views[input.viewId];
return attributes;
- },
+ }
);
return {
diff --git a/apps/desktop/src/main/handlers/mutations/view-update.ts b/apps/desktop/src/main/handlers/mutations/view-update.ts
index f7bfccf5..0e087ddb 100644
--- a/apps/desktop/src/main/handlers/mutations/view-update.ts
+++ b/apps/desktop/src/main/handlers/mutations/view-update.ts
@@ -1,4 +1,4 @@
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { nodeManager } from '@/main/node-manager';
import { ViewUpdateMutationInput } from '@/operations/mutations/view-update';
@@ -6,7 +6,7 @@ export class ViewUpdateMutationHandler
implements MutationHandler<ViewUpdateMutationInput>
{
async handleMutation(
- input: ViewUpdateMutationInput,
+ input: ViewUpdateMutationInput
): Promise<MutationResult<ViewUpdateMutationInput>> {
await nodeManager.updateNode(
input.userId,
@@ -18,7 +18,7 @@ export class ViewUpdateMutationHandler
attributes.views[input.view.id] = input.view;
return attributes;
- },
+ }
);
return {
diff --git a/apps/desktop/src/main/handlers/mutations/workspace-create.ts b/apps/desktop/src/main/handlers/mutations/workspace-create.ts
index abc38d01..ce515fac 100644
--- a/apps/desktop/src/main/handlers/mutations/workspace-create.ts
+++ b/apps/desktop/src/main/handlers/mutations/workspace-create.ts
@@ -1,14 +1,14 @@
import { databaseManager } from '@/main/data/database-manager';
import { httpClient } from '@/lib/http-client';
import { WorkspaceCreateMutationInput } from '@/operations/mutations/workspace-create';
-import { MutationHandler, MutationResult } from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { WorkspaceOutput } from '@/types/workspaces';
export class WorkspaceCreateMutationHandler
implements MutationHandler<WorkspaceCreateMutationInput>
{
async handleMutation(
- input: WorkspaceCreateMutationInput,
+ input: WorkspaceCreateMutationInput
): Promise<MutationResult<WorkspaceCreateMutationInput>> {
const account = await databaseManager.appDatabase
.selectFrom('accounts')
@@ -41,7 +41,7 @@ export class WorkspaceCreateMutationHandler
serverDomain: server.domain,
serverAttributes: server.attributes,
token: account.token,
- },
+ }
);
await databaseManager.appDatabase
@@ -60,7 +60,7 @@ export class WorkspaceCreateMutationHandler
.execute();
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- data.user.id,
+ data.user.id
);
const user = data.user.node;
diff --git a/apps/desktop/src/main/handlers/mutations/workspace-update.ts b/apps/desktop/src/main/handlers/mutations/workspace-update.ts
index 192f388f..69de3fb1 100644
--- a/apps/desktop/src/main/handlers/mutations/workspace-update.ts
+++ b/apps/desktop/src/main/handlers/mutations/workspace-update.ts
@@ -1,18 +1,14 @@
import { databaseManager } from '@/main/data/database-manager';
import { httpClient } from '@/lib/http-client';
import { WorkspaceUpdateMutationInput } from '@/operations/mutations/workspace-update';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationHandler, MutationResult } from '@/main/types';
import { Workspace } from '@/types/workspaces';
export class WorkspaceUpdateMutationHandler
implements MutationHandler<WorkspaceUpdateMutationInput>
{
async handleMutation(
- input: WorkspaceUpdateMutationInput,
+ input: WorkspaceUpdateMutationInput
): Promise<MutationResult<WorkspaceUpdateMutationInput>> {
const account = await databaseManager.appDatabase
.selectFrom('accounts')
@@ -45,7 +41,7 @@ export class WorkspaceUpdateMutationHandler
serverDomain: server.domain,
serverAttributes: server.attributes,
token: account.token,
- },
+ }
);
await databaseManager.appDatabase
@@ -61,7 +57,7 @@ export class WorkspaceUpdateMutationHandler
eb.and([
eb('account_id', '=', input.accountId),
eb('workspace_id', '=', input.id),
- ]),
+ ])
)
.execute();
diff --git a/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.ts b/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.ts
index d058e1aa..2d73dc6b 100644
--- a/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.ts
+++ b/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.ts
@@ -1,18 +1,14 @@
import { databaseManager } from '@/main/data/database-manager';
import { httpClient } from '@/lib/http-client';
import { WorkspaceUserRoleUpdateMutationInput } from '@/operations/mutations/workspace-user-role-update';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
import { WorkspaceUserRoleUpdateOutput } from '@/types/workspaces';
export class WorkspaceUserRoleUpdateMutationHandler
implements MutationHandler<WorkspaceUserRoleUpdateMutationInput>
{
async handleMutation(
- input: WorkspaceUserRoleUpdateMutationInput,
+ input: WorkspaceUserRoleUpdateMutationInput
): Promise<MutationResult<WorkspaceUserRoleUpdateMutationInput>> {
const workspace = await databaseManager.appDatabase
.selectFrom('workspaces')
@@ -65,11 +61,11 @@ export class WorkspaceUserRoleUpdateMutationHandler
serverDomain: server.domain,
serverAttributes: server.attributes,
token: account.token,
- },
+ }
);
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
await workspaceDatabase
diff --git a/apps/desktop/src/main/handlers/mutations/workspace-users-invite.ts b/apps/desktop/src/main/handlers/mutations/workspace-users-invite.ts
index 5b8459c0..29880108 100644
--- a/apps/desktop/src/main/handlers/mutations/workspace-users-invite.ts
+++ b/apps/desktop/src/main/handlers/mutations/workspace-users-invite.ts
@@ -1,11 +1,7 @@
import { databaseManager } from '@/main/data/database-manager';
import { httpClient } from '@/lib/http-client';
import { WorkspaceUsersInviteMutationInput } from '@/operations/mutations/workspace-users-invite';
-import {
- MutationChange,
- MutationHandler,
- MutationResult,
-} from '@/operations/mutations';
+import { MutationChange, MutationHandler, MutationResult } from '@/main/types';
import { WorkspaceUsersInviteOutput } from '@/types/workspaces';
import { CreateNode } from '@/main/data/workspace/schema';
@@ -13,7 +9,7 @@ export class WorkspaceUsersInviteMutationHandler
implements MutationHandler<WorkspaceUsersInviteMutationInput>
{
async handleMutation(
- input: WorkspaceUsersInviteMutationInput,
+ input: WorkspaceUsersInviteMutationInput
): Promise<MutationResult<WorkspaceUsersInviteMutationInput>> {
const workspace = await databaseManager.appDatabase
.selectFrom('workspaces')
@@ -66,11 +62,11 @@ export class WorkspaceUsersInviteMutationHandler
serverDomain: server.domain,
serverAttributes: server.attributes,
token: account.token,
- },
+ }
);
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const usersToCreate: CreateNode[] = data.users.map((user) => {
diff --git a/apps/desktop/src/main/handlers/queries/accounts-list.ts b/apps/desktop/src/main/handlers/queries/accounts-list.ts
index c466b3ba..2a6e12ad 100644
--- a/apps/desktop/src/main/handlers/queries/accounts-list.ts
+++ b/apps/desktop/src/main/handlers/queries/accounts-list.ts
@@ -1,20 +1,20 @@
import { AccountListQueryInput } from '@/operations/queries/account-list';
import { databaseManager } from '@/main/data/database-manager';
import { Account } from '@/types/accounts';
+import { SelectAccount } from '@/main/data/app/schema';
+import { isEqual } from 'lodash';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { SelectAccount } from '@/main/data/app/schema';
-import { isEqual } from 'lodash';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
export class AccountListQueryHandler
implements QueryHandler<AccountListQueryInput>
{
public async handleQuery(
- _: AccountListQueryInput,
+ _: AccountListQueryInput
): Promise<QueryResult<AccountListQueryInput>> {
const rows = await this.fetchAccounts();
return {
@@ -28,11 +28,11 @@ export class AccountListQueryHandler
public async checkForChanges(
changes: MutationChange[],
_: AccountListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<AccountListQueryInput>> {
if (
!changes.some(
- (change) => change.type === 'app' && change.table === 'accounts',
+ (change) => change.type === 'app' && change.table === 'accounts'
)
) {
return {
diff --git a/apps/desktop/src/main/handlers/queries/breadcrumb-list.ts b/apps/desktop/src/main/handlers/queries/breadcrumb-list.ts
index 7cf54a62..ebb4248e 100644
--- a/apps/desktop/src/main/handlers/queries/breadcrumb-list.ts
+++ b/apps/desktop/src/main/handlers/queries/breadcrumb-list.ts
@@ -1,22 +1,22 @@
import { BreadcrumbListQueryInput } from '@/operations/queries/breadcrumb-list';
import { databaseManager } from '@/main/data/database-manager';
-import {
- ChangeCheckResult,
- QueryHandler,
- QueryResult,
-} from '@/operations/queries';
import { sql } from 'kysely';
import { SelectNode } from '@/main/data/workspace/schema';
import { BreadcrumbNode } from '@/types/workspaces';
-import { mapNode } from '@/lib/nodes';
+import { mapNode } from '@/main/utils';
import { isEqual } from 'lodash';
-import { MutationChange } from '@/operations/mutations';
+import {
+ MutationChange,
+ ChangeCheckResult,
+ QueryHandler,
+ QueryResult,
+} from '@/main/types';
export class BreadcrumbListQueryHandler
implements QueryHandler<BreadcrumbListQueryInput>
{
public async handleQuery(
- input: BreadcrumbListQueryInput,
+ input: BreadcrumbListQueryInput
): Promise<QueryResult<BreadcrumbListQueryInput>> {
const rows = await this.fetchNodes(input);
return {
@@ -30,14 +30,14 @@ export class BreadcrumbListQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: BreadcrumbListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<BreadcrumbListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -64,10 +64,10 @@ export class BreadcrumbListQueryHandler
}
private async fetchNodes(
- input: BreadcrumbListQueryInput,
+ input: BreadcrumbListQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const query = sql<SelectNode>`
@@ -90,7 +90,7 @@ export class BreadcrumbListQueryHandler
private buildBreadcrumbNodes = (
nodeId: string,
- rows: SelectNode[],
+ rows: SelectNode[]
): BreadcrumbNode[] => {
const breadcrumbNodes: BreadcrumbNode[] = [];
diff --git a/apps/desktop/src/main/handlers/queries/chat-get.ts b/apps/desktop/src/main/handlers/queries/chat-get.ts
index e7e7536f..9d59ad02 100644
--- a/apps/desktop/src/main/handlers/queries/chat-get.ts
+++ b/apps/desktop/src/main/handlers/queries/chat-get.ts
@@ -1,19 +1,19 @@
import { ChatGetQueryInput } from '@/operations/queries/chat-get';
import { databaseManager } from '@/main/data/database-manager';
+import { mapNode } from '@/main/utils';
+import { SelectNode } from '@/main/data/workspace/schema';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { mapNode } from '@/lib/nodes';
-import { SelectNode } from '@/main/data/workspace/schema';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { isEqual } from 'lodash';
import { ChatNode } from '@/types/chats';
export class ChatGetQueryHandler implements QueryHandler<ChatGetQueryInput> {
async handleQuery(
- input: ChatGetQueryInput,
+ input: ChatGetQueryInput
): Promise<QueryResult<ChatGetQueryInput>> {
const chat = await this.fetchChat(input);
if (!chat) {
@@ -36,14 +36,14 @@ export class ChatGetQueryHandler implements QueryHandler<ChatGetQueryInput> {
async checkForChanges(
changes: MutationChange[],
input: ChatGetQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<ChatGetQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -86,10 +86,10 @@ export class ChatGetQueryHandler implements QueryHandler<ChatGetQueryInput> {
}
private async fetchChat(
- input: ChatGetQueryInput,
+ input: ChatGetQueryInput
): Promise<SelectNode | null> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const chat = await workspaceDatabase
@@ -103,10 +103,10 @@ export class ChatGetQueryHandler implements QueryHandler<ChatGetQueryInput> {
private async fetchCollaborators(
input: ChatGetQueryInput,
- chat: SelectNode,
+ chat: SelectNode
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
if (!chat.attributes) {
@@ -144,7 +144,7 @@ export class ChatGetQueryHandler implements QueryHandler<ChatGetQueryInput> {
private buildChat = (
chat: SelectNode,
- collaborators: SelectNode[],
+ collaborators: SelectNode[]
): ChatNode | null => {
const collaborator = mapNode(collaborators[0]);
if (collaborator.attributes.type !== 'user') {
diff --git a/apps/desktop/src/main/handlers/queries/document-get.ts b/apps/desktop/src/main/handlers/queries/document-get.ts
index 77e61223..340d8fda 100644
--- a/apps/desktop/src/main/handlers/queries/document-get.ts
+++ b/apps/desktop/src/main/handlers/queries/document-get.ts
@@ -5,22 +5,21 @@ import {
DocumentGetQueryOutput,
} from '@/operations/queries/document-get';
import { databaseManager } from '@/main/data/database-manager';
+import { SelectNode } from '@/main/data/workspace/schema';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-
-import { SelectNode } from '@/main/data/workspace/schema';
-import { MutationChange } from '@/operations/mutations';
-import { NodeAttributes } from '@/registry';
+} from '@/main/types';
+import { NodeAttributes } from '@colanode/core';
import { mapBlocksToContents } from '@/lib/editor';
export class DocumentGetQueryHandler
implements QueryHandler<DocumentGetQueryInput>
{
public async handleQuery(
- input: DocumentGetQueryInput,
+ input: DocumentGetQueryInput
): Promise<QueryResult<DocumentGetQueryInput>> {
const document = await this.fetchDocument(input);
return {
@@ -34,14 +33,14 @@ export class DocumentGetQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: DocumentGetQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<DocumentGetQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -68,10 +67,10 @@ export class DocumentGetQueryHandler
}
private async fetchDocument(
- input: DocumentGetQueryInput,
+ input: DocumentGetQueryInput
): Promise<SelectNode | undefined> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
return workspaceDatabase
@@ -82,7 +81,7 @@ export class DocumentGetQueryHandler
}
private buildOutput(
- document: SelectNode | null | undefined,
+ document: SelectNode | null | undefined
): DocumentGetQueryOutput {
if (!document) {
return {
diff --git a/apps/desktop/src/main/handlers/queries/file-get.ts b/apps/desktop/src/main/handlers/queries/file-get.ts
index 0f70db0e..09f843e6 100644
--- a/apps/desktop/src/main/handlers/queries/file-get.ts
+++ b/apps/desktop/src/main/handlers/queries/file-get.ts
@@ -1,11 +1,11 @@
import { FileGetQueryInput } from '@/operations/queries/file-get';
import { databaseManager } from '@/main/data/database-manager';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { isEqual } from 'lodash';
import { FileDetails } from '@/types/files';
@@ -22,7 +22,7 @@ interface FileRow {
export class FileGetQueryHandler implements QueryHandler<FileGetQueryInput> {
public async handleQuery(
- input: FileGetQueryInput,
+ input: FileGetQueryInput
): Promise<QueryResult<FileGetQueryInput>> {
const row = await this.fetchFile(input);
@@ -37,14 +37,14 @@ export class FileGetQueryHandler implements QueryHandler<FileGetQueryInput> {
public async checkForChanges(
changes: MutationChange[],
input: FileGetQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<FileGetQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
(change.table === 'nodes' || change.table === 'downloads') &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -71,19 +71,19 @@ export class FileGetQueryHandler implements QueryHandler<FileGetQueryInput> {
}
private async fetchFile(
- input: FileGetQueryInput,
+ input: FileGetQueryInput
): Promise<FileRow | undefined> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const row = await workspaceDatabase
.selectFrom('nodes as file')
.leftJoin('downloads as file_downloads', (join) =>
- join.onRef('file.id', '=', 'file_downloads.node_id'),
+ join.onRef('file.id', '=', 'file_downloads.node_id')
)
.leftJoin('nodes as created_by', (join) =>
- join.onRef('file.created_by', '=', 'created_by.id'),
+ join.onRef('file.created_by', '=', 'created_by.id')
)
.select([
'file.id',
diff --git a/apps/desktop/src/main/handlers/queries/file-list.ts b/apps/desktop/src/main/handlers/queries/file-list.ts
index 720b2fde..6810ee85 100644
--- a/apps/desktop/src/main/handlers/queries/file-list.ts
+++ b/apps/desktop/src/main/handlers/queries/file-list.ts
@@ -1,11 +1,11 @@
import { FileListQueryInput } from '@/operations/queries/file-list';
import { databaseManager } from '@/main/data/database-manager';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { NodeTypes } from '@/lib/constants';
import { compareString } from '@/lib/utils';
import { isEqual } from 'lodash';
@@ -23,7 +23,7 @@ interface FileRow {
export class FileListQueryHandler implements QueryHandler<FileListQueryInput> {
public async handleQuery(
- input: FileListQueryInput,
+ input: FileListQueryInput
): Promise<QueryResult<FileListQueryInput>> {
const files = await this.fetchFiles(input);
@@ -38,14 +38,14 @@ export class FileListQueryHandler implements QueryHandler<FileListQueryInput> {
public async checkForChanges(
changes: MutationChange[],
input: FileListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<FileListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
(change.table === 'nodes' || change.table === 'downloads') &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -73,14 +73,14 @@ export class FileListQueryHandler implements QueryHandler<FileListQueryInput> {
private async fetchFiles(input: FileListQueryInput): Promise<FileRow[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const offset = input.page * input.count;
const files = await workspaceDatabase
.selectFrom('nodes')
.leftJoin('downloads', (join) =>
- join.onRef('nodes.id', '=', 'downloads.node_id'),
+ join.onRef('nodes.id', '=', 'downloads.node_id')
)
.select([
'nodes.id',
@@ -95,7 +95,7 @@ export class FileListQueryHandler implements QueryHandler<FileListQueryInput> {
eb.and([
eb('parent_id', '=', input.parentId),
eb('type', '=', NodeTypes.File),
- ]),
+ ])
)
.orderBy('id', 'asc')
.limit(input.count)
diff --git a/apps/desktop/src/main/handlers/queries/index.ts b/apps/desktop/src/main/handlers/queries/index.ts
index ada23149..773c7af8 100644
--- a/apps/desktop/src/main/handlers/queries/index.ts
+++ b/apps/desktop/src/main/handlers/queries/index.ts
@@ -1,4 +1,5 @@
-import { QueryHandler, QueryMap } from '@/operations/queries';
+import { QueryMap } from '@/operations/queries';
+import { QueryHandler } from '@/main/types';
import { AccountListQueryHandler } from '@/main/handlers/queries/accounts-list';
import { BreadcrumbListQueryHandler } from '@/main/handlers/queries/breadcrumb-list';
import { MessageListQueryHandler } from '@/main/handlers/queries/message-list';
diff --git a/apps/desktop/src/main/handlers/queries/message-list.ts b/apps/desktop/src/main/handlers/queries/message-list.ts
index ab98bbdd..5ec54c96 100644
--- a/apps/desktop/src/main/handlers/queries/message-list.ts
+++ b/apps/desktop/src/main/handlers/queries/message-list.ts
@@ -1,15 +1,15 @@
import { MessageListQueryInput } from '@/operations/queries/message-list';
import { databaseManager } from '@/main/data/database-manager';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { SelectNode } from '@/main/data/workspace/schema';
import { NodeTypes } from '@/lib/constants';
import { MessageNode, MessageReactionCount } from '@/types/messages';
-import { mapNode } from '@/lib/nodes';
+import { mapNode } from '@/main/utils';
import { UserNode } from '@/types/users';
import { compareString } from '@/lib/utils';
import { isEqual } from 'lodash';
@@ -19,7 +19,7 @@ export class MessageListQueryHandler
implements QueryHandler<MessageListQueryInput>
{
public async handleQuery(
- input: MessageListQueryInput,
+ input: MessageListQueryInput
): Promise<QueryResult<MessageListQueryInput>> {
const messages = await this.fetchMesssages(input);
const authors = await this.fetchAuthors(input, messages);
@@ -36,14 +36,14 @@ export class MessageListQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: MessageListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<MessageListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -73,10 +73,10 @@ export class MessageListQueryHandler
}
private async fetchMesssages(
- input: MessageListQueryInput,
+ input: MessageListQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const offset = input.page * input.count;
@@ -87,7 +87,7 @@ export class MessageListQueryHandler
eb.and([
eb('parent_id', '=', input.conversationId),
eb('type', '=', NodeTypes.Message),
- ]),
+ ])
)
.orderBy('id', 'desc')
.limit(input.count)
@@ -99,14 +99,14 @@ export class MessageListQueryHandler
private async fetchAuthors(
input: MessageListQueryInput,
- messages: SelectNode[],
+ messages: SelectNode[]
): Promise<SelectNode[]> {
if (messages.length === 0) {
return [];
}
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const authorIds = messages.map((message) => message.created_by);
@@ -122,7 +122,7 @@ export class MessageListQueryHandler
private buildMessages = (
userId: string,
messageRows: SelectNode[],
- authorRows: SelectNode[],
+ authorRows: SelectNode[]
): MessageNode[] => {
const messages: MessageNode[] = [];
const authorMap = new Map<string, UserNode>();
@@ -174,7 +174,7 @@ export class MessageListQueryHandler
},
content: mapBlocksToContents(
messageNode.id,
- Object.values(messageNode.attributes.content ?? {}),
+ Object.values(messageNode.attributes.content ?? {})
),
reactionCounts,
};
diff --git a/apps/desktop/src/main/handlers/queries/node-collaborator-list.ts b/apps/desktop/src/main/handlers/queries/node-collaborator-list.ts
index c3a21507..8977b6f6 100644
--- a/apps/desktop/src/main/handlers/queries/node-collaborator-list.ts
+++ b/apps/desktop/src/main/handlers/queries/node-collaborator-list.ts
@@ -1,17 +1,17 @@
import { NodeCollaboratorListQueryInput } from '@/operations/queries/node-collaborator-list';
import { databaseManager } from '@/main/data/database-manager';
-import {
- ChangeCheckResult,
- QueryHandler,
- QueryResult,
-} from '@/operations/queries';
import {
InheritNodeCollaboratorsGroup,
NodeCollaboratorsWrapper,
NodeCollaborator,
} from '@/types/nodes';
-import { NodeAttributes } from '@/registry';
-import { MutationChange } from '@/operations/mutations';
+import { NodeAttributes } from '@colanode/core';
+import {
+ MutationChange,
+ ChangeCheckResult,
+ QueryHandler,
+ QueryResult,
+} from '@/main/types';
import { isEqual } from 'lodash';
type ExtractedNodeCollaborator = {
@@ -29,17 +29,17 @@ export class NodeCollaboratorListQueryHandler
implements QueryHandler<NodeCollaboratorListQueryInput>
{
public async handleQuery(
- input: NodeCollaboratorListQueryInput,
+ input: NodeCollaboratorListQueryInput
): Promise<QueryResult<NodeCollaboratorListQueryInput>> {
const ancestors = await this.fetchAncestors(input);
const extractedCollaborators = this.extractCollaborators(ancestors);
const collaboratorIds = extractedCollaborators.map(
- (collaborator) => collaborator.collaboratorId,
+ (collaborator) => collaborator.collaboratorId
);
const collaboratorNodes = await this.fetchCollaborators(
input,
- collaboratorIds,
+ collaboratorIds
);
return {
@@ -47,7 +47,7 @@ export class NodeCollaboratorListQueryHandler
input.nodeId,
ancestors,
collaboratorNodes,
- extractedCollaborators,
+ extractedCollaborators
),
state: {
ancestors,
@@ -60,14 +60,14 @@ export class NodeCollaboratorListQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: NodeCollaboratorListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<NodeCollaboratorListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -78,12 +78,12 @@ export class NodeCollaboratorListQueryHandler
const ancestors = await this.fetchAncestors(input);
const extractedCollaborators = this.extractCollaborators(ancestors);
const collaboratorIds = extractedCollaborators.map(
- (collaborator) => collaborator.collaboratorId,
+ (collaborator) => collaborator.collaboratorId
);
const collaboratorNodes = await this.fetchCollaborators(
input,
- collaboratorIds,
+ collaboratorIds
);
if (
@@ -103,7 +103,7 @@ export class NodeCollaboratorListQueryHandler
input.nodeId,
ancestors,
collaboratorNodes,
- extractedCollaborators,
+ extractedCollaborators
),
state: {
ancestors,
@@ -115,10 +115,10 @@ export class NodeCollaboratorListQueryHandler
}
private async fetchAncestors(
- input: NodeCollaboratorListQueryInput,
+ input: NodeCollaboratorListQueryInput
): Promise<NodeWithAttributesRow[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const result = await workspaceDatabase
@@ -133,7 +133,7 @@ export class NodeCollaboratorListQueryHandler
}
private extractCollaborators(
- nodes: NodeWithAttributesRow[],
+ nodes: NodeWithAttributesRow[]
): ExtractedNodeCollaborator[] {
const map: Map<string, ExtractedNodeCollaborator> = new Map();
@@ -170,14 +170,14 @@ export class NodeCollaboratorListQueryHandler
private async fetchCollaborators(
input: NodeCollaboratorListQueryInput,
- collaboratorIds: string[],
+ collaboratorIds: string[]
): Promise<NodeWithAttributesRow[]> {
if (collaboratorIds.length === 0) {
return [];
}
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const result = await workspaceDatabase
@@ -193,7 +193,7 @@ export class NodeCollaboratorListQueryHandler
nodeId: string,
ancestors: NodeWithAttributesRow[],
collaboratorNodes: NodeWithAttributesRow[],
- extractedCollaborators: ExtractedNodeCollaborator[],
+ extractedCollaborators: ExtractedNodeCollaborator[]
): NodeCollaboratorsWrapper => {
const direct: NodeCollaborator[] = [];
const inherit: InheritNodeCollaboratorsGroup[] = [];
@@ -202,7 +202,7 @@ export class NodeCollaboratorListQueryHandler
for (const extractedCollaborator of extractedCollaborators) {
const collaboratorNode = collaboratorNodes.find(
- (row) => row.id === extractedCollaborator.collaboratorId,
+ (row) => row.id === extractedCollaborator.collaboratorId
);
if (!collaboratorNode) {
diff --git a/apps/desktop/src/main/handlers/queries/node-collaborator-search.ts b/apps/desktop/src/main/handlers/queries/node-collaborator-search.ts
index 97f78445..631a38b0 100644
--- a/apps/desktop/src/main/handlers/queries/node-collaborator-search.ts
+++ b/apps/desktop/src/main/handlers/queries/node-collaborator-search.ts
@@ -1,22 +1,22 @@
import { NodeCollaboratorSearchQueryInput } from '@/operations/queries/node-collaborator-search';
import { databaseManager } from '@/main/data/database-manager';
-import {
- ChangeCheckResult,
- QueryHandler,
- QueryResult,
-} from '@/operations/queries';
import { sql } from 'kysely';
import { SelectNode } from '@/main/data/workspace/schema';
import { NodeTypes } from '@/lib/constants';
import { NodeCollaborator } from '@/types/nodes';
-import { MutationChange } from '@/operations/mutations';
+import {
+ MutationChange,
+ ChangeCheckResult,
+ QueryHandler,
+ QueryResult,
+} from '@/main/types';
import { isEqual } from 'lodash';
export class NodeCollaboratorSearchQueryHandler
implements QueryHandler<NodeCollaboratorSearchQueryInput>
{
public async handleQuery(
- input: NodeCollaboratorSearchQueryInput,
+ input: NodeCollaboratorSearchQueryInput
): Promise<QueryResult<NodeCollaboratorSearchQueryInput>> {
if (input.searchQuery.length === 0) {
return {
@@ -39,14 +39,14 @@ export class NodeCollaboratorSearchQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: NodeCollaboratorSearchQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<NodeCollaboratorSearchQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -73,14 +73,14 @@ export class NodeCollaboratorSearchQueryHandler
}
private async fetchNodes(
- input: NodeCollaboratorSearchQueryInput,
+ input: NodeCollaboratorSearchQueryInput
): Promise<SelectNode[]> {
if (input.searchQuery.length === 0) {
return [];
}
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const query = sql<SelectNode>`
@@ -93,7 +93,7 @@ export class NodeCollaboratorSearchQueryHandler
input.excluded.length > 0
? sql`AND n.id NOT IN (${sql.join(
input.excluded.map((id) => sql`${id}`),
- sql`, `,
+ sql`, `
)})`
: sql``
}
diff --git a/apps/desktop/src/main/handlers/queries/node-get.ts b/apps/desktop/src/main/handlers/queries/node-get.ts
index d59330ad..c0bdb340 100644
--- a/apps/desktop/src/main/handlers/queries/node-get.ts
+++ b/apps/desktop/src/main/handlers/queries/node-get.ts
@@ -1,18 +1,18 @@
import { NodeGetQueryInput } from '@/operations/queries/node-get';
import { databaseManager } from '@/main/data/database-manager';
+import { mapNode } from '@/main/utils';
+import { SelectNode } from '@/main/data/workspace/schema';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { mapNode } from '@/lib/nodes';
-import { SelectNode } from '@/main/data/workspace/schema';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { isEqual } from 'lodash';
export class NodeGetQueryHandler implements QueryHandler<NodeGetQueryInput> {
public async handleQuery(
- input: NodeGetQueryInput,
+ input: NodeGetQueryInput
): Promise<QueryResult<NodeGetQueryInput>> {
const row = await this.fetchNode(input);
@@ -27,14 +27,14 @@ export class NodeGetQueryHandler implements QueryHandler<NodeGetQueryInput> {
public async checkForChanges(
changes: MutationChange[],
input: NodeGetQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<NodeGetQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -61,10 +61,10 @@ export class NodeGetQueryHandler implements QueryHandler<NodeGetQueryInput> {
}
private async fetchNode(
- input: NodeGetQueryInput,
+ input: NodeGetQueryInput
): Promise<SelectNode | undefined> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const row = await workspaceDatabase
diff --git a/apps/desktop/src/main/handlers/queries/record-list.ts b/apps/desktop/src/main/handlers/queries/record-list.ts
index ed612cfc..df84c933 100644
--- a/apps/desktop/src/main/handlers/queries/record-list.ts
+++ b/apps/desktop/src/main/handlers/queries/record-list.ts
@@ -1,11 +1,11 @@
import { RecordListQueryInput } from '@/operations/queries/record-list';
import { databaseManager } from '@/main/data/database-manager';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { SelectNode } from '@/main/data/workspace/schema';
import { sql } from 'kysely';
import {
@@ -25,9 +25,9 @@ import {
ViewSortAttributes,
DatabaseNode,
RecordNode,
-} from '@/registry';
+} from '@colanode/core';
import { isStringArray } from '@/lib/utils';
-import { mapNode } from '@/lib/nodes';
+import { mapNode } from '@/main/utils';
import { NodeTypes } from '@/lib/constants';
import { isEqual } from 'lodash';
@@ -35,7 +35,7 @@ export class RecordListQueryHandler
implements QueryHandler<RecordListQueryInput>
{
public async handleQuery(
- input: RecordListQueryInput,
+ input: RecordListQueryInput
): Promise<QueryResult<RecordListQueryInput>> {
const rows = await this.fetchRecords(input);
@@ -50,14 +50,14 @@ export class RecordListQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: RecordListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<RecordListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -84,16 +84,16 @@ export class RecordListQueryHandler
}
private async fetchRecords(
- input: RecordListQueryInput,
+ input: RecordListQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const database = await this.fetchDatabase(input.userId, input.databaseId);
const filterQuery = this.buildFiltersQuery(
input.filters,
- database.attributes.fields,
+ database.attributes.fields
);
const orderByQuery = `ORDER BY ${input.sorts.length > 0 ? this.buildSortOrdersQuery(input.sorts, database.attributes.fields) : 'n."index" ASC'}`;
@@ -143,7 +143,7 @@ export class RecordListQueryHandler
private async fetchDatabase(
userId: string,
- databaseId: string,
+ databaseId: string
): Promise<DatabaseNode> {
const workspaceDatabase =
await databaseManager.getWorkspaceDatabase(userId);
@@ -164,7 +164,7 @@ export class RecordListQueryHandler
private buildFiltersQuery = (
filters: ViewFilterAttributes[],
- fields: Record<string, FieldAttributes>,
+ fields: Record<string, FieldAttributes>
): string => {
if (filters.length === 0) {
return '';
@@ -183,7 +183,7 @@ export class RecordListQueryHandler
private buildFilterQuery = (
filter: ViewFilterAttributes,
- fields: Record<string, FieldAttributes>,
+ fields: Record<string, FieldAttributes>
): string | null => {
if (filter.type === 'group') {
return null;
@@ -228,7 +228,7 @@ export class RecordListQueryHandler
buildBooleanFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: BooleanFieldAttributes,
+ field: BooleanFieldAttributes
): string | null => {
if (filter.operator === 'is_true') {
return `json_extract(n.attributes, '$.fields.${field.id}.value') = true`;
@@ -243,7 +243,7 @@ export class RecordListQueryHandler
private buildNumberFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: NumberFieldAttributes,
+ field: NumberFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return this.buildIsEmptyFilterQuery(field.id);
@@ -296,7 +296,7 @@ export class RecordListQueryHandler
private buildTextFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: TextFieldAttributes,
+ field: TextFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return this.buildIsEmptyFilterQuery(field.id);
@@ -354,7 +354,7 @@ export class RecordListQueryHandler
private buildEmailFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: EmailFieldAttributes,
+ field: EmailFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return this.buildIsEmptyFilterQuery(field.id);
@@ -412,7 +412,7 @@ export class RecordListQueryHandler
private buildPhoneFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: PhoneFieldAttributes,
+ field: PhoneFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return this.buildIsEmptyFilterQuery(field.id);
@@ -470,7 +470,7 @@ export class RecordListQueryHandler
private buildUrlFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: UrlFieldAttributes,
+ field: UrlFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return this.buildIsEmptyFilterQuery(field.id);
@@ -528,7 +528,7 @@ export class RecordListQueryHandler
private buildSelectFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: SelectFieldAttributes,
+ field: SelectFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return this.buildIsEmptyFilterQuery(field.id);
@@ -559,7 +559,7 @@ export class RecordListQueryHandler
private buildMultiSelectFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: MultiSelectFieldAttributes,
+ field: MultiSelectFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return `json_extract(n.attributes, '$.fields.${field.id}.value') IS NULL OR json_array_length(json_extract(n.attributes, '$.fields.${field.id}.value')) = 0`;
@@ -590,7 +590,7 @@ export class RecordListQueryHandler
private buildDateFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: DateFieldAttributes,
+ field: DateFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return this.buildIsEmptyFilterQuery(field.id);
@@ -648,7 +648,7 @@ export class RecordListQueryHandler
private buildCreatedAtFilterQuery = (
filter: ViewFieldFilterAttributes,
- field: CreatedAtFieldAttributes,
+ _: CreatedAtFieldAttributes
): string | null => {
if (filter.operator === 'is_empty') {
return `n.created_at IS NULL`;
@@ -718,7 +718,7 @@ export class RecordListQueryHandler
private buildSortOrdersQuery = (
sorts: ViewSortAttributes[],
- fields: Record<string, FieldAttributes>,
+ fields: Record<string, FieldAttributes>
): string => {
return sorts
.map((sort) => this.buildSortOrderQuery(sort, fields))
@@ -728,7 +728,7 @@ export class RecordListQueryHandler
private buildSortOrderQuery = (
sort: ViewSortAttributes,
- fields: Record<string, FieldAttributes>,
+ fields: Record<string, FieldAttributes>
): string | null => {
const field = fields[sort.fieldId];
if (!field) {
diff --git a/apps/desktop/src/main/handlers/queries/server-list.ts b/apps/desktop/src/main/handlers/queries/server-list.ts
index 5deb3d7f..e95b2c28 100644
--- a/apps/desktop/src/main/handlers/queries/server-list.ts
+++ b/apps/desktop/src/main/handlers/queries/server-list.ts
@@ -1,12 +1,12 @@
import { ServerListQueryInput } from '@/operations/queries/server-list';
import { databaseManager } from '@/main/data/database-manager';
+import { SelectServer } from '@/main/data/app/schema';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { SelectServer } from '@/main/data/app/schema';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { isEqual } from 'lodash';
import { Server } from '@/types/servers';
@@ -14,7 +14,7 @@ export class ServerListQueryHandler
implements QueryHandler<ServerListQueryInput>
{
async handleQuery(
- _: ServerListQueryInput,
+ _: ServerListQueryInput
): Promise<QueryResult<ServerListQueryInput>> {
const rows = await this.fetchServers();
return {
@@ -28,11 +28,11 @@ export class ServerListQueryHandler
async checkForChanges(
changes: MutationChange[],
_: ServerListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<ServerListQueryInput>> {
if (
!changes.some(
- (change) => change.type === 'app' && change.table === 'servers',
+ (change) => change.type === 'app' && change.table === 'servers'
)
) {
return {
diff --git a/apps/desktop/src/main/handlers/queries/sidebar-chat-list.ts b/apps/desktop/src/main/handlers/queries/sidebar-chat-list.ts
index c7d11e7c..77cc624a 100644
--- a/apps/desktop/src/main/handlers/queries/sidebar-chat-list.ts
+++ b/apps/desktop/src/main/handlers/queries/sidebar-chat-list.ts
@@ -1,15 +1,15 @@
import { SidebarChatListQueryInput } from '@/operations/queries/sidebar-chat-list';
import { databaseManager } from '@/main/data/database-manager';
+import { SelectNode } from '@/main/data/workspace/schema';
+import { NodeTypes } from '@/lib/constants';
+import { SidebarChatNode } from '@/types/workspaces';
+import { mapNode } from '@/main/utils';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { SelectNode } from '@/main/data/workspace/schema';
-import { NodeTypes } from '@/lib/constants';
-import { SidebarChatNode } from '@/types/workspaces';
-import { mapNode } from '@/lib/nodes';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { isEqual } from 'lodash';
interface UnreadCountRow {
@@ -22,7 +22,7 @@ export class SidebarChatListQueryHandler
implements QueryHandler<SidebarChatListQueryInput>
{
public async handleQuery(
- input: SidebarChatListQueryInput,
+ input: SidebarChatListQueryInput
): Promise<QueryResult<SidebarChatListQueryInput>> {
const chats = await this.fetchChats(input);
const collaborators = await this.fetchChatCollaborators(input, chats);
@@ -33,7 +33,7 @@ export class SidebarChatListQueryHandler
input.userId,
chats,
collaborators,
- unreadCounts,
+ unreadCounts
),
state: {
chats,
@@ -46,14 +46,14 @@ export class SidebarChatListQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: SidebarChatListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<SidebarChatListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
(change.table === 'nodes' || change.table === 'user_nodes') &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -82,7 +82,7 @@ export class SidebarChatListQueryHandler
input.userId,
chats,
collaborators,
- unreadCounts,
+ unreadCounts
),
state: {
chats,
@@ -94,10 +94,10 @@ export class SidebarChatListQueryHandler
}
private async fetchChats(
- input: SidebarChatListQueryInput,
+ input: SidebarChatListQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const chats = await workspaceDatabase
@@ -111,10 +111,10 @@ export class SidebarChatListQueryHandler
private async fetchChatCollaborators(
input: SidebarChatListQueryInput,
- chats: SelectNode[],
+ chats: SelectNode[]
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const collaboratorIds: string[] = [];
@@ -149,10 +149,10 @@ export class SidebarChatListQueryHandler
private async fetchUnreadCounts(
input: SidebarChatListQueryInput,
- chats: SelectNode[],
+ chats: SelectNode[]
): Promise<UnreadCountRow[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const chatIds = chats.map((chat) => chat.id);
@@ -178,7 +178,7 @@ export class SidebarChatListQueryHandler
userId: string,
chats: SelectNode[],
collaborators: SelectNode[],
- unreadCounts: UnreadCountRow[],
+ unreadCounts: UnreadCountRow[]
): SidebarChatNode[] => {
const sidebarChatNodes: SidebarChatNode[] = [];
@@ -204,7 +204,7 @@ export class SidebarChatListQueryHandler
}
const collaboratorRow = collaborators.find(
- (r) => r.id === collaboratorId,
+ (r) => r.id === collaboratorId
);
if (!collaboratorRow) {
diff --git a/apps/desktop/src/main/handlers/queries/sidebar-space-list.ts b/apps/desktop/src/main/handlers/queries/sidebar-space-list.ts
index c7353318..6bafbf79 100644
--- a/apps/desktop/src/main/handlers/queries/sidebar-space-list.ts
+++ b/apps/desktop/src/main/handlers/queries/sidebar-space-list.ts
@@ -1,17 +1,17 @@
import { SidebarSpaceListQueryInput } from '@/operations/queries/sidebar-space-list';
import { databaseManager } from '@/main/data/database-manager';
-import {
- ChangeCheckResult,
- QueryHandler,
- QueryResult,
-} from '@/operations/queries';
import { sql } from 'kysely';
import { SelectNode } from '@/main/data/workspace/schema';
import { NodeTypes } from '@/lib/constants';
import { SidebarNode, SidebarSpaceNode } from '@/types/workspaces';
-import { mapNode } from '@/lib/nodes';
-import { Node } from '@/registry';
-import { MutationChange } from '@/operations/mutations';
+import { mapNode } from '@/main/utils';
+import { Node } from '@colanode/core';
+import {
+ MutationChange,
+ ChangeCheckResult,
+ QueryHandler,
+ QueryResult,
+} from '@/main/types';
import { isEqual } from 'lodash';
import { compareString } from '@/lib/utils';
@@ -25,7 +25,7 @@ export class SidebarSpaceListQueryHandler
implements QueryHandler<SidebarSpaceListQueryInput>
{
public async handleQuery(
- input: SidebarSpaceListQueryInput,
+ input: SidebarSpaceListQueryInput
): Promise<QueryResult<SidebarSpaceListQueryInput>> {
const rows = await this.fetchNodes(input);
const unreadCounts = await this.fetchUnreadCounts(input, rows);
@@ -42,14 +42,14 @@ export class SidebarSpaceListQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: SidebarSpaceListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<SidebarSpaceListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
(change.table === 'nodes' || change.table === 'user_nodes') &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -80,10 +80,10 @@ export class SidebarSpaceListQueryHandler
}
private async fetchNodes(
- input: SidebarSpaceListQueryInput,
+ input: SidebarSpaceListQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const query = sql<SelectNode>`
@@ -108,10 +108,10 @@ export class SidebarSpaceListQueryHandler
private async fetchUnreadCounts(
input: SidebarSpaceListQueryInput,
- rows: SelectNode[],
+ rows: SelectNode[]
): Promise<UnreadCountRow[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const channelIds = rows
@@ -138,7 +138,7 @@ export class SidebarSpaceListQueryHandler
private buildSidebarSpaceNodes = (
rows: SelectNode[],
- unreadCounts: UnreadCountRow[],
+ unreadCounts: UnreadCountRow[]
): SidebarSpaceNode[] => {
const nodes: Node[] = rows.map(mapNode);
const spaces: SidebarSpaceNode[] = [];
@@ -164,7 +164,7 @@ export class SidebarSpaceListQueryHandler
private buildSpaceNode = (
node: Node,
children: Node[],
- unreadCounts: UnreadCountRow[],
+ unreadCounts: UnreadCountRow[]
): SidebarSpaceNode | null => {
if (node.type !== 'space') {
return null;
@@ -191,7 +191,7 @@ export class SidebarSpaceListQueryHandler
private buildSidearNode = (
node: Node,
- unreadCounts: UnreadCountRow[],
+ unreadCounts: UnreadCountRow[]
): SidebarNode | null => {
const unreadCountRow = unreadCounts.find((r) => r.node_id === node.id);
diff --git a/apps/desktop/src/main/handlers/queries/user-search.ts b/apps/desktop/src/main/handlers/queries/user-search.ts
index dc8d00fc..e13658f5 100644
--- a/apps/desktop/src/main/handlers/queries/user-search.ts
+++ b/apps/desktop/src/main/handlers/queries/user-search.ts
@@ -1,22 +1,22 @@
import { UserSearchQueryInput } from '@/operations/queries/user-search';
import { databaseManager } from '@/main/data/database-manager';
-import {
- ChangeCheckResult,
- QueryHandler,
- QueryResult,
-} from '@/operations/queries';
import { sql } from 'kysely';
import { SelectNode } from '@/main/data/workspace/schema';
import { NodeTypes } from '@/lib/constants';
import { UserNode } from '@/types/users';
-import { MutationChange } from '@/operations/mutations';
+import {
+ MutationChange,
+ ChangeCheckResult,
+ QueryHandler,
+ QueryResult,
+} from '@/main/types';
import { isEqual } from 'lodash';
export class UserSearchQueryHandler
implements QueryHandler<UserSearchQueryInput>
{
public async handleQuery(
- input: UserSearchQueryInput,
+ input: UserSearchQueryInput
): Promise<QueryResult<UserSearchQueryInput>> {
const rows =
input.searchQuery.length > 0
@@ -33,14 +33,14 @@ export class UserSearchQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: UserSearchQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<UserSearchQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -71,10 +71,10 @@ export class UserSearchQueryHandler
}
private async searchUsers(
- input: UserSearchQueryInput,
+ input: UserSearchQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const query = sql<SelectNode>`
@@ -92,7 +92,7 @@ export class UserSearchQueryHandler
private async fetchUsers(input: UserSearchQueryInput): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
return workspaceDatabase
diff --git a/apps/desktop/src/main/handlers/queries/workspace-list.ts b/apps/desktop/src/main/handlers/queries/workspace-list.ts
index 0f2907f7..220db0e5 100644
--- a/apps/desktop/src/main/handlers/queries/workspace-list.ts
+++ b/apps/desktop/src/main/handlers/queries/workspace-list.ts
@@ -1,20 +1,20 @@
import { WorkspaceListQueryInput } from '@/operations/queries/workspace-list';
import { databaseManager } from '@/main/data/database-manager';
+import { Workspace, WorkspaceRole } from '@/types/workspaces';
+import { SelectWorkspace } from '@/main/data/app/schema';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { Workspace, WorkspaceRole } from '@/types/workspaces';
-import { SelectWorkspace } from '@/main/data/app/schema';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { isEqual } from 'lodash';
export class WorkspaceListQueryHandler
implements QueryHandler<WorkspaceListQueryInput>
{
public async handleQuery(
- input: WorkspaceListQueryInput,
+ _: WorkspaceListQueryInput
): Promise<QueryResult<WorkspaceListQueryInput>> {
const rows = await this.fetchWorkspaces();
@@ -28,12 +28,12 @@ export class WorkspaceListQueryHandler
public async checkForChanges(
changes: MutationChange[],
- input: WorkspaceListQueryInput,
- state: Record<string, any>,
+ _: WorkspaceListQueryInput,
+ state: Record<string, any>
): Promise<ChangeCheckResult<WorkspaceListQueryInput>> {
if (
!changes.some(
- (change) => change.type === 'app' && change.table === 'workspaces',
+ (change) => change.type === 'app' && change.table === 'workspaces'
)
) {
return {
@@ -69,7 +69,7 @@ export class WorkspaceListQueryHandler
databaseManager.appDatabase
.selectFrom('accounts')
.where('status', '=', 'active')
- .select('id'),
+ .select('id')
)
.execute();
}
diff --git a/apps/desktop/src/main/handlers/queries/workspace-user-list.ts b/apps/desktop/src/main/handlers/queries/workspace-user-list.ts
index bd2e387d..d50d2593 100644
--- a/apps/desktop/src/main/handlers/queries/workspace-user-list.ts
+++ b/apps/desktop/src/main/handlers/queries/workspace-user-list.ts
@@ -1,22 +1,22 @@
import { WorkspaceUserListQueryInput } from '@/operations/queries/workspace-user-list';
import { databaseManager } from '@/main/data/database-manager';
+import { NodeTypes } from '@/lib/constants';
+import { mapNode } from '@/main/utils';
+import { SelectNode } from '@/main/data/workspace/schema';
+import { UserNode } from '@colanode/core';
import {
+ MutationChange,
ChangeCheckResult,
QueryHandler,
QueryResult,
-} from '@/operations/queries';
-import { NodeTypes } from '@/lib/constants';
-import { mapNode } from '@/lib/nodes';
-import { SelectNode } from '@/main/data/workspace/schema';
-import { UserNode } from '@/registry';
-import { MutationChange } from '@/operations/mutations';
+} from '@/main/types';
import { isEqual } from 'lodash';
export class WorkspaceUserListQueryHandler
implements QueryHandler<WorkspaceUserListQueryInput>
{
public async handleQuery(
- input: WorkspaceUserListQueryInput,
+ input: WorkspaceUserListQueryInput
): Promise<QueryResult<WorkspaceUserListQueryInput>> {
const rows = await this.fetchNodes(input);
return {
@@ -30,14 +30,14 @@ export class WorkspaceUserListQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: WorkspaceUserListQueryInput,
- state: Record<string, any>,
+ state: Record<string, any>
): Promise<ChangeCheckResult<WorkspaceUserListQueryInput>> {
if (
!changes.some(
(change) =>
change.type === 'workspace' &&
change.table === 'nodes' &&
- change.userId === input.userId,
+ change.userId === input.userId
)
) {
return {
@@ -64,10 +64,10 @@ export class WorkspaceUserListQueryHandler
}
private async fetchNodes(
- input: WorkspaceUserListQueryInput,
+ input: WorkspaceUserListQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
- input.userId,
+ input.userId
);
const offset = input.page * input.count;
diff --git a/apps/desktop/src/main/mediator.ts b/apps/desktop/src/main/mediator.ts
index 46102e74..6ba2bdac 100644
--- a/apps/desktop/src/main/mediator.ts
+++ b/apps/desktop/src/main/mediator.ts
@@ -1,16 +1,8 @@
-import {
- MutationChange,
- MutationHandler,
- MutationInput,
- MutationMap,
-} from '@/operations/mutations';
+import { MutationInput, MutationMap } from '@/operations/mutations';
+import { MutationChange, MutationHandler } from '@/main/types';
import { mutationHandlerMap } from '@/main/handlers/mutations';
-import {
- QueryHandler,
- QueryInput,
- QueryMap,
- SubscribedQuery,
-} from '@/operations/queries';
+import { QueryInput, QueryMap } from '@/operations/queries';
+import { QueryHandler, SubscribedQuery } from '@/main/types';
import { queryHandlerMap } from '@/main/handlers/queries';
import { eventBus } from '@/lib/event-bus';
import {
@@ -25,7 +17,7 @@ class Mediator {
new Map();
public async executeMutation<T extends MutationInput>(
- input: T,
+ input: T
): Promise<MutationMap[T['type']]['output']> {
const handler = mutationHandlerMap[
input.type
@@ -40,7 +32,7 @@ class Mediator {
}
public async executeQuery<T extends QueryInput>(
- input: T,
+ input: T
): Promise<QueryMap[T['type']]['output']> {
const handler = queryHandlerMap[input.type] as unknown as QueryHandler<T>;
const result = await handler.handleQuery(input);
@@ -49,7 +41,7 @@ class Mediator {
public async executeQueryAndSubscribe<T extends QueryInput>(
id: string,
- input: T,
+ input: T
): Promise<QueryMap[T['type']]['output']> {
const handler = queryHandlerMap[input.type] as unknown as QueryHandler<T>;
const result = await handler.handleQuery(input);
@@ -62,7 +54,7 @@ class Mediator {
public async executeMessage<T extends MessageInput>(
context: MessageContext,
- input: T,
+ input: T
): Promise<void> {
const handler = messageHandlerMap[input.type] as MessageHandler<T>;
await handler.handleMessage(context, input);
@@ -85,7 +77,7 @@ class Mediator {
const changeCheckResult = await handler.checkForChanges(
changes,
query.input,
- query.result.state,
+ query.result.state
);
if (changeCheckResult.hasChanges && changeCheckResult.result) {
const newResult = changeCheckResult.result;
diff --git a/apps/desktop/src/main/node-manager.ts b/apps/desktop/src/main/node-manager.ts
index 63d88730..71671464 100644
--- a/apps/desktop/src/main/node-manager.ts
+++ b/apps/desktop/src/main/node-manager.ts
@@ -1,12 +1,10 @@
import * as Y from 'yjs';
-import { NodeAttributes } from '@/registry';
+import { NodeAttributes, registry, applyCrdt } from '@colanode/core';
import { fromUint8Array, toUint8Array } from 'js-base64';
-import { applyCrdt } from '@/main/crdt';
import {
LocalCreateNodeChangeData,
LocalUpdateNodeChangeData,
} from '@/types/sync';
-import { registry } from '@/registry';
import { generateId } from '@/lib/id';
import { IdType } from '@/lib/id';
import { databaseManager } from '@/main/data/database-manager';
@@ -19,7 +17,7 @@ class NodeManager {
transaction: Transaction<WorkspaceDatabaseSchema>,
userId: string,
id: string,
- attributes: NodeAttributes,
+ attributes: NodeAttributes
) {
const doc = new Y.Doc({
guid: id,
@@ -75,7 +73,7 @@ class NodeManager {
async updateNode(
userId: string,
id: string,
- updater: (attributes: NodeAttributes) => NodeAttributes,
+ updater: (attributes: NodeAttributes) => NodeAttributes
) {
const workspaceDatabase =
await databaseManager.getWorkspaceDatabase(userId);
@@ -113,7 +111,7 @@ class NodeManager {
applyCrdt(
registry[updatedAttributes.type].schema,
updatedAttributes,
- attributesMap,
+ attributesMap
);
});
@@ -165,10 +163,10 @@ class NodeManager {
return hasChanges;
});
- if (result) {
- return true;
- }
+ return result;
}
+
+ throw new Error('Failed to update node');
}
}
diff --git a/apps/desktop/src/main/sockets/socket-connection.ts b/apps/desktop/src/main/sockets/socket-connection.ts
index 6d302941..33f83bac 100644
--- a/apps/desktop/src/main/sockets/socket-connection.ts
+++ b/apps/desktop/src/main/sockets/socket-connection.ts
@@ -1,9 +1,15 @@
import { WebSocket } from 'ws';
-import { buildSynapseUrl } from '@/lib/servers';
import { BackoffCalculator } from '@/lib/backoff-calculator';
import { MessageContext, MessageInput } from '@/operations/messages';
import { mediator } from '@/main/mediator';
import { SelectAccount, SelectServer } from '@/main/data/app/schema';
+import { ServerAttributes } from '@/types/servers';
+
+const buildSynapseUrl = (server: SelectServer, deviceId: string) => {
+ const attributes = JSON.parse(server.attributes) as ServerAttributes;
+ const protocol = attributes?.insecure ? 'ws' : 'wss';
+ return `${protocol}://${server.domain}/v1/synapse?device_id=${deviceId}`;
+};
export class SocketConnection {
private readonly server: SelectServer;
@@ -35,7 +41,7 @@ export class SocketConnection {
headers: {
authorization: this.account.token,
},
- },
+ }
);
this.socket.onmessage = async (event) => {
diff --git a/apps/desktop/src/main/types.ts b/apps/desktop/src/main/types.ts
new file mode 100644
index 00000000..cae48d04
--- /dev/null
+++ b/apps/desktop/src/main/types.ts
@@ -0,0 +1,50 @@
+import { AppDatabaseSchema } from '@/main/data/app/schema';
+import { WorkspaceDatabaseSchema } from '@/main/data/workspace/schema';
+import { MutationInput, MutationMap } from '@/operations/mutations';
+import { QueryInput, QueryMap } from '@/operations/queries';
+
+export interface MutationHandler<T extends MutationInput> {
+ handleMutation: (input: T) => Promise<MutationResult<T>>;
+}
+
+export type MutationResult<T extends MutationInput> = {
+ output: MutationMap[T['type']]['output'];
+ changes?: MutationChange[];
+};
+
+export type MutationChange = AppMutationChange | WorkspaceMutationChange;
+
+export type AppMutationChange = {
+ type: 'app';
+ table: keyof AppDatabaseSchema;
+};
+
+export type WorkspaceMutationChange = {
+ type: 'workspace';
+ table: keyof WorkspaceDatabaseSchema;
+ userId: string;
+};
+
+export interface QueryHandler<T extends QueryInput> {
+ handleQuery: (input: T) => Promise<QueryResult<T>>;
+ checkForChanges: (
+ changes: MutationChange[],
+ input: T,
+ state: Record<string, any>
+ ) => Promise<ChangeCheckResult<T>>;
+}
+
+export type QueryResult<T extends QueryInput> = {
+ output: QueryMap[T['type']]['output'];
+ state: Record<string, any>;
+};
+
+export type SubscribedQuery<T extends QueryInput> = {
+ input: T;
+ result: QueryResult<T>;
+};
+
+export type ChangeCheckResult<T extends QueryInput> = {
+ hasChanges: boolean;
+ result?: QueryResult<T>;
+};
diff --git a/apps/desktop/src/main/utils.ts b/apps/desktop/src/main/utils.ts
index 9dfc380b..f2263421 100644
--- a/apps/desktop/src/main/utils.ts
+++ b/apps/desktop/src/main/utils.ts
@@ -1,6 +1,8 @@
import { app } from 'electron';
import { DeleteResult, InsertResult, UpdateResult } from 'kysely';
import path from 'path';
+import { SelectNode } from '@/main/data/workspace/schema';
+import { Node } from '@colanode/core';
export const appPath = app.getPath('userData');
@@ -24,7 +26,7 @@ export const hasInsertChanges = (result: InsertResult[]): boolean => {
}
return result.some(
- (r) => r.numInsertedOrUpdatedRows && r.numInsertedOrUpdatedRows > 0n,
+ (r) => r.numInsertedOrUpdatedRows && r.numInsertedOrUpdatedRows > 0n
);
};
@@ -39,3 +41,21 @@ export const hasUpdateChanges = (result: UpdateResult[]): boolean => {
export const hasDeleteChanges = (result: DeleteResult[]): boolean => {
return result.some((r) => r.numDeletedRows && r.numDeletedRows > 0n);
};
+
+export const mapNode = (row: SelectNode): Node => {
+ return {
+ id: row.id,
+ type: row.type as any,
+ index: row.index,
+ parentId: row.parent_id,
+ attributes: JSON.parse(row.attributes),
+ createdAt: row.created_at,
+ createdBy: row.created_by,
+ updatedAt: row.updated_at,
+ updatedBy: row.updated_by,
+ versionId: row.version_id,
+ serverCreatedAt: row.server_created_at,
+ serverUpdatedAt: row.server_updated_at,
+ serverVersionId: row.server_version_id,
+ };
+};
diff --git a/apps/desktop/src/operations/mutations/field-create.ts b/apps/desktop/src/operations/mutations/field-create.ts
index 8b49f89b..0761ec0e 100644
--- a/apps/desktop/src/operations/mutations/field-create.ts
+++ b/apps/desktop/src/operations/mutations/field-create.ts
@@ -1,4 +1,4 @@
-import { FieldType } from '@/registry';
+import { FieldType } from '@colanode/core';
export type FieldCreateMutationInput = {
type: 'field_create';
diff --git a/apps/desktop/src/operations/mutations/index.ts b/apps/desktop/src/operations/mutations/index.ts
index 0f6352e1..f0556d9d 100644
--- a/apps/desktop/src/operations/mutations/index.ts
+++ b/apps/desktop/src/operations/mutations/index.ts
@@ -1,28 +1,3 @@
-import { AppDatabaseSchema } from '@/main/data/app/schema';
-import { WorkspaceDatabaseSchema } from '@/main/data/workspace/schema';
-
export interface MutationMap {}
export type MutationInput = MutationMap[keyof MutationMap]['input'];
-
-export interface MutationHandler<T extends MutationInput> {
- handleMutation: (input: T) => Promise<MutationResult<T>>;
-}
-
-export type MutationResult<T extends MutationInput> = {
- output: MutationMap[T['type']]['output'];
- changes?: MutationChange[];
-};
-
-export type MutationChange = AppMutationChange | WorkspaceMutationChange;
-
-export type AppMutationChange = {
- type: 'app';
- table: keyof AppDatabaseSchema;
-};
-
-export type WorkspaceMutationChange = {
- type: 'workspace';
- table: keyof WorkspaceDatabaseSchema;
- userId: string;
-};
diff --git a/apps/desktop/src/operations/mutations/view-update.ts b/apps/desktop/src/operations/mutations/view-update.ts
index 12a29ce2..b4e0a5fc 100644
--- a/apps/desktop/src/operations/mutations/view-update.ts
+++ b/apps/desktop/src/operations/mutations/view-update.ts
@@ -1,4 +1,4 @@
-import { ViewAttributes } from '@/registry';
+import { ViewAttributes } from '@colanode/core';
export type ViewUpdateMutationInput = {
type: 'view_update';
diff --git a/apps/desktop/src/operations/queries/index.ts b/apps/desktop/src/operations/queries/index.ts
index 8fa7911f..2c7a2806 100644
--- a/apps/desktop/src/operations/queries/index.ts
+++ b/apps/desktop/src/operations/queries/index.ts
@@ -1,29 +1,3 @@
-import { MutationChange } from '@/operations/mutations';
-
export interface QueryMap {}
export type QueryInput = QueryMap[keyof QueryMap]['input'];
-
-export interface QueryHandler<T extends QueryInput> {
- handleQuery: (input: T) => Promise<QueryResult<T>>;
- checkForChanges: (
- changes: MutationChange[],
- input: T,
- state: Record<string, any>
- ) => Promise<ChangeCheckResult<T>>;
-}
-
-export type QueryResult<T extends QueryInput> = {
- output: QueryMap[T['type']]['output'];
- state: Record<string, any>;
-};
-
-export type SubscribedQuery<T extends QueryInput> = {
- input: T;
- result: QueryResult<T>;
-};
-
-export type ChangeCheckResult<T extends QueryInput> = {
- hasChanges: boolean;
- result?: QueryResult<T>;
-};
diff --git a/apps/desktop/src/operations/queries/node-get.ts b/apps/desktop/src/operations/queries/node-get.ts
index c969ebe6..0607391c 100644
--- a/apps/desktop/src/operations/queries/node-get.ts
+++ b/apps/desktop/src/operations/queries/node-get.ts
@@ -1,4 +1,4 @@
-import { Node } from '@/registry';
+import { Node } from '@colanode/core';
export type NodeGetQueryInput = {
type: 'node_get';
diff --git a/apps/desktop/src/operations/queries/record-list.ts b/apps/desktop/src/operations/queries/record-list.ts
index 8ed2b34f..013f5bf0 100644
--- a/apps/desktop/src/operations/queries/record-list.ts
+++ b/apps/desktop/src/operations/queries/record-list.ts
@@ -1,5 +1,8 @@
-import { RecordNode } from '@/registry';
-import { ViewFilterAttributes, ViewSortAttributes } from '@/registry';
+import {
+ RecordNode,
+ ViewFilterAttributes,
+ ViewSortAttributes,
+} from '@colanode/core';
export type RecordListQueryInput = {
type: 'record_list';
diff --git a/apps/desktop/src/operations/queries/workspace-user-list.ts b/apps/desktop/src/operations/queries/workspace-user-list.ts
index 44ce28fa..616a0343 100644
--- a/apps/desktop/src/operations/queries/workspace-user-list.ts
+++ b/apps/desktop/src/operations/queries/workspace-user-list.ts
@@ -1,4 +1,4 @@
-import { UserNode } from '@/registry';
+import { UserNode } from '@colanode/core';
export type WorkspaceUserListQueryInput = {
type: 'workspace_user_list';
diff --git a/apps/desktop/src/renderer/app-loading.tsx b/apps/desktop/src/renderer/app-loading.tsx
index f9479312..c3293c12 100644
--- a/apps/desktop/src/renderer/app-loading.tsx
+++ b/apps/desktop/src/renderer/app-loading.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Spinner } from '@/renderer/components/ui/spinner';
export const AppLoading = () => {
diff --git a/apps/desktop/src/renderer/components/accounts/account-logout.tsx b/apps/desktop/src/renderer/components/accounts/account-logout.tsx
index 217b6f8b..e410b7c2 100644
--- a/apps/desktop/src/renderer/components/accounts/account-logout.tsx
+++ b/apps/desktop/src/renderer/components/accounts/account-logout.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/accounts/account-settings-dialog.tsx b/apps/desktop/src/renderer/components/accounts/account-settings-dialog.tsx
index c3eccb87..1b678113 100644
--- a/apps/desktop/src/renderer/components/accounts/account-settings-dialog.tsx
+++ b/apps/desktop/src/renderer/components/accounts/account-settings-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Dialog,
DialogContent,
@@ -23,7 +22,6 @@ interface AccountSettingsDialogProps {
}
export const AccountSettingsDialog = ({
- id,
open,
onOpenChange,
}: AccountSettingsDialogProps) => {
diff --git a/apps/desktop/src/renderer/components/accounts/email-login.tsx b/apps/desktop/src/renderer/components/accounts/email-login.tsx
index d25b02d7..b40c522b 100644
--- a/apps/desktop/src/renderer/components/accounts/email-login.tsx
+++ b/apps/desktop/src/renderer/components/accounts/email-login.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Input } from '@/renderer/components/ui/input';
import { Button } from '@/renderer/components/ui/button';
import { Spinner } from '@/renderer/components/ui/spinner';
diff --git a/apps/desktop/src/renderer/components/accounts/email-register.tsx b/apps/desktop/src/renderer/components/accounts/email-register.tsx
index 9656e207..e0415d6b 100644
--- a/apps/desktop/src/renderer/components/accounts/email-register.tsx
+++ b/apps/desktop/src/renderer/components/accounts/email-register.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Input } from '@/renderer/components/ui/input';
import { Button } from '@/renderer/components/ui/button';
import { Spinner } from '@/renderer/components/ui/spinner';
diff --git a/apps/desktop/src/renderer/components/accounts/login.tsx b/apps/desktop/src/renderer/components/accounts/login.tsx
index d8503e79..e879c1bc 100644
--- a/apps/desktop/src/renderer/components/accounts/login.tsx
+++ b/apps/desktop/src/renderer/components/accounts/login.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { LoginForm } from '@/renderer/components/accounts/login-form';
import { useQuery } from '@/renderer/hooks/use-query';
diff --git a/apps/desktop/src/renderer/components/avatars/avatar-picker.tsx b/apps/desktop/src/renderer/components/avatars/avatar-picker.tsx
index cd9342b2..653aff53 100644
--- a/apps/desktop/src/renderer/components/avatars/avatar-picker.tsx
+++ b/apps/desktop/src/renderer/components/avatars/avatar-picker.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Tabs,
TabsContent,
diff --git a/apps/desktop/src/renderer/components/avatars/avatar-upload.tsx b/apps/desktop/src/renderer/components/avatars/avatar-upload.tsx
index 05403795..16ee8fcb 100644
--- a/apps/desktop/src/renderer/components/avatars/avatar-upload.tsx
+++ b/apps/desktop/src/renderer/components/avatars/avatar-upload.tsx
@@ -16,7 +16,7 @@ export const AvatarUpload = ({ onUpload }: AvatarUploadProps) => {
const [isFileDialogOpen, setIsFileDialogOpen] = React.useState(false);
const [url, setUrl] = React.useState<string | undefined>(undefined);
- const handleSubmit = async (url: string) => {
+ const handleSubmit = async (_: string) => {
// TODO
};
diff --git a/apps/desktop/src/renderer/components/avatars/avatar.tsx b/apps/desktop/src/renderer/components/avatars/avatar.tsx
index 075759c3..1f557e14 100644
--- a/apps/desktop/src/renderer/components/avatars/avatar.tsx
+++ b/apps/desktop/src/renderer/components/avatars/avatar.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { cn } from '@/lib/utils';
import {
getAvatarSizeClasses,
@@ -57,7 +56,7 @@ const AvatarFallback = ({ id, name, size, className }: AvatarProps) => {
className={cn(
'inline-flex items-center justify-center overflow-hidden rounded text-white shadow',
getAvatarSizeClasses(size),
- className,
+ className
)}
style={{ backgroundColor: color }}
>
diff --git a/apps/desktop/src/renderer/components/channels/channel-container.tsx b/apps/desktop/src/renderer/components/channels/channel-container.tsx
index 22361486..5f6f68d5 100644
--- a/apps/desktop/src/renderer/components/channels/channel-container.tsx
+++ b/apps/desktop/src/renderer/components/channels/channel-container.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Conversation } from '@/renderer/components/messages/conversation';
interface ChannelContainerProps {
diff --git a/apps/desktop/src/renderer/components/channels/channel-create-dialog.tsx b/apps/desktop/src/renderer/components/channels/channel-create-dialog.tsx
index f410f5ba..27c04f53 100644
--- a/apps/desktop/src/renderer/components/channels/channel-create-dialog.tsx
+++ b/apps/desktop/src/renderer/components/channels/channel-create-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import {
Dialog,
diff --git a/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx b/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx
index c36c5c7b..b1b6078d 100644
--- a/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/chats/chat-container.tsx b/apps/desktop/src/renderer/components/chats/chat-container.tsx
index 1c2969c0..e7163794 100644
--- a/apps/desktop/src/renderer/components/chats/chat-container.tsx
+++ b/apps/desktop/src/renderer/components/chats/chat-container.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Conversation } from '@/renderer/components/messages/conversation';
interface ChatContainerProps {
diff --git a/apps/desktop/src/renderer/components/collaborators/node-collaborator-role-dropdown.tsx b/apps/desktop/src/renderer/components/collaborators/node-collaborator-role-dropdown.tsx
index ac3d05f6..1240829f 100644
--- a/apps/desktop/src/renderer/components/collaborators/node-collaborator-role-dropdown.tsx
+++ b/apps/desktop/src/renderer/components/collaborators/node-collaborator-role-dropdown.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
DropdownMenu,
DropdownMenuContent,
diff --git a/apps/desktop/src/renderer/components/collaborators/node-collaborator.tsx b/apps/desktop/src/renderer/components/collaborators/node-collaborator.tsx
index 709146c8..dbe0440b 100644
--- a/apps/desktop/src/renderer/components/collaborators/node-collaborator.tsx
+++ b/apps/desktop/src/renderer/components/collaborators/node-collaborator.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { NodeCollaborator as NodeCollaboratorType } from '@/types/nodes';
import { Avatar } from '@/renderer/components/avatars/avatar';
import { NodeCollaboratorRoleDropdown } from '@/renderer/components/collaborators/node-collaborator-role-dropdown';
diff --git a/apps/desktop/src/renderer/components/collaborators/node-collaborators-popover.tsx b/apps/desktop/src/renderer/components/collaborators/node-collaborators-popover.tsx
index 3008e480..d60519d2 100644
--- a/apps/desktop/src/renderer/components/collaborators/node-collaborators-popover.tsx
+++ b/apps/desktop/src/renderer/components/collaborators/node-collaborators-popover.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Popover,
PopoverTrigger,
diff --git a/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsx b/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsx
index d0ca677d..0af4a5cd 100644
--- a/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsx
+++ b/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsx
@@ -1,8 +1,11 @@
import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useMutation } from '@/renderer/hooks/use-mutation';
-import { RecordNode } from '@/registry';
-import { SelectFieldAttributes, SelectOptionAttributes } from '@/registry';
+import {
+ RecordNode,
+ SelectFieldAttributes,
+ SelectOptionAttributes,
+} from '@colanode/core';
import { useDrag } from 'react-dnd';
import { cn } from '@/lib/utils';
@@ -22,7 +25,7 @@ export const BoardViewCard = ({ record }: BoardViewCardProps) => {
const [, drag] = useDrag({
type: 'board-record',
item: { id: record.id },
- end: (item, monitor) => {
+ end: (_, monitor) => {
const dropResult = monitor.getDropResult<DragResult>();
if (dropResult != null) {
if (isPending) return;
@@ -64,7 +67,7 @@ export const BoardViewCard = ({ record }: BoardViewCardProps) => {
key={record.id}
className={cn(
'animate-fade-in flex cursor-pointer flex-col gap-1 rounded-md border p-2 text-left hover:bg-gray-50',
- hasName ? '' : 'text-muted-foreground',
+ hasName ? '' : 'text-muted-foreground'
)}
onClick={() => workspace.openModal(record.id)}
>
diff --git a/apps/desktop/src/renderer/components/databases/boards/board-view-column-header.tsx b/apps/desktop/src/renderer/components/databases/boards/board-view-column-header.tsx
index 474059b1..002f53a4 100644
--- a/apps/desktop/src/renderer/components/databases/boards/board-view-column-header.tsx
+++ b/apps/desktop/src/renderer/components/databases/boards/board-view-column-header.tsx
@@ -1,6 +1,5 @@
-import React from 'react';
import { SelectOptionBadge } from '@/renderer/components/databases/fields/select-option-badge';
-import { SelectOptionAttributes } from '@/registry';
+import { SelectOptionAttributes } from '@colanode/core';
interface BoardViewColumnHeaderProps {
option: SelectOptionAttributes;
diff --git a/apps/desktop/src/renderer/components/databases/boards/board-view-column-records.tsx b/apps/desktop/src/renderer/components/databases/boards/board-view-column-records.tsx
index 90b5b35b..fe8e16a3 100644
--- a/apps/desktop/src/renderer/components/databases/boards/board-view-column-records.tsx
+++ b/apps/desktop/src/renderer/components/databases/boards/board-view-column-records.tsx
@@ -1,11 +1,10 @@
-import React from 'react';
import { useDatabase } from '@/renderer/contexts/database';
import { useInfiniteQuery } from '@/renderer/hooks/use-infinite-query';
import {
SelectFieldAttributes,
SelectOptionAttributes,
ViewFilterAttributes,
-} from '@/registry';
+} from '@colanode/core';
import { BoardViewCard } from '@/renderer/components/databases/boards/board-view-card';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useView } from '@/renderer/contexts/view';
@@ -35,38 +34,37 @@ export const BoardViewColumnRecords = ({
value: [option.id],
},
];
- const { data, isPending, isFetchingNextPage, fetchNextPage, hasNextPage } =
- useInfiniteQuery({
- initialPageInput: {
+ const { data } = useInfiniteQuery({
+ initialPageInput: {
+ type: 'record_list',
+ databaseId: database.id,
+ filters: filters,
+ sorts: view.sorts,
+ page: 0,
+ count: RECORDS_PER_PAGE,
+ userId: workspace.userId,
+ },
+ getNextPageInput(page, pages) {
+ if (page > pages.length) {
+ return undefined;
+ }
+
+ const lastPage = pages[page - 1];
+ if (lastPage.length < RECORDS_PER_PAGE) {
+ return undefined;
+ }
+
+ return {
type: 'record_list',
databaseId: database.id,
filters: filters,
- sorts: view.sorts,
- page: 0,
+ sorts: Object.values(view.sorts),
+ page: page,
count: RECORDS_PER_PAGE,
userId: workspace.userId,
- },
- getNextPageInput(page, pages) {
- if (page > pages.length) {
- return undefined;
- }
-
- const lastPage = pages[page - 1];
- if (lastPage.length < RECORDS_PER_PAGE) {
- return undefined;
- }
-
- return {
- type: 'record_list',
- databaseId: database.id,
- filters: filters,
- sorts: Object.values(view.sorts),
- page: page,
- count: RECORDS_PER_PAGE,
- userId: workspace.userId,
- };
- },
- });
+ };
+ },
+ });
const records = data?.flatMap((page) => page) ?? [];
return (
diff --git a/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsx b/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsx
index c7e839ff..63ce0c43 100644
--- a/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsx
+++ b/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import { getSelectOptionLightColorClass } from '@/lib/databases';
import { cn } from '@/lib/utils';
import { useDrop } from 'react-dnd';
-import { SelectFieldAttributes, SelectOptionAttributes } from '@/registry';
+import { SelectFieldAttributes, SelectOptionAttributes } from '@colanode/core';
import { BoardViewColumnHeader } from '@/renderer/components/databases/boards/board-view-column-header';
import { BoardViewColumnRecords } from '@/renderer/components/databases/boards/board-view-column-records';
diff --git a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsx b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsx
index 2f918cad..28ab9ed4 100644
--- a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsx
+++ b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsx
@@ -1,6 +1,5 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
-import { RecordNode } from '@/registry';
+import { RecordNode } from '@colanode/core';
import { cn } from '@/lib/utils';
interface CalendarViewCardProps {
@@ -19,7 +18,7 @@ export const CalendarViewCard = ({ record }: CalendarViewCardProps) => {
key={record.id}
className={cn(
'animate-fade-in flex cursor-pointer flex-col gap-1 rounded-md border p-2 hover:bg-gray-50',
- hasName ? '' : 'text-muted-foreground',
+ hasName ? '' : 'text-muted-foreground'
)}
onClick={() => workspace.openModal(record.id)}
>
diff --git a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsx b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsx
index 38840eb4..1239d031 100644
--- a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsx
+++ b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsx
@@ -1,6 +1,5 @@
-import React from 'react';
import { cn, isSameDay } from '@/lib/utils';
-import { RecordNode } from '@/registry';
+import { RecordNode } from '@colanode/core';
import { CalendarViewCard } from '@/renderer/components/databases/calendars/calendar-view-card';
import { Plus } from 'lucide-react';
@@ -27,13 +26,13 @@ export const CalendarViewDay = ({
<div
className={cn(
'flex justify-between text-sm',
- isOutside ? 'text-muted-foreground' : '',
+ isOutside ? 'text-muted-foreground' : ''
)}
>
<Plus
className={cn(
'size-4 cursor-pointer opacity-0',
- canCreateRecord ? 'group-hover:opacity-100' : '',
+ canCreateRecord ? 'group-hover:opacity-100' : ''
)}
onClick={() => {}}
/>
diff --git a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsx b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsx
index 1567285d..db89f924 100644
--- a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsx
+++ b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsx
@@ -3,11 +3,7 @@ import { buttonVariants } from '@/renderer/components/ui/button';
import { cn, getDisplayedDates, toUTCDate } from '@/lib/utils';
import { DayPicker, DayProps } from 'react-day-picker';
import { CalendarViewDay } from '@/renderer/components/databases/calendars/calendar-view-day';
-import {
- ViewAttributes,
- FieldAttributes,
- ViewFilterAttributes,
-} from '@/registry';
+import { FieldAttributes, ViewFilterAttributes } from '@colanode/core';
import { useInfiniteQuery } from '@/renderer/hooks/use-infinite-query';
import { useDatabase } from '@/renderer/contexts/database';
import { filterRecords } from '@/lib/databases';
@@ -47,38 +43,37 @@ export const CalendarViewGrid = ({ field }: CalendarViewGridProps) => {
},
];
- const { data, isPending, isFetchingNextPage, fetchNextPage, hasNextPage } =
- useInfiniteQuery({
- initialPageInput: {
+ const { data, isPending } = useInfiniteQuery({
+ initialPageInput: {
+ type: 'record_list',
+ databaseId: database.id,
+ filters: filters,
+ sorts: view.sorts,
+ page: 0,
+ count: RECORDS_PER_PAGE,
+ userId: workspace.userId,
+ },
+ getNextPageInput(page, pages) {
+ if (page > pages.length) {
+ return undefined;
+ }
+
+ const lastPage = pages[page - 1];
+ if (lastPage.length < RECORDS_PER_PAGE) {
+ return undefined;
+ }
+
+ return {
type: 'record_list',
databaseId: database.id,
filters: filters,
- sorts: view.sorts,
- page: 0,
+ sorts: Object.values(view.sorts),
+ page: page,
count: RECORDS_PER_PAGE,
userId: workspace.userId,
- },
- getNextPageInput(page, pages) {
- if (page > pages.length) {
- return undefined;
- }
-
- const lastPage = pages[page - 1];
- if (lastPage.length < RECORDS_PER_PAGE) {
- return undefined;
- }
-
- return {
- type: 'record_list',
- databaseId: database.id,
- filters: filters,
- sorts: Object.values(view.sorts),
- page: page,
- count: RECORDS_PER_PAGE,
- userId: workspace.userId,
- };
- },
- });
+ };
+ },
+ });
if (isPending) {
return null;
@@ -102,7 +97,7 @@ export const CalendarViewGrid = ({ field }: CalendarViewGridProps) => {
nav: 'space-x-1 flex items-center',
nav_button: cn(
buttonVariants({ variant: 'outline' }),
- 'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',
+ 'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100'
),
nav_button_previous: 'absolute left-1',
nav_button_next: 'absolute right-1',
@@ -114,7 +109,7 @@ export const CalendarViewGrid = ({ field }: CalendarViewGridProps) => {
cell: cn(
'relative flex-1 h-40 p-2 text-right text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent',
'[&:has([aria-selected])]:rounded-md',
- 'border-r first:border-l border-gray-100 overflow-auto',
+ 'border-r first:border-l border-gray-100 overflow-auto'
),
}}
components={{
@@ -137,7 +132,7 @@ export const CalendarViewGrid = ({ field }: CalendarViewGridProps) => {
records,
filter,
field,
- workspace.userId,
+ workspace.userId
);
return (
diff --git a/apps/desktop/src/renderer/components/databases/database-container.tsx b/apps/desktop/src/renderer/components/databases/database-container.tsx
index 9e9b0f51..d71ebfcb 100644
--- a/apps/desktop/src/renderer/components/databases/database-container.tsx
+++ b/apps/desktop/src/renderer/components/databases/database-container.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Database } from '@/renderer/components/databases/database';
import { DatabaseViews } from '@/renderer/components/databases/database-views';
diff --git a/apps/desktop/src/renderer/components/databases/database-create-dialog.tsx b/apps/desktop/src/renderer/components/databases/database-create-dialog.tsx
index 0b17df7a..7d6c90a0 100644
--- a/apps/desktop/src/renderer/components/databases/database-create-dialog.tsx
+++ b/apps/desktop/src/renderer/components/databases/database-create-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import {
Dialog,
diff --git a/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx b/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx
index eee9742c..d95c4614 100644
--- a/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/databases/fields/field-attrs.tsx b/apps/desktop/src/renderer/components/databases/fields/field-attrs.tsx
index 8607638c..6316bfec 100644
--- a/apps/desktop/src/renderer/components/databases/fields/field-attrs.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/field-attrs.tsx
@@ -1,5 +1,3 @@
-import React from 'react';
-
export const FieldAttrs = () => {
return <div></div>;
};
diff --git a/apps/desktop/src/renderer/components/databases/fields/field-delete-dialog.tsx b/apps/desktop/src/renderer/components/databases/fields/field-delete-dialog.tsx
index 8564b802..0635d28f 100644
--- a/apps/desktop/src/renderer/components/databases/fields/field-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/field-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/databases/fields/field-icon.tsx b/apps/desktop/src/renderer/components/databases/fields/field-icon.tsx
index f0447e5b..73e98df3 100644
--- a/apps/desktop/src/renderer/components/databases/fields/field-icon.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/field-icon.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { FieldType } from '@/registry';
+import { FieldType } from '@colanode/core';
import {
SquareCheck,
User,
@@ -12,7 +11,6 @@ import {
ListCheck,
Text,
Link,
- X,
ShieldQuestion,
} from 'lucide-react';
diff --git a/apps/desktop/src/renderer/components/databases/fields/field-rename-input.tsx b/apps/desktop/src/renderer/components/databases/fields/field-rename-input.tsx
index 01d5dcbe..f32efa44 100644
--- a/apps/desktop/src/renderer/components/databases/fields/field-rename-input.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/field-rename-input.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { FieldAttributes } from '@/registry';
+import { FieldAttributes } from '@colanode/core';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useDatabase } from '@/renderer/contexts/database';
diff --git a/apps/desktop/src/renderer/components/databases/fields/field-select.tsx b/apps/desktop/src/renderer/components/databases/fields/field-select.tsx
index f9976eca..88b34e19 100644
--- a/apps/desktop/src/renderer/components/databases/fields/field-select.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/field-select.tsx
@@ -13,7 +13,7 @@ import {
CommandItem,
CommandList,
} from '@/renderer/components/ui/command';
-import { FieldType, FieldAttributes } from '@/registry';
+import { FieldType, FieldAttributes } from '@colanode/core';
import { cn } from '@/lib/utils';
import { FieldIcon } from './field-icon';
import { Check, ChevronDown } from 'lucide-react';
@@ -68,7 +68,7 @@ export const FieldSelect = ({ fields, value, onChange }: FieldSelectProps) => {
<Check
className={cn(
'ml-auto size-4',
- value === field.id ? 'opacity-100' : 'opacity-0',
+ value === field.id ? 'opacity-100' : 'opacity-0'
)}
/>
</div>
diff --git a/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsx b/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsx
index 38a4bdb2..8c8cadce 100644
--- a/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsx
@@ -13,7 +13,7 @@ import {
CommandItem,
CommandList,
} from '@/renderer/components/ui/command';
-import { FieldType } from '@/registry';
+import { FieldType } from '@colanode/core';
import { cn } from '@/lib/utils';
import { FieldIcon } from './field-icon';
import { Check, ChevronsUpDown } from 'lucide-react';
@@ -125,7 +125,7 @@ export const FieldTypeSelect = ({ type, onChange }: FieldTypeSelectProps) => {
<Check
className={cn(
'ml-auto size-4',
- type === fieldType.type ? 'opacity-100' : 'opacity-0',
+ type === fieldType.type ? 'opacity-100' : 'opacity-0'
)}
/>
</div>
diff --git a/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsx b/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsx
index 365e3174..54605e20 100644
--- a/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsx
@@ -8,7 +8,10 @@ import {
CommandList,
} from '@/renderer/components/ui/command';
import { SelectOptionBadge } from '@/renderer/components/databases/fields/select-option-badge';
-import { MultiSelectFieldAttributes, SelectFieldAttributes } from '@/registry';
+import {
+ MultiSelectFieldAttributes,
+ SelectFieldAttributes,
+} from '@colanode/core';
import { getRandomSelectOptionColor } from '@/lib/databases';
import { SelectOptionSettingsPopover } from '@/renderer/components/databases/fields/select-option-settings-popover';
import { useWorkspace } from '@/renderer/contexts/workspace';
diff --git a/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsx b/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsx
index 278e60bf..8284fcd3 100644
--- a/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { cn } from '@/lib/utils';
import { getSelectOptionColorClass } from '@/lib/databases';
@@ -13,7 +12,7 @@ export const SelectOptionBadge = ({ name, color }: SelectOptionBadgeProps) => {
className={cn(
'line-clamp-1 inline-flex w-max items-center rounded-md border px-1 py-0.5 text-xs',
'transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
- getSelectOptionColorClass(color),
+ getSelectOptionColorClass(color)
)}
>
{name}
diff --git a/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx b/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx
index 2d2e26dd..e60d14f1 100644
--- a/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsx b/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsx
index 00bb83ba..52dfb186 100644
--- a/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsx
@@ -8,7 +8,7 @@ import {
import { Separator } from '@/renderer/components/ui/separator';
import { selectOptionColors } from '@/lib/databases';
import { cn } from '@/lib/utils';
-import { SelectOptionAttributes } from '@/registry';
+import { SelectOptionAttributes } from '@colanode/core';
import { SelectOptionDeleteDialog } from '@/renderer/components/databases/fields/select-option-delete-dialog';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { Ellipsis, Trash2 } from 'lucide-react';
diff --git a/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsx
index e9c3d8c1..bbf164fc 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsx
@@ -1,5 +1,7 @@
-import React from 'react';
-import { BooleanFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import {
+ BooleanFieldAttributes,
+ ViewFieldFilterAttributes,
+} from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -30,7 +32,7 @@ export const ViewBooleanFieldFilter = ({
const operator =
booleanFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? booleanFieldFilterOperators[0];
return (
diff --git a/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsx b/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsx
index cd5d279c..74edea5b 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsx
@@ -1,8 +1,7 @@
-import React from 'react';
import {
CreatedAtFieldAttributes,
ViewFieldFilterAttributes,
-} from '@/registry';
+} from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -34,7 +33,7 @@ export const ViewCreatedAtFieldFilter = ({
const operator =
dateFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? dateFieldFilterOperators[0];
const dateTextValue = (filter.value as string) ?? null;
diff --git a/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsx
index 38fe662e..d046cf3a 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { DateFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import { DateFieldAttributes, ViewFieldFilterAttributes } from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -31,7 +30,7 @@ export const ViewDateFieldFilter = ({
const operator =
dateFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? dateFieldFilterOperators[0];
const dateTextValue = filter.value as string | null;
diff --git a/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsx
index 6671052d..19be17d3 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsx
@@ -1,5 +1,7 @@
-import React from 'react';
-import { EmailFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import {
+ EmailFieldAttributes,
+ ViewFieldFilterAttributes,
+} from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -31,7 +33,7 @@ export const ViewEmailFieldFilter = ({
const operator =
emailFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? emailFieldFilterOperators[0];
const textValue = filter.value as string | null;
diff --git a/apps/desktop/src/renderer/components/databases/search/view-filter-button.tsx b/apps/desktop/src/renderer/components/databases/search/view-filter-button.tsx
index ea230175..d091e6b8 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-filter-button.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-filter-button.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { ViewFilterAddPopover } from '@/renderer/components/databases/search/view-filter-add-popover';
import { useView } from '@/renderer/contexts/view';
import { Filter } from 'lucide-react';
diff --git a/apps/desktop/src/renderer/components/databases/search/view-filters.tsx b/apps/desktop/src/renderer/components/databases/search/view-filters.tsx
index d123d034..75e66749 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-filters.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-filters.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useDatabase } from '@/renderer/contexts/database';
import { ViewTextFieldFilter } from '@/renderer/components/databases/search/view-text-field-filter';
import { ViewNumberFieldFilter } from '@/renderer/components/databases/search/view-number-field-filter';
@@ -27,7 +26,7 @@ export const ViewFilters = () => {
}
const field = database.fields.find(
- (field) => field.id === filter.fieldId,
+ (field) => field.id === filter.fieldId
);
if (!field) {
diff --git a/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsx
index 4201cf4b..13d7d8c6 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsx
@@ -1,8 +1,7 @@
-import React from 'react';
import {
MultiSelectFieldAttributes,
ViewFieldFilterAttributes,
-} from '@/registry';
+} from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -35,12 +34,12 @@ export const ViewMultiSelectFieldFilter = ({
const selectOptions = Object.values(field.options ?? {});
const operator =
selectFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? selectFieldFilterOperators[0];
const selectOptionIds = (filter.value as string[]) ?? [];
const selectedOptions = selectOptions.filter((option) =>
- selectOptionIds.includes(option.id),
+ selectOptionIds.includes(option.id)
);
const hideInput =
diff --git a/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsx
index 9460ab86..44752723 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsx
@@ -1,5 +1,7 @@
-import React from 'react';
-import { NumberFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import {
+ NumberFieldAttributes,
+ ViewFieldFilterAttributes,
+} from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -31,7 +33,7 @@ export const ViewNumberFieldFilter = ({
const operator =
numberFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? numberFieldFilterOperators[0];
const numberValue = filter.value as number | null;
diff --git a/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsx
index 1a2f517e..bc9750f2 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsx
@@ -1,5 +1,7 @@
-import React from 'react';
-import { PhoneFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import {
+ PhoneFieldAttributes,
+ ViewFieldFilterAttributes,
+} from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -31,7 +33,7 @@ export const ViewPhoneFieldFilter = ({
const operator =
phoneFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? phoneFieldFilterOperators[0];
const phoneValue = filter.value as string | null;
diff --git a/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsx
index ff81c82e..21c9b185 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsx
@@ -1,5 +1,7 @@
-import React from 'react';
-import { SelectFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import {
+ SelectFieldAttributes,
+ ViewFieldFilterAttributes,
+} from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -32,12 +34,12 @@ export const ViewSelectFieldFilter = ({
const selectOptions = Object.values(field.options ?? {});
const operator =
selectFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? selectFieldFilterOperators[0];
const selectOptionIds = (filter.value as string[]) ?? [];
const selectedOptions = selectOptions.filter((option) =>
- selectOptionIds.includes(option.id),
+ selectOptionIds.includes(option.id)
);
const hideInput =
diff --git a/apps/desktop/src/renderer/components/databases/search/view-sort-button.tsx b/apps/desktop/src/renderer/components/databases/search/view-sort-button.tsx
index f102b5ca..e4d13bf4 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-sort-button.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-sort-button.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { ViewSortAddPopover } from '@/renderer/components/databases/search/view-sort-add-popover';
import { useView } from '@/renderer/contexts/view';
import { ArrowDownAz } from 'lucide-react';
diff --git a/apps/desktop/src/renderer/components/databases/search/view-sort-row.tsx b/apps/desktop/src/renderer/components/databases/search/view-sort-row.tsx
index d7196f4a..1b269dfe 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-sort-row.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-sort-row.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { FieldAttributes, ViewSortAttributes } from '@/registry';
+import { FieldAttributes, ViewSortAttributes } from '@colanode/core';
import {
DropdownMenu,
DropdownMenuContent,
diff --git a/apps/desktop/src/renderer/components/databases/search/view-sorts.tsx b/apps/desktop/src/renderer/components/databases/search/view-sorts.tsx
index 98b5eed2..f72623f5 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-sorts.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-sorts.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Popover,
PopoverContent,
@@ -39,7 +38,7 @@ export const ViewSorts = () => {
<PopoverContent className="flex flex-col gap-2 p-2">
{view.sorts.map((sort) => {
const field = database.fields.find(
- (field) => field.id === sort.fieldId,
+ (field) => field.id === sort.fieldId
);
if (!field) return null;
diff --git a/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsx
index ea158989..f0ed0472 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { TextFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import { TextFieldAttributes, ViewFieldFilterAttributes } from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -31,7 +30,7 @@ export const ViewTextFieldFilter = ({
const operator =
textFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? textFieldFilterOperators[0];
const textValue = filter.value as string | null;
diff --git a/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsx
index 14053aff..66997370 100644
--- a/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsx
+++ b/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { UrlFieldAttributes, ViewFieldFilterAttributes } from '@/registry';
+import { UrlFieldAttributes, ViewFieldFilterAttributes } from '@colanode/core';
import {
Popover,
PopoverContent,
@@ -31,7 +30,7 @@ export const ViewUrlFieldFilter = ({
const operator =
urlFieldFilterOperators.find(
- (operator) => operator.value === filter.operator,
+ (operator) => operator.value === filter.operator
) ?? urlFieldFilterOperators[0];
const urlValue = filter.value as string | null;
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-boolean-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-boolean-cell.tsx
index 4fb86b46..d4f5fcb4 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-boolean-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-boolean-cell.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { Checkbox } from '@/renderer/components/ui/checkbox';
-import { BooleanFieldAttributes } from '@/registry';
+import { BooleanFieldAttributes } from '@colanode/core';
import { useRecord } from '@/renderer/contexts/record';
interface TableViewBooleanCellProps {
@@ -11,7 +11,7 @@ export const TableViewBooleanCell = ({ field }: TableViewBooleanCellProps) => {
const record = useRecord();
const [input, setInput] = React.useState<boolean>(
- record.getBooleanValue(field),
+ record.getBooleanValue(field)
);
React.useEffect(() => {
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-at-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-at-cell.tsx
index 08831b41..0a3b5095 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-at-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-at-cell.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { CreatedAtFieldAttributes } from '@/registry';
+import { CreatedAtFieldAttributes } from '@colanode/core';
import { useRecord } from '@/renderer/contexts/record';
interface TableViewCreatedAtCellProps {
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-by-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-by-cell.tsx
index 3d4c87fb..bcbdca83 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-by-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-created-by-cell.tsx
@@ -1,6 +1,5 @@
-import React from 'react';
import { Avatar } from '@/renderer/components/avatars/avatar';
-import { CreatedByFieldAttributes } from '@/registry';
+import { CreatedByFieldAttributes } from '@colanode/core';
import { useQuery } from '@/renderer/hooks/use-query';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-date-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-date-cell.tsx
index b864ca59..1ac6f61c 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-date-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-date-cell.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { DateFieldAttributes } from '@/registry';
+import { DateFieldAttributes } from '@colanode/core';
import { DatePicker } from '@/renderer/components/ui/date-picker';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-email-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-email-cell.tsx
index 22b449d4..a8400450 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-email-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-email-cell.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { EmailFieldAttributes } from '@/registry';
+import { EmailFieldAttributes } from '@colanode/core';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-multi-select-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-multi-select-cell.tsx
index 56de8137..42923f26 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-multi-select-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-multi-select-cell.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { MultiSelectFieldAttributes } from '@/registry';
+import { MultiSelectFieldAttributes } from '@colanode/core';
import { SelectOptionBadge } from '@/renderer/components/databases/fields/select-option-badge';
import {
Popover,
@@ -20,7 +20,7 @@ export const TableViewMultiSelectCell = ({
const [open, setOpen] = React.useState(false);
const [selectedValues, setSelectedValues] = React.useState(
- record.getMultiSelectValue(field),
+ record.getMultiSelectValue(field)
);
React.useEffect(() => {
@@ -29,7 +29,7 @@ export const TableViewMultiSelectCell = ({
const selectOptions = Object.values(field.options ?? {});
const selectedOptions = selectOptions.filter((option) =>
- selectedValues.includes(option.id),
+ selectedValues.includes(option.id)
);
return (
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-number-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-number-cell.tsx
index fced089d..33110d41 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-number-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-number-cell.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { NumberFieldAttributes } from '@/registry';
+import { NumberFieldAttributes } from '@colanode/core';
import { SmartNumberInput } from '@/renderer/components/ui/smart-number-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-phone-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-phone-cell.tsx
index 137a51e9..3ff382ca 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-phone-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-phone-cell.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { PhoneFieldAttributes } from '@/registry';
+import { PhoneFieldAttributes } from '@colanode/core';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-select-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-select-cell.tsx
index 732df8de..7edb08a4 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-select-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-select-cell.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { SelectFieldAttributes } from '@/registry';
+import { SelectFieldAttributes } from '@colanode/core';
import { SelectOptionBadge } from '@/renderer/components/databases/fields/select-option-badge';
import {
Popover,
@@ -17,7 +17,7 @@ export const TableViewSelectCell = ({ field }: TableViewSelectCellProps) => {
const record = useRecord();
const [open, setOpen] = React.useState(false);
const [selectedValue, setSelectedValue] = React.useState(
- record.getSelectValue(field),
+ record.getSelectValue(field)
);
React.useEffect(() => {
@@ -26,7 +26,7 @@ export const TableViewSelectCell = ({ field }: TableViewSelectCellProps) => {
const selectOptions = Object.values(field.options ?? {});
const selectedOption = selectOptions.find(
- (option) => option.id === selectedValue,
+ (option) => option.id === selectedValue
);
return (
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-text-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-text-cell.tsx
index 5fa55083..5d64b0aa 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-text-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-text-cell.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { TextFieldAttributes } from '@/registry';
+import { TextFieldAttributes } from '@colanode/core';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsx
index 784095e9..a4c2097d 100644
--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { UrlFieldAttributes } from '@/registry';
+import { UrlFieldAttributes } from '@colanode/core';
import { cn, isValidUrl } from '@/lib/utils';
import {
HoverCard,
@@ -48,7 +47,7 @@ export const TableViewUrlCell = ({ field }: TableViewUrlCellProps) => {
<HoverCardContent
className={cn(
'flex w-full min-w-80 max-w-128 flex-row items-center justify-between gap-2 text-ellipsis',
- !isUrl && 'hidden',
+ !isUrl && 'hidden'
)}
>
<a
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-body.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-body.tsx
index 499bb2e9..76d4cb88 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-body.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-body.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useDatabase } from '@/renderer/contexts/database';
import { TableViewRow } from '@/renderer/components/databases/tables/table-view-row';
import { TableViewEmptyPlaceholder } from '@/renderer/components/databases/tables/table-view-empty-placeholder';
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-empty-placeholder.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-empty-placeholder.tsx
index c8573953..6b48db76 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-empty-placeholder.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-empty-placeholder.tsx
@@ -1,5 +1,3 @@
-import React from 'react';
-
export const TableViewEmptyPlaceholder = () => {
return (
<div className="flex w-full flex-col items-center justify-center border-b p-10 text-sm text-muted-foreground">
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-field-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-field-cell.tsx
index b9c63f93..4a76abf8 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-field-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-field-cell.tsx
@@ -1,6 +1,4 @@
-import React from 'react';
-import { RecordNode } from '@/registry';
-import { FieldAttributes } from '@/registry';
+import { RecordNode, FieldAttributes } from '@colanode/core';
import { TableViewTextCell } from '@/renderer/components/databases/tables/cells/table-view-text-cell';
import { TableViewNumberCell } from '@/renderer/components/databases/tables/cells/table-view-number-cell';
import { TableViewBooleanCell } from '@/renderer/components/databases/tables/cells/table-view-boolean-cell';
@@ -18,10 +16,7 @@ interface TableViewFieldCellProps {
field: FieldAttributes;
}
-export const TableViewFieldCell = ({
- record,
- field,
-}: TableViewFieldCellProps) => {
+export const TableViewFieldCell = ({ field }: TableViewFieldCellProps) => {
switch (field.type) {
case 'text':
return <TableViewTextCell field={field} />;
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-header.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-header.tsx
index 6922f53c..a467d0b9 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-header.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-header.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useView } from '@/renderer/contexts/view';
import { TableViewNameHeader } from '@/renderer/components/databases/tables/table-view-name-header';
import { TableViewFieldHeader } from '@/renderer/components/databases/tables/table-view-field-header';
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-load-more-row.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-load-more-row.tsx
index 297389cd..d42af77b 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-load-more-row.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-load-more-row.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Spinner } from '@/renderer/components/ui/spinner';
import { ArrowDown } from 'lucide-react';
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx
index 0466bf5e..cc259a7b 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import isHotkey from 'is-hotkey';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { Spinner } from '@/renderer/components/ui/spinner';
-import { RecordNode } from '@/registry';
+import { RecordNode } from '@colanode/core';
import { useMutation } from '@/renderer/hooks/use-mutation';
import { Maximize2 } from 'lucide-react';
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsx
index 71146860..256fba1f 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Resizable } from 're-resizable';
import {
Popover,
@@ -56,7 +55,7 @@ export const TableViewNameHeader = () => {
right: '-3px',
},
}}
- onResizeStop={(e, direction, ref) => {
+ onResizeStop={(_, __, ref) => {
const newWidth = ref.offsetWidth;
view.resizeName(newWidth);
}}
@@ -68,7 +67,7 @@ export const TableViewNameHeader = () => {
'flex h-8 w-full cursor-pointer flex-row items-center gap-1 p-1 text-sm hover:bg-gray-50',
dropMonitor.isOver && dropMonitor.canDrop
? 'border-r-2 border-blue-300'
- : 'border-r',
+ : 'border-r'
)}
ref={dropRef}
>
@@ -80,7 +79,7 @@ export const TableViewNameHeader = () => {
<div className="p-1">
<Input
value={'Name'}
- onChange={(e) => {
+ onChange={(_) => {
// setName(e.target.value);
// updateName(e.target.value);
}}
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-record-create-row.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-record-create-row.tsx
index 0ab8859e..19cd7cca 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-record-create-row.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-record-create-row.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useDatabase } from '@/renderer/contexts/database';
import { useMutation } from '@/renderer/hooks/use-mutation';
import { useWorkspace } from '@/renderer/contexts/workspace';
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-row.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-row.tsx
index 74b107b1..436e62f4 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-row.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-row.tsx
@@ -1,7 +1,6 @@
-import React from 'react';
import { TableViewNameCell } from '@/renderer/components/databases/tables/table-view-name-cell';
import { TableViewFieldCell } from '@/renderer/components/databases/tables/table-view-field-cell';
-import { RecordNode } from '@/registry';
+import { RecordNode } from '@colanode/core';
import { useView } from '@/renderer/contexts/view';
import { RecordProvider } from '@/renderer/components/records/record-provider';
diff --git a/apps/desktop/src/renderer/components/databases/view-delete-dialog.tsx b/apps/desktop/src/renderer/components/databases/view-delete-dialog.tsx
index 33d12f83..d674c3bc 100644
--- a/apps/desktop/src/renderer/components/databases/view-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/databases/view-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/databases/view-settings-button.tsx b/apps/desktop/src/renderer/components/databases/view-settings-button.tsx
index 9543c34a..0cdf1d5e 100644
--- a/apps/desktop/src/renderer/components/databases/view-settings-button.tsx
+++ b/apps/desktop/src/renderer/components/databases/view-settings-button.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Settings } from 'lucide-react';
export const ViewSettingsButton = () => {
diff --git a/apps/desktop/src/renderer/components/databases/view-tab.tsx b/apps/desktop/src/renderer/components/databases/view-tab.tsx
index feec1293..5d4ee643 100644
--- a/apps/desktop/src/renderer/components/databases/view-tab.tsx
+++ b/apps/desktop/src/renderer/components/databases/view-tab.tsx
@@ -1,7 +1,6 @@
-import React from 'react';
import { cn } from '@/lib/utils';
import { Avatar } from '@/renderer/components/avatars/avatar';
-import { ViewAttributes } from '@/registry/database';
+import { ViewAttributes } from '@colanode/core';
interface ViewTabProps {
view: ViewAttributes;
@@ -15,7 +14,7 @@ export const ViewTab = ({ view, isActive, onClick }: ViewTabProps) => {
role="presentation"
className={cn(
'inline-flex cursor-pointer flex-row items-center gap-1 border-b-2 p-1 pl-0 text-sm',
- isActive ? 'border-gray-500' : 'border-transparent',
+ isActive ? 'border-gray-500' : 'border-transparent'
)}
onClick={() => onClick()}
onKeyDown={() => onClick()}
diff --git a/apps/desktop/src/renderer/components/databases/view-tabs.tsx b/apps/desktop/src/renderer/components/databases/view-tabs.tsx
index 9088f43f..7d9c80fa 100644
--- a/apps/desktop/src/renderer/components/databases/view-tabs.tsx
+++ b/apps/desktop/src/renderer/components/databases/view-tabs.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { ViewTab } from '@/renderer/components/databases/view-tab';
import { ViewCreateButton } from '@/renderer/components/databases/view-create-button';
import { useDatabaseViews } from '@/renderer/contexts/database-views';
diff --git a/apps/desktop/src/renderer/components/databases/view.tsx b/apps/desktop/src/renderer/components/databases/view.tsx
index dc713d4c..b0e950c4 100644
--- a/apps/desktop/src/renderer/components/databases/view.tsx
+++ b/apps/desktop/src/renderer/components/databases/view.tsx
@@ -5,7 +5,7 @@ import {
ViewFieldFilterAttributes,
ViewFilterAttributes,
ViewSortAttributes,
-} from '@/registry/database';
+} from '@colanode/core';
import { TableView } from '@/renderer/components/databases/tables/table-view';
import { BoardView } from '@/renderer/components/databases/boards/board-view';
import { CalendarView } from '@/renderer/components/databases/calendars/calendar-view';
@@ -29,7 +29,7 @@ interface ViewProps {
export const View = ({ view }: ViewProps) => {
const workspace = useWorkspace();
const database = useDatabase();
- const { mutate, isPending } = useMutation();
+ const { mutate } = useMutation();
const fields: ViewField[] = React.useMemo(() => {
return database.fields
@@ -50,7 +50,7 @@ export const View = ({ view }: ViewProps) => {
const [isSearchBarOpened, setIsSearchBarOpened] = React.useState(false);
const [isSortsOpened, setIsSortsOpened] = React.useState(false);
const [openedFieldFilters, setOpenedFieldFilters] = React.useState<string[]>(
- [],
+ []
);
return (
@@ -138,7 +138,7 @@ export const View = ({ view }: ViewProps) => {
database.fields,
Object.values(view.fields),
id,
- after,
+ after
);
if (newIndex === null) {
return;
diff --git a/apps/desktop/src/renderer/components/documents/document.tsx b/apps/desktop/src/renderer/components/documents/document.tsx
index eb7f663f..34765912 100644
--- a/apps/desktop/src/renderer/components/documents/document.tsx
+++ b/apps/desktop/src/renderer/components/documents/document.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { DocumentEditor } from '@/renderer/components/documents/document-editor';
import { useQuery } from '@/renderer/hooks/use-query';
import { useWorkspace } from '@/renderer/contexts/workspace';
diff --git a/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsx b/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsx
index a6b1a12b..ad984b99 100644
--- a/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsx
+++ b/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Emoji } from '@/lib/emojis';
import { EmojiElement } from '@/renderer/components/emojis/emoji-element';
import { useEmojiPicker } from '@/renderer/contexts/emoji-picker';
diff --git a/apps/desktop/src/renderer/components/files/file-block.tsx b/apps/desktop/src/renderer/components/files/file-block.tsx
index cfc62c9d..053bc2e8 100644
--- a/apps/desktop/src/renderer/components/files/file-block.tsx
+++ b/apps/desktop/src/renderer/components/files/file-block.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { getFileUrl } from '@/lib/files';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useQuery } from '@/renderer/hooks/use-query';
diff --git a/apps/desktop/src/renderer/components/files/file-container.tsx b/apps/desktop/src/renderer/components/files/file-container.tsx
index 17252568..66799d7a 100644
--- a/apps/desktop/src/renderer/components/files/file-container.tsx
+++ b/apps/desktop/src/renderer/components/files/file-container.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useQuery } from '@/renderer/hooks/use-query';
import { FilePreview } from '@/renderer/components/files/file-preview';
diff --git a/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx b/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx
index fea5697c..c226a686 100644
--- a/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/files/file-download.tsx b/apps/desktop/src/renderer/components/files/file-download.tsx
index 596e10ca..f96a43f4 100644
--- a/apps/desktop/src/renderer/components/files/file-download.tsx
+++ b/apps/desktop/src/renderer/components/files/file-download.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useMutation } from '@/renderer/hooks/use-mutation';
import { Spinner } from '@/renderer/components/ui/spinner';
diff --git a/apps/desktop/src/renderer/components/files/file-icon.tsx b/apps/desktop/src/renderer/components/files/file-icon.tsx
index 24341d41..3ba7f1b2 100644
--- a/apps/desktop/src/renderer/components/files/file-icon.tsx
+++ b/apps/desktop/src/renderer/components/files/file-icon.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { FileImage, File, FileVideo, FileAudio, FileText } from 'lucide-react';
interface FileIconProps {
diff --git a/apps/desktop/src/renderer/components/files/file-preview.tsx b/apps/desktop/src/renderer/components/files/file-preview.tsx
index a6f8131c..0ef29f4b 100644
--- a/apps/desktop/src/renderer/components/files/file-preview.tsx
+++ b/apps/desktop/src/renderer/components/files/file-preview.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { match } from 'ts-pattern';
import { getFilePreviewType } from '@/lib/files';
import { FilePreviewImage } from '@/renderer/components/files/previews/file-preview-image';
diff --git a/apps/desktop/src/renderer/components/files/file-thumbnail.tsx b/apps/desktop/src/renderer/components/files/file-thumbnail.tsx
index 12204279..b4cffc81 100644
--- a/apps/desktop/src/renderer/components/files/file-thumbnail.tsx
+++ b/apps/desktop/src/renderer/components/files/file-thumbnail.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { getFileUrl } from '@/lib/files';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { cn } from '@/lib/utils';
diff --git a/apps/desktop/src/renderer/components/files/previews/file-preview-image.tsx b/apps/desktop/src/renderer/components/files/previews/file-preview-image.tsx
index 09dadec9..5039e5c9 100644
--- a/apps/desktop/src/renderer/components/files/previews/file-preview-image.tsx
+++ b/apps/desktop/src/renderer/components/files/previews/file-preview-image.tsx
@@ -1,5 +1,3 @@
-import React from 'react';
-
interface FilePreviewImageProps {
url: string;
name: string;
diff --git a/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsx b/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsx
index e756c2f0..152ad75e 100644
--- a/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsx
+++ b/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { getFriendlyNameFromMimeType } from '@/lib/files';
import { FileIcon } from '@/renderer/components/files/file-icon';
diff --git a/apps/desktop/src/renderer/components/files/previews/file-preview-video.tsx b/apps/desktop/src/renderer/components/files/previews/file-preview-video.tsx
index 68546cf3..d5e3a5a4 100644
--- a/apps/desktop/src/renderer/components/files/previews/file-preview-video.tsx
+++ b/apps/desktop/src/renderer/components/files/previews/file-preview-video.tsx
@@ -1,5 +1,3 @@
-import React from 'react';
-
interface FilePreviewVideoProps {
url: string;
}
diff --git a/apps/desktop/src/renderer/components/folders/folder-create-dialog.tsx b/apps/desktop/src/renderer/components/folders/folder-create-dialog.tsx
index a02358c7..7f9383ea 100644
--- a/apps/desktop/src/renderer/components/folders/folder-create-dialog.tsx
+++ b/apps/desktop/src/renderer/components/folders/folder-create-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import {
Dialog,
diff --git a/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx b/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx
index 0fded722..f4908dbc 100644
--- a/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/folders/folder-files.tsx b/apps/desktop/src/renderer/components/folders/folder-files.tsx
index 368ad21e..e8808e30 100644
--- a/apps/desktop/src/renderer/components/folders/folder-files.tsx
+++ b/apps/desktop/src/renderer/components/folders/folder-files.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { match } from 'ts-pattern';
import { FolderContext } from '@/renderer/contexts/folder';
import { FolderLayoutType } from '@/types/folders';
diff --git a/apps/desktop/src/renderer/components/folders/galleries/gallery-layout.tsx b/apps/desktop/src/renderer/components/folders/galleries/gallery-layout.tsx
index d80c3b27..a2e9ef87 100644
--- a/apps/desktop/src/renderer/components/folders/galleries/gallery-layout.tsx
+++ b/apps/desktop/src/renderer/components/folders/galleries/gallery-layout.tsx
@@ -1,5 +1,3 @@
-import React from 'react';
-
export const GalleryLayout = () => {
return <div>GalleryLayout</div>;
};
diff --git a/apps/desktop/src/renderer/components/folders/grids/grid-file.tsx b/apps/desktop/src/renderer/components/folders/grids/grid-file.tsx
index 0c12f078..8a65d0b7 100644
--- a/apps/desktop/src/renderer/components/folders/grids/grid-file.tsx
+++ b/apps/desktop/src/renderer/components/folders/grids/grid-file.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { FileNode } from '@/types/files';
import { FileThumbnail } from '@/renderer/components/files/file-thumbnail';
import { FileContextMenu } from '@/renderer/components/files/file-context-menu';
diff --git a/apps/desktop/src/renderer/components/folders/grids/grid-layout.tsx b/apps/desktop/src/renderer/components/folders/grids/grid-layout.tsx
index 08d50405..fb6bbbf2 100644
--- a/apps/desktop/src/renderer/components/folders/grids/grid-layout.tsx
+++ b/apps/desktop/src/renderer/components/folders/grids/grid-layout.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useFolder } from '@/renderer/contexts/folder';
import { GridFile } from '@/renderer/components/folders/grids/grid-file';
diff --git a/apps/desktop/src/renderer/components/folders/lists/list-layout.tsx b/apps/desktop/src/renderer/components/folders/lists/list-layout.tsx
index b65ae4e0..9b1bfbdf 100644
--- a/apps/desktop/src/renderer/components/folders/lists/list-layout.tsx
+++ b/apps/desktop/src/renderer/components/folders/lists/list-layout.tsx
@@ -1,5 +1,3 @@
-import React from 'react';
-
export const ListLayout = () => {
return <div>ListLayout</div>;
};
diff --git a/apps/desktop/src/renderer/components/icons/icon-picker-item.tsx b/apps/desktop/src/renderer/components/icons/icon-picker-item.tsx
index 2712ecd4..7cc438ac 100644
--- a/apps/desktop/src/renderer/components/icons/icon-picker-item.tsx
+++ b/apps/desktop/src/renderer/components/icons/icon-picker-item.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Icon } from '@/lib/icons';
import { useIconPicker } from '@/renderer/contexts/icon-picker';
import { IconElement } from '@/renderer/components/icons/icon-element';
diff --git a/apps/desktop/src/renderer/components/messages/conversation.tsx b/apps/desktop/src/renderer/components/messages/conversation.tsx
index 88424b49..c35f8968 100644
--- a/apps/desktop/src/renderer/components/messages/conversation.tsx
+++ b/apps/desktop/src/renderer/components/messages/conversation.tsx
@@ -29,15 +29,13 @@ export const Conversation = ({ conversationId }: ConversationProps) => {
if (containerRef.current && viewportRef.current) {
// observe resize of container when new messages are appended or internal elements are loaded (e.g. images)
observerRef.current = new ResizeObserver(() => {
- if (!viewportRef.current) {
- return;
- }
-
- if (shouldScrollToBottomRef.current) {
- bottomRef.current?.scrollIntoView();
- } else {
- viewportRef.current.scrollTop =
- viewportRef.current.scrollHeight - scrollPositionRef.current;
+ if (viewportRef.current) {
+ if (shouldScrollToBottomRef.current) {
+ bottomRef.current?.scrollIntoView();
+ } else {
+ viewportRef.current.scrollTop =
+ viewportRef.current.scrollHeight - scrollPositionRef.current;
+ }
}
});
@@ -49,6 +47,8 @@ export const Conversation = ({ conversationId }: ConversationProps) => {
}
};
}
+
+ return () => {};
}, [conversationId]);
const handleScroll = () => {
diff --git a/apps/desktop/src/renderer/components/messages/message-editor.tsx b/apps/desktop/src/renderer/components/messages/message-editor.tsx
index 38be117e..0120fd4d 100644
--- a/apps/desktop/src/renderer/components/messages/message-editor.tsx
+++ b/apps/desktop/src/renderer/components/messages/message-editor.tsx
@@ -84,7 +84,7 @@ export const MessageEditor = React.forwardRef<
class:
'prose-lg prose-stone dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full',
},
- handleKeyDown: (view, event) => {
+ handleKeyDown: (_, event) => {
return isHotkey('enter', event);
},
},
@@ -94,7 +94,7 @@ export const MessageEditor = React.forwardRef<
autofocus: 'end',
editable: props.canEdit,
},
- [props.conversationId],
+ [props.conversationId]
);
const handleSubmit = React.useCallback(() => {
@@ -196,6 +196,8 @@ export const MessageEditor = React.forwardRef<
handleSubmit();
return true;
}
+
+ return false;
}}
/>
</div>
diff --git a/apps/desktop/src/renderer/components/messages/message-reactions.tsx b/apps/desktop/src/renderer/components/messages/message-reactions.tsx
index 1fbd9a18..49b8438e 100644
--- a/apps/desktop/src/renderer/components/messages/message-reactions.tsx
+++ b/apps/desktop/src/renderer/components/messages/message-reactions.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { MessageNode } from '@/types/messages';
import { EmojiElement } from '@/renderer/components/emojis/emoji-element';
import { cn } from '@/lib/utils';
@@ -30,7 +29,7 @@ export const MessageReactions = ({
className={cn(
'rouded flex flex-row items-center gap-2 px-1 py-0.5 shadow',
'cursor-pointer text-sm text-muted-foreground hover:text-foreground',
- hasReacted ? 'bg-blue-100' : 'bg-gray-50',
+ hasReacted ? 'bg-blue-100' : 'bg-gray-50'
)}
onClick={() => onReactionClick(reaction.reaction)}
>
diff --git a/apps/desktop/src/renderer/components/messages/message-reference.tsx b/apps/desktop/src/renderer/components/messages/message-reference.tsx
index 7db01390..52979539 100644
--- a/apps/desktop/src/renderer/components/messages/message-reference.tsx
+++ b/apps/desktop/src/renderer/components/messages/message-reference.tsx
@@ -1,5 +1,3 @@
-import React from 'react';
-
export const MessageReference = () => {
return (
<div className="items-top flex flex-row gap-2 border-l-4 p-2">
diff --git a/apps/desktop/src/renderer/components/messages/message.tsx b/apps/desktop/src/renderer/components/messages/message.tsx
index dcb590f6..d00e5876 100644
--- a/apps/desktop/src/renderer/components/messages/message.tsx
+++ b/apps/desktop/src/renderer/components/messages/message.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Avatar } from '@/renderer/components/avatars/avatar';
import {
Tooltip,
@@ -24,7 +23,7 @@ interface MessageProps {
const shouldDisplayUserInfo = (
message: MessageNode,
- previousMessage?: MessageNode | null,
+ previousMessage?: MessageNode | null
) => {
if (!previousMessage) {
return true;
@@ -48,7 +47,6 @@ export const Message = ({
const workspace = useWorkspace();
const { mutate, isPending } = useMutation();
- const canEdit = true;
const canDelete = true;
const canReplyInThread = false;
const displayUserInfo = shouldDisplayUserInfo(message, previousMessage);
@@ -158,7 +156,7 @@ export const Message = ({
message.reactionCounts.some(
(reactionCount) =>
reactionCount.reaction === reaction &&
- reactionCount.isReactedTo,
+ reactionCount.isReactedTo
)
) {
mutate({
diff --git a/apps/desktop/src/renderer/components/pages/page-container.tsx b/apps/desktop/src/renderer/components/pages/page-container.tsx
index 72f79671..8a5835af 100644
--- a/apps/desktop/src/renderer/components/pages/page-container.tsx
+++ b/apps/desktop/src/renderer/components/pages/page-container.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { ScrollArea } from '@/renderer/components/ui/scroll-area';
import { Document } from '@/renderer/components/documents/document';
diff --git a/apps/desktop/src/renderer/components/pages/page-create-dialog.tsx b/apps/desktop/src/renderer/components/pages/page-create-dialog.tsx
index 3ac9f6a5..f987bcc7 100644
--- a/apps/desktop/src/renderer/components/pages/page-create-dialog.tsx
+++ b/apps/desktop/src/renderer/components/pages/page-create-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import {
Dialog,
diff --git a/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx b/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx
index 8f7847bd..0f295886 100644
--- a/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/records/record-attributes.tsx b/apps/desktop/src/renderer/components/records/record-attributes.tsx
index a8b577b0..24f6b86b 100644
--- a/apps/desktop/src/renderer/components/records/record-attributes.tsx
+++ b/apps/desktop/src/renderer/components/records/record-attributes.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { RecordName } from '@/renderer/components/records/record-name';
import { useDatabase } from '@/renderer/contexts/database';
import { RecordField } from '@/renderer/components/records/record-field';
diff --git a/apps/desktop/src/renderer/components/records/record-container.tsx b/apps/desktop/src/renderer/components/records/record-container.tsx
index 64f05a8d..d41c6687 100644
--- a/apps/desktop/src/renderer/components/records/record-container.tsx
+++ b/apps/desktop/src/renderer/components/records/record-container.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useQuery } from '@/renderer/hooks/use-query';
import { Database } from '@/renderer/components/databases/database';
import { RecordAttributes } from '@/renderer/components/records/record-attributes';
diff --git a/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx b/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx
index 861f31e0..8ece6c8e 100644
--- a/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
AlertDialog,
AlertDialogCancel,
diff --git a/apps/desktop/src/renderer/components/records/record-field-value.tsx b/apps/desktop/src/renderer/components/records/record-field-value.tsx
index 0bcf59b8..951fa4a3 100644
--- a/apps/desktop/src/renderer/components/records/record-field-value.tsx
+++ b/apps/desktop/src/renderer/components/records/record-field-value.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { FieldAttributes } from '@/registry';
+import { FieldAttributes } from '@colanode/core';
import { RecordTextValue } from '@/renderer/components/records/values/record-text-value';
import { RecordNumberValue } from '@/renderer/components/records/values/record-number-value';
import { RecordBooleanValue } from '@/renderer/components/records/values/record-boolean-value';
@@ -37,5 +36,7 @@ export const RecordFieldValue = ({ field }: RecordFieldValueProps) => {
return <RecordUrlValue field={field} />;
case 'multiSelect':
return <RecordMultiSelectValue field={field} />;
+ default:
+ return null;
}
};
diff --git a/apps/desktop/src/renderer/components/records/record-field.tsx b/apps/desktop/src/renderer/components/records/record-field.tsx
index 0b961e12..ed1560be 100644
--- a/apps/desktop/src/renderer/components/records/record-field.tsx
+++ b/apps/desktop/src/renderer/components/records/record-field.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { FieldAttributes } from '@/registry';
+import { FieldAttributes } from '@colanode/core';
import {
Popover,
PopoverContent,
diff --git a/apps/desktop/src/renderer/components/records/record-name.tsx b/apps/desktop/src/renderer/components/records/record-name.tsx
index af87421c..02ebc190 100644
--- a/apps/desktop/src/renderer/components/records/record-name.tsx
+++ b/apps/desktop/src/renderer/components/records/record-name.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useMutation } from '@/renderer/hooks/use-mutation';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useWorkspace } from '@/renderer/contexts/workspace';
diff --git a/apps/desktop/src/renderer/components/records/record-provider.tsx b/apps/desktop/src/renderer/components/records/record-provider.tsx
index 61b41d71..c29e42ad 100644
--- a/apps/desktop/src/renderer/components/records/record-provider.tsx
+++ b/apps/desktop/src/renderer/components/records/record-provider.tsx
@@ -1,7 +1,6 @@
import React from 'react';
import { RecordContext } from '@/renderer/contexts/record';
-import { RecordNode } from '@/registry';
-import { useDatabase } from '@/renderer/contexts/database';
+import { RecordNode } from '@colanode/core';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useMutation } from '@/renderer/hooks/use-mutation';
@@ -13,7 +12,6 @@ export const RecordProvider = ({
children: React.ReactNode;
}) => {
const workspace = useWorkspace();
- const database = useDatabase();
const { mutate } = useMutation();
diff --git a/apps/desktop/src/renderer/components/records/values/record-boolean-value.tsx b/apps/desktop/src/renderer/components/records/values/record-boolean-value.tsx
index df882972..094c54ca 100644
--- a/apps/desktop/src/renderer/components/records/values/record-boolean-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-boolean-value.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { Checkbox } from '@/renderer/components/ui/checkbox';
-import { BooleanFieldAttributes } from '@/registry';
+import { BooleanFieldAttributes } from '@colanode/core';
import { useRecord } from '@/renderer/contexts/record';
interface RecordBooleanValueProps {
@@ -11,7 +11,7 @@ export const RecordBooleanValue = ({ field }: RecordBooleanValueProps) => {
const record = useRecord();
const [input, setInput] = React.useState<boolean>(
- record.getBooleanValue(field),
+ record.getBooleanValue(field)
);
React.useEffect(() => {
diff --git a/apps/desktop/src/renderer/components/records/values/record-created-at-value.tsx b/apps/desktop/src/renderer/components/records/values/record-created-at-value.tsx
index c790c9ae..73d3304f 100644
--- a/apps/desktop/src/renderer/components/records/values/record-created-at-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-created-at-value.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { CreatedAtFieldAttributes } from '@/registry';
+import { CreatedAtFieldAttributes } from '@colanode/core';
import { useRecord } from '@/renderer/contexts/record';
interface RecordCreatedAtValueProps {
diff --git a/apps/desktop/src/renderer/components/records/values/record-created-by-value.tsx b/apps/desktop/src/renderer/components/records/values/record-created-by-value.tsx
index e07a7292..74c721bd 100644
--- a/apps/desktop/src/renderer/components/records/values/record-created-by-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-created-by-value.tsx
@@ -1,6 +1,5 @@
-import React from 'react';
import { Avatar } from '@/renderer/components/avatars/avatar';
-import { CreatedByFieldAttributes } from '@/registry';
+import { CreatedByFieldAttributes } from '@colanode/core';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useQuery } from '@/renderer/hooks/use-query';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/records/values/record-email-value.tsx b/apps/desktop/src/renderer/components/records/values/record-email-value.tsx
index 84308177..244b9073 100644
--- a/apps/desktop/src/renderer/components/records/values/record-email-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-email-value.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { EmailFieldAttributes } from '@/registry';
+import { EmailFieldAttributes } from '@colanode/core';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/records/values/record-multi-select-value.tsx b/apps/desktop/src/renderer/components/records/values/record-multi-select-value.tsx
index ddd048d9..a570c8b1 100644
--- a/apps/desktop/src/renderer/components/records/values/record-multi-select-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-multi-select-value.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { MultiSelectFieldAttributes } from '@/registry';
+import { MultiSelectFieldAttributes } from '@colanode/core';
import {
Popover,
PopoverTrigger,
@@ -20,7 +20,7 @@ export const RecordMultiSelectValue = ({
const [open, setOpen] = React.useState(false);
const [selectedValues, setSelectedValues] = React.useState(
- record.getMultiSelectValue(field),
+ record.getMultiSelectValue(field)
);
React.useEffect(() => {
@@ -29,7 +29,7 @@ export const RecordMultiSelectValue = ({
const selectOptions = Object.values(field.options ?? {});
const selectedOptions = selectOptions.filter((option) =>
- selectedValues.includes(option.id),
+ selectedValues.includes(option.id)
);
return (
diff --git a/apps/desktop/src/renderer/components/records/values/record-number-value.tsx b/apps/desktop/src/renderer/components/records/values/record-number-value.tsx
index f6486e82..83391489 100644
--- a/apps/desktop/src/renderer/components/records/values/record-number-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-number-value.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { NumberFieldAttributes } from '@/registry';
+import { type NumberFieldAttributes } from '@colanode/core';
import { SmartNumberInput } from '@/renderer/components/ui/smart-number-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/records/values/record-phone-value.tsx b/apps/desktop/src/renderer/components/records/values/record-phone-value.tsx
index 0d10dbdf..66185c36 100644
--- a/apps/desktop/src/renderer/components/records/values/record-phone-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-phone-value.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { PhoneFieldAttributes } from '@/registry';
+import { PhoneFieldAttributes } from '@colanode/core';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/records/values/record-select-value.tsx b/apps/desktop/src/renderer/components/records/values/record-select-value.tsx
index 7112f3bd..bfeac650 100644
--- a/apps/desktop/src/renderer/components/records/values/record-select-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-select-value.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { SelectFieldAttributes } from '@/registry';
+import { SelectFieldAttributes } from '@colanode/core';
import { SelectOptionBadge } from '@/renderer/components/databases/fields/select-option-badge';
import {
Popover,
@@ -18,7 +18,7 @@ export const RecordSelectValue = ({ field }: RecordSelectValueProps) => {
const [open, setOpen] = React.useState(false);
const [selectedValue, setSelectedValue] = React.useState(
- record.getSelectValue(field),
+ record.getSelectValue(field)
);
React.useEffect(() => {
diff --git a/apps/desktop/src/renderer/components/records/values/record-text-value.tsx b/apps/desktop/src/renderer/components/records/values/record-text-value.tsx
index 5d84e826..f9708b5d 100644
--- a/apps/desktop/src/renderer/components/records/values/record-text-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-text-value.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { TextFieldAttributes } from '@/registry';
+import { TextFieldAttributes } from '@colanode/core';
import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';
import { useRecord } from '@/renderer/contexts/record';
diff --git a/apps/desktop/src/renderer/components/records/values/record-url-value.tsx b/apps/desktop/src/renderer/components/records/values/record-url-value.tsx
index c6b9a6ff..dde5bb74 100644
--- a/apps/desktop/src/renderer/components/records/values/record-url-value.tsx
+++ b/apps/desktop/src/renderer/components/records/values/record-url-value.tsx
@@ -1,5 +1,4 @@
-import React from 'react';
-import { UrlFieldAttributes } from '@/registry';
+import { UrlFieldAttributes } from '@colanode/core';
import { cn, isValidUrl } from '@/lib/utils';
import {
HoverCard,
@@ -48,7 +47,7 @@ export const RecordUrlValue = ({ field }: RecordUrlValueProps) => {
<HoverCardContent
className={cn(
'flex w-full min-w-80 max-w-128 flex-row items-center justify-between gap-2 text-ellipsis',
- !isUrl && 'hidden',
+ !isUrl && 'hidden'
)}
>
<a
diff --git a/apps/desktop/src/renderer/components/spaces/space-create-dialog.tsx b/apps/desktop/src/renderer/components/spaces/space-create-dialog.tsx
index b440c395..c04d5b53 100644
--- a/apps/desktop/src/renderer/components/spaces/space-create-dialog.tsx
+++ b/apps/desktop/src/renderer/components/spaces/space-create-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Dialog,
DialogContent,
diff --git a/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx b/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx
index 1021d23c..f0ad6514 100644
--- a/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx
+++ b/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Button } from '@/renderer/components/ui/button';
import { Spinner } from '@/renderer/components/ui/spinner';
import { useWorkspace } from '@/renderer/contexts/workspace';
@@ -10,7 +9,7 @@ interface SpaceDeleteFormProps {
onDeleted: () => void;
}
-export const SpaceDeleteForm = ({ id, onDeleted }: SpaceDeleteFormProps) => {
+export const SpaceDeleteForm = ({ id }: SpaceDeleteFormProps) => {
const workspace = useWorkspace();
const { mutate, isPending } = useMutation();
diff --git a/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx b/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx
index cf612944..53959afe 100644
--- a/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx
+++ b/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Dialog,
DialogContent,
diff --git a/apps/desktop/src/renderer/components/ui/calendar.tsx b/apps/desktop/src/renderer/components/ui/calendar.tsx
index 87cf9dce..1f0dacd1 100644
--- a/apps/desktop/src/renderer/components/ui/calendar.tsx
+++ b/apps/desktop/src/renderer/components/ui/calendar.tsx
@@ -25,7 +25,7 @@ function Calendar({
nav: 'space-x-1 flex items-center',
nav_button: cn(
buttonVariants({ variant: 'outline' }),
- 'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',
+ 'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100'
),
nav_button_previous: 'absolute left-1',
nav_button_next: 'absolute right-1',
@@ -38,11 +38,11 @@ function Calendar({
'relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md',
props.mode === 'range'
? '[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md'
- : '[&:has([aria-selected])]:rounded-md',
+ : '[&:has([aria-selected])]:rounded-md'
),
day: cn(
buttonVariants({ variant: 'ghost' }),
- 'h-8 w-8 p-0 font-normal aria-selected:opacity-100',
+ 'h-8 w-8 p-0 font-normal aria-selected:opacity-100'
),
day_range_start: 'day-range-start',
day_range_end: 'day-range-end',
@@ -58,8 +58,8 @@ function Calendar({
...classNames,
}}
components={{
- IconLeft: ({ ...props }) => <ChevronLeftIcon className="h-4 w-4" />,
- IconRight: ({ ...props }) => <ChevronRightIcon className="h-4 w-4" />,
+ IconLeft: () => <ChevronLeftIcon className="h-4 w-4" />,
+ IconRight: () => <ChevronRightIcon className="h-4 w-4" />,
}}
{...props}
/>
diff --git a/apps/desktop/src/renderer/components/ui/toaster.tsx b/apps/desktop/src/renderer/components/ui/toaster.tsx
index 9335e02f..d781a543 100644
--- a/apps/desktop/src/renderer/components/ui/toaster.tsx
+++ b/apps/desktop/src/renderer/components/ui/toaster.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Toast,
ToastClose,
diff --git a/apps/desktop/src/renderer/components/workspaces/containers/breadcrumb-item.tsx b/apps/desktop/src/renderer/components/workspaces/containers/breadcrumb-item.tsx
index 71620828..6dd24914 100644
--- a/apps/desktop/src/renderer/components/workspaces/containers/breadcrumb-item.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/containers/breadcrumb-item.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { cn } from '@/lib/utils';
import { Avatar } from '@/renderer/components/avatars/avatar';
import { BreadcrumbNode } from '@/types/workspaces';
diff --git a/apps/desktop/src/renderer/components/workspaces/containers/chat-breadcrumb.tsx b/apps/desktop/src/renderer/components/workspaces/containers/chat-breadcrumb.tsx
index 3909c71a..828c9eb3 100644
--- a/apps/desktop/src/renderer/components/workspaces/containers/chat-breadcrumb.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/containers/chat-breadcrumb.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { useQuery } from '@/renderer/hooks/use-query';
import {
diff --git a/apps/desktop/src/renderer/components/workspaces/containers/container-header.tsx b/apps/desktop/src/renderer/components/workspaces/containers/container-header.tsx
index 434488f0..9765436f 100644
--- a/apps/desktop/src/renderer/components/workspaces/containers/container-header.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/containers/container-header.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { getIdType, IdType } from '@/lib/id';
import { Breadcrumb } from '@/renderer/components/workspaces/containers/breadcrumb';
import { ChatBreadcrumb } from '@/renderer/components/workspaces/containers/chat-breadcrumb';
diff --git a/apps/desktop/src/renderer/components/workspaces/containers/container-settings.tsx b/apps/desktop/src/renderer/components/workspaces/containers/container-settings.tsx
index e89413d8..108479b9 100644
--- a/apps/desktop/src/renderer/components/workspaces/containers/container-settings.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/containers/container-settings.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { IdType } from '@/lib/id';
import { getIdType } from '@/lib/id';
import { match } from 'ts-pattern';
diff --git a/apps/desktop/src/renderer/components/workspaces/containers/container.tsx b/apps/desktop/src/renderer/components/workspaces/containers/container.tsx
index c023361f..b63810be 100644
--- a/apps/desktop/src/renderer/components/workspaces/containers/container.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/containers/container.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { match } from 'ts-pattern';
import { useParams } from 'react-router-dom';
import { PageContainer } from '@/renderer/components/pages/page-container';
diff --git a/apps/desktop/src/renderer/components/workspaces/modals/modal-content.tsx b/apps/desktop/src/renderer/components/workspaces/modals/modal-content.tsx
index 60b3c952..5f881ba9 100644
--- a/apps/desktop/src/renderer/components/workspaces/modals/modal-content.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/modals/modal-content.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { match } from 'ts-pattern';
import { ChannelContainer } from '@/renderer/components/channels/channel-container';
import { PageContainer } from '@/renderer/components/pages/page-container';
diff --git a/apps/desktop/src/renderer/components/workspaces/modals/modal-header.tsx b/apps/desktop/src/renderer/components/workspaces/modals/modal-header.tsx
index 18a3a308..374d7975 100644
--- a/apps/desktop/src/renderer/components/workspaces/modals/modal-header.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/modals/modal-header.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { Fullscreen } from 'lucide-react';
diff --git a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-chats.tsx b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-chats.tsx
index 2d1ada5e..8c8b960b 100644
--- a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-chats.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-chats.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { ChatCreatePopover } from '@/renderer/components/chats/chat-create-popover';
import { useQuery } from '@/renderer/hooks/use-query';
import { SidebarChatItem } from '@/renderer/components/workspaces/sidebars/sidebar-chat-item';
diff --git a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-footer.tsx b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-footer.tsx
index e2c2bf28..eb555259 100644
--- a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-footer.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-footer.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
DropdownMenu,
DropdownMenuContent,
diff --git a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-header.tsx b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-header.tsx
index 0fb579f9..a2e61bf7 100644
--- a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-header.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-header.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useWorkspace } from '@/renderer/contexts/workspace';
import { Avatar } from '@/renderer/components/avatars/avatar';
import { useAccount } from '@/renderer/contexts/account';
diff --git a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-space-item.tsx b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-space-item.tsx
index 05880c9a..e27de0da 100644
--- a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-space-item.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-space-item.tsx
@@ -62,8 +62,6 @@ export const SidebarSpaceItem = ({ node }: SidebarSpaceNodeProps) => {
open: false,
});
- const isActive = false;
-
return (
<React.Fragment>
<Collapsible
@@ -75,6 +73,7 @@ export const SidebarSpaceItem = ({ node }: SidebarSpaceNodeProps) => {
<SidebarMenuItem>
<CollapsibleTrigger asChild>
<SidebarMenuButton
+ isActive={nodeId === node.id}
tooltip={node.name ?? ''}
className="group/space-button"
>
diff --git a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-spaces.tsx b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-spaces.tsx
index 2826cc3e..dab85ee5 100644
--- a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-spaces.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar-spaces.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { SidebarSpaceItem } from '@/renderer/components/workspaces/sidebars/sidebar-space-item';
import { useQuery } from '@/renderer/hooks/use-query';
import { useWorkspace } from '@/renderer/contexts/workspace';
diff --git a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar.tsx b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar.tsx
index f2a1d798..58bc2585 100644
--- a/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/sidebars/sidebar.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
Sidebar as SidebarWrapper,
SidebarContent as SidebarContentWrapper,
diff --git a/apps/desktop/src/renderer/components/workspaces/workspace-create.tsx b/apps/desktop/src/renderer/components/workspaces/workspace-create.tsx
index 324d1674..ca0b7223 100644
--- a/apps/desktop/src/renderer/components/workspaces/workspace-create.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/workspace-create.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { toast } from '@/renderer/hooks/use-toast';
import { useMutation } from '@/renderer/hooks/use-mutation';
import { useAccount } from '@/renderer/contexts/account';
diff --git a/apps/desktop/src/renderer/components/workspaces/workspace-update.tsx b/apps/desktop/src/renderer/components/workspaces/workspace-update.tsx
index 61aea8cf..9e4d33c9 100644
--- a/apps/desktop/src/renderer/components/workspaces/workspace-update.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/workspace-update.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { toast } from '@/renderer/hooks/use-toast';
import { useMutation } from '@/renderer/hooks/use-mutation';
import { useWorkspace } from '@/renderer/contexts/workspace';
diff --git a/apps/desktop/src/renderer/components/workspaces/workspace-user-role-dropdown.tsx b/apps/desktop/src/renderer/components/workspaces/workspace-user-role-dropdown.tsx
index 95d6bf63..5276636d 100644
--- a/apps/desktop/src/renderer/components/workspaces/workspace-user-role-dropdown.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/workspace-user-role-dropdown.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
DropdownMenu,
DropdownMenuContent,
@@ -20,24 +19,30 @@ interface WorkspaceRoleItem {
}
const roles: WorkspaceRoleItem[] = [
- {
- name: 'Owner',
- value: WorkspaceRole.Owner,
- description: 'Owner',
- enabled: false,
- },
{
name: 'Admin',
- value: WorkspaceRole.Admin,
+ value: 'admin',
description: 'Administration access',
enabled: true,
},
+ {
+ name: 'Editor',
+ value: 'editor',
+ description: 'Can edit content',
+ enabled: true,
+ },
{
name: 'Collaborator',
- value: WorkspaceRole.Collaborator,
+ value: 'collaborator',
description: 'Can contribute in content',
enabled: true,
},
+ {
+ name: 'Viewer',
+ value: 'viewer',
+ description: 'Can view content',
+ enabled: true,
+ },
];
interface WorkspaceUserRoleDropdownProps {
diff --git a/apps/desktop/src/renderer/components/workspaces/workspace-users.tsx b/apps/desktop/src/renderer/components/workspaces/workspace-users.tsx
index 9c4174dc..0f829c6d 100644
--- a/apps/desktop/src/renderer/components/workspaces/workspace-users.tsx
+++ b/apps/desktop/src/renderer/components/workspaces/workspace-users.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { useInfiniteQuery } from '@/renderer/hooks/use-infinite-query';
import { Separator } from '@/renderer/components/ui/separator';
import { WorkspaceUserInvite } from '@/renderer/components/workspaces/workspace-user-invite';
diff --git a/apps/desktop/src/renderer/contexts/database-views.ts b/apps/desktop/src/renderer/contexts/database-views.ts
index 830d0af7..be572008 100644
--- a/apps/desktop/src/renderer/contexts/database-views.ts
+++ b/apps/desktop/src/renderer/contexts/database-views.ts
@@ -1,4 +1,4 @@
-import { ViewAttributes } from '@/registry';
+import { ViewAttributes } from '@colanode/core';
import { createContext, useContext } from 'react';
interface DatabaseViewsContext {
@@ -8,7 +8,7 @@ interface DatabaseViewsContext {
}
export const DatabaseViewsContext = createContext<DatabaseViewsContext>(
- {} as DatabaseViewsContext,
+ {} as DatabaseViewsContext
);
export const useDatabaseViews = () => useContext(DatabaseViewsContext);
diff --git a/apps/desktop/src/renderer/contexts/database.ts b/apps/desktop/src/renderer/contexts/database.ts
index 153df2a1..7b4ce8fb 100644
--- a/apps/desktop/src/renderer/contexts/database.ts
+++ b/apps/desktop/src/renderer/contexts/database.ts
@@ -4,7 +4,7 @@ import {
FieldAttributes,
FieldType,
SelectOptionAttributes,
-} from '@/registry';
+} from '@colanode/core';
interface DatabaseContext {
id: string;
@@ -17,13 +17,13 @@ interface DatabaseContext {
createSelectOption: (fieldId: string, name: string, color: string) => void;
updateSelectOption: (
fieldId: string,
- attributes: SelectOptionAttributes,
+ attributes: SelectOptionAttributes
) => void;
deleteSelectOption: (fieldId: string, optionId: string) => void;
}
export const DatabaseContext = createContext<DatabaseContext>(
- {} as DatabaseContext,
+ {} as DatabaseContext
);
export const useDatabase = () => useContext(DatabaseContext);
diff --git a/apps/desktop/src/renderer/contexts/record.ts b/apps/desktop/src/renderer/contexts/record.ts
index afed8a81..7fc8d5e1 100644
--- a/apps/desktop/src/renderer/contexts/record.ts
+++ b/apps/desktop/src/renderer/contexts/record.ts
@@ -14,7 +14,7 @@ import {
SelectFieldAttributes,
TextFieldAttributes,
UrlFieldAttributes,
-} from '@/registry';
+} from '@colanode/core';
import { createContext, useContext } from 'react';
interface RecordContext {
diff --git a/apps/desktop/src/renderer/contexts/view.ts b/apps/desktop/src/renderer/contexts/view.ts
index 25d29924..11109ba2 100644
--- a/apps/desktop/src/renderer/contexts/view.ts
+++ b/apps/desktop/src/renderer/contexts/view.ts
@@ -1,4 +1,4 @@
-import { ViewFilterAttributes, ViewSortAttributes } from '@/registry';
+import { ViewFilterAttributes, ViewSortAttributes } from '@colanode/core';
import { ViewField } from '@/types/databases';
import { createContext, useContext } from 'react';
diff --git a/apps/desktop/src/renderer/editor/extensions/id.tsx b/apps/desktop/src/renderer/editor/extensions/id.tsx
index bc9bc79c..8a6eb784 100644
--- a/apps/desktop/src/renderer/editor/extensions/id.tsx
+++ b/apps/desktop/src/renderer/editor/extensions/id.tsx
@@ -1,6 +1,6 @@
import { Extension } from '@tiptap/react';
import { Plugin, PluginKey } from 'prosemirror-state';
-import { generateId, getIdTypeFromNode, IdType } from '@/lib/id';
+import { generateId, getIdTypeFromNode } from '@/lib/id';
import { EditorNodeTypes } from '@/lib/constants';
const types = [
diff --git a/apps/desktop/src/renderer/editor/menu/bubble-menu.tsx b/apps/desktop/src/renderer/editor/menu/bubble-menu.tsx
index 6914fdfe..2b824263 100644
--- a/apps/desktop/src/renderer/editor/menu/bubble-menu.tsx
+++ b/apps/desktop/src/renderer/editor/menu/bubble-menu.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import {
BubbleMenu,
type BubbleMenuProps,
@@ -58,7 +57,7 @@ export const EditorBubbleMenu = (props: EditorBubbleMenuProps) => {
type="button"
className={cn(
'flex h-8 w-8 items-center justify-center rounded-md hover:cursor-pointer hover:bg-gray-100',
- props.editor?.isActive('bold') === true ? 'bg-gray-100' : 'bg-white',
+ props.editor?.isActive('bold') === true ? 'bg-gray-100' : 'bg-white'
)}
onClick={() => props.editor?.chain().focus().toggleBold().run()}
>
@@ -68,9 +67,7 @@ export const EditorBubbleMenu = (props: EditorBubbleMenuProps) => {
type="button"
className={cn(
'flex h-8 w-8 items-center justify-center rounded-md hover:cursor-pointer hover:bg-gray-100',
- props.editor?.isActive('italic') === true
- ? 'bg-gray-100'
- : 'bg-white',
+ props.editor?.isActive('italic') === true ? 'bg-gray-100' : 'bg-white'
)}
onClick={() => props.editor?.chain().focus().toggleItalic().run()}
>
@@ -82,7 +79,7 @@ export const EditorBubbleMenu = (props: EditorBubbleMenuProps) => {
'flex h-8 w-8 items-center justify-center rounded-md hover:cursor-pointer hover:bg-gray-100',
props.editor?.isActive('underline') === true
? 'bg-gray-100'
- : 'bg-white',
+ : 'bg-white'
)}
onClick={() => props.editor?.chain().focus().toggleUnderline().run()}
>
@@ -92,9 +89,7 @@ export const EditorBubbleMenu = (props: EditorBubbleMenuProps) => {
type="button"
className={cn(
'flex h-8 w-8 items-center justify-center rounded-md hover:cursor-pointer hover:bg-gray-100',
- props.editor?.isActive('strike') === true
- ? 'bg-gray-100'
- : 'bg-white',
+ props.editor?.isActive('strike') === true ? 'bg-gray-100' : 'bg-white'
)}
onClick={() => props.editor?.chain().focus().toggleStrike().run()}
>
@@ -104,7 +99,7 @@ export const EditorBubbleMenu = (props: EditorBubbleMenuProps) => {
type="button"
className={cn(
'flex h-8 w-8 items-center justify-center rounded-md hover:cursor-pointer hover:bg-gray-100',
- props.editor?.isActive('code') === true ? 'bg-gray-100' : 'bg-white',
+ props.editor?.isActive('code') === true ? 'bg-gray-100' : 'bg-white'
)}
onClick={() => props.editor?.chain().focus().toggleCode().run()}
>
diff --git a/apps/desktop/src/renderer/editor/menu/color-button.tsx b/apps/desktop/src/renderer/editor/menu/color-button.tsx
index 3cc70877..710e2dbc 100644
--- a/apps/desktop/src/renderer/editor/menu/color-button.tsx
+++ b/apps/desktop/src/renderer/editor/menu/color-button.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Editor } from '@tiptap/core';
import {
Popover,
@@ -82,11 +81,11 @@ export const ColorButton = ({
setIsOpen: (isOpen: boolean) => void;
}) => {
const activeColor = colors.find((color) =>
- editor.isActive('color', { color: color.color }),
+ editor.isActive('color', { color: color.color })
);
const activeHighlight = colors.find((color) =>
- editor.isActive('highlight', { highlight: color.color }),
+ editor.isActive('highlight', { highlight: color.color })
);
return (
@@ -95,7 +94,7 @@ export const ColorButton = ({
<span
className={cn(
'flex h-8 w-8 items-center justify-center rounded-md hover:cursor-pointer hover:bg-gray-100',
- activeHighlight?.bgClass ?? 'bg-white',
+ activeHighlight?.bgClass ?? 'bg-white'
)}
>
<Baseline className={cn('size-4', activeColor?.textClass ?? '')} />
@@ -143,7 +142,7 @@ export const ColorButton = ({
<div
className={cn(
'relative inline-flex h-6 w-6 items-center justify-center overflow-hidden rounded shadow',
- color.bgClass,
+ color.bgClass
)}
>
<span className="font-medium">A</span>
diff --git a/apps/desktop/src/renderer/editor/menu/link-button.tsx b/apps/desktop/src/renderer/editor/menu/link-button.tsx
index 729b8460..788e6462 100644
--- a/apps/desktop/src/renderer/editor/menu/link-button.tsx
+++ b/apps/desktop/src/renderer/editor/menu/link-button.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { Editor } from '@tiptap/core';
import { Input } from '@/renderer/components/ui/input';
@@ -45,7 +44,7 @@ export const LinkButton = ({ editor, isOpen, setIsOpen }: LinkButtonProps) => {
<span
className={cn(
'flex h-8 w-8 items-center justify-center rounded-md hover:cursor-pointer hover:bg-gray-100',
- editor.isActive('link') ? 'bg-gray-100' : 'bg-white',
+ editor.isActive('link') ? 'bg-gray-100' : 'bg-white'
)}
>
<Link className="size-4" />
diff --git a/apps/desktop/src/renderer/editor/renderers/blockquote.tsx b/apps/desktop/src/renderer/editor/renderers/blockquote.tsx
index 69a37f36..0873c00a 100644
--- a/apps/desktop/src/renderer/editor/renderers/blockquote.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/blockquote.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/bullet-list.tsx b/apps/desktop/src/renderer/editor/renderers/bullet-list.tsx
index 5fc4793e..ea773779 100644
--- a/apps/desktop/src/renderer/editor/renderers/bullet-list.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/bullet-list.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/document.tsx b/apps/desktop/src/renderer/editor/renderers/document.tsx
index 27fd072a..944fa55a 100644
--- a/apps/desktop/src/renderer/editor/renderers/document.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/document.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/file.tsx b/apps/desktop/src/renderer/editor/renderers/file.tsx
index b54ee396..fcf854bc 100644
--- a/apps/desktop/src/renderer/editor/renderers/file.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/file.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { JSONContent } from '@tiptap/core';
import { FileBlock } from '@/renderer/components/files/file-block';
diff --git a/apps/desktop/src/renderer/editor/renderers/heading1.tsx b/apps/desktop/src/renderer/editor/renderers/heading1.tsx
index 3d38a982..de652b6b 100644
--- a/apps/desktop/src/renderer/editor/renderers/heading1.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/heading1.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/heading2.tsx b/apps/desktop/src/renderer/editor/renderers/heading2.tsx
index f87c6cc7..41d7925c 100644
--- a/apps/desktop/src/renderer/editor/renderers/heading2.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/heading2.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/heading3.tsx b/apps/desktop/src/renderer/editor/renderers/heading3.tsx
index 537509d8..36d33881 100644
--- a/apps/desktop/src/renderer/editor/renderers/heading3.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/heading3.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/list-item.tsx b/apps/desktop/src/renderer/editor/renderers/list-item.tsx
index 45a0fb2a..b86852c8 100644
--- a/apps/desktop/src/renderer/editor/renderers/list-item.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/list-item.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/message-reference.tsx b/apps/desktop/src/renderer/editor/renderers/message-reference.tsx
index 55e2bd04..3c49aa3e 100644
--- a/apps/desktop/src/renderer/editor/renderers/message-reference.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/message-reference.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/message.tsx b/apps/desktop/src/renderer/editor/renderers/message.tsx
index 7feda466..f9a5ad78 100644
--- a/apps/desktop/src/renderer/editor/renderers/message.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/message.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/node.tsx b/apps/desktop/src/renderer/editor/renderers/node.tsx
index d589a499..5e99c6e5 100644
--- a/apps/desktop/src/renderer/editor/renderers/node.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/node.tsx
@@ -1,4 +1,4 @@
-import React, { ReactElement } from 'react';
+import { ReactElement } from 'react';
import { BlockquoteRenderer } from '@/renderer/editor/renderers/blockquote';
import { BulletListRenderer } from '@/renderer/editor/renderers/bullet-list';
import { CodeBlockRenderer } from '@/renderer/editor/renderers/code-block';
diff --git a/apps/desktop/src/renderer/editor/renderers/ordered-list.tsx b/apps/desktop/src/renderer/editor/renderers/ordered-list.tsx
index 6235a797..a732409f 100644
--- a/apps/desktop/src/renderer/editor/renderers/ordered-list.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/ordered-list.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/paragraph.tsx b/apps/desktop/src/renderer/editor/renderers/paragraph.tsx
index 4b6c7f38..d091ccdd 100644
--- a/apps/desktop/src/renderer/editor/renderers/paragraph.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/paragraph.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { cn } from '@/lib/utils';
diff --git a/apps/desktop/src/renderer/editor/renderers/task-item.tsx b/apps/desktop/src/renderer/editor/renderers/task-item.tsx
index 63a33209..0ffc1d49 100644
--- a/apps/desktop/src/renderer/editor/renderers/task-item.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/task-item.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/renderers/task-list.tsx b/apps/desktop/src/renderer/editor/renderers/task-list.tsx
index fc000aeb..04822420 100644
--- a/apps/desktop/src/renderer/editor/renderers/task-list.tsx
+++ b/apps/desktop/src/renderer/editor/renderers/task-list.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { defaultClasses } from '@/renderer/editor/classes';
import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';
import { JSONContent } from '@tiptap/core';
diff --git a/apps/desktop/src/renderer/editor/views/file-placeholder.tsx b/apps/desktop/src/renderer/editor/views/file-placeholder.tsx
index 769d919f..2fe6521b 100644
--- a/apps/desktop/src/renderer/editor/views/file-placeholder.tsx
+++ b/apps/desktop/src/renderer/editor/views/file-placeholder.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { type NodeViewProps } from '@tiptap/core';
import { NodeViewWrapper } from '@tiptap/react';
import { FilePreview } from '@/renderer/components/files/file-preview';
diff --git a/apps/desktop/src/renderer/editor/views/file.tsx b/apps/desktop/src/renderer/editor/views/file.tsx
index 81957ce1..988a070f 100644
--- a/apps/desktop/src/renderer/editor/views/file.tsx
+++ b/apps/desktop/src/renderer/editor/views/file.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { type NodeViewProps } from '@tiptap/core';
import { NodeViewWrapper } from '@tiptap/react';
import { FileBlock } from '@/renderer/components/files/file-block';
diff --git a/apps/desktop/src/renderer/editor/views/folder.tsx b/apps/desktop/src/renderer/editor/views/folder.tsx
index f467f8cf..d445addc 100644
--- a/apps/desktop/src/renderer/editor/views/folder.tsx
+++ b/apps/desktop/src/renderer/editor/views/folder.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { type NodeViewProps } from '@tiptap/core';
import { NodeViewWrapper } from '@tiptap/react';
import { Avatar } from '@/renderer/components/avatars/avatar';
diff --git a/apps/desktop/src/renderer/editor/views/message-reference.tsx b/apps/desktop/src/renderer/editor/views/message-reference.tsx
index 96a5d9b6..d60357e3 100644
--- a/apps/desktop/src/renderer/editor/views/message-reference.tsx
+++ b/apps/desktop/src/renderer/editor/views/message-reference.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { type NodeViewProps } from '@tiptap/core';
import { NodeViewContent, NodeViewWrapper } from '@tiptap/react';
diff --git a/apps/desktop/src/renderer/editor/views/page.tsx b/apps/desktop/src/renderer/editor/views/page.tsx
index d2d02ded..c0d34d13 100644
--- a/apps/desktop/src/renderer/editor/views/page.tsx
+++ b/apps/desktop/src/renderer/editor/views/page.tsx
@@ -1,4 +1,3 @@
-import React from 'react';
import { type NodeViewProps } from '@tiptap/core';
import { NodeViewWrapper } from '@tiptap/react';
import { Avatar } from '@/renderer/components/avatars/avatar';
diff --git a/apps/desktop/src/types/databases.ts b/apps/desktop/src/types/databases.ts
index 04d7349f..f8edac61 100644
--- a/apps/desktop/src/types/databases.ts
+++ b/apps/desktop/src/types/databases.ts
@@ -1,4 +1,4 @@
-import { FieldAttributes } from '@/registry';
+import { FieldAttributes } from '@colanode/core';
export type ViewField = {
field: FieldAttributes;
diff --git a/apps/desktop/src/types/nodes.ts b/apps/desktop/src/types/nodes.ts
index 76273ae0..527e590b 100644
--- a/apps/desktop/src/types/nodes.ts
+++ b/apps/desktop/src/types/nodes.ts
@@ -1,4 +1,4 @@
-import { NodeAttributes } from '@/registry';
+import { NodeAttributes } from '@colanode/core';
export type ServerNode = {
id: string;
diff --git a/apps/desktop/src/types/workspaces.ts b/apps/desktop/src/types/workspaces.ts
index 2d6c5fac..596f8a3e 100644
--- a/apps/desktop/src/types/workspaces.ts
+++ b/apps/desktop/src/types/workspaces.ts
@@ -1,11 +1,6 @@
import { ServerNode } from '@/types/nodes';
-export enum WorkspaceRole {
- Owner = 'owner',
- Admin = 'admin',
- Collaborator = 'collaborator',
- Viewer = 'viewer',
-}
+export type WorkspaceRole = 'admin' | 'editor' | 'collaborator' | 'viewer';
export type Workspace = {
id: string;
diff --git a/apps/desktop/tsconfig.json b/apps/desktop/tsconfig.json
index d2cf0493..316b605a 100644
--- a/apps/desktop/tsconfig.json
+++ b/apps/desktop/tsconfig.json
@@ -1,12 +1,8 @@
{
- "$schema": "https://json.schemastore.org/tsconfig",
- "display": "Desktop",
- "extends": "../../tsconfig.base.json",
"files": [],
- "references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.web.json" }],
- "compilerOptions": {
- "paths": {
- "@/*": ["src/*"]
- }
- }
+ "references": [
+ { "path": "../../packages/core/tsconfig.json" },
+ { "path": "./tsconfig.node.json" },
+ { "path": "./tsconfig.web.json" }
+ ]
}
diff --git a/apps/desktop/tsconfig.node.json b/apps/desktop/tsconfig.node.json
index eae16a18..fbbf388a 100644
--- a/apps/desktop/tsconfig.node.json
+++ b/apps/desktop/tsconfig.node.json
@@ -6,8 +6,7 @@
"src/preload/**/*",
"src/lib/**/*",
"src/operations/**/*",
- "src/types/**/*",
- "src/registry/**/*"
+ "src/types/**/*"
],
"compilerOptions": {
"composite": true,
@@ -16,7 +15,6 @@
"@/lib/*": ["./src/lib/*"],
"@/operations/*": ["./src/operations/*"],
"@/types/*": ["./src/types/*"],
- "@/registry/*": ["./src/registry/*"],
"@/main/*": ["./src/main/*"]
}
}
diff --git a/apps/desktop/tsconfig.web.json b/apps/desktop/tsconfig.web.json
index c0f463fd..f39a22e4 100644
--- a/apps/desktop/tsconfig.web.json
+++ b/apps/desktop/tsconfig.web.json
@@ -6,8 +6,7 @@
"src/preload/*.d.ts",
"src/operations/**/*",
"src/types/**/*",
- "src/lib/**/*",
- "src/registry/**/*"
+ "src/lib/**/*"
],
"compilerOptions": {
"composite": true,
@@ -16,8 +15,7 @@
"@/renderer/*": ["./src/renderer/*"],
"@/lib/*": ["./src/lib/*"],
"@/operations/*": ["./src/operations/*"],
- "@/types/*": ["./src/types/*"],
- "@/registry/*": ["./src/registry/*"]
+ "@/types/*": ["./src/types/*"]
}
}
}
diff --git a/packages/core/package.json b/packages/core/package.json
index f9297bb5..85768365 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -22,5 +22,10 @@
"prettier": "^3.3.3",
"typescript": "^5.6.3",
"vitest": "^1.6.0"
+ },
+ "dependencies": {
+ "diff": "^7.0.0",
+ "yjs": "^13.6.20",
+ "zod": "^3.23.8"
}
}
diff --git a/apps/desktop/src/main/crdt.ts b/packages/core/src/crdt.ts
similarity index 97%
rename from apps/desktop/src/main/crdt.ts
rename to packages/core/src/crdt.ts
index 471e5971..0bc65e63 100644
--- a/apps/desktop/src/main/crdt.ts
+++ b/packages/core/src/crdt.ts
@@ -1,13 +1,13 @@
import { z } from 'zod';
import * as Y from 'yjs';
-import { ZodText } from '@/registry/zod';
+import { ZodText } from './registry/zod';
import { isEqual } from 'lodash';
import { diffChars } from 'diff';
export const applyCrdt = (
schema: z.ZodSchema,
attributes: z.infer<typeof schema>,
- attributesMap: Y.Map<any>,
+ attributesMap: Y.Map<any>
) => {
if (!(schema instanceof z.ZodObject)) {
throw new Error('Schema must be a ZodObject');
@@ -24,7 +24,7 @@ export const applyCrdt = (
const applyObjectChanges = (
schema: z.ZodObject<any, any, any, any>,
attributes: any,
- yMap: Y.Map<any>,
+ yMap: Y.Map<any>
) => {
for (const [key, value] of Object.entries(attributes)) {
if (value === null) {
@@ -91,7 +91,7 @@ const applyObjectChanges = (
}
const deletedKeys = Array.from(yMap.keys()).filter(
- (key) => !attributes.hasOwnProperty(key),
+ (key) => !attributes.hasOwnProperty(key)
);
for (const key of deletedKeys) {
@@ -102,7 +102,7 @@ const applyObjectChanges = (
const applyArrayChanges = (
schemaField: z.ZodArray<any>,
value: Array<any>,
- yArray: Y.Array<any>,
+ yArray: Y.Array<any>
) => {
const itemSchema = extractType(schemaField.element, value);
const length = value.length;
@@ -193,7 +193,7 @@ const applyArrayChanges = (
const applyRecordChanges = (
schemaField: z.ZodRecord<any, any>,
record: Record<any, any>,
- yMap: Y.Map<any>,
+ yMap: Y.Map<any>
) => {
const valueSchema = extractType(schemaField.valueSchema, record);
for (const [key, value] of Object.entries(record)) {
@@ -259,7 +259,7 @@ const applyRecordChanges = (
}
const deletedKeys = Array.from(yMap.keys()).filter(
- (key) => !record.hasOwnProperty(key),
+ (key) => !record.hasOwnProperty(key)
);
for (const key of deletedKeys) {
@@ -291,7 +291,7 @@ const applyTextChanges = (value: string, yText: Y.Text) => {
const extractType = (
schema: z.ZodType<any, any, any>,
- value: any,
+ value: any
): z.ZodType<any, any, any> => {
if (schema instanceof z.ZodOptional) {
return extractType(schema.unwrap(), value);
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 7a180e9e..2cc006a4 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -1,3 +1,303 @@
-export const core = () => {
- return 'core library';
+import * as yjs from 'yjs';
+import { z as zod } from 'zod';
+import { applyCrdt } from './crdt';
+import {
+ ChannelAttributes,
+ channelAttributesSchema,
+ channelModel,
+} from './registry/channel';
+import {
+ PageAttributes,
+ pageAttributesSchema,
+ pageModel,
+} from './registry/page';
+import {
+ ChatAttributes,
+ chatAttributesSchema,
+ chatModel,
+} from './registry/chat';
+import {
+ SpaceAttributes,
+ spaceAttributesSchema,
+ spaceModel,
+} from './registry/space';
+import {
+ UserAttributes,
+ userAttributesSchema,
+ userModel,
+} from './registry/user';
+import {
+ MessageAttributes,
+ messageAttributesSchema,
+ messageModel,
+} from './registry/message';
+import {
+ ViewFieldAttributes,
+ viewFieldAttributesSchema,
+ ViewFieldFilterAttributes,
+ viewFieldFilterAttributesSchema,
+ ViewGroupFilterAttributes,
+ viewGroupFilterAttributesSchema,
+ ViewFilterAttributes,
+ viewFilterAttributesSchema,
+ ViewSortAttributes,
+ viewSortAttributesSchema,
+ ViewAttributes,
+ viewAttributesSchema,
+ DatabaseAttributes,
+ databaseAttributesSchema,
+ databaseModel,
+} from './registry/database';
+import {
+ FileAttributes,
+ fileAttributesSchema,
+ fileModel,
+} from './registry/file';
+import {
+ FolderAttributes,
+ folderAttributesSchema,
+ folderModel,
+} from './registry/folder';
+import {
+ RecordAttributes,
+ recordAttributesSchema,
+ recordModel,
+} from './registry/record';
+import {
+ blockLeafSchema,
+ blockSchema,
+ BlockLeaf,
+ Block,
+} from './registry/block';
+import {
+ selectOptionAttributesSchema,
+ booleanFieldAttributesSchema,
+ booleanFieldValueSchema,
+ collaboratorFieldAttributesSchema,
+ collaboratorFieldValueSchema,
+ createdAtFieldAttributesSchema,
+ dateFieldAttributesSchema,
+ dateFieldValueSchema,
+ emailFieldAttributesSchema,
+ emailFieldValueSchema,
+ numberFieldAttributesSchema,
+ numberFieldValueSchema,
+ phoneFieldAttributesSchema,
+ phoneFieldValueSchema,
+ textFieldAttributesSchema,
+ textFieldValueSchema,
+ urlFieldAttributesSchema,
+ urlFieldValueSchema,
+ updatedAtFieldAttributesSchema,
+ updatedAtFieldValueSchema,
+ updatedByFieldAttributesSchema,
+ updatedByFieldValueSchema,
+ fieldAttributesSchema,
+ fieldValueSchema,
+ BooleanFieldAttributes,
+ BooleanFieldValue,
+ CollaboratorFieldAttributes,
+ CollaboratorFieldValue,
+ CreatedAtFieldAttributes,
+ CreatedAtFieldValue,
+ DateFieldAttributes,
+ DateFieldValue,
+ EmailFieldAttributes,
+ EmailFieldValue,
+ FileFieldAttributes,
+ FileFieldValue,
+ MultiSelectFieldAttributes,
+ MultiSelectFieldValue,
+ NumberFieldAttributes,
+ NumberFieldValue,
+ PhoneFieldAttributes,
+ PhoneFieldValue,
+ RelationFieldAttributes,
+ RelationFieldValue,
+ RollupFieldAttributes,
+ RollupFieldValue,
+ SelectFieldAttributes,
+ SelectFieldValue,
+ TextFieldAttributes,
+ TextFieldValue,
+ UrlFieldAttributes,
+ CreatedByFieldAttributes,
+ CreatedByFieldValue,
+ UpdatedByFieldAttributes,
+ FieldAttributes,
+ FieldValue,
+ FieldType,
+ SelectOptionAttributes,
+ UpdatedAtFieldAttributes,
+ UpdatedAtFieldValue,
+ createdAtFieldValueSchema,
+ createdByFieldAttributesSchema,
+ createdByFieldValueSchema,
+ fileFieldAttributesSchema,
+ fileFieldValueSchema,
+ multiSelectFieldAttributesSchema,
+ multiSelectFieldValueSchema,
+ relationFieldAttributesSchema,
+ relationFieldValueSchema,
+ rollupFieldAttributesSchema,
+ rollupFieldValueSchema,
+ selectFieldAttributesSchema,
+ selectFieldValueSchema,
+} from './registry/fields';
+import { NodeRole, NodeModel, NodeMutationContext } from './registry/core';
+import {
+ registry,
+ NodeAttributes,
+ ChannelNode,
+ ChatNode,
+ DatabaseNode,
+ FileNode,
+ FolderNode,
+ MessageNode,
+ PageNode,
+ RecordNode,
+ SpaceNode,
+ UserNode,
+ Node,
+} from './registry';
+
+export {
+ yjs,
+ zod,
+ registry,
+ type ChannelAttributes,
+ channelAttributesSchema,
+ channelModel,
+ type PageAttributes,
+ pageAttributesSchema,
+ pageModel,
+ type ChatAttributes,
+ chatAttributesSchema,
+ chatModel,
+ type SpaceAttributes,
+ spaceAttributesSchema,
+ spaceModel,
+ type UserAttributes,
+ userAttributesSchema,
+ userModel,
+ type MessageAttributes,
+ messageAttributesSchema,
+ messageModel,
+ type ViewFieldAttributes,
+ viewFieldAttributesSchema,
+ type ViewFieldFilterAttributes,
+ viewFieldFilterAttributesSchema,
+ type ViewGroupFilterAttributes,
+ viewGroupFilterAttributesSchema,
+ type ViewFilterAttributes,
+ viewFilterAttributesSchema,
+ type ViewSortAttributes,
+ viewSortAttributesSchema,
+ type ViewAttributes,
+ viewAttributesSchema,
+ type DatabaseAttributes,
+ databaseAttributesSchema,
+ databaseModel,
+ type FileAttributes,
+ fileAttributesSchema,
+ fileModel,
+ type FolderAttributes,
+ folderAttributesSchema,
+ folderModel,
+ type RecordAttributes,
+ recordAttributesSchema,
+ recordModel,
+ blockLeafSchema,
+ blockSchema,
+ selectOptionAttributesSchema,
+ booleanFieldAttributesSchema,
+ booleanFieldValueSchema,
+ collaboratorFieldAttributesSchema,
+ collaboratorFieldValueSchema,
+ createdAtFieldAttributesSchema,
+ dateFieldAttributesSchema,
+ dateFieldValueSchema,
+ emailFieldAttributesSchema,
+ emailFieldValueSchema,
+ numberFieldAttributesSchema,
+ numberFieldValueSchema,
+ phoneFieldAttributesSchema,
+ phoneFieldValueSchema,
+ textFieldAttributesSchema,
+ textFieldValueSchema,
+ urlFieldAttributesSchema,
+ urlFieldValueSchema,
+ updatedAtFieldAttributesSchema,
+ updatedAtFieldValueSchema,
+ updatedByFieldAttributesSchema,
+ updatedByFieldValueSchema,
+ fieldAttributesSchema,
+ fieldValueSchema,
+ type BooleanFieldAttributes,
+ type BooleanFieldValue,
+ type CollaboratorFieldAttributes,
+ type CollaboratorFieldValue,
+ type CreatedAtFieldAttributes,
+ type CreatedAtFieldValue,
+ type DateFieldAttributes,
+ type DateFieldValue,
+ type EmailFieldAttributes,
+ type EmailFieldValue,
+ type FileFieldAttributes,
+ type FileFieldValue,
+ type MultiSelectFieldAttributes,
+ type MultiSelectFieldValue,
+ type NumberFieldAttributes,
+ type NumberFieldValue,
+ type PhoneFieldAttributes,
+ type PhoneFieldValue,
+ type RelationFieldAttributes,
+ type RelationFieldValue,
+ type RollupFieldAttributes,
+ type RollupFieldValue,
+ type SelectFieldAttributes,
+ type SelectFieldValue,
+ type TextFieldAttributes,
+ type TextFieldValue,
+ type UrlFieldAttributes,
+ type CreatedByFieldAttributes,
+ type CreatedByFieldValue,
+ type UpdatedByFieldAttributes,
+ type FieldAttributes,
+ type FieldValue,
+ type FieldType,
+ type SelectOptionAttributes,
+ type UpdatedAtFieldAttributes,
+ type UpdatedAtFieldValue,
+ createdAtFieldValueSchema,
+ createdByFieldAttributesSchema,
+ createdByFieldValueSchema,
+ fileFieldAttributesSchema,
+ fileFieldValueSchema,
+ multiSelectFieldAttributesSchema,
+ multiSelectFieldValueSchema,
+ relationFieldAttributesSchema,
+ relationFieldValueSchema,
+ rollupFieldAttributesSchema,
+ rollupFieldValueSchema,
+ selectFieldAttributesSchema,
+ selectFieldValueSchema,
+ type NodeRole,
+ type NodeModel,
+ type NodeMutationContext,
+ type NodeAttributes,
+ type ChannelNode,
+ type ChatNode,
+ type DatabaseNode,
+ type FileNode,
+ type FolderNode,
+ type MessageNode,
+ type PageNode,
+ type RecordNode,
+ type SpaceNode,
+ type UserNode,
+ type BlockLeaf,
+ type Block,
+ type Node,
+ applyCrdt,
};
diff --git a/apps/desktop/src/registry/block.ts b/packages/core/src/registry/block.ts
similarity index 91%
rename from apps/desktop/src/registry/block.ts
rename to packages/core/src/registry/block.ts
index ea45b82c..f503b9d2 100644
--- a/apps/desktop/src/registry/block.ts
+++ b/packages/core/src/registry/block.ts
@@ -1,4 +1,4 @@
-import { ZodText } from '@/registry/zod';
+import { ZodText } from './zod';
import { z } from 'zod';
export const blockLeafSchema = z.object({
@@ -9,7 +9,7 @@ export const blockLeafSchema = z.object({
z.object({
type: z.string(),
attrs: z.record(z.any()).nullable(),
- }),
+ })
)
.nullable(),
});
diff --git a/apps/desktop/src/registry/channel.ts b/packages/core/src/registry/channel.ts
similarity index 91%
rename from apps/desktop/src/registry/channel.ts
rename to packages/core/src/registry/channel.ts
index 8228fc4a..c345f4c5 100644
--- a/apps/desktop/src/registry/channel.ts
+++ b/packages/core/src/registry/channel.ts
@@ -1,5 +1,5 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
+import { NodeModel } from './core';
import { isEqual } from 'lodash';
export const channelAttributesSchema = z.object({
@@ -26,7 +26,7 @@ export const channelModel: NodeModel = {
}
const parent = context.ancestors[0];
- if (parent.type !== 'space') {
+ if (!parent || parent.type !== 'space') {
return false;
}
@@ -48,7 +48,7 @@ export const channelModel: NodeModel = {
return context.hasEditorAccess();
},
- canDelete: async (context, node) => {
+ canDelete: async (context, _) => {
return context.hasEditorAccess();
},
};
diff --git a/apps/desktop/src/registry/chat.ts b/packages/core/src/registry/chat.ts
similarity index 94%
rename from apps/desktop/src/registry/chat.ts
rename to packages/core/src/registry/chat.ts
index f7457d5a..99703519 100644
--- a/apps/desktop/src/registry/chat.ts
+++ b/packages/core/src/registry/chat.ts
@@ -1,5 +1,5 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
+import { NodeModel } from './core';
export const chatAttributesSchema = z.object({
type: z.literal('chat'),
diff --git a/apps/desktop/src/registry/core.ts b/packages/core/src/registry/core.ts
similarity index 85%
rename from apps/desktop/src/registry/core.ts
rename to packages/core/src/registry/core.ts
index 66e3b422..196bcf52 100644
--- a/apps/desktop/src/registry/core.ts
+++ b/packages/core/src/registry/core.ts
@@ -1,5 +1,5 @@
import { ZodSchema } from 'zod';
-import { Node, NodeAttributes } from '@/registry';
+import { Node, NodeAttributes } from './';
export type NodeRole = 'admin' | 'editor' | 'collaborator' | 'viewer';
@@ -20,12 +20,12 @@ export interface NodeModel {
schema: ZodSchema;
canCreate: (
context: NodeMutationContext,
- attributes: NodeAttributes,
+ attributes: NodeAttributes
) => Promise<boolean>;
canUpdate: (
context: NodeMutationContext,
node: Node,
- attributes: NodeAttributes,
+ attributes: NodeAttributes
) => Promise<boolean>;
canDelete: (context: NodeMutationContext, node: Node) => Promise<boolean>;
}
diff --git a/apps/desktop/src/registry/database.ts b/packages/core/src/registry/database.ts
similarity index 95%
rename from apps/desktop/src/registry/database.ts
rename to packages/core/src/registry/database.ts
index 78e26faf..5bc8ad08 100644
--- a/apps/desktop/src/registry/database.ts
+++ b/packages/core/src/registry/database.ts
@@ -1,6 +1,6 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
-import { fieldAttributesSchema } from '@/registry/fields';
+import { NodeModel } from './core';
+import { fieldAttributesSchema } from './fields';
import { isEqual } from 'lodash';
export const viewFieldAttributesSchema = z.object({
@@ -105,7 +105,7 @@ export const databaseModel: NodeModel = {
return context.hasEditorAccess();
},
- canDelete: async (context, node) => {
+ canDelete: async (context, _) => {
return context.hasEditorAccess();
},
};
diff --git a/apps/desktop/src/registry/fields.ts b/packages/core/src/registry/fields.ts
similarity index 100%
rename from apps/desktop/src/registry/fields.ts
rename to packages/core/src/registry/fields.ts
diff --git a/apps/desktop/src/registry/file.ts b/packages/core/src/registry/file.ts
similarity index 71%
rename from apps/desktop/src/registry/file.ts
rename to packages/core/src/registry/file.ts
index c82c1a78..aee6b7fd 100644
--- a/apps/desktop/src/registry/file.ts
+++ b/packages/core/src/registry/file.ts
@@ -1,5 +1,5 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
+import { NodeModel } from './core';
export const fileAttributesSchema = z.object({
type: z.literal('file'),
@@ -16,13 +16,13 @@ export type FileAttributes = z.infer<typeof fileAttributesSchema>;
export const fileModel: NodeModel = {
type: 'file',
schema: fileAttributesSchema,
- canCreate: async (context, attributes) => {
+ canCreate: async (_, __) => {
return true;
},
- canUpdate: async (context, node, attributes) => {
+ canUpdate: async (_, __, ___) => {
return true;
},
- canDelete: async (context, node) => {
+ canDelete: async (_, __) => {
return true;
},
};
diff --git a/apps/desktop/src/registry/folder.ts b/packages/core/src/registry/folder.ts
similarity index 93%
rename from apps/desktop/src/registry/folder.ts
rename to packages/core/src/registry/folder.ts
index 2ff3001d..d2d6b807 100644
--- a/apps/desktop/src/registry/folder.ts
+++ b/packages/core/src/registry/folder.ts
@@ -1,5 +1,5 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
+import { NodeModel } from './core';
import { isEqual } from 'lodash';
export const folderAttributesSchema = z.object({
@@ -38,7 +38,7 @@ export const folderModel: NodeModel = {
return context.hasEditorAccess();
},
- canDelete: async (context, node) => {
+ canDelete: async (context, _) => {
return context.hasEditorAccess();
},
};
diff --git a/apps/desktop/src/registry/index.ts b/packages/core/src/registry/index.ts
similarity index 62%
rename from apps/desktop/src/registry/index.ts
rename to packages/core/src/registry/index.ts
index da2e1f69..cf92f91d 100644
--- a/apps/desktop/src/registry/index.ts
+++ b/packages/core/src/registry/index.ts
@@ -1,28 +1,14 @@
-import { ChannelAttributes, channelModel } from '@/registry/channel';
-import { NodeModel } from '@/registry/core';
-import { PageAttributes, pageModel } from '@/registry/page';
-import { ChatAttributes, chatModel } from '@/registry/chat';
-import { SpaceAttributes, spaceModel } from '@/registry/space';
-import { UserAttributes, userModel } from '@/registry/user';
-import { MessageAttributes, messageModel } from '@/registry/message';
-import { DatabaseAttributes, databaseModel } from '@/registry/database';
-import { FileAttributes, fileModel } from '@/registry/file';
-import { FolderAttributes, folderModel } from '@/registry/folder';
-import { RecordAttributes, recordModel } from '@/registry/record';
-
-export * from '@/registry/channel';
-export * from '@/registry/core';
-export * from '@/registry/page';
-export * from '@/registry/chat';
-export * from '@/registry/space';
-export * from '@/registry/user';
-export * from '@/registry/message';
-export * from '@/registry/database';
-export * from '@/registry/file';
-export * from '@/registry/folder';
-export * from '@/registry/record';
-export * from '@/registry/block';
-export * from '@/registry/fields';
+import { ChannelAttributes, channelModel } from './channel';
+import { NodeModel } from './core';
+import { PageAttributes, pageModel } from './page';
+import { ChatAttributes, chatModel } from './chat';
+import { SpaceAttributes, spaceModel } from './space';
+import { UserAttributes, userModel } from './user';
+import { MessageAttributes, messageModel } from './message';
+import { DatabaseAttributes, databaseModel } from './database';
+import { FileAttributes, fileModel } from './file';
+import { FolderAttributes, folderModel } from './folder';
+import { RecordAttributes, recordModel } from './record';
export const registry: Record<string, NodeModel> = {
channel: channelModel,
diff --git a/apps/desktop/src/registry/message.ts b/packages/core/src/registry/message.ts
similarity index 92%
rename from apps/desktop/src/registry/message.ts
rename to packages/core/src/registry/message.ts
index 45ac8f83..1c1649f6 100644
--- a/apps/desktop/src/registry/message.ts
+++ b/packages/core/src/registry/message.ts
@@ -1,6 +1,6 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
-import { blockSchema } from '@/registry/block';
+import { NodeModel } from './core';
+import { blockSchema } from './block';
import { isEqual } from 'lodash';
export const messageAttributesSchema = z.object({
diff --git a/apps/desktop/src/registry/page.ts b/packages/core/src/registry/page.ts
similarity index 89%
rename from apps/desktop/src/registry/page.ts
rename to packages/core/src/registry/page.ts
index 309147df..e24cefa6 100644
--- a/apps/desktop/src/registry/page.ts
+++ b/packages/core/src/registry/page.ts
@@ -1,6 +1,6 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
-import { blockSchema } from '@/registry/block';
+import { NodeModel } from './core';
+import { blockSchema } from './block';
import { isEqual } from 'lodash';
export const pageAttributesSchema = z.object({
@@ -40,7 +40,7 @@ export const pageModel: NodeModel = {
return context.hasEditorAccess();
},
- canDelete: async (context, node) => {
+ canDelete: async (context, _) => {
return context.hasEditorAccess();
},
};
diff --git a/apps/desktop/src/registry/record.ts b/packages/core/src/registry/record.ts
similarity index 82%
rename from apps/desktop/src/registry/record.ts
rename to packages/core/src/registry/record.ts
index 3a9bd015..2c836bad 100644
--- a/apps/desktop/src/registry/record.ts
+++ b/packages/core/src/registry/record.ts
@@ -1,7 +1,7 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
-import { fieldValueSchema } from '@/registry/fields';
-import { blockSchema } from '@/registry/block';
+import { NodeModel } from './core';
+import { fieldValueSchema } from './fields';
+import { blockSchema } from './block';
export const recordAttributesSchema = z.object({
type: z.literal('record'),
@@ -32,7 +32,7 @@ export const recordModel: NodeModel = {
return context.hasCollaboratorAccess();
},
- canDelete: async (context, node) => {
+ canDelete: async (context, _) => {
return context.hasCollaboratorAccess();
},
};
diff --git a/apps/desktop/src/registry/space.ts b/packages/core/src/registry/space.ts
similarity index 73%
rename from apps/desktop/src/registry/space.ts
rename to packages/core/src/registry/space.ts
index ba1d4366..eaaa67a3 100644
--- a/apps/desktop/src/registry/space.ts
+++ b/packages/core/src/registry/space.ts
@@ -1,5 +1,5 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
+import { NodeModel } from './core';
export const spaceAttributesSchema = z.object({
type: z.literal('space'),
@@ -15,13 +15,13 @@ export type SpaceAttributes = z.infer<typeof spaceAttributesSchema>;
export const spaceModel: NodeModel = {
type: 'space',
schema: spaceAttributesSchema,
- canCreate: async (context, attributes) => {
+ canCreate: async (_, __) => {
return true;
},
- canUpdate: async (context, node, attributes) => {
+ canUpdate: async (_, __, ___) => {
return true;
},
- canDelete: async (context, node) => {
+ canDelete: async (_, __) => {
return true;
},
};
diff --git a/apps/desktop/src/registry/user.ts b/packages/core/src/registry/user.ts
similarity index 62%
rename from apps/desktop/src/registry/user.ts
rename to packages/core/src/registry/user.ts
index dc1ae901..da5c3f3a 100644
--- a/apps/desktop/src/registry/user.ts
+++ b/packages/core/src/registry/user.ts
@@ -1,6 +1,5 @@
import { z } from 'zod';
-import { NodeModel } from '@/registry/core';
-import { WorkspaceRole } from '@/types/workspaces';
+import { NodeModel } from './core';
export const userAttributesSchema = z.object({
type: z.literal('user'),
@@ -9,7 +8,7 @@ export const userAttributesSchema = z.object({
email: z.string().email(),
avatar: z.string().nullable(),
accountId: z.string(),
- role: z.nativeEnum(WorkspaceRole),
+ role: z.enum(['admin', 'editor', 'collaborator', 'viewer']),
});
export type UserAttributes = z.infer<typeof userAttributesSchema>;
@@ -17,13 +16,13 @@ export type UserAttributes = z.infer<typeof userAttributesSchema>;
export const userModel: NodeModel = {
type: 'user',
schema: userAttributesSchema,
- canCreate: async (context, attributes) => {
+ canCreate: async (_, __) => {
return true;
},
- canUpdate: async (context, node, attributes) => {
+ canUpdate: async (_, __, ___) => {
return true;
},
- canDelete: async (context, node) => {
+ canDelete: async (_, __) => {
return true;
},
};
diff --git a/apps/desktop/src/registry/zod.ts b/packages/core/src/registry/zod.ts
similarity index 100%
rename from apps/desktop/src/registry/zod.ts
rename to packages/core/src/registry/zod.ts
diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json
index 93a1dfe0..1ccb5176 100644
--- a/packages/core/tsconfig.json
+++ b/packages/core/tsconfig.json
@@ -5,6 +5,6 @@
"compilerOptions": {
"declaration": true,
"declarationMap": true,
- "composite": true
- }
+ "composite": true,
+ },
}
diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.ts
deleted file mode 100644
index 5d3ea8f6..00000000
--- a/packages/core/vitest.config.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import path from 'node:path';
-import { configDefaults, defineConfig } from 'vitest/config';
-
-export default defineConfig({
- test: {
- exclude: [...configDefaults.exclude],
- },
- resolve: {
- alias: {
- '~': path.resolve(__dirname, './src'),
- },
- },
-});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2ce85a96..b27c8286 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -30,6 +30,9 @@ importers:
apps/desktop:
dependencies:
+ '@colanode/core':
+ specifier: workspace:*
+ version: link:../../packages/core
'@electron-toolkit/preload':
specifier: ^3.0.1
version: 3.0.1([email protected])
@@ -201,9 +204,6 @@ importers:
date-fns:
specifier: ^3.6.0
version: 3.6.0
- diff:
- specifier: ^7.0.0
- version: 7.0.0
electron-updater:
specifier: ^6.1.7
version: 6.3.9
@@ -285,12 +285,6 @@ importers:
ws:
specifier: ^8.18.0
version: 8.18.0
- yjs:
- specifier: ^13.6.20
- version: 13.6.20
- zod:
- specifier: ^3.23.8
- version: 3.23.8
devDependencies:
'@electron-forge/cli':
specifier: ^7.5.0
@@ -505,6 +499,16 @@ importers:
packages/core:
+ dependencies:
+ diff:
+ specifier: ^7.0.0
+ version: 7.0.0
+ yjs:
+ specifier: ^13.6.20
+ version: 13.6.20
+ zod:
+ specifier: ^3.23.8
+ version: 3.23.8
devDependencies:
eslint:
specifier: ^8.57.1
@@ -7295,7 +7299,7 @@ snapshots:
'@babel/traverse': 7.25.9
'@babel/types': 7.26.0
convert-source-map: 2.0.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 6.3.1
@@ -7383,7 +7387,7 @@ snapshots:
'@babel/parser': 7.26.2
'@babel/template': 7.25.9
'@babel/types': 7.26.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
globals: 11.12.0
transitivePeerDependencies:
- supports-color
@@ -7409,7 +7413,7 @@ snapshots:
'@electron/get': 3.1.0
chalk: 4.1.2
commander: 4.1.1
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 10.1.0
listr2: 7.0.2
semver: 7.6.3
@@ -7424,7 +7428,7 @@ snapshots:
'@electron/rebuild': 3.7.0
'@malept/cross-spawn-promise': 2.0.0
chalk: 4.1.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
find-up: 5.0.0
fs-extra: 10.1.0
log-symbols: 4.1.0
@@ -7452,7 +7456,7 @@ snapshots:
'@electron/rebuild': 3.7.0
'@malept/cross-spawn-promise': 2.0.0
chalk: 4.1.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fast-glob: 3.3.2
filenamify: 4.3.0
find-up: 5.0.0
@@ -7558,7 +7562,7 @@ snapshots:
'@electron-forge/shared-types': 7.5.0
'@electron-forge/web-multi-logger': 7.5.0
chalk: 4.1.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 10.1.0
listr2: 7.0.2
transitivePeerDependencies:
@@ -7588,7 +7592,7 @@ snapshots:
dependencies:
'@electron-forge/shared-types': 7.5.0
'@malept/cross-spawn-promise': 2.0.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 10.1.0
username: 5.1.0
transitivePeerDependencies:
@@ -7692,7 +7696,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
env-paths: 2.2.1
fs-extra: 8.1.0
got: 11.8.6
@@ -7706,7 +7710,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
env-paths: 2.2.1
fs-extra: 8.1.0
got: 11.8.6
@@ -7736,7 +7740,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 9.1.0
promise-retry: 2.0.1
transitivePeerDependencies:
@@ -7745,7 +7749,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
compare-version: 0.1.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 10.1.0
isbinaryfile: 4.0.10
minimist: 1.2.8
@@ -7761,7 +7765,7 @@ snapshots:
'@electron/osx-sign': 1.0.5
'@electron/universal': 2.0.1
'@electron/windows-sign': 1.1.3
- debug: 4.3.7([email protected])
+ debug: 4.3.7
extract-zip: 2.0.1
filenamify: 4.3.0
fs-extra: 11.2.0
@@ -7782,7 +7786,7 @@ snapshots:
'@electron/node-gyp': https://codeload.github.com/electron/node-gyp/tar.gz/06b29aafb7708acef8b3669835c8a7857ebc92d2
'@malept/cross-spawn-promise': 2.0.0
chalk: 4.1.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
detect-libc: 2.0.3
fs-extra: 10.1.0
got: 11.8.6
@@ -7801,7 +7805,7 @@ snapshots:
dependencies:
'@electron/asar': 3.2.16
'@malept/cross-spawn-promise': 1.1.1
- debug: 4.3.7([email protected])
+ debug: 4.3.7
dir-compare: 3.3.0
fs-extra: 9.1.0
minimatch: 3.1.2
@@ -7813,7 +7817,7 @@ snapshots:
dependencies:
'@electron/asar': 3.2.16
'@malept/cross-spawn-promise': 2.0.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
dir-compare: 4.2.0
fs-extra: 11.2.0
minimatch: 9.0.5
@@ -7824,7 +7828,7 @@ snapshots:
'@electron/[email protected]':
dependencies:
cross-dirname: 0.1.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 11.2.0
minimist: 1.2.8
postject: 1.0.0-alpha.6
@@ -7987,7 +7991,7 @@ snapshots:
'@eslint/[email protected]':
dependencies:
ajv: 6.12.6
- debug: 4.3.7([email protected])
+ debug: 4.3.7
espree: 9.6.1
globals: 13.24.0
ignore: 5.3.2
@@ -8026,7 +8030,7 @@ snapshots:
'@humanwhocodes/[email protected]':
dependencies:
'@humanwhocodes/object-schema': 2.0.3
- debug: 4.3.7([email protected])
+ debug: 4.3.7
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -8157,7 +8161,7 @@ snapshots:
'@malept/[email protected]':
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 9.1.0
lodash: 4.17.21
tmp-promise: 3.0.3
@@ -9531,7 +9535,7 @@ snapshots:
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/type-utils': 5.62.0([email protected])([email protected])
'@typescript-eslint/utils': 5.62.0([email protected])([email protected])
- debug: 4.3.7([email protected])
+ debug: 4.3.7
eslint: 8.57.1
graphemer: 1.4.0
ignore: 5.3.2
@@ -9566,7 +9570,7 @@ snapshots:
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/typescript-estree': 5.62.0([email protected])
- debug: 4.3.7([email protected])
+ debug: 4.3.7
eslint: 8.57.1
optionalDependencies:
typescript: 5.6.3
@@ -9579,7 +9583,7 @@ snapshots:
'@typescript-eslint/types': 7.18.0
'@typescript-eslint/typescript-estree': 7.18.0([email protected])
'@typescript-eslint/visitor-keys': 7.18.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
eslint: 8.57.1
optionalDependencies:
typescript: 5.6.3
@@ -9600,7 +9604,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 5.62.0([email protected])
'@typescript-eslint/utils': 5.62.0([email protected])([email protected])
- debug: 4.3.7([email protected])
+ debug: 4.3.7
eslint: 8.57.1
tsutils: 3.21.0([email protected])
optionalDependencies:
@@ -9612,7 +9616,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 7.18.0([email protected])
'@typescript-eslint/utils': 7.18.0([email protected])([email protected])
- debug: 4.3.7([email protected])
+ debug: 4.3.7
eslint: 8.57.1
ts-api-utils: 1.4.0([email protected])
optionalDependencies:
@@ -9628,7 +9632,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/visitor-keys': 5.62.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
globby: 11.1.0
is-glob: 4.0.3
semver: 7.6.3
@@ -9642,7 +9646,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 7.18.0
'@typescript-eslint/visitor-keys': 7.18.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
globby: 11.1.0
is-glob: 4.0.3
minimatch: 9.0.5
@@ -9752,7 +9756,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
transitivePeerDependencies:
- supports-color
@@ -9814,7 +9818,7 @@ snapshots:
builder-util: 24.13.1
builder-util-runtime: 9.2.4
chromium-pickle-js: 0.2.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
dmg-builder: 24.13.3([email protected])
ejs: 3.1.10
electron-builder-squirrel-windows: 24.13.3([email protected])
@@ -10099,14 +10103,14 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
sax: 1.4.1
transitivePeerDependencies:
- supports-color
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
sax: 1.4.1
transitivePeerDependencies:
- supports-color
@@ -10120,7 +10124,7 @@ snapshots:
builder-util-runtime: 9.2.4
chalk: 4.1.2
cross-spawn: 7.0.3
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 10.1.0
http-proxy-agent: 5.0.0
https-proxy-agent: 5.0.1
@@ -10466,6 +10470,10 @@ snapshots:
dependencies:
ms: 2.1.3
+ dependencies:
+ ms: 2.1.3
+
dependencies:
ms: 2.1.3
@@ -10634,7 +10642,7 @@ snapshots:
dependencies:
'@malept/cross-spawn-promise': 1.1.1
asar: 3.2.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 9.1.0
glob: 7.2.3
lodash: 4.17.21
@@ -10650,7 +10658,7 @@ snapshots:
dependencies:
'@malept/cross-spawn-promise': 1.1.1
- debug: 4.3.7([email protected])
+ debug: 4.3.7
electron-installer-common: 0.10.3
fs-extra: 9.1.0
get-folder-size: 2.0.1
@@ -10664,7 +10672,7 @@ snapshots:
dependencies:
'@malept/cross-spawn-promise': 1.1.1
- debug: 4.3.7([email protected])
+ debug: 4.3.7
electron-installer-common: 0.10.3
fs-extra: 9.1.0
lodash: 4.17.21
@@ -10716,7 +10724,7 @@ snapshots:
dependencies:
'@electron/asar': 3.2.16
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 7.0.1
lodash: 4.17.21
temp: 0.9.4
@@ -11025,7 +11033,7 @@ snapshots:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.3
- debug: 4.3.7([email protected])
+ debug: 4.3.7
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.2.2
@@ -11159,7 +11167,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
get-stream: 5.2.0
yauzl: 2.10.0
optionalDependencies:
@@ -11260,7 +11268,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
fs-extra: 10.1.0
transitivePeerDependencies:
- supports-color
@@ -11346,7 +11354,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
flora-colossus: 2.0.0
fs-extra: 10.1.0
transitivePeerDependencies:
@@ -11576,7 +11584,7 @@ snapshots:
dependencies:
'@tootallnate/once': 2.0.0
agent-base: 6.0.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
transitivePeerDependencies:
- supports-color
@@ -11588,7 +11596,7 @@ snapshots:
dependencies:
agent-base: 6.0.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
transitivePeerDependencies:
- supports-color
@@ -12938,7 +12946,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
transitivePeerDependencies:
- supports-color
@@ -13312,7 +13320,7 @@ snapshots:
dependencies:
agent-base: 6.0.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
socks: 2.8.3
transitivePeerDependencies:
- supports-color
@@ -13470,7 +13478,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
transitivePeerDependencies:
- supports-color
diff --git a/tsconfig.base.json b/tsconfig.base.json
index 992b3310..6213b9fa 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -28,5 +28,7 @@
"paths": {
"~/*": ["./src/*"]
}
- }
+ },
+ "include": ["${configDir}/src", "${configDir}/src/**/*.json"],
+ "exclude": ["${configDir}/node_modules", "${configDir}/dist"]
}