diff --git a/apps/server/src/routes/route_api.ts b/apps/server/src/routes/route_api.ts index 10e3f078ea..fa2aabe2f8 100644 --- a/apps/server/src/routes/route_api.ts +++ b/apps/server/src/routes/route_api.ts @@ -102,8 +102,7 @@ function internalRoute

(method: HttpMethod, path: str return; } - if (result?.then) { - // promise + if (result instanceof Promise) { result.then((promiseResult: unknown) => handleResponse(resultHandler, req, res, promiseResult, start)).catch((e: unknown) => handleException(e, method, path, res)); } else { handleResponse(resultHandler, req, res, result, start); diff --git a/apps/server/src/services/config.ts b/apps/server/src/services/config.ts index 27643a79bf..30228ec05d 100644 --- a/apps/server/src/services/config.ts +++ b/apps/server/src/services/config.ts @@ -19,7 +19,7 @@ * ╚════════════════════════════════════════════════════════════════════════════╝ */ -import utils from "@triliumnext/core"; +import { utils } from "@triliumnext/core"; import fs from "fs"; import ini from "ini"; import path from "path"; diff --git a/apps/server/src/services/export/zip/abstract_provider.ts b/apps/server/src/services/export/zip/abstract_provider.ts index d3c5ea2220..edb5777c95 100644 --- a/apps/server/src/services/export/zip/abstract_provider.ts +++ b/apps/server/src/services/export/zip/abstract_provider.ts @@ -6,9 +6,9 @@ import type BBranch from "../../../becca/entities/bbranch.js"; import type BNote from "../../../becca/entities/bnote.js"; import type { default as NoteMeta, NoteMetaFile } from "../../meta/note_meta.js"; -type RewriteLinksFn = (content: string, noteMeta: NoteMeta) => string; +export type { ExportFormat, NoteMeta } from "@triliumnext/core"; -export type ExportFormat = "html" | "markdown" | "share"; +type RewriteLinksFn = (content: string, noteMeta: NoteMeta) => string; export interface AdvancedExportOptions { /** diff --git a/apps/server/src/services/meta/attachment_meta.ts b/apps/server/src/services/meta/attachment_meta.ts index f0c50360f7..dfbb43af05 100644 --- a/apps/server/src/services/meta/attachment_meta.ts +++ b/apps/server/src/services/meta/attachment_meta.ts @@ -1,8 +1 @@ -export default interface AttachmentMeta { - attachmentId?: string; - title: string; - role: string; - mime: string; - position?: number; - dataFileName: string; -} +export type { AttachmentMeta as default } from "@triliumnext/core"; diff --git a/apps/server/src/services/meta/attribute_meta.ts b/apps/server/src/services/meta/attribute_meta.ts index aa3d36b8c2..75bd6ba922 100644 --- a/apps/server/src/services/meta/attribute_meta.ts +++ b/apps/server/src/services/meta/attribute_meta.ts @@ -1,10 +1 @@ -import type { AttributeType } from "@triliumnext/commons"; - -export default interface AttributeMeta { - noteId?: string; - type: AttributeType; - name: string; - value: string; - isInheritable?: boolean; - position?: number; -} +export type { AttributeMeta as default } from "@triliumnext/core"; diff --git a/apps/server/src/services/meta/note_meta.ts b/apps/server/src/services/meta/note_meta.ts index 7a7a9f4b7c..e661899d5c 100644 --- a/apps/server/src/services/meta/note_meta.ts +++ b/apps/server/src/services/meta/note_meta.ts @@ -1,32 +1 @@ -import type { NoteType } from "@triliumnext/commons"; -import type AttachmentMeta from "./attachment_meta.js"; -import type AttributeMeta from "./attribute_meta.js"; -import type { ExportFormat } from "../export/zip/abstract_provider.js"; - -export interface NoteMetaFile { - formatVersion: number; - appVersion: string; - files: NoteMeta[]; -} - -export default interface NoteMeta { - noteId?: string; - notePath?: string[]; - isClone?: boolean; - title?: string; - notePosition?: number; - prefix?: string | null; - isExpanded?: boolean; - type?: NoteType; - mime?: string; - /** 'html' or 'markdown', applicable to text notes only */ - format?: ExportFormat; - dataFileName?: string; - dirFileName?: string; - /** this file should not be imported (e.g., HTML navigation) */ - noImport?: boolean; - isImportRoot?: boolean; - attributes?: AttributeMeta[]; - attachments?: AttachmentMeta[]; - children?: NoteMeta[]; -} +export { type NoteMeta as default, type NoteMetaFile } from "@triliumnext/core"; diff --git a/apps/server/src/services/utils.ts b/apps/server/src/services/utils.ts index e9f611f157..7b4d6cd1d3 100644 --- a/apps/server/src/services/utils.ts +++ b/apps/server/src/services/utils.ts @@ -192,7 +192,6 @@ export function waitForStreamToFinish(stream: any): Promise { } export default { - compareVersions, constantTimeCompare, escapeHtml, escapeRegExp, diff --git a/packages/trilium-core/src/index.ts b/packages/trilium-core/src/index.ts index 42bc8fb02d..1b7a181392 100644 --- a/packages/trilium-core/src/index.ts +++ b/packages/trilium-core/src/index.ts @@ -95,6 +95,7 @@ export { default as setup } from "./services/setup"; export { getPlatform, type PlatformProvider } from "./services/platform"; export { t } from "i18next"; export type { RequestProvider, ExecOpts, CookieJar } from "./services/request"; +export type * from "./meta"; export async function initializeCore({ dbConfig, executionContext, crypto, translations, messaging, request, schema, extraAppInfo, platform }: { dbConfig: SqlServiceParams, diff --git a/packages/trilium-core/src/meta.ts b/packages/trilium-core/src/meta.ts new file mode 100644 index 0000000000..44006bf37d --- /dev/null +++ b/packages/trilium-core/src/meta.ts @@ -0,0 +1,49 @@ +import type { AttributeType, NoteType } from "@triliumnext/commons"; + +export type ExportFormat = "html" | "markdown" | "share"; + +export interface AttachmentMeta { + attachmentId?: string; + title: string; + role: string; + mime: string; + position?: number; + dataFileName: string; +} + +export interface AttributeMeta { + noteId?: string; + type: AttributeType; + name: string; + value: string; + isInheritable?: boolean; + position?: number; +} + +export interface NoteMetaFile { + formatVersion: number; + appVersion: string; + files: NoteMeta[]; +} + +export interface NoteMeta { + noteId?: string; + notePath?: string[]; + isClone?: boolean; + title?: string; + notePosition?: number; + prefix?: string | null; + isExpanded?: boolean; + type?: NoteType; + mime?: string; + /** 'html' or 'markdown', applicable to text notes only */ + format?: ExportFormat; + dataFileName?: string; + dirFileName?: string; + /** this file should not be imported (e.g., HTML navigation) */ + noImport?: boolean; + isImportRoot?: boolean; + attributes?: AttributeMeta[]; + attachments?: AttachmentMeta[]; + children?: NoteMeta[]; +}