Skip to content

feat: fix node types export, add introspection#1815

Merged
harbournick merged 1 commit intomainfrom
nick/it-37-request-for-zod-schemas-or-typescript-interfaces-for-node
Jan 23, 2026
Merged

feat: fix node types export, add introspection#1815
harbournick merged 1 commit intomainfrom
nick/it-37-request-for-zod-schemas-or-typescript-interfaces-for-node

Conversation

@harbournick
Copy link
Collaborator

Add TypeScript types export and schema introspection for AI agents

Summary

Adds a new superdoc/types export for TypeScript type safety and a getSchemaIntrospection() function for runtime schema discovery. These features address customer requests for better tooling when building AI drafting agents (IT-37).

Changes

New superdoc/types export

  • Exports TypeScript interfaces for all node and mark types
  • NodeName - union of all valid node names (now 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

New getSchemaIntrospection() function

  • 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 'superdoc';

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

@harbournick harbournick self-assigned this Jan 23, 2026
@linear
Copy link

linear bot commented Jan 23, 2026

@caio-pizzol
Copy link
Contributor

oh merged the docs PR already - lmk if we should hide it for now @harbournick

@harbournick harbournick merged commit 9b8d0d4 into main Jan 23, 2026
2 of 4 checks passed
@harbournick harbournick deleted the nick/it-37-request-for-zod-schemas-or-typescript-interfaces-for-node branch January 23, 2026 19:47
harbournick pushed a commit that referenced this pull request Jan 23, 2026
# [1.9.0-next.1](v1.8.3...v1.9.0-next.1) (2026-01-23)

### Bug Fixes

* preserve style on row insertion ([#1553](#1553)) ([92f67dc](92f67dc))
* table resize ([#1821](#1821)) ([e7e1eb8](e7e1eb8))

### Features

* fix node types export, add introspection ([#1815](#1815)) ([9b8d0d4](9b8d0d4))
@harbournick
Copy link
Collaborator Author

🎉 This PR is included in version 1.9.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

harbournick pushed a commit that referenced this pull request Jan 29, 2026
# [1.9.0](v1.8.3...v1.9.0) (2026-01-29)

### Bug Fixes

* add typesVersions for TypeScript subpath exports ([#1851](#1851)) ([923ab29](923ab29))
* annotation and interaction issues ([#1847](#1847)) ([ffb1055](ffb1055))
* annotation formatting ([0ac67b2](0ac67b2))
* apply correct style to inserted links ([#1871](#1871)) ([36e3c4b](36e3c4b))
* block ID collisions and missing positions in paragraph converter ([3e75a98](3e75a98))
* correct cursor position when typing after fully track-deleted content ([#1828](#1828)) ([8de1c5f](8de1c5f))
* **export:** prefix Relationship IDs with rId for valid xsd:ID ([#1855](#1855)) ([11e67e1](11e67e1))
* incorrect list counter calculation (SD-1658) ([#1867](#1867)) ([a960a65](a960a65))
* list numbering sync for cloned defs and zero start overrides ([c21301b](c21301b))
* make test:slow script find the slow test file ([5a6b6d6](5a6b6d6))
* patch broken numbering definitions ([#1848](#1848)) ([f34b121](f34b121))
* preserve style on row insertion ([#1553](#1553)) ([92f67dc](92f67dc))
* preserve text selection on right-click in Firefox ([#1826](#1826)) ([0a23338](0a23338))
* remove redundant parameters in pm-adapter (SD-1587) ([#1823](#1823)) ([e315ad4](e315ad4))
* table resize ([#1821](#1821)) ([e7e1eb8](e7e1eb8))
* text in new paragraph doesn't inherit styles (SD-1657) ([#1869](#1869)) ([275fef2](275fef2))

### Features

* dev collab mode ([#1860](#1860)) ([469477b](469477b))
* fix node types export, add introspection ([#1815](#1815)) ([9b8d0d4](9b8d0d4))
@harbournick
Copy link
Collaborator Author

🎉 This PR is included in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants