import { URI } from "vscode-uri"; import { Decoration, DendronConfig, Diagnostic } from "."; import { IDendronError } from "../error"; import { VSRange } from "./compat"; import { DVault } from "./DVault"; import { FindNoteOpts } from "./FindNoteOpts"; import { DNodeProps, DNodeType, DNoteAnchorPositioned, DNoteLoc, NoteProps, NotePropsMeta, Position, SchemaData, SchemaProps } from "./foundation"; import { DHookDict } from "./hooks"; import { DendronASTDest, ProcFlavor } from "./unified"; export declare type OptionalExceptFor = Partial & Pick; export declare type EngineDeleteOpts = { /** * If true, delete only from metadata store. Otherwise, delete from metadata store and filesystem. */ metaOnly?: boolean; /** * If node is deleted and parents are stubs, default behavior is to alsod delete parents */ noDeleteParentStub?: boolean; }; export declare type AnyJson = boolean | number | string | null | JsonArray | JsonMap; export declare type JsonMap = { [key: string]: AnyJson; }; export declare type JsonArray = AnyJson[]; export declare type DLinkType = "wiki" | "refv2" | "hashtag" | "usertag" | "fmtag"; export declare type DNoteLinkData = { xvault?: boolean; /** Denotes that the link is a same file link, for example `[[#anchor]]` */ sameFile?: boolean; }; export declare type DNoteLink = { type: "ref" | "wiki" | "md" | "backlink" | "linkCandidate" | "frontmatterTag"; position?: Position; from: DNoteLoc; to?: DNoteLoc; data: TData; }; export declare type DNoteLinkRaw = Omit, "from"> & { from?: DNoteLoc; }; export declare type DNoteRefData = { anchorStart?: string; anchorEnd?: string; anchorStartOffset?: number; vaultName?: string; /** * File link: wiki based links (eg. [[foo]]) * Id link: TBD (eg. ^1234) */ type: "file" | "id"; } & DNoteLinkData; export declare type DNoteRefLink = DNoteLink; export declare type DNoteRefLinkRaw = DNoteLinkRaw; /** * Opts are arguments used when creating a node */ export declare type DNodeOpts = Partial, "fname|type|vault">> & { fname: string; type: DNodeType; vault: DVault; }; export declare type SchemaRaw = Pick & Partial & { title?: string; desc?: string; } & Partial>; export declare type SchemaOpts = Omit, "type" | "id" | "body"> & { id: string; }; export declare type NoteOpts = Omit; export declare type DNodePropsQuickInputV2 = DNodeProps & { label: string; detail?: string; alwaysShow?: boolean; }; /** * A reduced version of NoteQuickInput that only keeps the props necessary for * lookup quick pick items */ export declare type NoteQuickInputV2 = NotePropsMeta & { label: string; detail?: string; alwaysShow?: boolean; }; /** * Map of noteId -> noteProp */ export declare type NotePropsByIdDict = { [key: string]: NoteProps; }; /** * Map of noteFname -> list of noteIds. Since fname is not unique across vaults, there can be multiple ids with the same fname */ export declare type NotePropsByFnameDict = { [key: string]: string[]; }; /** * Type to keep track of forward index (notesById) and inverted indices (notesByFname) * Use {@link NoteDictsUtils} to perform operations that need to update all indices */ export declare type NoteDicts = { notesById: NotePropsByIdDict; notesByFname: NotePropsByFnameDict; }; export declare type SchemaPropsDict = { [key: string]: SchemaProps; }; export declare type SchemaModuleDict = { [key: string]: SchemaModuleProps; }; export declare type SchemaQuickInput = SchemaProps & { label: string; detail?: string; alwaysShow?: boolean; }; export declare type SchemaImport = string[]; export declare type SchemaModuleOpts = { version: number; imports?: SchemaImport; schemas: SchemaOpts[]; }; /** * This represents a `schema.yml` file */ export declare type SchemaModuleProps = { /** * Currently, this is set to 1. In the future, we might introduce * non-backward compatible schema changes */ version: number; /** * A schema can import schmeas from other files */ imports?: SchemaImport; /** * This is all the schema definitions in a schema module */ schemas: SchemaPropsDict; /** * This is the root note of your schema definitions. */ root: SchemaProps; /** * Name of the schema file without the `.schema.yml` suffix */ fname: string; /** * Vault */ vault: DVault; }; export interface RespV2 { data?: T; error: IDendronError | null; } export declare type RespV3ErrorResp = { error: IDendronError; data?: never; }; export declare type RespV3SuccessResp = { error?: never; data: T; }; /** * This lets us use a discriminated union to see if result has error or data * * If you need to make sure it is an error (or a success), * use {@link ErrorUtils.isErrorResp} type guard to help typescript narrow it down. */ export declare type RespV3 = RespV3ErrorResp | RespV3SuccessResp; export declare type RespWithOptError = { data: T; error?: IDendronError; }; /** * --- ENGINE OPTS */ export declare type EngineUpdateNodesOptsV2 = { /** * New Node, should add to `fullNode` cache */ newNode: boolean; }; export declare type EngineWriteOptsV2 = { /** * Write all children? * default: false */ recursive?: boolean; /** * Don't bother adding parent nodes. * Used when importing existing notes in bulk */ noAddParent?: boolean; /** * Should any configured hooks be run during the write */ runHooks?: boolean; /** * If true, overwrite existing note with same fname and vault, even if note has a different id * Commonly used if needed to override a note id */ overrideExisting?: boolean; /** * If true, write only to metadata store. Otherwise, write to metadata store and filesystem. */ metaOnly?: boolean; }; export declare type EngineSchemaWriteOpts = { /** * If true, write only to metadata store. Otherwise, write to metadata store and filesystem. */ metaOnly?: boolean; }; export declare type DEngineInitPayload = { notes: NotePropsByIdDict; wsRoot: string; vaults: DVault[]; config: DendronConfig; }; export declare type RenameNoteOpts = { oldLoc: DNoteLoc; newLoc: DNoteLoc; /** * Flag to determine whether we should touch metadata only * For example, if the code comes from vscode `rename` menu option, * we do not want to touch the filesystem. * If not provided, modify both metadata and filesystem. */ metaOnly?: boolean; }; export declare type RenderNoteOpts = { id: string; /** Optionally, an entire note can be provided to be rendered. If provided, the engine won't look up the note by id and will instead render this note. */ note?: NoteProps; /** `HTML` by default. */ dest?: DendronASTDest; /** `Preview` by default. */ flavor?: ProcFlavor; }; export declare type GetNoteBlocksOpts = { id: string; filterByAnchorType?: "header" | "block"; }; export declare type GetDecorationsOpts = { id: string; ranges: { range: VSRange; /** The document text that corresponds to this range. This is required because otherwise there's a data race between the notes in engine updating and decorations being generated. */ text: string; }[]; /** The text of the entire document. Required because we show warnings for the whole note even if they are not a visible range. */ text: string; }; export declare type QueryNotesOpts = { qs: string; /** * Original query string (which can contain minor modifications such as mapping '/'->'.') * This string is added for sorting the lookup results when there is exact match with * original query. */ originalQS: string; onlyDirectChildren?: boolean; vault?: DVault; }; export declare type BulkWriteNotesOpts = { notes: NoteProps[]; skipMetadata?: boolean; opts?: EngineWriteOptsV2; }; export declare type DCommonProps = { wsRoot: string; vaults: DVault[]; }; export declare type NoteChangeUpdateEntry = { prevNote: NoteProps; note: NoteProps; status: "update"; }; export declare type NoteChangeEntry = { note: NoteProps; status: "create" | "delete"; } | NoteChangeUpdateEntry; /** A block within a note that can be referenced using block anchors or headers. */ export declare type NoteBlock = { /** The actual text of the block. */ text: string; /** The anchor for this block, if one already exists. */ anchor?: DNoteAnchorPositioned; /** The position within the document at which the block is located. */ position: Position; /** The type of mdast node from which this block was extracted. Useful since entire lists are a special case. */ type: string; }; /** * --- ENGINE RESPONSE TYPES */ export declare type GetNoteResp = RespV3; export declare type BulkGetNoteResp = RespWithOptError; export declare type GetNoteMetaResp = RespV3; export declare type BulkGetNoteMetaResp = RespWithOptError; export declare type FindNotesResp = NoteProps[]; export declare type FindNotesMetaResp = NotePropsMeta[]; /** * Changed notes come from the following sources: * - notes that were deleted (eg. note being renamed had parent that was a stub) * - notes that were created (eg. note being created had no existing parents) * - notes that have had their links re-written */ export declare type WriteNoteResp = RespV3; export declare type BulkWriteNotesResp = RespWithOptError; export declare type UpdateNoteResp = RespV2; export declare type DeleteNoteResp = RespV3; export declare type QueryNotesResp = NoteProps[]; export declare type QueryNotesMetaResp = NotePropsMeta[]; export declare type RenameNoteResp = RespV3; export declare type EngineInfoResp = RespV3<{ version: string; }>; export declare type RenderNoteResp = RespV3; export declare type DEngineInitResp = RespWithOptError; export declare type StoreV2InitResp = RespWithOptError; export declare type DeleteSchemaResp = DEngineInitResp; export declare type GetSchemaResp = RespV3; export declare type WriteSchemaResp = RespV3; export declare type QuerySchemaResp = RespV3; export declare type GetNoteBlocksResp = RespV3; export declare type GetDecorationsResp = RespWithOptError<{ decorations?: Decoration[]; diagnostics?: Diagnostic[]; }>; export declare type DCommonMethods = { bulkWriteNotes: (opts: BulkWriteNotesOpts) => Promise; /** * Write note to metadata store and/or filesystem. This will update existing note or create new if one doesn't exist. * If another note with same fname + vault but different id exists, then return error (otherwise overrideExisting flag is passed) */ writeNote: (note: NoteProps, opts?: EngineWriteOptsV2) => Promise; writeSchema: (schema: SchemaModuleProps, opts?: EngineSchemaWriteOpts) => Promise; }; export declare type WorkspaceSettings = { folders: WorkspaceFolderRaw[]; settings: any | undefined; extensions: WorkspaceExtensionSetting; }; export declare type WorkspaceFolderRaw = { path: string; name?: string; }; export interface WorkspaceFolderCode { /** * The associated uri for this workspace folder. * * *Note:* The {@link Uri}-type was intentionally chosen such that future releases of the editor can support * workspace folders that are not stored on the local disk, e.g. `ftp://server/workspaces/foo`. */ readonly uri: URI; /** * The name of this workspace folder. Defaults to * the basename of its {@link Uri.path uri-path} */ readonly name: string; /** * The ordinal number of this workspace folder. */ readonly index: number; } export declare type WorkspaceExtensionSetting = { recommendations: string[]; unwantedRecommendations: string[]; }; export declare type DEngine = DCommonProps & DCommonMethods & { vaults: DVault[]; hooks: DHookDict; init: () => Promise; /** * Get NoteProps by id. If note doesn't exist, return error */ getNote: (id: string) => Promise; /** * Get NoteProps metadata by id. If note doesn't exist, return error */ getNoteMeta: (id: string) => Promise; /** * Bulk get NoteProps by list of ids */ bulkGetNotes: (ids: string[]) => Promise; /** * Bulk get NoteProps metadata by list of ids */ bulkGetNotesMeta: (ids: string[]) => Promise; /** * Find NoteProps by note properties. If no notes match, return empty list */ findNotes: (opts: FindNoteOpts) => Promise; /** * Find NoteProps metadata by note properties. If no notes metadata match, return empty list */ findNotesMeta: (opts: FindNoteOpts) => Promise; /** * Delete note from metadata store and/or filesystem. If note doesn't exist, return error */ deleteNote: (id: string, opts?: EngineDeleteOpts) => Promise; deleteSchema: (id: string, opts?: EngineDeleteOpts) => Promise; info: () => Promise; getSchema: (id: string) => Promise; querySchema: (qs: string) => Promise; /** * Query for NoteProps */ queryNotes: (opts: QueryNotesOpts) => Promise; /** * Query for NotePropsMeta */ queryNotesMeta: (opts: QueryNotesOpts) => Promise; /** * Rename note from old DNoteLoc to new DNoteLoc. New note keeps original id */ renameNote: (opts: RenameNoteOpts) => Promise; renderNote: (opts: RenderNoteOpts) => Promise; getNoteBlocks: (opts: GetNoteBlocksOpts) => Promise; /** Make sure to call this with plain VSRange and not vscode.Range objects, which can't make it across to the API */ getDecorations: (opts: GetDecorationsOpts) => Promise; }; /** * Implements the engine interface but has no backend store * ^sdxp5tjokad9 */ export declare type DEngineClient = Omit; export declare type DStore = DCommonProps & DCommonMethods & { /** * @deprecated * For access, see {@link DEngine.getNote} * Dictionary where key is the note id. */ notes: NotePropsByIdDict; /** * @deprecated * For access, see {@link DEngine.findNotes} * Dictionary where the key is lowercase note fname, and values are ids of notes with that fname (multiple ids since there might be notes with same fname in multiple vaults). */ noteFnames: NotePropsByFnameDict; init: () => Promise; /** * Get NoteProps by id. If note doesn't exist, return error */ getNote: (id: string) => Promise; getSchema: (id: string) => Promise; /** * @deprecated: Use {@link DEngine.writeNote} * @param note * @param opts * @returns The updated note. If `newNode` is set, this will have the updated parent id */ updateNote(note: NoteProps, opts?: EngineUpdateNodesOptsV2): Promise; /** * Find NoteProps by note properties. If no notes match, return empty list */ findNotes: (opts: FindNoteOpts) => Promise; deleteNote: (id: string, opts?: EngineDeleteOpts) => Promise; deleteSchema: (id: string, opts?: EngineDeleteOpts) => Promise; renameNote: (opts: RenameNoteOpts) => Promise; }; export declare type WorkspaceVault = { wsRoot: string; vault: DVault; }; export declare type WorkspaceOpts = { wsRoot: string; vaults: DVault[]; dendronConfig?: DendronConfig; }; export declare type DPod = { config: any; execute(opts: BasePodExecuteOpts): Promise; }; export declare type PodConfig = { key: string; description: string; type: "string" | "number" | "boolean" | "object"; required?: boolean; default?: any; example?: string; }; export declare type BasePodExecuteOpts = { config: TConfig; engine: DEngineClient; wsRoot: string; vaults: DVault[]; utilityMethods?: any; }; export declare enum MergeConflictOptions { OVERWRITE_LOCAL = "Overwrite local value with remote value", OVERWRITE_REMOTE = "Overwrite remote value with local value", SKIP = "Skip this conflict(We will not merge, you'll resolve this manually)", SKIP_ALL = "Skip All (you'll resolve all next conflicted entries manually) " } export declare type Conflict = { /** * Existing note */ conflictNote: NoteProps; /** * Newly written note */ conflictEntry: NoteProps; /** * Conflicted Data */ conflictData: string[]; }; export declare type PodConflictResolveOpts = { options: () => string[]; message: (conflict: Conflict) => string; validate: (choice: number, options: string[]) => any; }; export declare type DMessage = { type: TType; data: TData; source: TSource; }; export declare enum DMessageSource { vscode = "vscode", webClient = "webClient" } export declare enum DMessageEnum { /** * View is ready */ INIT = "init", ON_DID_CHANGE_ACTIVE_TEXT_EDITOR = "onDidChangeActiveTextEditor", ON_UPDATE_PREVIEW_HTML = "onUpdatePreviewHTML", MESSAGE_DISPATCHER_READY = "messageDispatcherReady" } export declare enum GraphViewMessageEnum { "onSelect" = "onSelect", "onGetActiveEditor" = "onGetActiveEditor", "onReady" = "onReady", "onRequestGraphOpts" = "onRequestGraphOpts", "onGraphLoad" = "onGraphLoad", "onGraphThemeChange" = "onGraphThemeChange", "configureCustomStyling" = "configureCustomStyling", "toggleGraphView" = "toggleGraphView", "onGraphDepthChange" = "onGraphDepthChange", "toggleGraphEdges" = "toggleGraphEdges" } export declare enum CalendarViewMessageType { "onSelect" = "onSelect", "onGetActiveEditor" = "onGetActiveEditor", "messageDispatcherReady" = "messageDispatcherReady" } export declare enum NoteViewMessageEnum { "onClick" = "onClick", "onGetActiveEditor" = "onGetActiveEditor", "onLock" = "onLock", "onUnlock" = "onUnlock" } export declare enum LookupViewMessageEnum { "onUpdate" = "onUpdate", "onValuesChange" = "onValuesChange", "onRequestControllerState" = "onRequestControllerState" } export declare enum ThemeMessageType { "onThemeChange" = "onThemeChange", "getTheme" = "getTheme" } export declare enum SeedBrowserMessageType { "onSeedAdd" = "onSeedAdd", "onOpenUrl" = "onOpenUrl", "onSeedStateChange" = "onSeedStateChange" } export declare enum ConfigureUIMessageEnum { "onUpdateConfig" = "onUpdateConfig", "openDendronConfigYaml" = "openDendronConfigYaml" } export declare enum GraphThemeEnum { Block = "Block", Classic = "Classic", Monokai = "Monokai", Custom = "Custom" } export declare enum GraphTypeEnum { fullGraph = "fullGraph", localGraph = "localGraph" } export declare type OnDidChangeActiveTextEditorData = { note: NoteProps | undefined; /** * Sync all notes */ sync?: boolean; /** * Sync the changed note */ syncChangedNote?: boolean; /** * Current active note. * If activeNote is defined, view will set that note as active note. Otherwise default to {@param note} */ activeNote?: NoteProps; }; export declare type OnUpdatePreviewHTMLData = { note: NoteProps; html: string; }; export declare type NoteViewMessageType = DMessageEnum | NoteViewMessageEnum; export declare type GraphViewMessageType = DMessageEnum | GraphViewMessageEnum; export declare type ConfigureUIMessageType = DMessageEnum | ConfigureUIMessageEnum; export declare type VSCodeMessage = DMessage; export declare type OnDidChangeActiveTextEditorMsg = DMessage<"onDidChangeActiveTextEditor", OnDidChangeActiveTextEditorData>; export declare type OnUpdatePreviewHTMLMsg = DMessage; export declare type GraphViewMessage = DMessage; export declare type ConfigureUIMessage = DMessage; export declare type CalendarViewMessage = DMessage; export declare type NoteViewMessage = DMessage; export declare type SeedBrowserMessage = DMessage; export declare type LookupViewMessage = DMessage; export declare type Awaited = T extends PromiseLike ? U : T;