Skip to content

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

Add prettier in desktop

Hakan Shehu4191734d5e14
diff --git a/desktop/.prettierrc b/desktop/.prettierrc
new file mode 100644
index 00000000..43cc3e4b
--- /dev/null
+++ b/desktop/.prettierrc
@@ -0,0 +1,8 @@
+{
+ "semi": true,
+ "trailingComma": "all",
+ "singleQuote": true,
+ "printWidth": 80,
+ "tabWidth": 2,
+ "plugins": ["prettier-plugin-tailwindcss"]
+}
diff --git a/desktop/package-lock.json b/desktop/package-lock.json
index 0ba5bf6a..3cce7f42 100644
--- a/desktop/package-lock.json
+++ b/desktop/package-lock.json
@@ -91,6 +91,8 @@
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"postcss": "^8.4.40",
+ "prettier": "^3.3.3",
+ "prettier-plugin-tailwindcss": "^0.6.5",
"tailwindcss": "^3.4.7",
"ts-node": "^10.9.2",
"typescript": "~4.5.4",
@@ -10517,6 +10519,97 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/prettier": {
+ "version": "3.3.3",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz",
+ "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "prettier": "bin/prettier.cjs"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/prettier/prettier?sponsor=1"
+ }
+ },
+ "node_modules/prettier-plugin-tailwindcss": {
+ "version": "0.6.5",
+ "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.5.tgz",
+ "integrity": "sha512-axfeOArc/RiGHjOIy9HytehlC0ZLeMaqY09mm8YCkMzznKiDkwFzOpBvtuhuv3xG5qB73+Mj7OCe2j/L1ryfuQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14.21.3"
+ },
+ "peerDependencies": {
+ "@ianvs/prettier-plugin-sort-imports": "*",
+ "@prettier/plugin-pug": "*",
+ "@shopify/prettier-plugin-liquid": "*",
+ "@trivago/prettier-plugin-sort-imports": "*",
+ "@zackad/prettier-plugin-twig-melody": "*",
+ "prettier": "^3.0",
+ "prettier-plugin-astro": "*",
+ "prettier-plugin-css-order": "*",
+ "prettier-plugin-import-sort": "*",
+ "prettier-plugin-jsdoc": "*",
+ "prettier-plugin-marko": "*",
+ "prettier-plugin-organize-attributes": "*",
+ "prettier-plugin-organize-imports": "*",
+ "prettier-plugin-sort-imports": "*",
+ "prettier-plugin-style-order": "*",
+ "prettier-plugin-svelte": "*"
+ },
+ "peerDependenciesMeta": {
+ "@ianvs/prettier-plugin-sort-imports": {
+ "optional": true
+ },
+ "@prettier/plugin-pug": {
+ "optional": true
+ },
+ "@shopify/prettier-plugin-liquid": {
+ "optional": true
+ },
+ "@trivago/prettier-plugin-sort-imports": {
+ "optional": true
+ },
+ "@zackad/prettier-plugin-twig-melody": {
+ "optional": true
+ },
+ "prettier-plugin-astro": {
+ "optional": true
+ },
+ "prettier-plugin-css-order": {
+ "optional": true
+ },
+ "prettier-plugin-import-sort": {
+ "optional": true
+ },
+ "prettier-plugin-jsdoc": {
+ "optional": true
+ },
+ "prettier-plugin-marko": {
+ "optional": true
+ },
+ "prettier-plugin-organize-attributes": {
+ "optional": true
+ },
+ "prettier-plugin-organize-imports": {
+ "optional": true
+ },
+ "prettier-plugin-sort-imports": {
+ "optional": true
+ },
+ "prettier-plugin-style-order": {
+ "optional": true
+ },
+ "prettier-plugin-svelte": {
+ "optional": true
+ }
+ }
+ },
"node_modules/progress": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
diff --git a/desktop/package.json b/desktop/package.json
index cfce6211..f8c23223 100644
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -9,7 +9,8 @@
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
- "lint": "eslint --ext .ts,.tsx ."
+ "lint": "eslint --ext .ts,.tsx .",
+ "format": "prettier --write \"{src,test}/**/*.{js,ts}\""
},
"devDependencies": {
"@electron-forge/cli": "^7.4.0",
@@ -31,6 +32,8 @@
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"postcss": "^8.4.40",
+ "prettier": "^3.3.3",
+ "prettier-plugin-tailwindcss": "^0.6.5",
"tailwindcss": "^3.4.7",
"ts-node": "^10.9.2",
"typescript": "~4.5.4",
diff --git a/desktop/src/components/ui/use-toast.ts b/desktop/src/components/ui/use-toast.ts
index f2f234fa..b211c8d1 100644
--- a/desktop/src/components/ui/use-toast.ts
+++ b/desktop/src/components/ui/use-toast.ts
@@ -1,104 +1,101 @@
// Inspired by react-hot-toast library
-import * as React from "react"
+import * as React from 'react';
-import type {
- ToastActionElement,
- ToastProps,
-} from "@/components/ui/toast"
+import type { ToastActionElement, ToastProps } from '@/components/ui/toast';
-const TOAST_LIMIT = 1
-const TOAST_REMOVE_DELAY = 1000000
+const TOAST_LIMIT = 1;
+const TOAST_REMOVE_DELAY = 1000000;
type ToasterToast = ToastProps & {
- id: string
- title?: React.ReactNode
- description?: React.ReactNode
- action?: ToastActionElement
-}
+ id: string;
+ title?: React.ReactNode;
+ description?: React.ReactNode;
+ action?: ToastActionElement;
+};
const actionTypes = {
- ADD_TOAST: "ADD_TOAST",
- UPDATE_TOAST: "UPDATE_TOAST",
- DISMISS_TOAST: "DISMISS_TOAST",
- REMOVE_TOAST: "REMOVE_TOAST",
-} as const
+ ADD_TOAST: 'ADD_TOAST',
+ UPDATE_TOAST: 'UPDATE_TOAST',
+ DISMISS_TOAST: 'DISMISS_TOAST',
+ REMOVE_TOAST: 'REMOVE_TOAST',
+} as const;
-let count = 0
+let count = 0;
function genId() {
- count = (count + 1) % Number.MAX_SAFE_INTEGER
- return count.toString()
+ count = (count + 1) % Number.MAX_SAFE_INTEGER;
+ return count.toString();
}
-type ActionType = typeof actionTypes
+type ActionType = typeof actionTypes;
type Action =
| {
- type: ActionType["ADD_TOAST"]
- toast: ToasterToast
+ type: ActionType['ADD_TOAST'];
+ toast: ToasterToast;
}
| {
- type: ActionType["UPDATE_TOAST"]
- toast: Partial<ToasterToast>
+ type: ActionType['UPDATE_TOAST'];
+ toast: Partial<ToasterToast>;
}
| {
- type: ActionType["DISMISS_TOAST"]
- toastId?: ToasterToast["id"]
+ type: ActionType['DISMISS_TOAST'];
+ toastId?: ToasterToast['id'];
}
| {
- type: ActionType["REMOVE_TOAST"]
- toastId?: ToasterToast["id"]
- }
+ type: ActionType['REMOVE_TOAST'];
+ toastId?: ToasterToast['id'];
+ };
interface State {
- toasts: ToasterToast[]
+ toasts: ToasterToast[];
}
-const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
+const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
const addToRemoveQueue = (toastId: string) => {
if (toastTimeouts.has(toastId)) {
- return
+ return;
}
const timeout = setTimeout(() => {
- toastTimeouts.delete(toastId)
+ toastTimeouts.delete(toastId);
dispatch({
- type: "REMOVE_TOAST",
+ type: 'REMOVE_TOAST',
toastId: toastId,
- })
- }, TOAST_REMOVE_DELAY)
+ });
+ }, TOAST_REMOVE_DELAY);
- toastTimeouts.set(toastId, timeout)
-}
+ toastTimeouts.set(toastId, timeout);
+};
export const reducer = (state: State, action: Action): State => {
switch (action.type) {
- case "ADD_TOAST":
+ case 'ADD_TOAST':
return {
...state,
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
- }
+ };
- case "UPDATE_TOAST":
+ case 'UPDATE_TOAST':
return {
...state,
toasts: state.toasts.map((t) =>
- t.id === action.toast.id ? { ...t, ...action.toast } : t
+ t.id === action.toast.id ? { ...t, ...action.toast } : t,
),
- }
+ };
- case "DISMISS_TOAST": {
- const { toastId } = action
+ case 'DISMISS_TOAST': {
+ const { toastId } = action;
// ! Side effects ! - This could be extracted into a dismissToast() action,
// but I'll keep it here for simplicity
if (toastId) {
- addToRemoveQueue(toastId)
+ addToRemoveQueue(toastId);
} else {
state.toasts.forEach((toast) => {
- addToRemoveQueue(toast.id)
- })
+ addToRemoveQueue(toast.id);
+ });
}
return {
@@ -109,84 +106,84 @@ export const reducer = (state: State, action: Action): State => {
...t,
open: false,
}
- : t
+ : t,
),
- }
+ };
}
- case "REMOVE_TOAST":
+ case 'REMOVE_TOAST':
if (action.toastId === undefined) {
return {
...state,
toasts: [],
- }
+ };
}
return {
...state,
toasts: state.toasts.filter((t) => t.id !== action.toastId),
- }
+ };
}
-}
+};
-const listeners: Array<(state: State) => void> = []
+const listeners: Array<(state: State) => void> = [];
-let memoryState: State = { toasts: [] }
+let memoryState: State = { toasts: [] };
const dispatch = (action: Action) => {
- memoryState = reducer(memoryState, action)
+ memoryState = reducer(memoryState, action);
listeners.forEach((listener) => {
- listener(memoryState)
- })
-}
+ listener(memoryState);
+ });
+};
-type Toast = Omit<ToasterToast, "id">
+type Toast = Omit<ToasterToast, 'id'>;
const toast = ({ ...props }: Toast) => {
- const id = genId()
+ const id = genId();
const update = (props: ToasterToast) =>
dispatch({
- type: "UPDATE_TOAST",
+ type: 'UPDATE_TOAST',
toast: { ...props, id },
- })
- const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })
+ });
+ const dismiss = () => dispatch({ type: 'DISMISS_TOAST', toastId: id });
dispatch({
- type: "ADD_TOAST",
+ type: 'ADD_TOAST',
toast: {
...props,
id,
open: true,
onOpenChange: (open) => {
- if (!open) dismiss()
+ if (!open) dismiss();
},
},
- })
+ });
return {
id: id,
dismiss,
update,
- }
-}
+ };
+};
const useToast = () => {
- const [state, setState] = React.useState<State>(memoryState)
+ const [state, setState] = React.useState<State>(memoryState);
React.useEffect(() => {
- listeners.push(setState)
+ listeners.push(setState);
return () => {
- const index = listeners.indexOf(setState)
+ const index = listeners.indexOf(setState);
if (index > -1) {
- listeners.splice(index, 1)
+ listeners.splice(index, 1);
}
- }
- }, [state])
+ };
+ }, [state]);
return {
...state,
toast,
- dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
- }
-}
+ dismiss: (toastId?: string) => dispatch({ type: 'DISMISS_TOAST', toastId }),
+ };
+};
-export { useToast, toast }
+export { useToast, toast };
diff --git a/desktop/src/contexts/account.ts b/desktop/src/contexts/account.ts
index c56507a2..3bd04635 100644
--- a/desktop/src/contexts/account.ts
+++ b/desktop/src/contexts/account.ts
@@ -1,8 +1,6 @@
-import { createContext, useContext } from "react";
-import { Account } from "@/types/accounts";
+import { createContext, useContext } from 'react';
+import { Account } from '@/types/accounts';
-export const AccountContext = createContext<Account>(
- {} as Account
-);
+export const AccountContext = createContext<Account>({} as Account);
export const useAccount = () => useContext(AccountContext);
diff --git a/desktop/src/contexts/axios.ts b/desktop/src/contexts/axios.ts
index 01d41ad4..1b34fe40 100644
--- a/desktop/src/contexts/axios.ts
+++ b/desktop/src/contexts/axios.ts
@@ -1,8 +1,6 @@
-import { createContext, useContext } from "react";
-import { AxiosInstance } from "axios";
+import { createContext, useContext } from 'react';
+import { AxiosInstance } from 'axios';
-export const AxiosContext = createContext<AxiosInstance>(
- {} as AxiosInstance
-);
+export const AxiosContext = createContext<AxiosInstance>({} as AxiosInstance);
export const useAxios = () => useContext(AxiosContext);
diff --git a/desktop/src/contexts/store.ts b/desktop/src/contexts/store.ts
index d398e7ae..23040983 100644
--- a/desktop/src/contexts/store.ts
+++ b/desktop/src/contexts/store.ts
@@ -1,6 +1,6 @@
-import { createContext, useContext } from "react";
-import { store, AppStore } from "@/store";
+import { createContext, useContext } from 'react';
+import { store, AppStore } from '@/store';
export const StoreContext = createContext<AppStore>(store);
-export const useStore = () => useContext(StoreContext);
\ No newline at end of file
+export const useStore = () => useContext(StoreContext);
diff --git a/desktop/src/contexts/workspace.ts b/desktop/src/contexts/workspace.ts
index d5e64028..0a826548 100644
--- a/desktop/src/contexts/workspace.ts
+++ b/desktop/src/contexts/workspace.ts
@@ -1,14 +1,14 @@
import { createContext, useContext } from 'react';
-import { Workspace } from "@/types/workspaces";
-import {Node} from "@/types/nodes";
+import { Workspace } from '@/types/workspaces';
+import { Node } from '@/types/nodes';
interface WorkspaceContext extends Workspace {
- addNode: (node: Node) => Promise<void>
- addNodes: (nodes: Node[]) => Promise<void>
- getNodes: () => Node[]
- updateNode: (node: Node) => Promise<void>
- deleteNode: (nodeId: string) => Promise<void>
- setContainerNode: (nodeId?: string | null) => void
+ addNode: (node: Node) => Promise<void>;
+ addNodes: (nodes: Node[]) => Promise<void>;
+ getNodes: () => Node[];
+ updateNode: (node: Node) => Promise<void>;
+ deleteNode: (nodeId: string) => Promise<void>;
+ setContainerNode: (nodeId?: string | null) => void;
}
export const WorkspaceContext = createContext<WorkspaceContext>(
@@ -16,4 +16,3 @@ export const WorkspaceContext = createContext<WorkspaceContext>(
);
export const useWorkspace = () => useContext(WorkspaceContext);
-
diff --git a/desktop/src/electron/database/global/index.ts b/desktop/src/electron/database/global/index.ts
index eb17b638..355c8499 100644
--- a/desktop/src/electron/database/global/index.ts
+++ b/desktop/src/electron/database/global/index.ts
@@ -1,13 +1,13 @@
-import {app} from "electron";
-import SQLite from "better-sqlite3";
-import {Kysely, Migration, Migrator, SqliteDialect} from "kysely";
-import { GlobalDatabaseSchema } from "@/electron/database/global/schema";
-import {Account} from "@/types/accounts";
-import {Workspace} from "@/types/workspaces";
-import {AccountTransactions, Transaction} from "@/types/transactions";
-import {globalDatabaseMigrations} from "@/electron/database/global/migrations";
-import {GlobalDatabaseData, WorkspaceDatabaseData} from "@/types/global";
-import {WorkspaceDatabase} from "@/electron/database/workspace";
+import { app } from 'electron';
+import SQLite from 'better-sqlite3';
+import { Kysely, Migration, Migrator, SqliteDialect } from 'kysely';
+import { GlobalDatabaseSchema } from '@/electron/database/global/schema';
+import { Account } from '@/types/accounts';
+import { Workspace } from '@/types/workspaces';
+import { AccountTransactions, Transaction } from '@/types/transactions';
+import { globalDatabaseMigrations } from '@/electron/database/global/migrations';
+import { GlobalDatabaseData, WorkspaceDatabaseData } from '@/types/global';
+import { WorkspaceDatabase } from '@/electron/database/workspace';
export class GlobalDatabase {
database: Kysely<GlobalDatabaseSchema>;
@@ -20,7 +20,7 @@ export class GlobalDatabase {
});
this.database = new Kysely<GlobalDatabaseSchema>({
- dialect
+ dialect,
});
}
@@ -38,9 +38,9 @@ export class GlobalDatabase {
return {
accounts,
- workspaces: workspaceDatabaseData
+ workspaces: workspaceDatabaseData,
};
- }
+ };
migrate = async () => {
const migrator = new Migrator({
@@ -48,35 +48,46 @@ export class GlobalDatabase {
provider: {
getMigrations(): Promise<Record<string, Migration>> {
return Promise.resolve(globalDatabaseMigrations);
- }
- }
- })
+ },
+ },
+ });
await migrator.migrateToLatest();
- }
+ };
- getWorkspaceDatabase = (accountId: string, workspaceId: string): WorkspaceDatabase => {
+ getWorkspaceDatabase = (
+ accountId: string,
+ workspaceId: string,
+ ): WorkspaceDatabase => {
const key = `${accountId}_${workspaceId}`;
const workspaceDatabase = this.workspaceDatabases.get(key);
if (!workspaceDatabase) {
- throw new Error(`Workspace database not found for workspace ID: ${workspaceId}`);
+ throw new Error(
+ `Workspace database not found for workspace ID: ${workspaceId}`,
+ );
}
return workspaceDatabase;
- }
+ };
- initWorkspaceDatabase = async (workspace: Workspace): Promise<WorkspaceDatabaseData> => {
+ initWorkspaceDatabase = async (
+ workspace: Workspace,
+ ): Promise<WorkspaceDatabaseData> => {
const key = `${workspace.accountId}_${workspace.id}`;
- const workspaceDatabase = new WorkspaceDatabase(workspace.accountId, workspace.id, this);
+ const workspaceDatabase = new WorkspaceDatabase(
+ workspace.accountId,
+ workspace.id,
+ this,
+ );
await workspaceDatabase.migrate();
this.workspaceDatabases.set(key, workspaceDatabase);
const nodes = await workspaceDatabase.getNodes();
return {
workspace,
- nodes
+ nodes,
};
- }
+ };
getAccounts = async (): Promise<Account[]> => {
const accounts = await this.database
@@ -89,16 +100,13 @@ export class GlobalDatabase {
name: account.name,
email: account.email,
avatar: account.avatar,
- token: account.token
+ token: account.token,
}));
- }
+ };
addAccount = async (account: Account) => {
- await this.database
- .insertInto('accounts')
- .values(account)
- .execute();
- }
+ await this.database.insertInto('accounts').values(account).execute();
+ };
getWorkspaces = async (): Promise<Workspace[]> => {
const workspaces = await this.database
@@ -106,7 +114,7 @@ export class GlobalDatabase {
.selectAll()
.execute();
- return workspaces.map(workspace => ({
+ return workspaces.map((workspace) => ({
id: workspace.id,
name: workspace.name,
description: workspace.description,
@@ -114,9 +122,9 @@ export class GlobalDatabase {
versionId: workspace.version_id,
accountId: workspace.account_id,
role: workspace.role,
- userNodeId: workspace.user_node_id
+ userNodeId: workspace.user_node_id,
}));
- }
+ };
addWorkspace = async (workspace: Workspace) => {
await this.database
@@ -129,12 +137,12 @@ export class GlobalDatabase {
version_id: workspace.versionId,
account_id: workspace.accountId,
role: workspace.role,
- user_node_id: workspace.userNodeId
+ user_node_id: workspace.userNodeId,
})
.execute();
await this.initWorkspaceDatabase(workspace);
- }
+ };
addTransaction = async (transaction: Transaction) => {
await this.database
@@ -146,12 +154,14 @@ export class GlobalDatabase {
input: transaction.input,
node_id: transaction.nodeId,
created_at: transaction.createdAt.toISOString(),
- workspace_id: transaction.workspaceId
+ workspace_id: transaction.workspaceId,
})
.execute();
- }
+ };
- getGroupedAccountTransactions = async (count: number): Promise<AccountTransactions[]> => {
+ getGroupedAccountTransactions = async (
+ count: number,
+ ): Promise<AccountTransactions[]> => {
const transactions = await this.database
.selectFrom('transactions')
.selectAll()
@@ -162,7 +172,9 @@ export class GlobalDatabase {
return [];
}
- const accountIds = transactions.map(transaction => transaction.account_id);
+ const accountIds = transactions.map(
+ (transaction) => transaction.account_id,
+ );
const accounts = await this.database
.selectFrom('accounts')
.selectAll()
@@ -170,7 +182,7 @@ export class GlobalDatabase {
.execute();
const transactionsMap = new Map<string, Transaction[]>();
- transactions.forEach(transaction => {
+ transactions.forEach((transaction) => {
const input = JSON.parse(transaction.input);
const transactionObj = {
id: transaction.id,
@@ -179,7 +191,7 @@ export class GlobalDatabase {
type: transaction.type,
nodeId: transaction.node_id,
input: input,
- createdAt: new Date(transaction.created_at)
+ createdAt: new Date(transaction.created_at),
};
if (transactionsMap.has(transaction.account_id)) {
@@ -189,24 +201,24 @@ export class GlobalDatabase {
}
});
- return accounts.map(account => ({
+ return accounts.map((account) => ({
account: {
id: account.id,
name: account.name,
email: account.email,
avatar: account.avatar,
- token: account.token
+ token: account.token,
},
- transactions: transactionsMap.get(account.id) || []
+ transactions: transactionsMap.get(account.id) || [],
}));
- }
+ };
deleteTransactions = async (ids: string[]) => {
await this.database
.deleteFrom('transactions')
.where('id', 'in', ids)
.execute();
- }
+ };
}
-export const globalDatabase = new GlobalDatabase();
\ No newline at end of file
+export const globalDatabase = new GlobalDatabase();
diff --git a/desktop/src/electron/database/global/migrations.ts b/desktop/src/electron/database/global/migrations.ts
index 0a2f86b7..d77a0e49 100644
--- a/desktop/src/electron/database/global/migrations.ts
+++ b/desktop/src/electron/database/global/migrations.ts
@@ -1,4 +1,4 @@
-import {Migration} from "kysely";
+import { Migration } from 'kysely';
const createAccountsTable: Migration = {
up: async (db) => {
@@ -9,12 +9,12 @@ const createAccountsTable: Migration = {
.addColumn('email', 'text', (col) => col.notNull())
.addColumn('avatar', 'text')
.addColumn('token', 'text', (col) => col.notNull())
- .execute()
+ .execute();
},
down: async (db) => {
- await db.schema.dropTable('accounts').execute()
- }
-}
+ await db.schema.dropTable('accounts').execute();
+ },
+};
const createWorkspacesTable: Migration = {
up: async (db) => {
@@ -28,12 +28,12 @@ const createWorkspacesTable: Migration = {
.addColumn('account_id', 'integer', (col) => col.notNull())
.addColumn('role', 'integer', (col) => col.notNull())
.addColumn('user_node_id', 'text', (col) => col.notNull())
- .execute()
+ .execute();
},
down: async (db) => {
- await db.schema.dropTable('workspaces').execute()
- }
-}
+ await db.schema.dropTable('workspaces').execute();
+ },
+};
const createTransactionsTable: Migration = {
up: async (db) => {
@@ -46,15 +46,15 @@ const createTransactionsTable: Migration = {
.addColumn('node_id', 'text', (col) => col.notNull())
.addColumn('input', 'text', (col) => col.notNull())
.addColumn('created_at', 'text', (col) => col.notNull())
- .execute()
+ .execute();
},
down: async (db) => {
- await db.schema.dropTable('transactions').execute()
- }
-}
+ await db.schema.dropTable('transactions').execute();
+ },
+};
export const globalDatabaseMigrations: Record<string, Migration> = {
'202408011709_create_accounts_table': createAccountsTable,
'202408011712_create_workspaces_table': createWorkspacesTable,
- '202408011715_create_transactions_table': createTransactionsTable
-}
\ No newline at end of file
+ '202408011715_create_transactions_table': createTransactionsTable,
+};
diff --git a/desktop/src/electron/database/global/schema.ts b/desktop/src/electron/database/global/schema.ts
index c50b9bf9..5234821e 100644
--- a/desktop/src/electron/database/global/schema.ts
+++ b/desktop/src/electron/database/global/schema.ts
@@ -31,4 +31,4 @@ export interface GlobalDatabaseSchema {
accounts: AccountsTableSchema;
workspaces: WorkspacesTableSchema;
transactions: TransactionsTableSchema;
-}
\ No newline at end of file
+}
diff --git a/desktop/src/electron/database/workspace/index.ts b/desktop/src/electron/database/workspace/index.ts
index 56f2bcf5..dab84fe6 100644
--- a/desktop/src/electron/database/workspace/index.ts
+++ b/desktop/src/electron/database/workspace/index.ts
@@ -1,12 +1,12 @@
-import {app} from "electron";
-import SQLite from "better-sqlite3";
-import {Kysely, Migration, Migrator, SqliteDialect} from "kysely";
-import {WorkspaceDatabaseSchema} from "@/electron/database/workspace/schema";
-import {workspaceDatabaseMigrations} from "@/electron/database/workspace/migrations";
-import * as fs from "node:fs";
-import {GlobalDatabase} from "@/electron/database/global";
-import {Node} from "@/types/nodes";
-import {NeuronId} from "@/lib/id";
+import { app } from 'electron';
+import SQLite from 'better-sqlite3';
+import { Kysely, Migration, Migrator, SqliteDialect } from 'kysely';
+import { WorkspaceDatabaseSchema } from '@/electron/database/workspace/schema';
+import { workspaceDatabaseMigrations } from '@/electron/database/workspace/migrations';
+import * as fs from 'node:fs';
+import { GlobalDatabase } from '@/electron/database/global';
+import { Node } from '@/types/nodes';
+import { NeuronId } from '@/lib/id';
export class WorkspaceDatabase {
accountId: string;
@@ -14,10 +14,14 @@ export class WorkspaceDatabase {
database: Kysely<WorkspaceDatabaseSchema>;
globalDatabase: GlobalDatabase;
- constructor(accountId: string, workspaceId: string, globalDatabase: GlobalDatabase) {
+ constructor(
+ accountId: string,
+ workspaceId: string,
+ globalDatabase: GlobalDatabase,
+ ) {
this.accountId = accountId;
this.workspaceId = workspaceId;
- this.globalDatabase = globalDatabase
+ this.globalDatabase = globalDatabase;
const appPath = app.getPath('userData');
const accountPath = `${appPath}/account_${accountId}`;
@@ -35,12 +39,9 @@ export class WorkspaceDatabase {
}
getNodes = async (): Promise<Node[]> => {
- const nodes = await this.database
- .selectFrom('nodes')
- .selectAll()
- .execute();
+ const nodes = await this.database.selectFrom('nodes').selectAll().execute();
- return nodes.map(node => ({
+ return nodes.map((node) => ({
id: node.id,
type: node.type,
parentId: node.parent_id,
@@ -53,7 +54,7 @@ export class WorkspaceDatabase {
updatedBy: node.updated_by,
versionId: node.version_id,
}));
- }
+ };
addNode = async (node: Node) => {
await this.database
@@ -71,23 +72,22 @@ export class WorkspaceDatabase {
})
.execute();
- await this.globalDatabase.
- addTransaction({
- id: NeuronId.generate(NeuronId.Type.Transaction),
- nodeId: node.id,
- type: 'create_node',
- workspaceId: node.workspaceId,
- accountId: this.accountId,
- input: JSON.stringify(node),
- createdAt: new Date(),
- });
- }
+ await this.globalDatabase.addTransaction({
+ id: NeuronId.generate(NeuronId.Type.Transaction),
+ nodeId: node.id,
+ type: 'create_node',
+ workspaceId: node.workspaceId,
+ accountId: this.accountId,
+ input: JSON.stringify(node),
+ createdAt: new Date(),
+ });
+ };
addNodes = async (nodes: Node[]) => {
await this.database
.insertInto('nodes')
.values(
- nodes.map(node => ({
+ nodes.map((node) => ({
id: node.id,
type: node.type,
parent_id: node.parentId,
@@ -97,7 +97,7 @@ export class WorkspaceDatabase {
version_id: node.versionId,
attrs: JSON.stringify(node.attrs),
content: JSON.stringify(node.content),
- }))
+ })),
)
.execute();
@@ -113,7 +113,7 @@ export class WorkspaceDatabase {
createdAt: new Date(),
});
}
- }
+ };
updateNode = async (node: Node) => {
await this.database
@@ -139,13 +139,10 @@ export class WorkspaceDatabase {
input: JSON.stringify(node),
createdAt: new Date(),
});
- }
+ };
deleteNode = async (nodeId: string) => {
- await this.database
- .deleteFrom('nodes')
- .where('id', '=', nodeId)
- .execute();
+ await this.database.deleteFrom('nodes').where('id', '=', nodeId).execute();
await this.globalDatabase.addTransaction({
id: NeuronId.generate(NeuronId.Type.Transaction),
@@ -156,7 +153,7 @@ export class WorkspaceDatabase {
input: null,
createdAt: new Date(),
});
- }
+ };
migrate = async () => {
const migrator = new Migrator({
@@ -164,10 +161,10 @@ export class WorkspaceDatabase {
provider: {
getMigrations(): Promise<Record<string, Migration>> {
return Promise.resolve(workspaceDatabaseMigrations);
- }
- }
- })
+ },
+ },
+ });
await migrator.migrateToLatest();
- }
+ };
}
diff --git a/desktop/src/electron/database/workspace/migrations.ts b/desktop/src/electron/database/workspace/migrations.ts
index 19803c96..c7bfacf2 100644
--- a/desktop/src/electron/database/workspace/migrations.ts
+++ b/desktop/src/electron/database/workspace/migrations.ts
@@ -1,4 +1,4 @@
-import {Migration} from "kysely";
+import { Migration } from 'kysely';
const createNodesTable: Migration = {
up: async (db) => {
@@ -15,13 +15,13 @@ const createNodesTable: Migration = {
.addColumn('created_by', 'text', (col) => col.notNull())
.addColumn('updated_by', 'text')
.addColumn('version_id', 'text', (col) => col.notNull())
- .execute()
+ .execute();
},
down: async (db) => {
- await db.schema.dropTable('nodes').execute()
- }
-}
+ await db.schema.dropTable('nodes').execute();
+ },
+};
export const workspaceDatabaseMigrations: Record<string, Migration> = {
- '202408011756_create_nodes_table': createNodesTable
-}
\ No newline at end of file
+ '202408011756_create_nodes_table': createNodesTable,
+};
diff --git a/desktop/src/electron/database/workspace/schema.ts b/desktop/src/electron/database/workspace/schema.ts
index b9e4e2b4..1eee0f4c 100644
--- a/desktop/src/electron/database/workspace/schema.ts
+++ b/desktop/src/electron/database/workspace/schema.ts
@@ -14,4 +14,4 @@ export interface NodesTableSchema {
export interface WorkspaceDatabaseSchema {
nodes: NodesTableSchema;
-}
\ No newline at end of file
+}
diff --git a/desktop/src/electron/event-loop.ts b/desktop/src/electron/event-loop.ts
index 251ccf38..49dc9edc 100644
--- a/desktop/src/electron/event-loop.ts
+++ b/desktop/src/electron/event-loop.ts
@@ -1,21 +1,22 @@
-import {globalDatabase} from "@/electron/database/global";
+import { globalDatabase } from '@/electron/database/global';
export const initEventLoop = () => {
setInterval(async () => {
await sendTransactions();
}, 10000);
-}
+};
const sendTransactions = async () => {
- const groupedAccountTransactions = await globalDatabase.getGroupedAccountTransactions(20);
+ const groupedAccountTransactions =
+ await globalDatabase.getGroupedAccountTransactions(20);
for (const accountTransactions of groupedAccountTransactions) {
- const transactionIds = accountTransactions.transactions.map(t => t.id);
- const response = await fetch("http://localhost:3000/v1/transactions", {
- method: "POST",
+ const transactionIds = accountTransactions.transactions.map((t) => t.id);
+ const response = await fetch('http://localhost:3000/v1/transactions', {
+ method: 'POST',
headers: {
- "Content-Type": "application/json",
- 'Authorization': `Bearer ${accountTransactions.account.token}`,
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${accountTransactions.account.token}`,
},
body: JSON.stringify({
transactions: accountTransactions.transactions,
@@ -26,4 +27,4 @@ const sendTransactions = async () => {
await globalDatabase.deleteTransactions(transactionIds);
}
}
-}
+};
diff --git a/desktop/src/lib/axios.ts b/desktop/src/lib/axios.ts
index 48c5c522..bff58aeb 100644
--- a/desktop/src/lib/axios.ts
+++ b/desktop/src/lib/axios.ts
@@ -44,4 +44,4 @@ export const parseApiError = (error: unknown): ApiErrorOutput => {
code: 'UNKNOWN',
message: 'An unknown error occurred',
};
-}
+};
diff --git a/desktop/src/lib/constants.ts b/desktop/src/lib/constants.ts
index ca12f2fb..1b66d44c 100644
--- a/desktop/src/lib/constants.ts
+++ b/desktop/src/lib/constants.ts
@@ -2,4 +2,4 @@ export const NodeTypes = {
Space: 'space',
Page: 'page',
Channel: 'channel',
-};
\ No newline at end of file
+};
diff --git a/desktop/src/lib/id.ts b/desktop/src/lib/id.ts
index 89f0b77c..56249fe0 100644
--- a/desktop/src/lib/id.ts
+++ b/desktop/src/lib/id.ts
@@ -1,6 +1,6 @@
-import { monotonicFactory } from 'ulid'
+import { monotonicFactory } from 'ulid';
-const ulid = monotonicFactory()
+const ulid = monotonicFactory();
enum IdType {
Account = 'ac',
@@ -16,7 +16,7 @@ enum IdType {
export class NeuronId {
public static generate(type: IdType): string {
- return ulid().toLowerCase() + type
+ return ulid().toLowerCase() + type;
}
public static is(id: string, type: IdType): boolean {
@@ -52,4 +52,3 @@ export class NeuronId {
public static Type = IdType;
}
-
diff --git a/desktop/src/lib/lowlight.ts b/desktop/src/lib/lowlight.ts
index 7bcdd978..21b02fc6 100644
--- a/desktop/src/lib/lowlight.ts
+++ b/desktop/src/lib/lowlight.ts
@@ -233,9 +233,12 @@ const parseNodes = (
};
})
.flat();
-}
+};
-export const highlightCode = (code: string, language?: string): CodeHighlight | null => {
+export const highlightCode = (
+ code: string,
+ language?: string,
+): CodeHighlight | null => {
try {
const result =
language && lowlightLanguages.includes(language)
@@ -251,4 +254,4 @@ export const highlightCode = (code: string, language?: string): CodeHighlight |
console.error('highlightCode', error, code, language);
return null;
}
-}
+};
diff --git a/desktop/src/lib/utils.ts b/desktop/src/lib/utils.ts
index 024f7973..594ead14 100644
--- a/desktop/src/lib/utils.ts
+++ b/desktop/src/lib/utils.ts
@@ -1,9 +1,9 @@
-import { type ClassValue, clsx } from "clsx"
-import { twMerge } from "tailwind-merge"
+import { type ClassValue, clsx } from 'clsx';
+import { twMerge } from 'tailwind-merge';
export const cn = (...inputs: ClassValue[]) => {
- return twMerge(clsx(inputs))
-}
+ return twMerge(clsx(inputs));
+};
export const hashCode = (str: string) => {
let hash = 0;
@@ -13,7 +13,7 @@ export const hashCode = (str: string) => {
hash |= 0; // Convert to 32bit integer
}
return hash;
-}
+};
export const updateScrollView = (container: HTMLElement, item: HTMLElement) => {
const containerHeight = container.offsetHeight;
@@ -27,4 +27,4 @@ export const updateScrollView = (container: HTMLElement, item: HTMLElement) => {
} else if (bottom > containerHeight + container.scrollTop) {
container.scrollTop += bottom - containerHeight - container.scrollTop + 5;
}
-}
\ No newline at end of file
+};
diff --git a/desktop/src/main.ts b/desktop/src/main.ts
index 00a8a5bc..b4de5b94 100644
--- a/desktop/src/main.ts
+++ b/desktop/src/main.ts
@@ -1,7 +1,7 @@
import { app, ipcMain, BrowserWindow } from 'electron';
import path from 'path';
-import { globalDatabase } from "@/electron/database/global";
-import {initEventLoop} from "@/electron/event-loop";
+import { globalDatabase } from '@/electron/database/global';
+import { initEventLoop } from '@/electron/event-loop';
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
@@ -21,7 +21,9 @@ const createWindow = () => {
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
} else {
- mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`));
+ mainWindow.loadFile(
+ path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`),
+ );
}
// Open the DevTools.
@@ -53,34 +55,55 @@ app.on('activate', () => {
// inter process handlers
ipcMain.handle('init', async () => globalDatabase.init());
ipcMain.handle('get-accounts', async () => globalDatabase.getAccounts());
-ipcMain.handle('add-account', async (_, account) => globalDatabase.addAccount(account));
+ipcMain.handle('add-account', async (_, account) =>
+ globalDatabase.addAccount(account),
+);
ipcMain.handle('get-workspaces', async () => globalDatabase.getWorkspaces());
-ipcMain.handle('add-workspace', async (_, workspace) => globalDatabase.addWorkspace(workspace));
-ipcMain.handle('add-transaction', async (_, transaction) => globalDatabase.addTransaction(transaction));
+ipcMain.handle('add-workspace', async (_, workspace) =>
+ globalDatabase.addWorkspace(workspace),
+);
+ipcMain.handle('add-transaction', async (_, transaction) =>
+ globalDatabase.addTransaction(transaction),
+);
ipcMain.handle('add-node', async (_, accountId, workspaceId, node) => {
- const workspaceDb = globalDatabase.getWorkspaceDatabase(accountId, workspaceId);
+ const workspaceDb = globalDatabase.getWorkspaceDatabase(
+ accountId,
+ workspaceId,
+ );
await workspaceDb.addNode(node);
});
ipcMain.handle('add-nodes', async (_, accountId, workspaceId, nodes) => {
- const workspaceDb = globalDatabase.getWorkspaceDatabase(accountId, workspaceId);
+ const workspaceDb = globalDatabase.getWorkspaceDatabase(
+ accountId,
+ workspaceId,
+ );
await workspaceDb.addNodes(nodes);
});
ipcMain.handle('get-nodes', async (_, accountId, workspaceId) => {
- const workspaceDb = globalDatabase.getWorkspaceDatabase(accountId, workspaceId);
+ const workspaceDb = globalDatabase.getWorkspaceDatabase(
+ accountId,
+ workspaceId,
+ );
return workspaceDb.getNodes();
});
ipcMain.handle('update-node', async (_, accountId, workspaceId, node) => {
- const workspaceDb = globalDatabase.getWorkspaceDatabase(accountId, workspaceId);
+ const workspaceDb = globalDatabase.getWorkspaceDatabase(
+ accountId,
+ workspaceId,
+ );
await workspaceDb.updateNode(node);
});
ipcMain.handle('delete-node', async (_, accountId, workspaceId, nodeId) => {
- const workspaceDb = globalDatabase.getWorkspaceDatabase(accountId, workspaceId);
+ const workspaceDb = globalDatabase.getWorkspaceDatabase(
+ accountId,
+ workspaceId,
+ );
await workspaceDb.deleteNode(nodeId);
});
-initEventLoop();
\ No newline at end of file
+initEventLoop();
diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts
index 9d93cffd..5423548b 100644
--- a/desktop/src/preload.ts
+++ b/desktop/src/preload.ts
@@ -1,22 +1,29 @@
import { contextBridge, ipcRenderer } from 'electron';
-import {Account} from "@/types/accounts";
-import {Workspace} from "@/types/workspaces";
-import {Transaction} from "@/types/transactions";
-import {Node} from "@/types/nodes";
+import { Account } from '@/types/accounts';
+import { Workspace } from '@/types/workspaces';
+import { Transaction } from '@/types/transactions';
+import { Node } from '@/types/nodes';
contextBridge.exposeInMainWorld('globalDb', {
init: () => ipcRenderer.invoke('init'),
getAccounts: () => ipcRenderer.invoke('get-accounts'),
addAccount: (account: Account) => ipcRenderer.invoke('add-account', account),
getWorkspaces: () => ipcRenderer.invoke('get-workspaces'),
- addWorkspace: (workspace: Workspace) => ipcRenderer.invoke('add-workspace', workspace),
- addTransaction: (transaction: Transaction) => ipcRenderer.invoke('add-transaction', transaction),
+ addWorkspace: (workspace: Workspace) =>
+ ipcRenderer.invoke('add-workspace', workspace),
+ addTransaction: (transaction: Transaction) =>
+ ipcRenderer.invoke('add-transaction', transaction),
});
contextBridge.exposeInMainWorld('workspaceDb', {
- addNode: (accountId: string, workspaceId: string, node: Node) => ipcRenderer.invoke('add-node', accountId, workspaceId, node),
- addNodes: (accountId: string, workspaceId: string, nodes: Node[]) => ipcRenderer.invoke('add-nodes', accountId, workspaceId, nodes),
- getNodes: (accountId: string, workspaceId: string) => ipcRenderer.invoke('get-nodes', accountId, workspaceId),
- updateNode: (accountId: string, workspaceId: string, node: Node) => ipcRenderer.invoke('update-node', accountId, workspaceId, node),
- deleteNode: (accountId: string, workspaceId: string, nodeId: string) => ipcRenderer.invoke('delete-node', accountId, workspaceId, nodeId),
-})
\ No newline at end of file
+ addNode: (accountId: string, workspaceId: string, node: Node) =>
+ ipcRenderer.invoke('add-node', accountId, workspaceId, node),
+ addNodes: (accountId: string, workspaceId: string, nodes: Node[]) =>
+ ipcRenderer.invoke('add-nodes', accountId, workspaceId, nodes),
+ getNodes: (accountId: string, workspaceId: string) =>
+ ipcRenderer.invoke('get-nodes', accountId, workspaceId),
+ updateNode: (accountId: string, workspaceId: string, node: Node) =>
+ ipcRenderer.invoke('update-node', accountId, workspaceId, node),
+ deleteNode: (accountId: string, workspaceId: string, nodeId: string) =>
+ ipcRenderer.invoke('delete-node', accountId, workspaceId, nodeId),
+});
diff --git a/desktop/src/renderer.ts b/desktop/src/renderer.ts
index f5cb21ca..2909291b 100644
--- a/desktop/src/renderer.ts
+++ b/desktop/src/renderer.ts
@@ -27,4 +27,4 @@
*/
import './styles/index.css';
-import './components/root'
+import './components/root';
diff --git a/desktop/src/store/index.ts b/desktop/src/store/index.ts
index f4d1b216..1e209559 100644
--- a/desktop/src/store/index.ts
+++ b/desktop/src/store/index.ts
@@ -1,7 +1,7 @@
-import {Account} from "@/types/accounts";
-import {Workspace} from "@/types/workspaces";
-import {makeAutoObservable} from "mobx";
-import {WorkspaceStore} from "@/store/workspace";
+import { Account } from '@/types/accounts';
+import { Workspace } from '@/types/workspaces';
+import { makeAutoObservable } from 'mobx';
+import { WorkspaceStore } from '@/store/workspace';
export class AppStore {
loaded: boolean;
@@ -29,11 +29,13 @@ export class AppStore {
}
getWorkspace(id: string) {
- return this.workspaces.find(workspace => workspace.id === id);
+ return this.workspaces.find((workspace) => workspace.id === id);
}
setWorkspaces(workspaces: Workspace[]) {
- this.workspaces = workspaces.map(workspace => new WorkspaceStore(workspace));
+ this.workspaces = workspaces.map(
+ (workspace) => new WorkspaceStore(workspace),
+ );
}
addWorkspace(workspace: Workspace) {
@@ -41,4 +43,4 @@ export class AppStore {
}
}
-export const store = new AppStore();
\ No newline at end of file
+export const store = new AppStore();
diff --git a/desktop/src/store/workspace.ts b/desktop/src/store/workspace.ts
index c856e36d..f9e67748 100644
--- a/desktop/src/store/workspace.ts
+++ b/desktop/src/store/workspace.ts
@@ -1,6 +1,6 @@
-import {Node} from "@/types/nodes";
-import {makeAutoObservable} from "mobx";
-import {Workspace, WorkspaceRole} from "@/types/workspaces";
+import { Node } from '@/types/nodes';
+import { makeAutoObservable } from 'mobx';
+import { Workspace, WorkspaceRole } from '@/types/workspaces';
export class WorkspaceStore {
id: string;
@@ -38,10 +38,13 @@ export class WorkspaceStore {
}
setNodes(nodes: Node[]) {
- this.nodes = nodes.reduce((acc, node) => {
- acc[node.id] = node;
- return acc;
- }, {} as Record<string, Node>);
+ this.nodes = nodes.reduce(
+ (acc, node) => {
+ acc[node.id] = node;
+ return acc;
+ },
+ {} as Record<string, Node>,
+ );
}
setNode(node: Node) {
@@ -55,4 +58,4 @@ export class WorkspaceStore {
setContainerNode(nodeId?: string | null) {
this.containerNodeId = nodeId;
}
-}
\ No newline at end of file
+}
diff --git a/desktop/src/types/accounts.ts b/desktop/src/types/accounts.ts
index cc62db9e..0b09d891 100644
--- a/desktop/src/types/accounts.ts
+++ b/desktop/src/types/accounts.ts
@@ -1,4 +1,4 @@
-import {Workspace} from "@/types/workspaces";
+import { Workspace } from '@/types/workspaces';
export type LoginOutput = {
account: Account;
@@ -11,4 +11,4 @@ export type Account = {
email: string;
avatar?: string | null;
token: string;
-};
\ No newline at end of file
+};
diff --git a/desktop/src/types/editor.ts b/desktop/src/types/editor.ts
index 5f678fc9..c2b43ec3 100644
--- a/desktop/src/types/editor.ts
+++ b/desktop/src/types/editor.ts
@@ -4,11 +4,9 @@ export type EditorCommandProps = {
editor: Editor;
range: Range;
context: EditorCommandContext | null;
-}
+};
-export type EditorCommandContext = {
-
-}
+export type EditorCommandContext = {};
export type EditorCommand = {
key: string;
@@ -18,4 +16,4 @@ export type EditorCommand = {
icon: string;
handler: (props: EditorCommandProps) => void;
disabled?: boolean;
-}
+};
diff --git a/desktop/src/types/global.ts b/desktop/src/types/global.ts
index 3b4f521a..dfdf780d 100644
--- a/desktop/src/types/global.ts
+++ b/desktop/src/types/global.ts
@@ -1,6 +1,6 @@
-import {Account} from "@/types/accounts";
-import {Workspace} from "@/types/workspaces";
-import {Node} from "@/types/nodes";
+import { Account } from '@/types/accounts';
+import { Workspace } from '@/types/workspaces';
+import { Node } from '@/types/nodes';
export type GlobalDatabaseData = {
accounts: Account[];
@@ -10,4 +10,4 @@ export type GlobalDatabaseData = {
export type WorkspaceDatabaseData = {
workspace: Workspace;
nodes: Node[];
-};
\ No newline at end of file
+};
diff --git a/desktop/src/types/nodes.ts b/desktop/src/types/nodes.ts
index 1d5ecd81..7dbc0ec2 100644
--- a/desktop/src/types/nodes.ts
+++ b/desktop/src/types/nodes.ts
@@ -22,4 +22,4 @@ export type NodeContent = {
export type NodeContentMarks = {
type: string;
attrs: any;
-}
\ No newline at end of file
+};
diff --git a/desktop/src/types/transactions.ts b/desktop/src/types/transactions.ts
index d116c291..0c0ccaaa 100644
--- a/desktop/src/types/transactions.ts
+++ b/desktop/src/types/transactions.ts
@@ -1,4 +1,4 @@
-import {Account} from "@/types/accounts";
+import { Account } from '@/types/accounts';
export type Transaction = {
id: string;
@@ -8,7 +8,7 @@ export type Transaction = {
nodeId: string;
input: any;
createdAt: Date;
-}
+};
export type CreateNodeTransactionInput = {
id: string;
@@ -29,9 +29,9 @@ export type UpdateNodeTransactionInput = {
export type DeleteNodeTransactionInput = {
id: string;
-}
+};
export type AccountTransactions = {
account: Account;
transactions: Transaction[];
-}
\ No newline at end of file
+};
diff --git a/desktop/src/types/window.d.ts b/desktop/src/types/window.d.ts
index 1e3c0b56..bdd30aff 100644
--- a/desktop/src/types/window.d.ts
+++ b/desktop/src/types/window.d.ts
@@ -1,24 +1,40 @@
-import {Workspace} from "@/types/workspaces";
-import {Transaction} from "@/types/transactions";
-import {Account} from "@/types/accounts";
-import {Node} from "@/types/nodes";
-import {GlobalDatabaseData} from "@/types/global";
+import { Workspace } from '@/types/workspaces';
+import { Transaction } from '@/types/transactions';
+import { Account } from '@/types/accounts';
+import { Node } from '@/types/nodes';
+import { GlobalDatabaseData } from '@/types/global';
export interface GlobalDbApi {
- init: () => Promise<GlobalDatabaseData>
- getAccounts: () => Promise<Account[]>
- addAccount: (account: Account) => Promise<void>
- getWorkspaces: () => Promise<Workspace[]>
- addWorkspace: (workspace: Workspace) => Promise<void>
- addTransaction: (transaction: Transaction) => Promise<void>
+ init: () => Promise<GlobalDatabaseData>;
+ getAccounts: () => Promise<Account[]>;
+ addAccount: (account: Account) => Promise<void>;
+ getWorkspaces: () => Promise<Workspace[]>;
+ addWorkspace: (workspace: Workspace) => Promise<void>;
+ addTransaction: (transaction: Transaction) => Promise<void>;
}
export interface WorkspaceDbApi {
- addNode: (accountId: string, workspaceId: string, node: Node) => Promise<void>
- addNodes: (accountId: string, workspaceId: string, nodes: Node[]) => Promise<void>
- getNodes: (accountId: string, workspaceId: string) => Promise<Node[]>
- updateNode: (accountId: string, workspaceId: string, node: Node) => Promise<void>
- deleteNode: (accountId: string, workspaceId: string, nodeId: string) => Promise<void>
+ addNode: (
+ accountId: string,
+ workspaceId: string,
+ node: Node,
+ ) => Promise<void>;
+ addNodes: (
+ accountId: string,
+ workspaceId: string,
+ nodes: Node[],
+ ) => Promise<void>;
+ getNodes: (accountId: string, workspaceId: string) => Promise<Node[]>;
+ updateNode: (
+ accountId: string,
+ workspaceId: string,
+ node: Node,
+ ) => Promise<void>;
+ deleteNode: (
+ accountId: string,
+ workspaceId: string,
+ nodeId: string,
+ ) => Promise<void>;
}
declare global {
@@ -26,4 +42,4 @@ declare global {
globalDb: GlobalDbApi;
workspaceDb: WorkspaceDbApi;
}
-}
\ No newline at end of file
+}
diff --git a/desktop/src/types/workspaces.ts b/desktop/src/types/workspaces.ts
index 5f0e7ced..9baaef01 100644
--- a/desktop/src/types/workspaces.ts
+++ b/desktop/src/types/workspaces.ts
@@ -2,7 +2,7 @@ export enum WorkspaceRole {
Owner = 1,
Admin = 2,
Collaborator = 3,
- Viewer = 4
+ Viewer = 4,
}
export type Workspace = {
@@ -14,4 +14,4 @@ export type Workspace = {
accountId: string;
role: WorkspaceRole;
userNodeId: string;
-};
\ No newline at end of file
+};