Skip to content

refactor(superdoc): publicize SearchMatch on the public type contract (SD-2828)#3105

Merged
caio-pizzol merged 1 commit into
mainfrom
caio/SD-2828-search-match
May 4, 2026
Merged

refactor(superdoc): publicize SearchMatch on the public type contract (SD-2828)#3105
caio-pizzol merged 1 commit into
mainfrom
caio/SD-2828-search-match

Conversation

@caio-pizzol

Copy link
Copy Markdown
Contributor

Promotes `SearchMatch` (and its `DocRange` companion) from a private search-extension typedef to the public `superdoc` type contract. Consumers wiring a custom search UI now get real field types on `id`, `from`, `to`, `text` instead of `Object`.

  • `SuperDoc.search()` returns `SearchMatch[] | undefined`
  • `SuperDoc.goToSearchResult(match)` accepts `SearchMatch`
  • New consumer fixture reads each public field and round-trips a result through `goToSearchResult`; strict `Equal<A,B>` assertions fail CI if either signature drifts.

Why now: this is the next item on the SD-2828 closeout list after the provider widening (#3101). No runtime change.

Review: confirm `SearchMatch` mirrors the source typedef in the search extension (`text`, `from`, `to`, `id`, optional `ranges` and `trackerIds`). The `all-public-types.ts` diff is two regenerated entries from the `--write` step.
Verified: consumer matrix 39/39, check:jsdoc clean, build:es declaration audit clean, SuperDoc.test.js 79/79.

… (SD-2828)

Promote `SearchMatch` (and its `DocRange` companion) from a private
search-extension typedef to the public `superdoc` type contract. Wires
`SuperDoc.search()` to `SearchMatch[] | undefined` and
`SuperDoc.goToSearchResult()` to `SearchMatch`, so consumers wiring a
custom search UI get real types on `id`, `from`, `to`, `text`
instead of `Object`.

Adds a consumer fixture that destructures the public fields and
round-trips a result through `goToSearchResult`, plus strict
`Equal<A,B>` type-equality assertions so a future re-narrowing or
field strip surfaces as a CI failure.
@caio-pizzol
caio-pizzol requested a review from a team as a code owner May 4, 2026 00:42
@linear

linear Bot commented May 4, 2026

Copy link
Copy Markdown

@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 eac8bcc into main May 4, 2026
74 checks passed
@caio-pizzol
caio-pizzol deleted the caio/SD-2828-search-match branch May 4, 2026 09:07
@superdoc-bot

superdoc-bot Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in @superdoc-dev/mcp v0.3.0-next.37

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in vscode-ext v2.3.0-next.81

@superdoc-bot

superdoc-bot Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in @superdoc-dev/react v1.2.0-next.79

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in superdoc-cli v0.8.0-next.55

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in superdoc v1.30.0-next.38

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in superdoc-sdk v1.8.0-next.40

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in superdoc-cli v0.9.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in superdoc v1.32.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in @superdoc-dev/mcp v0.4.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in @superdoc-dev/react v1.3.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in vscode-ext v2.4.0

@superdoc-bot

superdoc-bot Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

πŸŽ‰ This PR is included in superdoc-sdk v1.9.0

artemnistuley pushed a commit to artemnistuley/SuperDoc that referenced this pull request May 26, 2026
Closes out SD-2980's helper typing. The remaining 4 public helpers
exported via `trackChangesHelpers` (under `superdoc/super-editor`) now
carry concrete JSDoc and emit real return shapes instead of
`any` / `any[]`:

- `getLiveInlineMarksInRange({ doc, from, to })` β†’ `PmMark[]`
- `findTrackedMarkBetween({ tr, from, to, markName, attrs?, offset? })`
  β†’ `TrackedMarkRange | null`
- `trackedTransaction({ tr, state, user, replacements? })` β†’ `Transaction`
- `getTrackChanges(state, id?)` β†’ `TrackedMarkRange[]`

Reuses the existing `trackChangesHelpers/types.js` from PR B; adds one
new typedef:

- `TrackedMarkRange = { from: number; to: number; mark: PmMark }`
  shared by `findTrackedMarkBetween`'s non-null return and
  `getTrackChanges`'s array element.

`trackedTransaction.js` notes: the previous JSDoc used the single-blob
`@param {{ ... }} params` form, which does NOT bind to the destructured
arrow signature in vite-plugin-dts emit. Switched to per-property style
(matches PR B's working `findMarkInRangeBySnapshot` pattern). Also
deleted `trackedTransaction.d.ts` β€” a hand-written shim added in superdoc-dev#3105
that pinned the emit to `(...args: any[]): any` and silently shadowed
the real JSDoc. The shim is NOT in the `check-dts-shadows` allowlist
(only `packages/collaboration-yjs/` is), so deletion aligns with the
SD-2922 policy.

Drains the final 14 of 14 PR C audit findings; `tier-3-helpers` reaches
0 for the first time (total broad audit 171 β†’ 157). The remaining
broad findings live outside SD-2980 scope (`tier-5-other`,
`tier-4-public-contract` for SD-3235). Supported-root strict gate
remains 0.

Consumer fixture `track-changes-helpers-typed.ts` extended with PR C
coverage: each new helper's return type, element members
(`mark.type.name`, `from`, `to`), `Transaction` PM surface
(`.docChanged`, `.steps`), literal-union `replacements`, nullable
state, and `@ts-expect-error` on bad-shape args.

Scope intentionally narrow: no other trackChangesHelpers files touched
(internal step builders untouched), no helper de-dupe, no refactors.

Verified: type-check clean; pnpm test:editor β†’ 13120 pass;
deep-type-audit --pack β†’ 157 findings (was 171); --strict-supported-root
β†’ PASS (0 entries); typecheck-matrix β†’ 79/79.
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