diff --git a/apps/server/src/services/anonymization.ts b/apps/server/src/services/anonymization.ts index 6950be72d8..262251ba91 100644 --- a/apps/server/src/services/anonymization.ts +++ b/apps/server/src/services/anonymization.ts @@ -1,11 +1,11 @@ -import BUILTIN_ATTRIBUTES from "./builtin_attributes.js"; +import { AnonymizedDbResponse, BUILTIN_ATTRIBUTES, DatabaseAnonymizeResponse } from "@triliumnext/commons"; +import Database from "better-sqlite3"; import fs from "fs"; +import path from "path"; + import dataDir from "./data_dir.js"; import dateUtils from "./date_utils.js"; -import Database from "better-sqlite3"; import sql from "./sql.js"; -import path from "path"; -import { AnonymizedDbResponse, DatabaseAnonymizeResponse } from "@triliumnext/commons"; function getFullAnonymizationScript() { // we want to delete all non-builtin attributes because they can contain sensitive names and values @@ -86,7 +86,7 @@ function getExistingAnonymizedDatabases() { .readdirSync(dataDir.ANONYMIZED_DB_DIR) .filter((fileName) => fileName.includes("anonymized")) .map((fileName) => ({ - fileName: fileName, + fileName, filePath: path.resolve(dataDir.ANONYMIZED_DB_DIR, fileName) })) satisfies AnonymizedDbResponse[]; } diff --git a/apps/server/src/services/attributes.ts b/apps/server/src/services/attributes.ts index c1fec6808f..2e1a207447 100644 --- a/apps/server/src/services/attributes.ts +++ b/apps/server/src/services/attributes.ts @@ -1,13 +1,11 @@ -"use strict"; +import { type AttributeRow, BUILTIN_ATTRIBUTES } from "@triliumnext/commons"; -import searchService from "./search/services/search.js"; -import sql from "./sql.js"; import becca from "../becca/becca.js"; import BAttribute from "../becca/entities/battribute.js"; -import attributeFormatter from "./attribute_formatter.js"; -import BUILTIN_ATTRIBUTES from "./builtin_attributes.js"; import type BNote from "../becca/entities/bnote.js"; -import type { AttributeRow } from "@triliumnext/commons"; +import attributeFormatter from "./attribute_formatter.js"; +import searchService from "./search/services/search.js"; +import sql from "./sql.js"; const ATTRIBUTE_TYPES = new Set(["label", "relation"]); @@ -41,18 +39,18 @@ function getNoteWithLabel(name: string, value?: string): BNote | null { function createLabel(noteId: string, name: string, value: string = "") { return createAttribute({ - noteId: noteId, + noteId, type: "label", - name: name, - value: value + name, + value }); } function createRelation(noteId: string, name: string, targetNoteId: string) { return createAttribute({ - noteId: noteId, + noteId, type: "relation", - name: name, + name, value: targetNoteId }); } diff --git a/packages/commons/src/index.ts b/packages/commons/src/index.ts index 1ae730a563..d2e4f85d4c 100644 --- a/packages/commons/src/index.ts +++ b/packages/commons/src/index.ts @@ -13,3 +13,4 @@ export * from "./lib/attribute_names.js"; export * from "./lib/utils.js"; export * from "./lib/dayjs.js"; export * from "./lib/notes.js"; +export { default as BUILTIN_ATTRIBUTES } from "./lib/builtin_attributes.js"; diff --git a/apps/server/src/services/builtin_attributes.ts b/packages/commons/src/lib/builtin_attributes.ts similarity index 100% rename from apps/server/src/services/builtin_attributes.ts rename to packages/commons/src/lib/builtin_attributes.ts