@telefonica/markdown-confluence-sync
Version:
Creates/updates/deletes Confluence pages based on markdown files in a directory. Supports Mermaid diagrams and per-page configuration using frontmatter metadata. Works great with Docusaurus
93 lines (92 loc) • 3.89 kB
TypeScript
import type { OptionDefinition, OptionInterfaceOfType } from "@mocks-server/config";
import type { LogLevel } from "@mocks-server/logger";
import type { SyncModes } from "@telefonica/confluence-sync";
export type FilesPattern = string | string[];
export interface FileMetadata {
/** Path to the file */
path: string;
/** Confluence page id */
id?: string;
/** Confluence page title */
title?: string;
/** Short name of the page to be used in the names of the child pages, when assigning namespacing */
shortName?: string;
/** Whether to sync or not the page */
sync?: boolean;
}
export type FilesMetadata = FileMetadata[];
export type ContentPreprocessor = (content: string, path: string) => string;
export type DryRun = boolean;
declare global {
namespace MarkdownConfluenceSync {
interface Config {
/** Configuration options */
config?: {
/** Read configuration from file */
readFile?: boolean;
/** Read configuration from arguments */
readArguments?: boolean;
/** Read configuration from environment */
readEnvironment?: boolean;
};
/** Log level */
logLevel?: LogLevel;
/** Working Directory */
cwd?: string;
/** Mode to structure pages */
mode?: SyncModes;
/**
* Pattern to search files when flat or id mode are active
* @see {@link https://github.com/isaacs/node-glob#globpattern-string--string-options-globoptions--promisestring--path | Node Glob Pattern}
* @see {@link https://github.com/isaacs/node-glob#glob-primer}
* */
filesPattern?: FilesPattern;
/** Metadata for specific files */
filesMetadata?: FilesMetadata;
/** Patterns of files to ignore */
ignore?: FilesPattern[];
/** Hook enabling to modify the content of files before processing them */
preprocessor?: ContentPreprocessor;
/** Process markdown files without sending them to confluence-sync */
dryRun?: DryRun;
}
}
}
export type Configuration = MarkdownConfluenceSync.Config;
export type LogLevelOptionDefinition = OptionDefinition<LogLevel, {
hasDefault: true;
}>;
export type LogLevelOption = OptionInterfaceOfType<LogLevel, {
hasDefault: true;
}>;
export type ModeOptionDefinition = OptionDefinition<SyncModes, {
hasDefault: true;
}>;
export type ModeOption = OptionInterfaceOfType<SyncModes, {
hasDefault: true;
}>;
export type FilesPatternOptionDefinition = OptionDefinition<FilesPattern>;
export type FilesPatternOption = OptionInterfaceOfType<FilesPattern>;
export type FilesIgnoreOptionDefinition = OptionDefinition<FilesPattern>;
export type FilesIgnoreOption = OptionInterfaceOfType<FilesPattern>;
export type FilesMetadataOptionDefinition = OptionDefinition<FilesMetadata>;
export type FilesMetadataOption = OptionInterfaceOfType<FilesMetadata>;
export type ContentPreprocessorOptionDefinition = OptionDefinition<ContentPreprocessor>;
export type ContentPreprocessorOption = OptionInterfaceOfType<ContentPreprocessor>;
export type MainDryRunOptionDefinition = OptionDefinition<boolean, {
hasDefault: true;
}>;
export type MainDryRunOption = OptionInterfaceOfType<boolean, {
hasDefault: true;
}>;
/** Creates a MarkdownConfluenceSync interface */
export interface MarkdownConfluenceSyncConstructor {
/** Returns MarkdownConfluenceSync interface
* @returns MarkdownConfluenceSync instance {@link MarkdownConfluenceSyncInterface}.
*/
new (options: MarkdownConfluenceSync.Config): MarkdownConfluenceSyncInterface;
}
export interface MarkdownConfluenceSyncInterface {
/** Sync pages in Confluence*/
sync(): Promise<void>;
}