chore(monorepo/client): set up commons package

This commit is contained in:
Elian Doran
2025-04-18 02:45:31 +03:00
parent 25160a23a6
commit 42744acbb3
8 changed files with 6927 additions and 10 deletions

View File

@@ -0,0 +1,119 @@
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

@@ -0,0 +1,164 @@
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];