Skip to main content
This is useful for building AI drafting agents and ensuring type-safe document manipulation.

TypeScript Types Export

Exports TypeScript interfaces for all node and mark types:
  • NodeName - union of all valid node names (expands in IDE hover tooltips)
  • NodeAttrs<N> - get attribute type for a specific node
  • MarkName, MarkAttrs<M> - same for marks
  • Includes all specific attribute interfaces (ParagraphAttrs, TableAttrs, ImageAttrs, etc.)
import type { NodeName, NodeAttrs, ParagraphAttrs } from 'superdoc/types';

// NodeName shows all 39 node types in autocomplete
type Test = NodeAttrs<'paragraph'>; // Resolves to ParagraphAttrs

Schema Introspection

Returns JSON schema summary with all nodes, marks, and their attributes. Useful for AI agents that need schema context for prompt engineering. Supports different modes: docx, html, text
import { getSchemaIntrospection } from '@harbour-enterprises/superdoc';

const schema = await getSchemaIntrospection({ mode: 'docx' });
// Returns: { version, nodes: [...], marks: [...] }

Options

options
Object
Configuration options

Response

{
  "version": "1.8.2",
  "schemaVersion": "current",
  "topNode": "doc",
  "nodes": [
    {
      "name": "paragraph",
      "attrs": {
        "paragraphProperties": { "default": null, "required": false }
      },
      "group": "block",
      "content": "inline*"
    }
  ],
  "marks": [
    {
      "name": "bold",
      "attrs": {},
      "group": "formatting"
    }
  ]
}