chore(nx): move all monorepo-style in subfolder for processing

This commit is contained in:
Elian Doran
2025-04-22 10:06:06 +03:00
parent 2e200eab39
commit 62dbcc0a2e
1469 changed files with 16 additions and 16 deletions

View File

@@ -1 +0,0 @@
build

View File

@@ -1,30 +0,0 @@
{
"name": "@triliumnext/commons",
"version": "0.0.1",
"description": "Shared library between the clients (e.g. browser, Electron) and the server, mostly for type definitions and utility methods.",
"homepage": "https://github.com/TriliumNext/Notes#readme",
"bugs": {
"url": "https://github.com/TriliumNext/Notes/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/TriliumNext/Notes.git"
},
"license": "AGPL-3.0-only",
"author": {
"name": "TriliumNext Notes Team",
"email": "contact@eliandoran.me",
"url": "https://github.com/TriliumNext/Notes"
},
"type": "module",
"main": "build/index.js",
"types": "build/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"@types/node": "^22.14.1",
"typescript": "5.8.3",
"vitest": "^3.1.1"
}
}

View File

@@ -1,45 +0,0 @@
import { AttributeType } from "./rows.js";
type LauncherNoteType = "launcher" | "search" | "doc" | "noteMap" | "contentWidget" | "book" | "file" | "image" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "webView" | "code" | "mindMap" | "geoMap";
enum Command {
jumpToNote,
searchNotes,
createNoteIntoInbox,
showRecentChanges,
showOptions,
createAiChat
}
export interface HiddenSubtreeAttribute {
type: AttributeType;
name: string;
isInheritable?: boolean;
value?: string;
}
export interface HiddenSubtreeItem {
notePosition?: number;
id: string;
title: string;
type: LauncherNoteType;
icon?: string;
attributes?: HiddenSubtreeAttribute[];
children?: HiddenSubtreeItem[];
isExpanded?: boolean;
baseSize?: string;
growthFactor?: string;
targetNoteId?: "_backendLog" | "_globalNoteMap";
builtinWidget?:
| "todayInJournal"
| "bookmarks"
| "spacer"
| "backInHistoryButton"
| "forwardInHistoryButton"
| "syncStatus"
| "protectedSession"
| "calendar"
| "quickSearch"
| "aiChatLauncher";
command?: keyof typeof Command;
}

View File

@@ -1,10 +0,0 @@
export interface Locale {
id: string;
name: string;
/** `true` if the language is a right-to-left one, or `false` if it's left-to-right. */
rtl?: boolean;
/** `true` if the language is not supported by the application as a display language, but it is selectable by the user for the content. */
contentOnly?: boolean;
/** The value to pass to `--lang` for the Electron instance in order to set it as a locale. Not setting it will hide it from the list of supported locales. */
electronLocale?: string;
}

View File

@@ -1,6 +0,0 @@
export * from "./i18n.js";
export * from "./options_interface.js";
export * from "./keyboard_actions_interface.js";
export * from "./hidden_subtree.js";
export * from "./rows.js";
export * from "./test-utils.js"

View File

@@ -1,119 +0,0 @@
const enum KeyboardActionNamesEnum {
backInNoteHistory,
forwardInNoteHistory,
jumpToNote,
scrollToActiveNote,
quickSearch,
searchInSubtree,
expandSubtree,
collapseTree,
collapseSubtree,
sortChildNotes,
createNoteAfter,
createNoteInto,
createNoteIntoInbox,
deleteNotes,
moveNoteUp,
moveNoteDown,
moveNoteUpInHierarchy,
moveNoteDownInHierarchy,
editNoteTitle,
editBranchPrefix,
cloneNotesTo,
moveNotesTo,
copyNotesToClipboard,
pasteNotesFromClipboard,
cutNotesToClipboard,
selectAllNotesInParent,
addNoteAboveToSelection,
addNoteBelowToSelection,
duplicateSubtree,
openNewTab,
closeActiveTab,
reopenLastTab,
activateNextTab,
activatePreviousTab,
openNewWindow,
toggleTray,
toggleZenMode,
firstTab,
secondTab,
thirdTab,
fourthTab,
fifthTab,
sixthTab,
seventhTab,
eigthTab,
ninthTab,
lastTab,
showNoteSource,
showOptions,
showRevisions,
showRecentChanges,
showSQLConsole,
showBackendLog,
showCheatsheet,
showHelp,
addLinkToText,
followLinkUnderCursor,
insertDateTimeToText,
pasteMarkdownIntoText,
cutIntoNote,
addIncludeNoteToText,
editReadOnlyNote,
addNewLabel,
addNewRelation,
toggleRibbonTabClassicEditor,
toggleRibbonTabBasicProperties,
toggleRibbonTabBookProperties,
toggleRibbonTabFileProperties,
toggleRibbonTabImageProperties,
toggleRibbonTabOwnedAttributes,
toggleRibbonTabInheritedAttributes,
toggleRibbonTabPromotedAttributes,
toggleRibbonTabNoteMap,
toggleRibbonTabNoteInfo,
toggleRibbonTabNotePaths,
toggleRibbonTabSimilarNotes,
toggleRightPane,
printActiveNote,
exportAsPdf,
openNoteExternally,
renderActiveNote,
runActiveNote,
toggleNoteHoisting,
unhoist,
reloadFrontendApp,
openDevTools,
findInText,
toggleLeftPane,
toggleFullscreen,
zoomOut,
zoomIn,
zoomReset,
copyWithoutFormatting,
forceSaveRevision
}
export type KeyboardActionNames = keyof typeof KeyboardActionNamesEnum;
export interface KeyboardShortcut {
separator?: string;
actionName?: KeyboardActionNames;
description?: string;
defaultShortcuts?: string[];
effectiveShortcuts?: string[];
/**
* Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work,
* the focus has to be inside the element.
*
* So e.g. shortcuts with "note-tree" scope work only when the focus is in note tree.
* This allows to have the same shortcut have different actions attached based on the context
* e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.
*/
scope?: "window" | "note-tree" | "text-detail" | "code-detail";
}
export interface KeyboardShortcutWithRequiredActionName extends KeyboardShortcut {
actionName: KeyboardActionNames;
}

View File

