Skip to content

feat(public-facade): re-curate root index.ts with three tiers (SD-3212 b)#3389

Merged
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/SD-3212-b-recurate-public-index
May 19, 2026
Merged

feat(public-facade): re-curate root index.ts with three tiers (SD-3212 b)#3389
caio-pizzol merged 2 commits into
mainfrom
caio-pizzol/SD-3212-b-recurate-public-index

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol commented May 19, 2026

PR B of the SD-3212 (Phase 4b) sequence. Grows packages/superdoc/src/public/index.ts from 24 exports to 200, organized into three tiers per the classification artifact merged in #3380.

Distribution:

Tier Count
supported-root 132
legacy-root 60
internal-candidate 8

The three tiers:

  1. Supported root — documented public API; first-class root surface. Clean re-exports.
  2. Legacy root — typed for backward compatibility; not the recommended path. Per-name @deprecated JSDoc only where a real replacement exists (e.g. editor.commands.*editor.doc.*). Section-level framing carries "legacy compat" intent when no replacement exists.
  3. Internal candidate — accidental implementation leak. Kept typed under compat re-export with @internal so a future major can remove it. Only at root because at least one supported/legacy export reaches it transitively (enforced by the SD-3212 a1b closure gate).

Load-bearing architectural decision — please scrutinize: src/public/index.ts intentionally uses deep @superdoc/common/... imports at the source level (e.g. import { DOCX, PDF, HTML } from '@superdoc/common/document-types'). At source, deep imports are needed because the package-root re-export form (from '@superdoc/common') trips vite-plugin-dts into following the export * chain and landing on the WRONG file (shared/common/comments-types.js, which doesn't export these names).

Deep imports normally trip audit-declarations.cjs ("private @superdoc/* specifier in emitted .d.ts"). The existing postbuild inliner in ensure-types.cjs — which already handles this exact problem for src/index.js — has been extended to also patch dist/superdoc/src/public/index.d.ts. It strips the private specifiers from the emitted declarations and inlines local declare const DOCX: 'application/...' declarations.

Net effect:

  • Source side: deep imports (TS compiles them, dts plugin resolves to the correct definitions).
  • Emitted .d.ts: no @superdoc/* specifiers; values appear as local declare consts. Consumers see no behavior change vs src/index.js's historical handling.
  • Audit clean: audit-declarations.cjs no longer sees the private specifier (stripped postbuild).

If a reviewer is uncomfortable with the deep-imports + strip pattern, the alternative is filing a separate ticket against vite-plugin-dts for cross-package export * resolution. The strip-and-inline approach is the same one the codebase has been relying on for src/index.js since before SD-3175 — this PR just extends it to the new facade entry point.

Out of scope:

  • No package.json#exports change. PR C owns the root types flip.
  • No removal of any name. Path-as-contract principle: if reachable, must be typed. Removal of internal-candidate names happens in a future major after deprecation cycle.

Verified locally:

  • pnpm --filter superdoc build:es: all build steps green.
    • verify-public-facade-emit: 10 entries clean (root: 200 exports, was 24).
    • audit-declarations: no private @superdoc/* leak in emitted .d.ts.
    • check-export-coverage: 12 entries OK.
  • typecheck-matrix.mjs: 57/57 scenarios pass.
  • snapshot-superdoc-root-exports.mjs --check: matches the locked baseline.
  • check-root-classification-closure.mjs: 0 violations (the closure gate validates that no supported/legacy export references an internal-candidate type).

AGENTS.md update: new "Contributing to the public surface" section documents the three tiers, the four files every public-surface change must update, and the three CI gates that enforce consistency.

Sequence:

Related:

  • Parent: SD-3175 (path-as-contract umbrella)
  • SD-3212 (Phase 4b)
  • SD-3185 (original under-curated facade; this re-curates)

…2 b)

Grows packages/superdoc/src/public/index.ts from 24 exports to 200,
organized into three tiers per the SD-3212 A1 classification artifact:

  - supported-root (132): documented public API; first-class root surface.
  - legacy-root (60): typed for backward compat; not the recommended path.
    Per-name @deprecated JSDoc only where a real replacement exists.
  - internal-candidate (8): accidental implementation leaks; kept typed
    under compat re-export with @internal so a future major can remove
    them. Only at root because at least one supported/legacy export
    reaches them transitively.

Source map driven from src/index.js (runtime imports + JSDoc @typedef
block). All 200 names from the classification artifact accounted for.

vite-plugin-dts re-export resolution gap fixed in ensure-types.cjs:
the @superdoc/common package-root re-exports trip the plugin into
selecting the wrong file (shared/common/comments-types.js). The
existing postbuild inliner now patches dist/superdoc/src/public/index.d.ts
in addition to dist/superdoc/src/index.d.ts, stripping the private
@superdoc/* specifiers and emitting local declarations. Mirrors the
proven approach already used for src/index.js.

verify-public-facade-emit.cjs FACADE_ENTRIES['root (./index)'].expectedNames
grows to all 200 names (was 24). ui (71) preserved from SD-3204.

AGENTS.md adds a 'Contributing to the public surface' section
documenting the three tiers, the required snapshot/verifier updates
on every public-surface change, and the three CI gates that enforce
consistency.

Out of scope:
  - No package.json#exports change (PR C owns the root types flip).
  - No removal of any name (path-as-contract principle: if reachable,
    must be typed).

Verified locally:
  - pnpm --filter superdoc build:es: all build steps green, including
    verify-public-facade-emit (root: 200 exports), audit-declarations
    (no private @superdoc/* leak), check-export-coverage.
  - typecheck-matrix.mjs: 57/57 scenarios pass.
  - snapshot-superdoc-root-exports.mjs --check: matches.
  - check-root-classification-closure.mjs: 0 violations.

After this lands, PR C does the mechanical
package.json#exports['.'].types flip.
@caio-pizzol caio-pizzol requested a review from a team as a code owner May 19, 2026 17:06
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 19, 2026

SD-3212

@github-actions
Copy link
Copy Markdown
Contributor

Agent docs audit

Found deterministic findings on 1 changed agent-doc item(s).

packages/superdoc/AGENTS.md (283 lines)

  • over nested-warn (283 > 200)
  • 1 broken path ref(s)

Broken path refs:

  • superdoc/ui/react

Deterministic L1 only: no AI, no Bash, no secrets. Semantic L2/L3 audit runs weekly on main. Policy: agent-docs-policy.md.

@caio-pizzol
Copy link
Copy Markdown
Contributor Author

The superdoc/ui/react references are npm subpath imports, not filesystem paths; packages/superdoc/package.json#exports['./ui/react'] exists, so the audit's broken-path finding is a false positive. The line-count warning is pre-existing (261 on main, 283 here); this PR adds the SD-3212 contributor rules, and splitting AGENTS.md should be handled separately.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@caio-pizzol caio-pizzol merged commit c2adc19 into main May 19, 2026
71 checks passed
@caio-pizzol caio-pizzol deleted the caio-pizzol/SD-3212-b-recurate-public-index branch May 19, 2026 17:45
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 22, 2026

🎉 This PR is included in superdoc-cli v0.12.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 22, 2026

🎉 This PR is included in superdoc-sdk v1.11.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 22, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.7.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 22, 2026

🎉 This PR is included in superdoc v1.35.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 22, 2026

🎉 This PR is included in @superdoc-dev/react v1.6.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 22, 2026

🎉 This PR is included in vscode-ext v2.7.0

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