mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
refactor(server): integrate entity types changes into commons
This commit is contained in:
parent
a6833f5a6f
commit
998688573d
@ -12,11 +12,10 @@ import syncOptions from "../../services/sync_options.js";
|
|||||||
import utils, { safeExtractMessageAndStackFromError } from "../../services/utils.js";
|
import utils, { safeExtractMessageAndStackFromError } from "../../services/utils.js";
|
||||||
import ws from "../../services/ws.js";
|
import ws from "../../services/ws.js";
|
||||||
import type { Request } from "express";
|
import type { Request } from "express";
|
||||||
import type { EntityChange } from "../../services/entity_changes_interface.js";
|
|
||||||
import ValidationError from "../../errors/validation_error.js";
|
import ValidationError from "../../errors/validation_error.js";
|
||||||
import consistencyChecksService from "../../services/consistency_checks.js";
|
import consistencyChecksService from "../../services/consistency_checks.js";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { SyncTestResponse } from "@triliumnext/commons";
|
import { SyncTestResponse, type EntityChange } from "@triliumnext/commons";
|
||||||
|
|
||||||
async function testSync(): Promise<SyncTestResponse> {
|
async function testSync(): Promise<SyncTestResponse> {
|
||||||
try {
|
try {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import clsHooked from "cls-hooked";
|
import clsHooked from "cls-hooked";
|
||||||
import type { EntityChange } from "./entity_changes_interface.js";
|
import type { EntityChange } from "@triliumnext/commons";
|
||||||
const namespace = clsHooked.createNamespace("trilium");
|
const namespace = clsHooked.createNamespace("trilium");
|
||||||
|
|
||||||
type Callback = (...args: any[]) => any;
|
type Callback = (...args: any[]) => any;
|
||||||
|
@ -15,7 +15,7 @@ import eraseService from "../services/erase.js";
|
|||||||
import sanitizeAttributeName from "./sanitize_attribute_name.js";
|
import sanitizeAttributeName from "./sanitize_attribute_name.js";
|
||||||
import noteTypesService from "../services/note_types.js";
|
import noteTypesService from "../services/note_types.js";
|
||||||
import type { BranchRow } from "@triliumnext/commons";
|
import type { BranchRow } from "@triliumnext/commons";
|
||||||
import type { EntityChange } from "./entity_changes_interface.js";
|
import type { EntityChange } from "@triliumnext/commons";
|
||||||
import becca_loader from "../becca/becca_loader.js";
|
import becca_loader from "../becca/becca_loader.js";
|
||||||
const noteTypes = noteTypesService.getNoteTypeNames();
|
const noteTypes = noteTypesService.getNoteTypeNames();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { randomString } from "./utils.js";
|
|||||||
import instanceId from "./instance_id.js";
|
import instanceId from "./instance_id.js";
|
||||||
import becca from "../becca/becca.js";
|
import becca from "../becca/becca.js";
|
||||||
import blobService from "../services/blob.js";
|
import blobService from "../services/blob.js";
|
||||||
import type { EntityChange } from "./entity_changes_interface.js";
|
import type { EntityChange } from "@triliumnext/commons";
|
||||||
import type { Blob } from "./blob-interface.js";
|
import type { Blob } from "./blob-interface.js";
|
||||||
import eventService from "./events.js";
|
import eventService from "./events.js";
|
||||||
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
export interface EntityChange {
|
|
||||||
id?: number | null;
|
|
||||||
noteId?: string;
|
|
||||||
entityName: string;
|
|
||||||
entityId: string;
|
|
||||||
entity?: any;
|
|
||||||
positions?: Record<string, number>;
|
|
||||||
hash: string;
|
|
||||||
utcDateChanged?: string;
|
|
||||||
utcDateModified?: string;
|
|
||||||
utcDateCreated?: string;
|
|
||||||
isSynced: boolean | 1 | 0;
|
|
||||||
isErased: boolean | 1 | 0;
|
|
||||||
componentId?: string | null;
|
|
||||||
changeId?: string | null;
|
|
||||||
instanceId?: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EntityRow {
|
|
||||||
isDeleted?: boolean;
|
|
||||||
content?: Buffer | string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EntityChangeRecord {
|
|
||||||
entityChange: EntityChange;
|
|
||||||
entity?: EntityRow;
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ import optionService from "./options.js";
|
|||||||
import dateUtils from "./date_utils.js";
|
import dateUtils from "./date_utils.js";
|
||||||
import sqlInit from "./sql_init.js";
|
import sqlInit from "./sql_init.js";
|
||||||
import cls from "./cls.js";
|
import cls from "./cls.js";
|
||||||
import type { EntityChange } from "./entity_changes_interface.js";
|
import type { EntityChange } from "@triliumnext/commons";
|
||||||
|
|
||||||
function eraseNotes(noteIdsToErase: string[]) {
|
function eraseNotes(noteIdsToErase: string[]) {
|
||||||
if (noteIdsToErase.length === 0) {
|
if (noteIdsToErase.length === 0) {
|
||||||
|
@ -17,7 +17,7 @@ import ws from "./ws.js";
|
|||||||
import entityChangesService from "./entity_changes.js";
|
import entityChangesService from "./entity_changes.js";
|
||||||
import entityConstructor from "../becca/entity_constructor.js";
|
import entityConstructor from "../becca/entity_constructor.js";
|
||||||
import becca from "../becca/becca.js";
|
import becca from "../becca/becca.js";
|
||||||
import type { EntityChange, EntityChangeRecord, EntityRow } from "./entity_changes_interface.js";
|
import type { EntityChange, EntityChangeRecord, EntityRow } from "@triliumnext/commons";
|
||||||
import type { CookieJar, ExecOpts } from "./request_interface.js";
|
import type { CookieJar, ExecOpts } from "./request_interface.js";
|
||||||
import setupService from "./setup.js";
|
import setupService from "./setup.js";
|
||||||
import consistency_checks from "./consistency_checks.js";
|
import consistency_checks from "./consistency_checks.js";
|
||||||
|
@ -4,7 +4,7 @@ import entityChangesService from "./entity_changes.js";
|
|||||||
import eventService from "./events.js";
|
import eventService from "./events.js";
|
||||||
import entityConstructor from "../becca/entity_constructor.js";
|
import entityConstructor from "../becca/entity_constructor.js";
|
||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
import type { EntityChange, EntityChangeRecord, EntityRow } from "./entity_changes_interface.js";
|
import type { EntityChange, EntityChangeRecord, EntityRow } from "@triliumnext/commons";
|
||||||
|
|
||||||
interface UpdateContext {
|
interface UpdateContext {
|
||||||
alreadyErased: number;
|
alreadyErased: number;
|
||||||
|
@ -10,7 +10,7 @@ import becca from "../becca/becca.js";
|
|||||||
import AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js";
|
import AbstractBeccaEntity from "../becca/entities/abstract_becca_entity.js";
|
||||||
|
|
||||||
import type { IncomingMessage, Server as HttpServer } from "http";
|
import type { IncomingMessage, Server as HttpServer } from "http";
|
||||||
import type { EntityChange } from "./entity_changes_interface.js";
|
import { WebSocketMessage, type EntityChange } from "@triliumnext/commons";
|
||||||
|
|
||||||
let webSocketServer!: WebSocketServer;
|
let webSocketServer!: WebSocketServer;
|
||||||
let lastSyncedPush: number | null = null;
|
let lastSyncedPush: number | null = null;
|
||||||
|
@ -242,3 +242,31 @@ export interface SchemaResponse {
|
|||||||
type: string;
|
type: string;
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface EntityChange {
|
||||||
|
id?: number | null;
|
||||||
|
noteId?: string;
|
||||||
|
entityName: string;
|
||||||
|
entityId: string;
|
||||||
|
entity?: any;
|
||||||
|
positions?: Record<string, number>;
|
||||||
|
hash: string;
|
||||||
|
utcDateChanged?: string;
|
||||||
|
utcDateModified?: string;
|
||||||
|
utcDateCreated?: string;
|
||||||
|
isSynced: boolean | 1 | 0;
|
||||||
|
isErased: boolean | 1 | 0;
|
||||||
|
componentId?: string | null;
|
||||||
|
changeId?: string | null;
|
||||||
|
instanceId?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EntityRow {
|
||||||
|
isDeleted?: boolean;
|
||||||
|
content?: Buffer | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EntityChangeRecord {
|
||||||
|
entityChange: EntityChange;
|
||||||
|
entity?: EntityRow;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user