@@ -1,164 +0,0 @@
import type { KeyboardActionNames } from "./keyboard_actions_interface.js";
/**
* A dictionary where the keys are the option keys (e.g. `theme`) and their corresponding values.
*/
export type OptionMap = Record<OptionNames, string>;
/**
* For each keyboard action, there is a corresponding option which identifies the key combination defined by the user.
*/
type KeyboardShortcutsOptions<T extends KeyboardActionNames> = {
[key in T as `keyboardShortcuts${Capitalize<key>}`]: string;
};
export type FontFamily = "theme" | "serif" | "sans-serif" | "monospace" | string;
export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActionNames> {
openNoteContexts: string;
lastDailyBackupDate: string;
lastWeeklyBackupDate: string;
lastMonthlyBackupDate: string;
dbVersion: string;
theme: string;
syncServerHost: string;
syncServerTimeout: string;
syncProxy: string;
mainFontFamily: FontFamily;
treeFontFamily: FontFamily;
detailFontFamily: FontFamily;
monospaceFontFamily: FontFamily;
spellCheckLanguageCode: string;
codeNotesMimeTypes: string;
headingStyle: string;
highlightsList: string;
customSearchEngineName: string;
customSearchEngineUrl: string;
locale: string;
formattingLocale: string;
codeBlockTheme: string;
textNoteEditorType: string;
layoutOrientation: string;
allowedHtmlTags: string;
documentId: string;
documentSecret: string;
passwordVerificationHash: string;
passwordVerificationSalt: string;
passwordDerivedKeySalt: string;
encryptedDataKey: string;
hoistedNoteId: string;
// Multi-Factor Authentication
mfaEnabled: boolean;
mfaMethod: string;
totpEncryptionSalt: string;
totpEncryptedSecret: string;
totpVerificationHash: string;
encryptedRecoveryCodes: boolean;
userSubjectIdentifierSaved: boolean;
recoveryCodeInitialVector: string;
recoveryCodeSecurityKey: string;
recoveryCodesEncrypted: string;
lastSyncedPull: number;
lastSyncedPush: number;
revisionSnapshotTimeInterval: number;
revisionSnapshotTimeIntervalTimeScale: number;
revisionSnapshotNumberLimit: number;
protectedSessionTimeout: number;
protectedSessionTimeoutTimeScale: number;
zoomFactor: number;
mainFontSize: number;
treeFontSize: number;
detailFontSize: number;
monospaceFontSize: number;
imageMaxWidthHeight: number;
imageJpegQuality: number;
leftPaneWidth: number;
rightPaneWidth: number;
eraseEntitiesAfterTimeInSeconds: number;
eraseEntitiesAfterTimeScale: number;
autoReadonlySizeText: number;
autoReadonlySizeCode: number;
maxContentWidth: number;
minTocHeadings: number;
eraseUnusedAttachmentsAfterSeconds: number;
eraseUnusedAttachmentsAfterTimeScale: number;
firstDayOfWeek: number;
firstWeekOfYear: number;
minDaysInFirstWeek: number;
languages: string;
// Appearance
splitEditorOrientation: "horziontal" | "vertical";
initialized: boolean;
isPasswordSet: boolean;
overrideThemeFonts: boolean;
spellCheckEnabled: boolean;
autoFixConsistencyIssues: boolean;
vimKeymapEnabled: boolean;
codeLineWrapEnabled: boolean;
leftPaneVisible: boolean;
rightPaneVisible: boolean;
nativeTitleBarVisible: boolean;
hideArchivedNotes_main: boolean;
debugModeEnabled: boolean;
autoCollapseNoteTree: boolean;
dailyBackupEnabled: boolean;
weeklyBackupEnabled: boolean;
monthlyBackupEnabled: boolean;
compressImages: boolean;
downloadImagesAutomatically: boolean;
checkForUpdates: boolean;
disableTray: boolean;
promotedAttributesOpenInRibbon: boolean;
editedNotesOpenInRibbon: boolean;
codeBlockWordWrap: boolean;
textNoteEditorMultilineToolbar: boolean;
backgroundEffects: boolean;
// Share settings
redirectBareDomain: boolean;
showLoginInShareTheme: boolean;
// AI/LLM integration options
aiEnabled: boolean;
aiProvider: string;
aiSystemPrompt: string;
aiTemperature: string;
openaiApiKey: string;
openaiDefaultModel: string;
openaiEmbeddingModel: string;
openaiBaseUrl: string;
anthropicApiKey: string;
anthropicDefaultModel: string;
voyageEmbeddingModel: string;
voyageApiKey: string;
anthropicBaseUrl: string;
ollamaEnabled: boolean;
ollamaBaseUrl: string;
ollamaDefaultModel: string;
ollamaEmbeddingModel: string;
codeOpenAiModel: string;
aiProviderPrecedence: string;
// Embedding-related options
embeddingAutoUpdateEnabled: boolean;
embeddingUpdateInterval: number;
embeddingBatchSize: number;
embeddingDefaultDimension: number;
embeddingsDefaultProvider: string;
embeddingProviderPrecedence: string;
enableAutomaticIndexing: boolean;
embeddingGenerationLocation: string;
embeddingDimensionStrategy: string;
embeddingSimilarityThreshold: number;
maxNotesPerLlmQuery: number;
}
export type OptionNames = keyof OptionDefinitions;
export type FilterOptionsByType<U> = {
[K in keyof OptionDefinitions]: OptionDefinitions[K] extends U ? K : never;
}[keyof OptionDefinitions];

View File

