mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Rename databaseContext to databaseManager
This commit is contained in:
@@ -4,7 +4,7 @@ import { eventBus } from '@/lib/event-bus';
|
||||
import { MutationInput, MutationMap } from '@/types/mutations';
|
||||
import { QueryInput, QueryMap } from '@/types/queries';
|
||||
import { mediator } from '@/main/mediator';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { socketManager } from '@/main/sockets/socket-manager';
|
||||
import { synchronizer } from '@/main/synchronizer';
|
||||
|
||||
@@ -16,7 +16,7 @@ if (require('electron-squirrel-startup')) {
|
||||
}
|
||||
|
||||
const createWindow = async () => {
|
||||
await databaseContext.init();
|
||||
await databaseManager.init();
|
||||
socketManager.init();
|
||||
synchronizer.init();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { buildSqlite } from '@/main/data/utils';
|
||||
import { appDatabaseMigrations } from '@/main/data/app/migrations';
|
||||
import { workspaceDatabaseMigrations } from '@/main/data/workspace/migrations';
|
||||
|
||||
class DatabaseContext {
|
||||
class DatabaseManager {
|
||||
private readonly appPath: string;
|
||||
private initPromise: Promise<void> | null = null;
|
||||
private readonly workspaceDatabases: Map<
|
||||
@@ -131,4 +131,4 @@ class DatabaseContext {
|
||||
}
|
||||
}
|
||||
|
||||
export const databaseContext = new DatabaseContext();
|
||||
export const databaseManager = new DatabaseManager();
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes, ViewNodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -12,7 +12,7 @@ export class BoardViewCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: BoardViewCreateMutationInput,
|
||||
): Promise<MutationResult<BoardViewCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes, ViewNodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -12,7 +12,7 @@ export class CalendarViewCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: CalendarViewCreateMutationInput,
|
||||
): Promise<MutationResult<CalendarViewCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes, ViewNodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -12,7 +12,7 @@ export class ChannelCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: ChannelCreateMutationInput,
|
||||
): Promise<MutationResult<ChannelCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode } from '@/lib/nodes';
|
||||
@@ -11,7 +11,7 @@ export class ChatCreateMutationHandler
|
||||
public async handleMutation(
|
||||
input: ChatCreateMutationInput,
|
||||
): Promise<MutationResult<ChatCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -12,7 +12,7 @@ export class DatabaseCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: DatabaseCreateMutationInput,
|
||||
): Promise<MutationResult<DatabaseCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LoginOutput } from '@/types/accounts';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { buildAxiosInstance } from '@/lib/servers';
|
||||
import { EmailLoginMutationInput } from '@/types/mutations/email-login';
|
||||
import {
|
||||
@@ -14,7 +14,7 @@ export class EmailLoginMutationHandler
|
||||
async handleMutation(
|
||||
input: EmailLoginMutationInput,
|
||||
): Promise<MutationResult<EmailLoginMutationInput>> {
|
||||
const server = await databaseContext.appDatabase
|
||||
const server = await databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.where('domain', '=', input.server)
|
||||
@@ -35,7 +35,7 @@ export class EmailLoginMutationHandler
|
||||
});
|
||||
|
||||
const changedTables: MutationChange[] = [];
|
||||
await databaseContext.appDatabase.transaction().execute(async (trx) => {
|
||||
await databaseManager.appDatabase.transaction().execute(async (trx) => {
|
||||
await trx
|
||||
.insertInto('accounts')
|
||||
.values({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LoginOutput } from '@/types/accounts';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { buildAxiosInstance } from '@/lib/servers';
|
||||
import { EmailRegisterMutationInput } from '@/types/mutations/email-register';
|
||||
import {
|
||||
@@ -14,7 +14,7 @@ export class EmailRegisterMutationHandler
|
||||
handleMutation = async (
|
||||
input: EmailRegisterMutationInput,
|
||||
): Promise<MutationResult<EmailRegisterMutationInput>> => {
|
||||
const server = await databaseContext.appDatabase
|
||||
const server = await databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.where('domain', '=', input.server)
|
||||
@@ -39,7 +39,7 @@ export class EmailRegisterMutationHandler
|
||||
);
|
||||
|
||||
const changedTables: MutationChange[] = [];
|
||||
await databaseContext.appDatabase.transaction().execute(async (trx) => {
|
||||
await databaseManager.appDatabase.transaction().execute(async (trx) => {
|
||||
await trx
|
||||
.insertInto('accounts')
|
||||
.values({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes, ViewNodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -12,7 +12,7 @@ export class FieldCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: FieldCreateMutationInput,
|
||||
): Promise<MutationResult<FieldCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { mapContentsToEditorNodes } from '@/renderer/editor/mappers';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode } from '@/lib/nodes';
|
||||
@@ -14,7 +14,7 @@ export class MessageCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: MessageCreateMutationInput,
|
||||
): Promise<MutationResult<MessageCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeAttributeDeleteMutationInput } from '@/types/mutations/node-attribute-delete';
|
||||
@@ -11,7 +11,7 @@ export class NodeAttributeDeleteMutationHandler
|
||||
async handleMutation(
|
||||
input: NodeAttributeDeleteMutationInput,
|
||||
): Promise<MutationResult<NodeAttributeDeleteMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeAttributeSetMutationInput } from '@/types/mutations/node-attribute-set';
|
||||
@@ -11,7 +11,7 @@ export class NodeAttributeSetMutationHandler
|
||||
async handleMutation(
|
||||
input: NodeAttributeSetMutationInput,
|
||||
): Promise<MutationResult<NodeAttributeSetMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeCollaboratorCreateMutationInput } from '@/types/mutations/node-collaborator-create';
|
||||
@@ -9,7 +9,7 @@ export class NodeCollaboratorCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: NodeCollaboratorCreateMutationInput,
|
||||
): Promise<MutationResult<NodeCollaboratorCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeCollaboratorDeleteMutationInput } from '@/types/mutations/node-collaborator-delete';
|
||||
|
||||
@@ -8,7 +8,7 @@ export class NodeCollaboratorDeleteMutationHandler
|
||||
async handleMutation(
|
||||
input: NodeCollaboratorDeleteMutationInput,
|
||||
): Promise<MutationResult<NodeCollaboratorDeleteMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeCollaboratorSyncMutationInput } from '@/types/mutations/node-collaborator-sync';
|
||||
import { ServerNodeCollaborator, ServerNodeReaction } from '@/types/nodes';
|
||||
@@ -9,7 +9,7 @@ export class NodeCollaboratorSyncMutationHandler
|
||||
public async handleMutation(
|
||||
input: NodeCollaboratorSyncMutationInput,
|
||||
): Promise<MutationResult<NodeCollaboratorSyncMutationInput>> {
|
||||
const workspace = await databaseContext.appDatabase
|
||||
const workspace = await databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.selectAll()
|
||||
.where((eb) =>
|
||||
@@ -56,7 +56,7 @@ export class NodeCollaboratorSyncMutationHandler
|
||||
nodeCollaborator: ServerNodeCollaborator,
|
||||
): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
await workspaceDatabase
|
||||
.insertInto('node_collaborators')
|
||||
@@ -90,7 +90,7 @@ export class NodeCollaboratorSyncMutationHandler
|
||||
nodeCollaborator: ServerNodeCollaborator,
|
||||
): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
const existingNodeCollaborator = await workspaceDatabase
|
||||
.selectFrom('node_collaborators')
|
||||
@@ -145,7 +145,7 @@ export class NodeCollaboratorSyncMutationHandler
|
||||
nodeCollaborator: ServerNodeCollaborator,
|
||||
): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
await workspaceDatabase
|
||||
.deleteFrom('node_collaborators')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeCollaboratorUpdateMutationInput } from '@/types/mutations/node-collaborator-update';
|
||||
@@ -9,7 +9,7 @@ export class NodeCollaboratorUpdateMutationHandler
|
||||
async handleMutation(
|
||||
input: NodeCollaboratorUpdateMutationInput,
|
||||
): Promise<MutationResult<NodeCollaboratorUpdateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeDeleteMutationInput } from '@/types/mutations/node-delete';
|
||||
|
||||
@@ -8,7 +8,7 @@ export class NodeDeleteMutationHandler
|
||||
async handleMutation(
|
||||
input: NodeDeleteMutationInput,
|
||||
): Promise<MutationResult<NodeDeleteMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeReactionCreateMutationInput } from '@/types/mutations/node-reaction-create';
|
||||
|
||||
@@ -9,7 +9,7 @@ export class NodeReactionCreateMutationHandler
|
||||
input: NodeReactionCreateMutationInput,
|
||||
): Promise<MutationResult<NodeReactionCreateMutationInput>> {
|
||||
console.log('create node reaction', input);
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeReactionDeleteMutationInput } from '@/types/mutations/node-reaction-delete';
|
||||
|
||||
@@ -8,7 +8,7 @@ export class NodeReactionDeleteMutationHandler
|
||||
async handleMutation(
|
||||
input: NodeReactionDeleteMutationInput,
|
||||
): Promise<MutationResult<NodeReactionDeleteMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeReactionSyncMutationInput } from '@/types/mutations/node-reaction-sync';
|
||||
import { ServerNodeReaction } from '@/types/nodes';
|
||||
@@ -9,7 +9,7 @@ export class NodeReactionSyncMutationHandler
|
||||
public async handleMutation(
|
||||
input: NodeReactionSyncMutationInput,
|
||||
): Promise<MutationResult<NodeReactionSyncMutationInput>> {
|
||||
const workspace = await databaseContext.appDatabase
|
||||
const workspace = await databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.selectAll()
|
||||
.where((eb) =>
|
||||
@@ -54,7 +54,7 @@ export class NodeReactionSyncMutationHandler
|
||||
nodeReaction: ServerNodeReaction,
|
||||
): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
await workspaceDatabase
|
||||
.insertInto('node_reactions')
|
||||
@@ -78,7 +78,7 @@ export class NodeReactionSyncMutationHandler
|
||||
nodeReaction: ServerNodeReaction,
|
||||
): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
await workspaceDatabase
|
||||
.deleteFrom('node_reactions')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { NodeSyncMutationInput } from '@/types/mutations/node-sync';
|
||||
import { ServerNode } from '@/types/nodes';
|
||||
@@ -11,7 +11,7 @@ export class NodeSyncMutationHandler
|
||||
public async handleMutation(
|
||||
input: NodeSyncMutationInput,
|
||||
): Promise<MutationResult<NodeSyncMutationInput>> {
|
||||
const workspace = await databaseContext.appDatabase
|
||||
const workspace = await databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.selectAll()
|
||||
.where((eb) =>
|
||||
@@ -55,7 +55,7 @@ export class NodeSyncMutationHandler
|
||||
|
||||
private async insertNode(userId: string, node: ServerNode): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
await workspaceDatabase
|
||||
.insertInto('nodes')
|
||||
@@ -86,7 +86,7 @@ export class NodeSyncMutationHandler
|
||||
|
||||
private async updateNode(userId: string, node: ServerNode): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
const existingNode = await workspaceDatabase
|
||||
.selectFrom('nodes')
|
||||
@@ -127,7 +127,7 @@ export class NodeSyncMutationHandler
|
||||
|
||||
private async deleteNode(userId: string, node: ServerNode): Promise<void> {
|
||||
const workspaceDatabase =
|
||||
await databaseContext.getWorkspaceDatabase(userId);
|
||||
await databaseManager.getWorkspaceDatabase(userId);
|
||||
|
||||
await workspaceDatabase
|
||||
.deleteFrom('nodes')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes, ViewNodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -12,7 +12,7 @@ export class PageCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: PageCreateMutationInput,
|
||||
): Promise<MutationResult<PageCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -11,7 +11,7 @@ export class RecordCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: RecordCreateMutationInput,
|
||||
): Promise<MutationResult<RecordCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -11,7 +11,7 @@ export class SelectOptionCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: SelectOptionCreateMutationInput,
|
||||
): Promise<MutationResult<SelectOptionCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { MutationHandler, MutationResult } from '@/types/mutations';
|
||||
import { ServerCreateMutationInput } from '@/types/mutations/server-create';
|
||||
import { ServerConfig } from '@/types/servers';
|
||||
@@ -14,7 +14,7 @@ export class ServerCreateMutationHandler
|
||||
`http://${input.domain}/v1/config`,
|
||||
);
|
||||
|
||||
await databaseContext.appDatabase
|
||||
await databaseManager.appDatabase
|
||||
.insertInto('servers')
|
||||
.values({
|
||||
domain: input.domain,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -11,7 +11,7 @@ export class SpaceCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: SpaceCreateMutationInput,
|
||||
): Promise<MutationResult<SpaceCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { NodeTypes, ViewNodeTypes } from '@/lib/constants';
|
||||
import { NeuronId } from '@/lib/id';
|
||||
import { buildCreateNode, generateNodeIndex } from '@/lib/nodes';
|
||||
@@ -12,7 +12,7 @@ export class TableViewCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: TableViewCreateMutationInput,
|
||||
): Promise<MutationResult<TableViewCreateMutationInput>> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { buildAxiosInstance } from '@/lib/servers';
|
||||
import { WorkspaceAccountRoleUpdateMutationInput } from '@/types/mutations/workspace-account-role-update';
|
||||
import {
|
||||
@@ -14,7 +14,7 @@ export class WorkspaceAccountRoleUpdateMutationHandler
|
||||
async handleMutation(
|
||||
input: WorkspaceAccountRoleUpdateMutationInput,
|
||||
): Promise<MutationResult<WorkspaceAccountRoleUpdateMutationInput>> {
|
||||
const workspace = await databaseContext.appDatabase
|
||||
const workspace = await databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.selectAll()
|
||||
.where('user_id', '=', input.userId)
|
||||
@@ -28,7 +28,7 @@ export class WorkspaceAccountRoleUpdateMutationHandler
|
||||
};
|
||||
}
|
||||
|
||||
const account = await databaseContext.appDatabase
|
||||
const account = await databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.selectAll()
|
||||
.where('id', '=', workspace.account_id)
|
||||
@@ -42,7 +42,7 @@ export class WorkspaceAccountRoleUpdateMutationHandler
|
||||
};
|
||||
}
|
||||
|
||||
const server = await databaseContext.appDatabase
|
||||
const server = await databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.where('domain', '=', account.server)
|
||||
@@ -68,7 +68,7 @@ export class WorkspaceAccountRoleUpdateMutationHandler
|
||||
},
|
||||
);
|
||||
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { buildAxiosInstance } from '@/lib/servers';
|
||||
import { WorkspaceAccountsInviteMutationInput } from '@/types/mutations/workspace-accounts-invite';
|
||||
import {
|
||||
@@ -15,7 +15,7 @@ export class WorkspaceAccountsInviteMutationHandler
|
||||
async handleMutation(
|
||||
input: WorkspaceAccountsInviteMutationInput,
|
||||
): Promise<MutationResult<WorkspaceAccountsInviteMutationInput>> {
|
||||
const workspace = await databaseContext.appDatabase
|
||||
const workspace = await databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.selectAll()
|
||||
.where('user_id', '=', input.userId)
|
||||
@@ -29,7 +29,7 @@ export class WorkspaceAccountsInviteMutationHandler
|
||||
};
|
||||
}
|
||||
|
||||
const account = await databaseContext.appDatabase
|
||||
const account = await databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.selectAll()
|
||||
.where('id', '=', workspace.account_id)
|
||||
@@ -43,7 +43,7 @@ export class WorkspaceAccountsInviteMutationHandler
|
||||
};
|
||||
}
|
||||
|
||||
const server = await databaseContext.appDatabase
|
||||
const server = await databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.where('domain', '=', account.server)
|
||||
@@ -69,7 +69,7 @@ export class WorkspaceAccountsInviteMutationHandler
|
||||
},
|
||||
);
|
||||
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { buildAxiosInstance } from '@/lib/servers';
|
||||
import { WorkspaceCreateMutationInput } from '@/types/mutations/workspace-create';
|
||||
import {
|
||||
@@ -14,7 +14,7 @@ export class WorkspaceCreateMutationHandler
|
||||
async handleMutation(
|
||||
input: WorkspaceCreateMutationInput,
|
||||
): Promise<MutationResult<WorkspaceCreateMutationInput>> {
|
||||
const account = await databaseContext.appDatabase
|
||||
const account = await databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.selectAll()
|
||||
.where('id', '=', input.accountId)
|
||||
@@ -24,7 +24,7 @@ export class WorkspaceCreateMutationHandler
|
||||
throw new Error('Account not found!');
|
||||
}
|
||||
|
||||
const server = await databaseContext.appDatabase
|
||||
const server = await databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.where('domain', '=', account.server)
|
||||
@@ -44,7 +44,7 @@ export class WorkspaceCreateMutationHandler
|
||||
description: input.description,
|
||||
});
|
||||
|
||||
await databaseContext.appDatabase
|
||||
await databaseManager.appDatabase
|
||||
.insertInto('workspaces')
|
||||
.values({
|
||||
workspace_id: data.id ?? data.id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { buildAxiosInstance } from '@/lib/servers';
|
||||
import { WorkspaceUpdateMutationInput } from '@/types/mutations/workspace-update';
|
||||
import {
|
||||
@@ -14,7 +14,7 @@ export class WorkspaceUpdateMutationHandler
|
||||
async handleMutation(
|
||||
input: WorkspaceUpdateMutationInput,
|
||||
): Promise<MutationResult<WorkspaceUpdateMutationInput>> {
|
||||
const account = await databaseContext.appDatabase
|
||||
const account = await databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.selectAll()
|
||||
.where('id', '=', input.accountId)
|
||||
@@ -24,7 +24,7 @@ export class WorkspaceUpdateMutationHandler
|
||||
throw new Error('Account not found!');
|
||||
}
|
||||
|
||||
const server = await databaseContext.appDatabase
|
||||
const server = await databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.where('domain', '=', account.server)
|
||||
@@ -44,7 +44,7 @@ export class WorkspaceUpdateMutationHandler
|
||||
description: input.description,
|
||||
});
|
||||
|
||||
await databaseContext.appDatabase
|
||||
await databaseManager.appDatabase
|
||||
.updateTable('workspaces')
|
||||
.set({
|
||||
name: data.name,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AccountListQueryInput } from '@/types/queries/account-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { Account } from '@/types/accounts';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { SelectAccount } from '@/main/data/app/schema';
|
||||
@@ -55,7 +55,7 @@ export class AccountListQueryHandler
|
||||
}
|
||||
|
||||
private fetchAccounts(): Promise<SelectAccount[]> {
|
||||
return databaseContext.appDatabase
|
||||
return databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.selectAll()
|
||||
.where('status', '=', 'active')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BreadcrumbListQueryInput } from '@/types/queries/breadcrumb-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -62,7 +62,7 @@ export class BreadcrumbListQueryHandler
|
||||
private async fetchNodes(
|
||||
input: BreadcrumbListQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DatabaseGetQueryInput } from '@/types/queries/database-get';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -69,7 +69,7 @@ export class DatabaseGetQueryHandler
|
||||
private async fetchNodes(
|
||||
input: DatabaseGetQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DatabaseViewListQueryInput } from '@/types/queries/database-view-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
import { mapNode } from '@/lib/nodes';
|
||||
@@ -68,7 +68,7 @@ export class DatabaseViewListQueryHandler
|
||||
private async fetchNodes(
|
||||
input: DatabaseViewListQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DocumentGetQueryInput } from '@/types/queries/document-get';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -67,7 +67,7 @@ export class DocumentGetQueryHandler
|
||||
private async fetchNodes(
|
||||
input: DocumentGetQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MessageListQueryInput } from '@/types/queries/message-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { MutationChange } from '@/types/mutations';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -71,7 +71,7 @@ export class MessageListQueryHandler
|
||||
private async fetchMesssages(
|
||||
input: MessageListQueryInput,
|
||||
): Promise<MessageRow[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeCollaboratorListQueryInput } from '@/types/queries/node-collaborator-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
@@ -75,7 +75,7 @@ export class NodeCollaboratorListQueryHandler
|
||||
private async fetchCollaborators(
|
||||
input: NodeCollaboratorListQueryInput,
|
||||
): Promise<NodeCollaboratorRow[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeCollaboratorSearchQueryInput } from '@/types/queries/node-collaborator-search';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -71,7 +71,7 @@ export class NodeCollaboratorSearchQueryHandler
|
||||
private async fetchNodes(
|
||||
input: NodeCollaboratorSearchQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NodeGetQueryInput } from '@/types/queries/node-get';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { mapNode } from '@/lib/nodes';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -56,7 +56,7 @@ export class NodeGetQueryHandler implements QueryHandler<NodeGetQueryInput> {
|
||||
}
|
||||
|
||||
private async fetchNode(input: NodeGetQueryInput): Promise<SelectNode> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RecordGetQueryInput } from '@/types/queries/record-get';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { mapNode } from '@/lib/nodes';
|
||||
import { sql } from 'kysely';
|
||||
@@ -61,7 +61,7 @@ export class RecordGetQueryHandler
|
||||
}
|
||||
|
||||
private async fetchNodes(input: RecordGetQueryInput): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RecordListQueryInput } from '@/types/queries/record-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { MutationChange } from '@/types/mutations';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -84,7 +84,7 @@ export class RecordListQueryHandler
|
||||
private async fetchRecords(
|
||||
input: RecordListQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ServerListQueryInput } from '@/types/queries/server-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { SelectServer } from '@/main/data/app/schema';
|
||||
import { MutationChange } from '@/types/mutations';
|
||||
@@ -55,7 +55,7 @@ export class ServerListQueryHandler
|
||||
}
|
||||
|
||||
private fetchServers(): Promise<SelectServer[]> {
|
||||
return databaseContext.appDatabase
|
||||
return databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.execute();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SidebarChatListQueryInput } from '@/types/queries/sidebar-chat-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -67,7 +67,7 @@ export class SidebarChatListQueryHandler
|
||||
private async fetchChats(
|
||||
input: SidebarChatListQueryInput,
|
||||
): Promise<ChatRow[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SidebarSpaceListQueryInput } from '@/types/queries/sidebar-space-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -64,7 +64,7 @@ export class SidebarSpaceListQueryHandler
|
||||
private async fetchNodes(
|
||||
input: SidebarSpaceListQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UserSearchQueryInput } from '@/types/queries/user-search';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { sql } from 'kysely';
|
||||
import { SelectNode } from '@/main/data/workspace/schema';
|
||||
@@ -69,7 +69,7 @@ export class UserSearchQueryHandler
|
||||
}
|
||||
|
||||
private async fetchNodes(input: UserSearchQueryInput): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WorkspaceListQueryInput } from '@/types/queries/workspace-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { Workspace, WorkspaceRole } from '@/types/workspaces';
|
||||
import { SelectWorkspace } from '@/main/data/app/schema';
|
||||
@@ -56,13 +56,13 @@ export class WorkspaceListQueryHandler
|
||||
}
|
||||
|
||||
private fetchWorkspaces(): Promise<SelectWorkspace[]> {
|
||||
return databaseContext.appDatabase
|
||||
return databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.selectAll()
|
||||
.where(
|
||||
'account_id',
|
||||
'in',
|
||||
databaseContext.appDatabase
|
||||
databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.where('status', '=', 'active')
|
||||
.select('id'),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WorkspaceUserListQueryInput } from '@/types/queries/workspace-user-list';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ChangeCheckResult, QueryHandler, QueryResult } from '@/types/queries';
|
||||
import { NodeTypes } from '@/lib/constants';
|
||||
import { mapNode } from '@/lib/nodes';
|
||||
@@ -62,7 +62,7 @@ export class WorkspaceUserListQueryHandler
|
||||
private async fetchNodes(
|
||||
input: WorkspaceUserListQueryInput,
|
||||
): Promise<SelectNode[]> {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
input.userId,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { SocketConnection } from '@/main/sockets/socket-connection';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
|
||||
const EVENT_LOOP_INTERVAL = 5000;
|
||||
|
||||
@@ -29,12 +29,12 @@ class SocketManager {
|
||||
}
|
||||
|
||||
private async checkAccounts() {
|
||||
const servers = await databaseContext.appDatabase
|
||||
const servers = await databaseManager.appDatabase
|
||||
.selectFrom('servers')
|
||||
.selectAll()
|
||||
.execute();
|
||||
|
||||
const accounts = await databaseContext.appDatabase
|
||||
const accounts = await databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.selectAll()
|
||||
.where('status', '=', 'active')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { buildAxiosInstance } from '@/lib/servers';
|
||||
import { SelectWorkspace } from '@/main/data/app/schema';
|
||||
import { databaseContext } from '@/main/data/database-context';
|
||||
import { databaseManager } from '@/main/data/database-manager';
|
||||
import { ServerSyncResponse, WorkspaceSyncData } from '@/types/sync';
|
||||
|
||||
const EVENT_LOOP_INTERVAL = 100;
|
||||
@@ -33,7 +33,7 @@ class Synchronizer {
|
||||
}
|
||||
|
||||
private async checkForWorkspaceSyncs(): Promise<void> {
|
||||
const unsyncedWorkspaces = await databaseContext.appDatabase
|
||||
const unsyncedWorkspaces = await databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.selectAll()
|
||||
.where('synced', '=', 0)
|
||||
@@ -49,7 +49,7 @@ class Synchronizer {
|
||||
}
|
||||
|
||||
private async checkForWorkspaceChanges() {
|
||||
const workspaces = await databaseContext.appDatabase
|
||||
const workspaces = await databaseManager.appDatabase
|
||||
.selectFrom('workspaces')
|
||||
.innerJoin('accounts', 'workspaces.account_id', 'accounts.id')
|
||||
.innerJoin('servers', 'accounts.server', 'servers.domain')
|
||||
@@ -64,7 +64,7 @@ class Synchronizer {
|
||||
.execute();
|
||||
|
||||
for (const workspace of workspaces) {
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
workspace.user_id,
|
||||
);
|
||||
|
||||
@@ -127,7 +127,7 @@ class Synchronizer {
|
||||
}
|
||||
|
||||
private async syncWorkspace(workspace: SelectWorkspace): Promise<void> {
|
||||
const credentials = await databaseContext.appDatabase
|
||||
const credentials = await databaseManager.appDatabase
|
||||
.selectFrom('accounts')
|
||||
.innerJoin('servers', 'accounts.server', 'servers.domain')
|
||||
.select(['domain', 'attributes', 'token'])
|
||||
@@ -147,7 +147,7 @@ class Synchronizer {
|
||||
`/v1/sync/${workspace.workspace_id}`,
|
||||
);
|
||||
|
||||
const workspaceDatabase = await databaseContext.getWorkspaceDatabase(
|
||||
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
|
||||
workspace.user_id,
|
||||
);
|
||||
|
||||
@@ -197,7 +197,7 @@ class Synchronizer {
|
||||
}
|
||||
});
|
||||
|
||||
await databaseContext.appDatabase
|
||||
await databaseManager.appDatabase
|
||||
.updateTable('workspaces')
|
||||
.set({
|
||||
synced: 1,
|
||||
|
||||
Reference in New Issue
Block a user