Skip to content

CoreEngine API

Complete API reference for the DocsJS CoreEngine.

Constructor

ts
new CoreEngine(config?: EngineConfig)

Creates a new CoreEngine instance.

Parameters

ParameterTypeDescription
configEngineConfigOptional engine configuration

Example

ts
import { CoreEngine } from "@coding01/docsjs";

const engine = new CoreEngine({
  profile: "knowledge-base",
  plugins: [myPlugin],
});

Methods

transformDocument

ts
transformDocument(file: File, options?: TransformOptions): Promise<TransformResult>

Transform a document file.

Parameters

ParameterTypeDescription
fileFileThe document file to transform
optionsTransformOptionsOptional transformation options

Returns

Promise<TransformResult> - The transformation result

Example

ts
const result = await engine.transformDocument(file);
console.log(result.output);
console.log(result.diagnostics);
console.log(result.metrics);

applyProfile

ts
applyProfile(profileId: string): void

Apply a processing profile.

Parameters

ParameterTypeDescription
profileIdstringThe profile ID to apply

Example

ts
engine.applyProfile("knowledge-base");

registerPlugin

ts
registerPlugin(plugin: PluginConfig): void

Register a custom plugin.

Parameters

ParameterTypeDescription
pluginPluginConfigThe plugin configuration

Example

ts
engine.registerPlugin({
  name: "my-plugin",
  availableHooks: ["afterParse"],
  afterParse: (context) => context,
});

registerProfile

ts
registerProfile(profile: ProfileConfig): void

Register a custom profile.

Parameters

ParameterTypeDescription
profileProfileConfigThe profile configuration

Example

ts
engine.registerProfile({
  id: "custom-profile",
  name: "Custom Profile",
  parse: { features: { mathML: true } },
});

getProfile

ts
getProfile(profileId: string): ProfileConfig | undefined

Get a registered profile.

Parameters

ParameterTypeDescription
profileIdstringThe profile ID

Returns

ProfileConfig | undefined - The profile or undefined

getProfiles

ts
getProfiles(): ProfileConfig[]

Get all registered profiles.

Returns

ProfileConfig[] - Array of profiles

clearPlugins

ts
clearPlugins(): void

Remove all registered plugins.

clearProfiles

ts
clearProfiles(): void

Remove all registered custom profiles.

Types

EngineConfig

ts
interface EngineConfig {
  profile?: string;
  plugins?: PluginConfig[];
  security?: SecurityConfig;
  performance?: PerformanceConfig;
}

TransformOptions

ts
interface TransformOptions {
  profile?: string;
  outputFormat?: "html" | "markdown" | "json";
  plugins?: PluginConfig[];
}

TransformResult

ts
interface TransformResult {
  output: string;
  diagnostics: Diagnostic[];
  metrics: PerformanceMetrics;
  metadata?: DocumentMetadata;
}

Diagnostic

ts
interface Diagnostic {
  type: "error" | "warning" | "info";
  message: string;
  location?: {
    line: number;
    column: number;
  };
  code?: string;
}

PerformanceMetrics

ts
interface PerformanceMetrics {
  parseTime: number;
  transformTime: number;
  renderTime: number;
  totalTime: number;
  memoryUsage?: number;
}

Next Steps

Released under the MIT License.