@@ -1,155 +0,0 @@
// TODO: Booleans should probably be numbers instead (as SQLite does not have booleans.);
// TODO: check against schema.sql which properties really are "optional"
export interface AttachmentRow {
attachmentId?: string;
ownerId?: string;
role: string;
mime: string;
title: string;
position?: number;
blobId?: string;
isProtected?: boolean;
dateModified?: string;
utcDateModified?: string;
utcDateScheduledForErasureSince?: string;
isDeleted?: boolean;
deleteId?: string;
contentLength?: number;
content?: Buffer | string;
}
export interface RevisionRow {
revisionId?: string;
noteId: string;
type: NoteType;
mime: string;
isProtected?: boolean;
title: string;
blobId?: string;
dateLastEdited?: string;
dateCreated: string;
utcDateLastEdited?: string;
utcDateCreated: string;
utcDateModified: string;
contentLength?: number;
}
export interface RecentNoteRow {
noteId: string;
notePath: string;
utcDateCreated?: string;
}
/**
* Database representation of an option.
*
* Options are key-value pairs that are used to store information such as user preferences (for example
* the current theme, sync server information), but also information about the state of the application).
*/
export interface OptionRow {
/** The name of the option. */
name: string;
/** The value of the option. */
value: string;
/** `true` if the value should be synced across multiple instances (e.g. locale) or `false` if it should be local-only (e.g. theme). */
isSynced: boolean;
utcDateModified?: string;
}
export interface EtapiTokenRow {
etapiTokenId?: string;
name: string;
tokenHash: string;
utcDateCreated?: string;
utcDateModified?: string;
isDeleted?: boolean;
}
export interface BlobRow {
blobId: string;
content: string | Buffer;
contentLength: number;
dateModified: string;
utcDateModified: string;
}
export type AttributeType = "label" | "relation" | "label-definition" | "relation-definition";
export interface AttributeRow {
attributeId?: string;
noteId?: string;
type: AttributeType;
name: string;
position?: number | null;
value?: string;
isInheritable?: boolean;
utcDateModified?: string;
}
export interface BranchRow {
branchId?: string;
noteId: string;
parentNoteId: string;
prefix?: string | null;
notePosition?: number | null;
isExpanded?: boolean;
isDeleted?: boolean;
utcDateModified?: string;
}
/**
* There are many different Note types, some of which are entirely opaque to the
* end user. Those types should be used only for checking against, they are
* not for direct use.
*/
export const ALLOWED_NOTE_TYPES = [
"file",
"image",
"search",
"noteMap",
"launcher",
"doc",
"contentWidget",
"text",
"relationMap",
"render",
"canvas",
"mermaid",
"book",
"webView",
"code",
"mindMap",
"geoMap"
] as const;
export type NoteType = (typeof ALLOWED_NOTE_TYPES)[number];
export interface NoteRow {
noteId: string;
deleteId: string;
title: string;
type: NoteType;
mime: string;
isProtected: boolean;
isDeleted: boolean;
blobId: string;
dateCreated: string;
dateModified: string;
utcDateCreated: string;
utcDateModified: string;
content?: string | Buffer;
}
export interface NoteEmbeddingRow {
embedId: string;
noteId: string;
providerId: string;
modelId: string;
dimension: number;
embedding: Buffer;
version: number;
dateCreated: string;
utcDateCreated: string;
dateModified: string;
utcDateModified: string;
}

View File

@@ -1,14 +0,0 @@
import { describe, it, expect } from "vitest";
import { trimIndentation } from "./test-utils.js";
describe("Utils", () => {
it("trims indentation", () => {
expect(trimIndentation`\
Hello
world
123`).toBe(`\
Hello
world
123`);
});
});

View File

@@ -1,56 +0,0 @@
/**
* Reads the level of indentation of the first line and trims the identation for all the text by that amount.
*
* For example, for:
*
* ```json
* {
* "hello": "world"
* }
* ```
*
* it results in:
*
* ```json
* {
* "hello": "world"
* }
* ```
*
* This is meant to be used as a template string, where it allows the indentation of the template without affecting whitespace changes.
*
* @example const html = trimIndentation`\
* <h1>Heading 1</h1>
* <h2>Heading 2</h2>
* <h3>Heading 3</h3>
* <h4>Heading 4</h4>
* <h5>Heading 5</h5>
* <h6>Heading 6</h6>
* `;
* @param strings
* @returns
*/
export function trimIndentation(strings: TemplateStringsArray, ...values: any[]) {
// Combine the strings with the values using interpolation
let str = strings.reduce((acc, curr, index) => {
return acc + curr + (values[index] !== undefined ? values[index] : '');
}, '');
// Count the number of spaces on the first line.
let numSpaces = 0;
while (str.charAt(numSpaces) == " " && numSpaces < str.length) {
numSpaces++;
}
// Trim the indentation of the first line in all the lines.
const lines = str.split("\n");
const output = [];
for (let i = 0; i < lines.length; i++) {
let numSpacesLine = 0;
while (str.charAt(numSpacesLine) == " " && numSpacesLine < str.length) {
numSpacesLine++;
}
output.push(lines[i].substring(numSpacesLine));
}
return output.join("\n");
}

View File

@@ -1,8 +0,0 @@
{
"compilerOptions": {
"module": "NodeNext",
"declaration": true,
"outDir": "build",
},
"include": [ "./src/**/*.ts" ]
}