diff --git a/packages/common-all/src/constants/configs/base.ts b/packages/common-all/src/constants/configs/base.ts new file mode 100644 index 0000000000..66c7f1fe49 --- /dev/null +++ b/packages/common-all/src/constants/configs/base.ts @@ -0,0 +1,30 @@ +import { + DendronConfigEntry, + VaultSyncModeEnum, +} from "../../types/configs/base"; + +export const VAULT_SYNC_MODES: Record< + VaultSyncModeEnum, + DendronConfigEntry +> = { + [VaultSyncModeEnum.skip]: { + value: VaultSyncModeEnum.skip, + label: "Skip", + desc: "Skip entirely. You must manage the repository manually.", + }, + [VaultSyncModeEnum.noPush]: { + value: VaultSyncModeEnum.noPush, + label: "No Push", + desc: "Commit any changes and pull updates, but don't push. You can watch the repository and make local changes without sharing them back", + }, + [VaultSyncModeEnum.noCommit]: { + value: VaultSyncModeEnum.noCommit, + label: "No Commit", + desc: "Pull and push updates if the workspace is clean, but don't commit. You manually commit your local changes, but automatically share them once you committed.", + }, + [VaultSyncModeEnum.sync]: { + value: VaultSyncModeEnum.sync, + label: "Sync", + desc: "Commit changes, and pull and push updates. Treats workspace vaults like regular vaults.", + }, +}; diff --git a/packages/common-all/src/constants/configs/commands.ts b/packages/common-all/src/constants/configs/commands.ts new file mode 100644 index 0000000000..9c7a8cbe32 --- /dev/null +++ b/packages/common-all/src/constants/configs/commands.ts @@ -0,0 +1,170 @@ +import { + DendronConfigEntry, + DendronConfigEntryCollection, +} from "../../types/configs/base"; +import { DendronCommandConfig } from "../../types/configs/commands/commands"; +import { + LookupConfig, + NoteLookupConfig, + LookupSelectionModeEnum, +} from "../../types/configs/commands/lookup"; +import { RandomNoteConfig } from "../../types/configs/commands/randomNote"; +import { InsertNoteConfig } from "../../types/configs/commands/insertNote"; +import { + InsertNoteLinkConfig, + InsertNoteLinkAliasModeEnum, +} from "../../types/configs/commands/insertNoteLink"; +import { InsertNoteIndexConfig } from "../../types/configs/commands/insertNoteIndex"; + +/** + * Lookup + */ + +/** + * Selection mode entries + */ +const SELECTION_MODES: Record< + LookupSelectionModeEnum, + DendronConfigEntry +> = { + [LookupSelectionModeEnum.extract]: { + value: LookupSelectionModeEnum.extract, + label: "Extract Selection", + desc: "Extract selection of active editor and use it as body of new note.", + }, + [LookupSelectionModeEnum.link]: { + value: LookupSelectionModeEnum.link, + label: "Selection to Link", + desc: "Use selection of active editor for the basename of the lookup value.", + }, + [LookupSelectionModeEnum.none]: { + value: LookupSelectionModeEnum.none, + label: "None", + desc: "Do not set selection mode", + }, +}; + +/** + * Note lookup entry collection + */ +const NOTE: DendronConfigEntryCollection = { + selectionMode: SELECTION_MODES, + confirmVaultOnCreate: { + label: "Confirm Vault on Create.", + desc: "Prompt for vault selection when creating new note.", + }, +}; + +/** + * Lookup entry collection + */ +const LOOKUP: DendronConfigEntryCollection = { + note: NOTE, +}; + +/** + * Random note + */ + +/** + * Random note entries + */ +const RANDOM_NOTE: DendronConfigEntryCollection = { + include: { + label: "Hierarchies to Include", + desc: "Hierarchies to include when opening a random note", + }, + exclude: { + label: "hierarchies to Exclude", + desc: "Hierarchies not to include when opening a random note", + }, +}; + +/** + * Insert note + */ + +/** + * Insert note entries + */ +const INSERT_NOTE: DendronConfigEntryCollection = { + initialValue: { + label: "Initial Value", + desc: "Initial value that will be filled when prompted.", + }, +}; + +/** + * Insert note link + */ + +/** + * Insert note link alias mode entries + */ +const ALIAS_MODES: Record< + InsertNoteLinkAliasModeEnum, + DendronConfigEntry +> = { + [InsertNoteLinkAliasModeEnum.snippet]: { + value: InsertNoteLinkAliasModeEnum.snippet, + label: "Snippet Mode", + desc: "Insert note link as snippet string", + }, + [InsertNoteLinkAliasModeEnum.selection]: { + value: InsertNoteLinkAliasModeEnum.selection, + label: "Selection Mode", + desc: "Extract selection and use as link alias", + }, + [InsertNoteLinkAliasModeEnum.title]: { + value: InsertNoteLinkAliasModeEnum.title, + label: "Title Mode", + desc: "Use linked note's title as link alias", + }, + [InsertNoteLinkAliasModeEnum.prompt]: { + value: InsertNoteLinkAliasModeEnum.prompt, + label: "Prompt Mode", + desc: "Prompt for input to be used as link alias", + }, + [InsertNoteLinkAliasModeEnum.none]: { + value: InsertNoteLinkAliasModeEnum.none, + label: "No Alias Mode", + desc: "Do not add link alias", + }, +}; + +/** + * Insert note link entries + */ +const INSERT_NOTE_LINK: DendronConfigEntryCollection = { + aliasMode: ALIAS_MODES, + enableMultiSelect: { + label: "Enable Multi-select", + desc: "Enable multi-select when inserting note links", + }, +}; + +/** + * Insert note index + */ + +/** + * Insert note index entries + */ +export const INSERT_NOTE_INDEX: DendronConfigEntryCollection = + { + enableMarker: { + label: `Enable Marker`, + desc: `Insert note index between autogenerated markers`, + }, + }; + +/** + * Command entry collection + */ +export const COMMANDS: DendronConfigEntryCollection = { + lookup: LOOKUP, + randomNote: RANDOM_NOTE, + insertNote: INSERT_NOTE, + insertNoteLink: INSERT_NOTE_LINK, + insertNoteIndex: INSERT_NOTE_INDEX, +}; diff --git a/packages/common-all/src/constants/configs/dendronConfig.ts b/packages/common-all/src/constants/configs/dendronConfig.ts new file mode 100644 index 0000000000..3a532f4184 --- /dev/null +++ b/packages/common-all/src/constants/configs/dendronConfig.ts @@ -0,0 +1,17 @@ +import { DendronConfigEntryCollection } from "../../types/configs/base"; +import { DendronConfig } from "../../types/configs/dendronConfig"; +import { GLOBAL } from "./global"; +import { COMMANDS } from "./commands"; +import { WORKSPACE } from "./workspace"; +import { PREVIEW } from "./preview"; +import { PUBLISHING } from "./publishing"; +import { DEV } from "./dev"; + +export const DENDRON_CONFIG: DendronConfigEntryCollection = { + global: GLOBAL, + commands: COMMANDS, + workspace: WORKSPACE, + preview: PREVIEW, + publishing: PUBLISHING, + dev: DEV, +}; diff --git a/packages/common-all/src/constants/configs/dev.ts b/packages/common-all/src/constants/configs/dev.ts new file mode 100644 index 0000000000..8f7415a40f --- /dev/null +++ b/packages/common-all/src/constants/configs/dev.ts @@ -0,0 +1,29 @@ +import { DendronConfigEntryCollection } from "../../types/configs/base"; +import { DendronDevConfig } from "../../types/configs/dev/dev"; + +export const DEV: DendronConfigEntryCollection = { + nextServerUrl: { + label: "Next Server URL", + desc: "Custom URL for the nextjs server.", + }, + nextStaticRoot: { + label: "Next Static Root", + desc: "Root directory for the static assets of the nextjs server.", + }, + engineServerPort: { + label: "Engine Server Port", + desc: "What port to use for the engine server. Defaults to creating on startup.", + }, + enableWebUI: { + label: "Enable web UI", + desc: "Enable experimental web ui. Defaults to false.", + }, + enableLinkCandidates: { + label: "Enable Link Candidates", + desc: "Enable displaying and indexing link candidates. Defaults to false.", + }, + enablePreviewV2: { + label: "Enable Preview V2", + desc: "Use preview V2 as the default preview.", + }, +}; diff --git a/packages/common-all/src/constants/configs/global.ts b/packages/common-all/src/constants/configs/global.ts new file mode 100644 index 0000000000..f50b45ce27 --- /dev/null +++ b/packages/common-all/src/constants/configs/global.ts @@ -0,0 +1,89 @@ +import { TopLevelDendronConfig } from "../../types/configs/dendronConfig"; +import { + DendronConfigEntry, + DendronConfigEntryCollection, +} from "../../types/configs/base"; +import { DendronGlobalConfig } from "../../types/configs/global/global"; + +export const ENABLE_MERMAID = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Enable Mermaid (${namespace})`, + desc: `Enable the use of mermaid for rendering diagrams. (${namespace})`, + }; +}; + +export const ENABLE_NUNJUCKS = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Enable Nunjucks (${namespace})`, + desc: `Enable the use of nunjucks templates in the note body. (${namespace})`, + }; +}; + +export const ENABLE_PRETTY_REFS = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Enable Pretty Refs (${namespace})`, + desc: `Enable rendering note references as pretty refs. (${namespace})`, + }; +}; + +export const ENABLE_KATEX = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Enable Katex (${namespace})`, + desc: `Enable the use of katex for rendering math. (${namespace})`, + }; +}; + +export const ENABLE_FM_TITLE = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Enable Frontmatter Title (${namespace})`, + desc: `Insert frontmatter title of note to the body (${namespace})`, + }; +}; + +export const ENABLE_HIERARCHY_DISPLAY = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Enable Hierarchy Display (${namespace})`, + desc: `Enable rendering of children link block at the end of the note. (${namespace})`, + }; +}; + +export const HIERARCHY_DISPLAY_TITLE = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Hierarhcy Display Title ${namespace}`, + desc: `Title to display for the children links block. ${namespace}`, + }; +}; + +export const ENABLE_NOTE_TITLE_FOR_LINK = ( + namespace: TopLevelDendronConfig +): DendronConfigEntry => { + return { + label: `Enable Note Title for Links (${namespace})`, + desc: `Enable rendering of naked links as the title of the note. (${namespace})`, + }; +}; + +export const GLOBAL: DendronConfigEntryCollection = { + enableFMTitle: ENABLE_FM_TITLE("global"), // TODO: split implementation to respect non-global config + enableHierarchyDisplay: ENABLE_HIERARCHY_DISPLAY("global"), // TODO: split + hierarchyDisplayTitle: HIERARCHY_DISPLAY_TITLE("global"), //TODO: split + enableNoteTitleForLink: ENABLE_NOTE_TITLE_FOR_LINK("global"), // TODO: split + enableMermaid: ENABLE_MERMAID("global"), + enableNunjucks: ENABLE_NUNJUCKS("global"), + enablePrettyRefs: ENABLE_PRETTY_REFS("global"), + enableKatex: ENABLE_KATEX("global"), +}; diff --git a/packages/common-all/src/constants/configs/preview.ts b/packages/common-all/src/constants/configs/preview.ts new file mode 100644 index 0000000000..0cd4069d3e --- /dev/null +++ b/packages/common-all/src/constants/configs/preview.ts @@ -0,0 +1,23 @@ +import { DendronConfigEntryCollection } from "../../types/configs/base"; +import { DendronPreviewConfig } from "../../types/configs/preview/preview"; +import { + ENABLE_HIERARCHY_DISPLAY, + HIERARCHY_DISPLAY_TITLE, + ENABLE_FM_TITLE, + ENABLE_NOTE_TITLE_FOR_LINK, + ENABLE_MERMAID, + ENABLE_NUNJUCKS, + ENABLE_KATEX, + ENABLE_PRETTY_REFS, +} from "./global"; + +export const PREVIEW: DendronConfigEntryCollection = { + enableFMTitle: ENABLE_FM_TITLE("preview"), // TODO: split + enableHierarchyDisplay: ENABLE_HIERARCHY_DISPLAY("preview"), // TODO: split + hierarchyDisplayTitle: HIERARCHY_DISPLAY_TITLE("preview"), // TODO: split + enableNoteTitleForLink: ENABLE_NOTE_TITLE_FOR_LINK("preview"), // TODO: split + enableMermaid: ENABLE_MERMAID("preview"), + enableNunjucks: ENABLE_NUNJUCKS("preview"), + enablePrettyRefs: ENABLE_PRETTY_REFS("preview"), + enableKatex: ENABLE_KATEX("preview"), +}; diff --git a/packages/common-all/src/constants/configs/publishing.ts b/packages/common-all/src/constants/configs/publishing.ts new file mode 100644 index 0000000000..bbe5eb68fb --- /dev/null +++ b/packages/common-all/src/constants/configs/publishing.ts @@ -0,0 +1,204 @@ +import { + DendronConfigEntry, + DendronConfigEntryCollection, +} from "../../types/configs/base"; +import { + DendronPublishingConfig, + GoogleAnalyticsConfig, +} from "../../types/configs/publishing/publishing"; +import { SEOConfig } from "../../types/configs/publishing/seo"; +import { + GithubConfig, + GithubEditViewModeEnum, +} from "../../types/configs/publishing/github"; +import { + ENABLE_HIERARCHY_DISPLAY, + HIERARCHY_DISPLAY_TITLE, + ENABLE_FM_TITLE, + ENABLE_NOTE_TITLE_FOR_LINK, + ENABLE_MERMAID, + ENABLE_NUNJUCKS, + ENABLE_KATEX, + ENABLE_PRETTY_REFS, +} from "./global"; + +const GITHUB_EDIT_VIEW_MODE: Record< + GithubEditViewModeEnum, + DendronConfigEntry +> = { + [GithubEditViewModeEnum.edit]: { + value: GithubEditViewModeEnum.edit, + label: "Edit", + desc: "Links directly to edit mode.", + }, + [GithubEditViewModeEnum.tree]: { + value: GithubEditViewModeEnum.tree, + label: "Tree", + desc: "Links to Github page.", + }, +}; + +const GITHUB: DendronConfigEntryCollection = { + cname: { + label: "CNAME", + desc: "CNAME used for Github Pages", + }, + enableEditLink: { + label: "Enable Edit Link", + desc: "Add a link to Github where you can edit the page.", + }, + editLinkText: { + label: "Edit Link Text", + desc: "Text to use for the Github edit link.", + }, + editBranch: { + label: "Edit Branch", + desc: "Branch that the stie is served from.", + }, + editViewMode: GITHUB_EDIT_VIEW_MODE, + editRepository: { + label: "Edit Repository", + desc: "URL of the Github repository. This value will be ignored if you are using remote vaults.", + }, +}; + +const GA: DendronConfigEntryCollection = { + tracking: { + label: "Tracking", + desc: "Google Analytics tracking number", + }, +}; + +const SEO: DendronConfigEntryCollection = { + title: { + label: "Title", + desc: "Set SEO title.", + }, + description: { + label: "Description", + desc: "Set SEO description.", + }, + author: { + label: "Author", + desc: "Set SEO author.", + }, + twitter: { + label: "Twitter", + desc: "set SEO twitter.", + }, + image: { + label: "Image", + desc: "Set SEO image.", + }, +}; + +export const PUBLISHING: DendronConfigEntryCollection = + { + enableFMTitle: ENABLE_FM_TITLE("publishing"), + enableHierarchyDisplay: ENABLE_HIERARCHY_DISPLAY("publishing"), + hierarchyDisplayTitle: HIERARCHY_DISPLAY_TITLE("publishing"), + enableNoteTitleForLink: ENABLE_NOTE_TITLE_FOR_LINK("publishing"), + enableMermaid: ENABLE_MERMAID("publishing"), + enableNunjucks: ENABLE_NUNJUCKS("publishing"), + enablePrettyRefs: ENABLE_PRETTY_REFS("publishing"), + enableKatex: ENABLE_KATEX("publishing"), + assetsPrefix: { + label: "Assets Prefix", + desc: "Prefix for assets for publishing.", + }, + canonicalBaseUrl: { + label: "Canonical Base URL", + desc: "The base URL used for generating canonical URLs from each page for publishing.", + }, + copyAssets: { + label: "Copy Assets", + desc: "Copy assets from vault to published site.", + }, + customHeaderPath: { + label: "Custom Header Path", + desc: "Path to the custom header file to include in each published notes.", + }, + ga: GA, + siteFaviconPath: { + label: "Site Favicon Path", + desc: "Path to favicon relative to the workspace.", + }, + logoPath: { + label: "Logo Path", + desc: "Path to the site logo.", + }, + siteIndex: { + label: "Site Index", + desc: "The domain of your `siteHierarhcies` page.", + }, + siteHierarchies: { + label: "Site Hierarchies", + desc: "List of hierarchies to publish.", + }, + enableSiteLastModified: { + label: "Site Last Modified", + desc: "Show last modified timestamp on the site", + }, + siteRootDir: { + label: "Site Root Dir", + desc: "Where your site will be published, relative to the Dendron workspace.", + }, + siteRepoDir: { + label: "Site Repo Dir", + desc: "Location of the Github repository where your site notes are located. By default this is assumed to be your workspace root.", + }, + siteUrl: { + label: "Site URL", + desc: "URL of the site without trailing slash.", + }, + enableFrontmatterTags: { + label: "Enable Frontmatter Tags", + desc: "Show Frontmatter tags in published site.", + }, + enableRandomlyColoredTags: { + label: "Enable Randomly Colored Tags", + desc: "Display randomly generated colors for tags.", + }, + hierarchy: { + label: "Hierarchy", + desc: "Control publication on a per-hierarchy basis", + }, + duplicateNoteBehavior: { + label: "Duplicate Note Behavior", + desc: "How duplicate notes are handled when publishing a multi-vault workspace.", + }, + writeStubs: { + label: "Write Stubs", + desc: "Write stub notes to disk when publishing. If this is set to fale, stub notes will be published with a different id each time.", + }, + seo: SEO, + github: GITHUB, + enableContainers: { + label: "Enable Containers", + desc: "Use remark-containers in published site.", + }, + generateChangelog: { + label: "Generate Changelog", + desc: "Generate changelog for published site.", + }, + previewPort: { + label: "Preview Port", + desc: "Set an alternative port to be used for previewing published site.", + }, + segmentKey: { + label: "Segment Key", + desc: "Value of the Segment API key.", + }, + cognitoUserPoolId: { + label: "Cognito User Pool ID", + desc: "Value of Cognito user pool ID.", + }, + cognitoClientId: { + label: "Cognito Client ID", + desc: "Value of Cognito client ID.", + }, + enablePrettyLinks: { + label: "Enable Pretty Links", + desc: "Note links are published without the .html file extension.", + }, + }; diff --git a/packages/common-all/src/constants/configs/workspace.ts b/packages/common-all/src/constants/configs/workspace.ts new file mode 100644 index 0000000000..38abf21d57 --- /dev/null +++ b/packages/common-all/src/constants/configs/workspace.ts @@ -0,0 +1,166 @@ +import { + DendronConfigEntry, + DendronConfigEntryCollection, +} from "../../types/configs/base"; +import { NoteAddBehaviorEnum } from "../../types/configs/workspace/types"; +import { + // dayOfWeekNumber, + JournalConfig, +} from "../../types/configs/workspace/journal"; +import { DendronWorkspaceConfig } from "../../types/configs/workspace/workspace"; +import { DendronGraphConfig } from "../../types/configs/workspace/graph"; +import { ScratchConfig } from "../../types/configs/workspace/scratch"; +import { VAULT_SYNC_MODES } from "./base"; + +const ADD_BEHAVIOR: Record> = { + [NoteAddBehaviorEnum.childOfDomain]: { + value: "childOfDomain", + label: "Child of Domain", + desc: "Note is added as the child of domain of the current hierarchy", + }, + [NoteAddBehaviorEnum.childOfDomainNamespace]: { + value: "childOfDomainNamespace", + label: "Child of Domain Namespace", + desc: "Note is added as child of the namespace of the current domain if it has a namespace. Otherwise added as child of domain.", + }, + [NoteAddBehaviorEnum.childOfCurrent]: { + value: "childOfCurrent", + label: "Child of Current", + desc: "Note is added as a child of the current open note", + }, + [NoteAddBehaviorEnum.asOwnDomain]: { + value: "asOwnDomain", + label: "as Own Domain", + desc: "Note is created under the domain specified by journal name value", + }, +}; + +const GRAPH: DendronConfigEntryCollection = { + zoomSpeed: { + label: "Zoom Speed", + desc: "The speed at which the graph zooms in and out. Lower is slower, higher is faster.", + }, +}; + +/** + * Given a {@link dayOfWeekNumber}, returns a {@link DendronConfigEntry} that holds + * user friendly description of the first day of week behavior. + * + * @param value {@link dayOfWeekNumber} + * @returns DendronConfigEntry + */ +// const FIRST_DAY_OF_WEEK = ( +// value: dayOfWeekNumber +// ): DendronConfigEntry => { +// const dayOfWeek = [ +// "Sunday", +// "Monday", +// "Tuesday", +// "Wednesday", +// "Thursday", +// "Friday", +// "Saturday", +// ]; +// const valueToDay = dayOfWeek[value]; +// return { +// value, +// label: valueToDay, +// desc: `Set start of the week to ${valueToDay}`, +// }; +// }; + +const JOURNAL: DendronConfigEntryCollection = { + dailyDomain: { + label: "Daily Domain", + desc: "Domain where the journal notes are created", + }, + dailyVault: { + label: "Daily Vault", + desc: "Name of vault where daily journal should be in", + }, + name: { + label: "Journal Name", + desc: "Name used for journal notes", + }, + dateFormat: { + label: "Date Format", + desc: "Date format used for journal notes", + }, + addBehavior: ADD_BEHAVIOR, + // firstDayOfWeek: FIRST_DAY_OF_WEEK, +}; + +const SCRATCH: DendronConfigEntryCollection = { + name: { + label: "Scratch Name", + desc: "Name used for scratch notes", + }, + dateFormat: { + label: "Date Format", + desc: "Date format used for scratch notes", + }, + addBehavior: ADD_BEHAVIOR, +}; + +export const WORKSPACE: DendronConfigEntryCollection = { + dendronVersion: { + label: "Dendron version", + desc: "Dendron version. Set up by plugin.", + }, + workspaces: { + label: "Workspaces", + desc: "Workspaces", + }, + seeds: { + label: "Seeds", + desc: "Seeds", + }, + vaults: { + label: "Vaults", + desc: "Vaults", + }, + hooks: { + label: "Hooks", + desc: "Hooks", + }, + journal: JOURNAL, + scratch: SCRATCH, + graph: GRAPH, + disableTelemetry: { + label: `Disable Telemetry`, + desc: `Disable telemetry that collects usage data to help improve Dendron.`, + }, + enableAutoCreateOnDefinition: { + label: "Enable auto create on definition", + desc: "Automatically create note when looking up definition", + }, + enableXVaultWikiLink: { + label: "Enable cross-vault wikilink", + desc: "Enable cross-vault wikilinks", + }, + enableRemoteVaultInit: { + label: "Enable Remote Vault Init", + desc: "Enable initializing remote vaults on startup.", + }, + workspaceVaultSyncMode: VAULT_SYNC_MODES, + enableAutoFoldFrontmatter: { + label: "Enable Auto Fold Frontmatter", + desc: "Enable Automatically folding frontmatter block when opening a new note.", + }, + maxPreviewsCached: { + label: "Max Preview Cached", + desc: "Maximum number of rendered previews to cache.", + }, + maxNoteLength: { + label: "Max Note Length", + desc: "Maximum number of characters in a note. Notes with characters exceeding this number will have some Dendron features disabled.", + }, + feedback: { + label: "Feedback", + desc: "Enable feedback widget.", + }, + apiEndpoint: { + label: "API Endpoint", + desc: "Endpoint for backend API functionality.", + }, +}; diff --git a/packages/common-all/src/types/configs/base.ts b/packages/common-all/src/types/configs/base.ts new file mode 100644 index 0000000000..e49f9d652a --- /dev/null +++ b/packages/common-all/src/types/configs/base.ts @@ -0,0 +1,38 @@ +/** + * DendronConfigEntry + * Holds the value, label, and description of individual configuration entries. + * + * For config entries that can be an arbitrary value, only specify the label and description. + * For config entries that have pre-defined choices, provide the value as well as label and description specific to that value. + */ +export type DendronConfigEntry = { + value?: T; + label: string; + desc: string; +}; + +/** + * DendronConfigEntryCollection + * type for an object that has the same properties of T + * mapped to it, that can have any value for each key. + * Any optional properties are required here. + * + * This is used as the type signature of the object that + * maps config properties to their respective DendronConfigEntry + */ +export type DendronConfigEntryCollection = { + [Property in keyof T]-?: + | DendronConfigEntryCollection + | Record + | DendronConfigEntry + | ((...args: any[]) => DendronConfigEntry); +}; + +export enum VaultSyncModeEnum { + skip = "skip", + noPush = "noPush", + noCommit = "noCommit", + sync = "sync", +} + +export type VaultSyncMode = keyof typeof VaultSyncModeEnum; diff --git a/packages/common-all/src/types/configs/commands/commands.ts b/packages/common-all/src/types/configs/commands/commands.ts new file mode 100644 index 0000000000..7cae9236fd --- /dev/null +++ b/packages/common-all/src/types/configs/commands/commands.ts @@ -0,0 +1,37 @@ +import { + genDefaultInsertNoteLinkConfig, + InsertNoteLinkConfig, +} from "./insertNoteLink"; +import { genDefaultLookupConfig, LookupConfig } from "./lookup"; +import { + genDefaultInsertNoteIndexConfig, + InsertNoteIndexConfig, +} from "./insertNoteIndex"; +import { genDefaultRandomNoteConfig, RandomNoteConfig } from "./randomNote"; +import { genDefaultInsertNoteConfig, InsertNoteConfig } from "./insertNote"; + +/** + * Namespace for all command related configurations + */ +export type DendronCommandConfig = { + lookup: LookupConfig; + randomNote: RandomNoteConfig; + insertNote: InsertNoteConfig; + insertNoteLink: InsertNoteLinkConfig; + insertNoteIndex: InsertNoteIndexConfig; +}; + +/** + * Generates default {@link DendronCommandConfig} using + * respective default config generators that each command config implements. + * @returns DendronCommandConfig + */ +export function genDefaultCommandConfig(): DendronCommandConfig { + return { + lookup: genDefaultLookupConfig(), + randomNote: genDefaultRandomNoteConfig(), + insertNote: genDefaultInsertNoteConfig(), + insertNoteLink: genDefaultInsertNoteLinkConfig(), + insertNoteIndex: genDefaultInsertNoteIndexConfig(), + }; +} diff --git a/packages/common-all/src/types/configs/commands/insertNote.ts b/packages/common-all/src/types/configs/commands/insertNote.ts new file mode 100644 index 0000000000..2f582f01ab --- /dev/null +++ b/packages/common-all/src/types/configs/commands/insertNote.ts @@ -0,0 +1,16 @@ +/** + * Namespace for configuring {@link InsertNoteCommand} + */ +export type InsertNoteConfig = { + initialValue?: string; +}; + +/** + * Generates default {@link InsertNoteConfig} + * @returns InsertNoteConfig + */ +export function genDefaultInsertNoteConfig(): InsertNoteConfig { + return { + initialValue: "templates", + }; +} diff --git a/packages/common-all/src/types/configs/commands/insertNoteIndex.ts b/packages/common-all/src/types/configs/commands/insertNoteIndex.ts new file mode 100644 index 0000000000..f233e12890 --- /dev/null +++ b/packages/common-all/src/types/configs/commands/insertNoteIndex.ts @@ -0,0 +1,16 @@ +/** + * Namespace for configuring {@link InsertNoteIndexCommand} + */ +export type InsertNoteIndexConfig = { + enableMarker: boolean; +}; + +/** + * Generates default {@link InsertNoteIndexConfig} + * @returns InsertNoteIndexConfig + */ +export function genDefaultInsertNoteIndexConfig(): InsertNoteIndexConfig { + return { + enableMarker: false, + }; +} diff --git a/packages/common-all/src/types/configs/commands/insertNoteLink.ts b/packages/common-all/src/types/configs/commands/insertNoteLink.ts new file mode 100644 index 0000000000..bdc19e76c6 --- /dev/null +++ b/packages/common-all/src/types/configs/commands/insertNoteLink.ts @@ -0,0 +1,34 @@ +/** + * Enum definitions of possible alias mode values + */ +export enum InsertNoteLinkAliasModeEnum { + snippet = "snippet", + selection = "selection", + title = "title", + prompt = "prompt", + none = "none", +} + +/** + * String literal types generated from {@link InsertNoteLinkAliasModeEnum} + */ +export type InsertNoteLinkAliasMode = keyof typeof InsertNoteLinkAliasModeEnum; + +/** + * Namespace for configuring {@link InsertNoteLinkCommand} + */ +export type InsertNoteLinkConfig = { + aliasMode: InsertNoteLinkAliasModeEnum; + enableMultiSelect: boolean; +}; + +/** + * Generates default {@link InsertNoteLinkConfig} + * @returns InsertNoteLinkConfig + */ +export function genDefaultInsertNoteLinkConfig(): InsertNoteLinkConfig { + return { + aliasMode: InsertNoteLinkAliasModeEnum.none, + enableMultiSelect: false, + }; +} diff --git a/packages/common-all/src/types/configs/commands/lookup.ts b/packages/common-all/src/types/configs/commands/lookup.ts new file mode 100644 index 0000000000..fb4a7c4d21 --- /dev/null +++ b/packages/common-all/src/types/configs/commands/lookup.ts @@ -0,0 +1,41 @@ +/** + * Enum definition of possible lookup selection behavior values + */ +export enum LookupSelectionModeEnum { + extract = "extract", + link = "link", + none = "none", +} + +/** + * String literal type generated from {@link NoteLookupSelectionBehaviorEnum} + */ +export type LookupSelectionMode = keyof typeof LookupSelectionModeEnum; + +/** + * Namespace for configuring lookup commands + */ +export type LookupConfig = { + note: NoteLookupConfig; +}; + +/** + * Namespace for configuring {@link NoteLookupCommand} + */ +export type NoteLookupConfig = { + selectionMode: LookupSelectionMode; + confirmVaultOnCreate?: boolean; +}; + +/** + * Generates default {@link LookupConfig} + * @returns LookupConfig + */ +export function genDefaultLookupConfig(): LookupConfig { + return { + note: { + selectionMode: LookupSelectionModeEnum.extract, + confirmVaultOnCreate: false, + }, + }; +} diff --git a/packages/common-all/src/types/configs/commands/randomNote.ts b/packages/common-all/src/types/configs/commands/randomNote.ts new file mode 100644 index 0000000000..c07b1fd45f --- /dev/null +++ b/packages/common-all/src/types/configs/commands/randomNote.ts @@ -0,0 +1,15 @@ +/** + * Namespace for configuring {@link RandomNoteCommand} + */ +export type RandomNoteConfig = { + include?: string[]; + exclude?: string[]; +}; + +/** + * Generates default {@link RandomNoteConfig} + * @returns RandomNoteConfig + */ +export function genDefaultRandomNoteConfig(): RandomNoteConfig { + return {}; +} diff --git a/packages/common-all/src/types/configs/dendronConfig.ts b/packages/common-all/src/types/configs/dendronConfig.ts new file mode 100644 index 0000000000..1b4b1a8162 --- /dev/null +++ b/packages/common-all/src/types/configs/dendronConfig.ts @@ -0,0 +1,49 @@ +import { + DendronCommandConfig, + genDefaultCommandConfig, +} from "./commands/commands"; +import { + DendronWorkspaceConfig, + genDefaultWorkspaceConfig, +} from "./workspace/workspace"; +import { + DendronPreviewConfig, + genDefaultPreviewConfig, +} from "./preview/preview"; +import { + DendronPublishingConfig, + genDefaultPublishingConfig, +} from "./publishing/publishing"; +import { DendronGlobalConfig, genDefaultGlobalConfig } from "./global/global"; +import { DendronDevConfig, genDefaultDevConfig } from "./dev/dev"; + +/** + * DendronConfig + * This is the top level config that will hold everything. + */ +export type DendronConfig = { + global: DendronGlobalConfig; + commands: DendronCommandConfig; + workspace: DendronWorkspaceConfig; + preview: DendronPreviewConfig; + publishing: DendronPublishingConfig; + dev?: DendronDevConfig; +}; + +export type TopLevelDendronConfig = keyof DendronConfig; + +/** + * Generates a default DendronConfig using + * respective default config generators of each sub config groups. + * @returns DendronConfig + */ +export function genDefaultDendronConfig(): DendronConfig { + return { + global: genDefaultGlobalConfig(), + commands: genDefaultCommandConfig(), + workspace: genDefaultWorkspaceConfig(), + preview: genDefaultPreviewConfig(), + publishing: genDefaultPublishingConfig(), + dev: genDefaultDevConfig(), + }; +} diff --git a/packages/common-all/src/types/configs/dev/dev.ts b/packages/common-all/src/types/configs/dev/dev.ts new file mode 100644 index 0000000000..81ba362cb0 --- /dev/null +++ b/packages/common-all/src/types/configs/dev/dev.ts @@ -0,0 +1,41 @@ +/** + * Namespace for all dev configurations. + * + * This is a namespace for all feature configs that are experimental. + * Keep this as flat as possible unless you know in advance + * what the config namespace will look like once it goes out of beta. + */ +export type DendronDevConfig = { + /** + * Custom next server + */ + nextServerUrl?: string; + /** + * Static assets for next + */ + nextStaticRoot?: string; + /** + * What port to use for engine server. Default behavior is to create at startup + */ + engineServerPort?: number; + /** + * Enable experimental web ui. Default is false + */ + enableWebUI?: boolean; + /** + * Enable displaying and indexing link candidates. Default is false + */ + enableLinkCandidates?: boolean; + /** + * Enable new preview as default + */ + enablePreviewV2?: boolean; +}; + +/** + * Generates defaults for {@link DendronDevConfig} + * @returns DendronDevConfig + */ +export function genDefaultDevConfig(): DendronDevConfig | undefined { + return; +} diff --git a/packages/common-all/src/types/configs/global/global.ts b/packages/common-all/src/types/configs/global/global.ts new file mode 100644 index 0000000000..b20a3714d9 --- /dev/null +++ b/packages/common-all/src/types/configs/global/global.ts @@ -0,0 +1,30 @@ +/** + * Namespace for all global configurations. + */ +export type DendronGlobalConfig = { + enableFMTitle: boolean; // TODO: split implementation to respect non-global config + enableHierarchyDisplay: boolean; // TODO: split + hierarchyDisplayTitle?: string; // TODO: split + enableNoteTitleForLink: boolean; // TODO: split + enableMermaid: boolean; // TODO: split + enableNunjucks: boolean; // TODO: split + enablePrettyRefs: boolean; // TODO: split + enableKatex: boolean; // TODO: split +}; + +/** + * Generates default for {@link DendronGlobalConfig} + * @returns DendronGlobalConfig + */ +export function genDefaultGlobalConfig(): DendronGlobalConfig { + return { + enableFMTitle: true, // TODO: split implementation to respect non-global config + enableHierarchyDisplay: true, // TODO: split + hierarchyDisplayTitle: "children", // TODO: split + enableNoteTitleForLink: true, // TODO: split + enableMermaid: true, + enableKatex: true, + enableNunjucks: false, + enablePrettyRefs: true, + }; +} diff --git a/packages/common-all/src/types/configs/preview/preview.ts b/packages/common-all/src/types/configs/preview/preview.ts new file mode 100644 index 0000000000..ec6d09aea0 --- /dev/null +++ b/packages/common-all/src/types/configs/preview/preview.ts @@ -0,0 +1,21 @@ +/** + * Namespace for all preview related configurations + */ +export type DendronPreviewConfig = { + enableFMTitle?: boolean; // TODO: split + enableHierarchyDisplay?: boolean; // TODO: split + hierarchyDisplayTitle?: string; // TODO: split + enableNoteTitleForLink?: boolean; // TODO: split + enableMermaid?: boolean; + enableNunjucks?: boolean; + enablePrettyRefs?: boolean; + enableKatex?: boolean; +}; + +/** + * Generate defaults for {@link DendronPreviewConfig} + * @returns DendronPreviewConfig + */ +export function genDefaultPreviewConfig(): DendronPreviewConfig { + return {}; +} diff --git a/packages/common-all/src/types/configs/publishing/github.ts b/packages/common-all/src/types/configs/publishing/github.ts new file mode 100644 index 0000000000..622abe3a5a --- /dev/null +++ b/packages/common-all/src/types/configs/publishing/github.ts @@ -0,0 +1,27 @@ +export enum GithubEditViewModeEnum { + tree = "tree", + edit = "edit", +} + +export type GithubEditViewMode = keyof typeof GithubEditViewModeEnum; + +/** + * Namespace for publishing related github configs + */ +export type GithubConfig = { + cname?: string; + enableEditLink: boolean; + editLinkText?: string; + editBranch?: string; + editViewMode?: GithubEditViewMode; + editRepository?: string; +}; + +export function genDefaultGithubConfig(): GithubConfig { + return { + enableEditLink: true, + editLinkText: "Edit this page on GitHub", + editBranch: "main", + editViewMode: GithubEditViewModeEnum.tree, + }; +} diff --git a/packages/common-all/src/types/configs/publishing/publishing.ts b/packages/common-all/src/types/configs/publishing/publishing.ts new file mode 100644 index 0000000000..45555af182 --- /dev/null +++ b/packages/common-all/src/types/configs/publishing/publishing.ts @@ -0,0 +1,98 @@ +import { DVault } from "../../workspace"; +import { GithubConfig, genDefaultGithubConfig } from "./github"; +import { SEOConfig, genDefaultSEOConfig } from "./seo"; + +/** + * Namespace for all publishing related configurations + */ +export type DendronPublishingConfig = { + enableFMTitle?: boolean; // TODO: split implementation to respect non-global config + enableHierarchyDisplay?: boolean; // TODO: split + hierarchyDisplayTitle?: string; // TODO: split + enableNoteTitleForLink?: boolean; // TODO: split + enableMermaid?: boolean; + enableNunjucks?: boolean; + enablePrettyRefs?: boolean; + enableKatex?: boolean; + + assetsPrefix?: string; + copyAssets: boolean; + + canonicalBaseUrl?: string; + customHeaderPath?: string; + ga?: GoogleAnalyticsConfig; + logoPath?: string; + siteFaviconPath?: string; + siteIndex?: string; + siteHierarchies: string[]; + enableSiteLastModified: boolean; + siteRootDir: string; + siteRepoDir?: string; + siteUrl?: string; + enableFrontmatterTags: boolean; + enableRandomlyColoredTags?: boolean; + hierarchy?: { [key: string]: HierarchyConfig }; + duplicateNoteBehavior?: DuplicateNoteBehavior; + writeStubs: boolean; + seo: SEOConfig; + github: GithubConfig; + enableContainers: boolean; + generateChangelog: boolean; + + previewPort?: number; + segmentKey?: string; + cognitoUserPoolId?: string; + cognitoClientId?: string; + enablePrettyLinks: boolean; +}; + +export enum DuplicateNoteActionEnum { + useVault = "useVault", +} + +export type DuplicateNoteAction = keyof typeof DuplicateNoteActionEnum; + +export type UseVaultBehaviorPayload = { vault: DVault } | string[]; + +export type DuplicateNoteActionPayload = UseVaultBehaviorPayload; + +export type DuplicateNoteBehavior = { + action: DuplicateNoteAction; + payload: DuplicateNoteActionPayload; +}; + +export type HierarchyConfig = { + publishByDefault?: boolean | { [key: string]: boolean }; + noindexByDefault?: boolean; + customFrontmatter?: CustomFMEntry[]; +}; + +export type CustomFMEntry = { + key: string; + value: any; +}; + +export type GoogleAnalyticsConfig = { + tracking?: string; +}; + +/** + * Generate default {@link DendronPublishingConfig} + * @returns DendronPublishingConfig + */ +export function genDefaultPublishingConfig(): DendronPublishingConfig { + return { + copyAssets: true, + siteHierarchies: ["root"], + writeStubs: false, + enableContainers: false, + generateChangelog: false, + siteRootDir: "docs", + seo: genDefaultSEOConfig(), + github: genDefaultGithubConfig(), + enableSiteLastModified: true, + enableFrontmatterTags: true, + enableRandomlyColoredTags: true, + enablePrettyLinks: true, + }; +} diff --git a/packages/common-all/src/types/configs/publishing/seo.ts b/packages/common-all/src/types/configs/publishing/seo.ts new file mode 100644 index 0000000000..7bfea18684 --- /dev/null +++ b/packages/common-all/src/types/configs/publishing/seo.ts @@ -0,0 +1,21 @@ +/** + * Namespace for SEO related site configurations. + */ +export type SEOConfig = { + title?: string; + description?: string; + author?: string; + twitter?: string; + image?: string; +}; + +/** + * Generate default {@link SEOConfig} + * @returns SEOConfig + */ +export function genDefaultSEOConfig(): SEOConfig { + return { + title: "Dendron", + description: "Personal Knowledge Space", + }; +} diff --git a/packages/common-all/src/types/configs/workspace/graph.ts b/packages/common-all/src/types/configs/workspace/graph.ts new file mode 100644 index 0000000000..fe16efd45d --- /dev/null +++ b/packages/common-all/src/types/configs/workspace/graph.ts @@ -0,0 +1,16 @@ +/** + * Namespace for all graph related configurations. + */ +export type DendronGraphConfig = { + zoomSpeed: number; +}; + +/** + * Generates default {@link DendronGraphConfig} + * @returns DendronGraphConfig + */ +export function genDefaultGraphConfig(): DendronGraphConfig { + return { + zoomSpeed: 1, + }; +} diff --git a/packages/common-all/src/types/configs/workspace/journal.ts b/packages/common-all/src/types/configs/workspace/journal.ts new file mode 100644 index 0000000000..0469618548 --- /dev/null +++ b/packages/common-all/src/types/configs/workspace/journal.ts @@ -0,0 +1,31 @@ +import { NoteAddBehaviorEnum } from "./types"; + +/** + * Namespace for configuring journal note behavior + */ +export type JournalConfig = { + dailyDomain: string; + dailyVault?: string; + name: string; + dateFormat: string; + addBehavior: NoteAddBehaviorEnum; + // firstDayOfWeek: number; +}; + +// const assertion to tell the compiler that we only want these as dayOfWeekNumber. +const possibleDayOfWeekNumber = [0, 1, 2, 3, 4, 5, 6] as const; +export type dayOfWeekNumber = typeof possibleDayOfWeekNumber[number]; + +/** + * Generates default {@link JournalConfig} + * @returns JouranlConfig + */ +export function genDefaultJournalConfig(): JournalConfig { + return { + dailyDomain: "daily", + name: "journal", + dateFormat: "y.MM.dd", + addBehavior: NoteAddBehaviorEnum.childOfDomain, + // firstDayOfWeek: 1, + }; +} diff --git a/packages/common-all/src/types/configs/workspace/scratch.ts b/packages/common-all/src/types/configs/workspace/scratch.ts new file mode 100644 index 0000000000..50ec58c8b2 --- /dev/null +++ b/packages/common-all/src/types/configs/workspace/scratch.ts @@ -0,0 +1,22 @@ +import { JournalConfig } from "./journal"; +import { NoteAddBehaviorEnum } from "./types"; + +/** + * Namespace for configuring scratch note behavior + */ +export type ScratchConfig = Pick< + JournalConfig, + "name" | "dateFormat" | "addBehavior" +>; + +/** + * Generates default {@link ScratchConfig} + * @returns ScratchConfig + */ +export function genDefaultScratchConfig(): ScratchConfig { + return { + name: "scratch", + dateFormat: "y.MM.dd.HHmmss", + addBehavior: NoteAddBehaviorEnum.asOwnDomain, + }; +} diff --git a/packages/common-all/src/types/configs/workspace/types.ts b/packages/common-all/src/types/configs/workspace/types.ts new file mode 100644 index 0000000000..a7e285a20a --- /dev/null +++ b/packages/common-all/src/types/configs/workspace/types.ts @@ -0,0 +1,14 @@ +/** + * Enum definition of possible note add behavior values. + */ +export enum NoteAddBehaviorEnum { + childOfDomain = "childOfDomain", + childOfDomainNamespace = "childOfDomainNamespace", + childOfCurrent = "childOfCurrent", + asOwnDomain = "asOwnDomain", +} + +/** + * String literal type generated from {@link NoteAddBehaviorEnum} + */ +export type NoteAddBehavior = keyof typeof NoteAddBehaviorEnum; diff --git a/packages/common-all/src/types/configs/workspace/workspace.ts b/packages/common-all/src/types/configs/workspace/workspace.ts new file mode 100644 index 0000000000..b2156fb834 --- /dev/null +++ b/packages/common-all/src/types/configs/workspace/workspace.ts @@ -0,0 +1,68 @@ +import { DVault, RemoteEndpoint } from "../../workspace"; +import { genDefaultJournalConfig, JournalConfig } from "./journal"; +import { genDefaultScratchConfig, ScratchConfig } from "./scratch"; +import { genDefaultGraphConfig, DendronGraphConfig } from "../workspace/graph"; +import { SeedSite } from "../../seed"; +import { DHookDict } from "../../hooks"; +import { VaultSyncMode, VaultSyncModeEnum } from "../base"; + +/** + * Namespace for configurations that affect the workspace + */ +export type DendronWorkspaceConfig = { + // general + dendronVersion?: string; + workspaces?: { [key: string]: DendronWorkspaceEntry | undefined }; + seeds?: { [key: string]: DendronSeedEntry | undefined }; + vaults: DVault[]; + hooks?: DHookDict; + // features + journal: JournalConfig; + scratch: ScratchConfig; + graph: DendronGraphConfig; + disableTelemetry?: boolean; + enableAutoCreateOnDefinition: boolean; + enableXVaultWikiLink: boolean; + enableRemoteVaultInit: boolean; + workspaceVaultSyncMode: VaultSyncMode; + enableAutoFoldFrontmatter: boolean; + // performance related + maxPreviewsCached: number; + maxNoteLength: number; + // + feedback?: boolean; + apiEndpoint?: string; +}; + +export type DendronWorkspace = { + name: string; + vaults: DVault[]; + remote: RemoteEndpoint; +}; + +export type DendronWorkspaceEntry = Omit; + +export type DendronSeedEntry = { + branch?: string; + site?: SeedSite; +}; + +/** + * Generates default {@link DendronWorkspaceConfig} + * @returns DendronWorkspaceConfig + */ +export function genDefaultWorkspaceConfig(): DendronWorkspaceConfig { + return { + vaults: [], + journal: genDefaultJournalConfig(), + scratch: genDefaultScratchConfig(), + graph: genDefaultGraphConfig(), + enableAutoCreateOnDefinition: false, + enableXVaultWikiLink: false, + enableRemoteVaultInit: true, + workspaceVaultSyncMode: VaultSyncModeEnum.noCommit, + enableAutoFoldFrontmatter: false, + maxPreviewsCached: 10, + maxNoteLength: 204800, + }; +}