Skip to content

feat(docs): document embedded-API entity types as an APIModels reference#2305

Merged
mariechatfield merged 8 commits into
mainfrom
marie/api-models-reference-docs
Jun 30, 2026
Merged

feat(docs): document embedded-API entity types as an APIModels reference#2305
mariechatfield merged 8 commits into
mainfrom
marie/api-models-reference-docs

Conversation

@mariechatfield

Copy link
Copy Markdown
Contributor

Summary

Documents the @gusto/embedded-api entity types in the SDK reference. Previously every hook/component that returned a raw embedded-API type (Form, Employee, Compensation, …) rendered it as bare, unlinked text in the generated tables, because those types live outside TypeDoc's entry point.

  • Re-export the referenced models/components/* entity types through a generated barrel (src/models/external.ts), surfaced as the APIModels namespace from src/index.ts, so TypeDoc documents their full shapes and every reference becomes a link.
  • Generator (build/deriveExternalModels.ts, wired in via models:derive / models:verify):
    • version-agnostic (reads the dated package + repo + version from the package's own package.json)
    • auto-detects value-enums vs type-only re-exports
    • backfills a TSDoc summary for entities the upstream package doesn't document (otherwise excludeNotDocumented silently drops them)
    • follows transitive type references (same-file siblings + ./<module> imports) so sub-types like DepartmentEmployees, Job, MinimumWages are documented and linked instead of rendering bare
    • formats its output with the repo's Prettier config so the auto-derived file passes format:check
  • Rewrites {@link Entity} prose refs to {@link APIModels.Entity}.
  • Each entity's "Defined in" links to gusto-typescript-client at the installed version tag (e.g. …/blob/gusto_embedded_v_2025_11_15/v0.0.2/…#L11), with the correct source line.
  • Sidebar: APIModels is pinned to the end as "API Models" (its own group, not under "Namespaces").
  • CI: a dedicated derive-models job single-sources the barrel; build (→ API report) and derive-check-src (→ docs) both consume that one artifact, so external.ts + docs + report regenerate consistently in one derive-commit.

Distributed size impact

Does the barrel bloat the published package / pull every model in via tree-shaking?

No runtime impact. The namespace is exported type-only (export type * as APIModels), so it is fully erased from the JS bundle.

main (before) this branch (after) Δ
Runtime JS (dist/**/*.js) 2082.2 KB 2082.2 KB 0
Type declarations (dist/**/*.d.ts) ~1316.8 KB 1346.5 KB +29.7 KB

Why there's no runtime cost or tree-shaking hazard:

  • No external.js chunk is emitted, and APIModels appears in zero dist JS files — the type-only namespace re-export is stripped by the TS transform before bundling.
  • dist/models/external.d.ts is 29.7 KB of re-export lines only — zero inlined type bodies. The actual model definitions stay in @gusto/embedded-api (already a dependency); they are not copied into our dist.
  • Tree-shaking is moot: there is no runtime code to shake. A consumer that references APIModels.Employee pulls only the type into their type-check — nothing into their bundle. The value-enums the barrel re-exports (GarnishmentType, etc.) are reached at runtime only via their existing direct imports in components, never via this barrel.

So the entire footprint of this feature on the published artifact is ~30 KB of additional .d.ts re-export lines, and 0 bytes of runtime JS.

Generated output

docs/reference/** and .reports/*.md are intentionally not committed here — CI's derive step regenerates and commits them (it already has on this branch). src/models/external.ts is committed because it is part of the compile graph.

🤖 Generated with Claude Code

mariechatfield and others added 8 commits June 29, 2026 15:32
Re-export the @gusto/embedded-api component entity types referenced across src
through src/models/external.ts, surfaced as the APIModels namespace, so TypeDoc
documents their shapes in the reference instead of rendering bare unlinked text.

- build/deriveExternalModels.ts generates the barrel (version-agnostic; auto
  value/type detection; backfills TSDoc summaries for entities the upstream
  package leaves undocumented, which excludeNotDocumented would otherwise drop).
  Wired in via models:derive / models:verify.
- rewrite {@link Entity} prose refs to {@link APIModels.Entity}.
- typedoc-custom router: link each entity's "Defined in" to gusto-typescript-client
  at the installed package's version tag, and place APIModels last in the sidebar
  as "API Models" (its own group, not under Namespaces).

Generated reference output (docs/reference, .reports) intentionally left for CI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a derive-models job that generates src/models/external.ts once and uploads it
as the derived-models artifact. build (→ dist → API report) and derive-check-src
(→ TypeDoc docs) both download that single artifact, so every derived output in a
run reflects the same barrel. derive-commit pushes external.ts, docs, and the API
report together as one self-consistent commit; a stale barrel hard-fails on
main/merge_group/dependabot.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
deriveExternalModels emitted raw output, so CI's derive-commit pushed an
unformatted src/models/external.ts that failed format:check. Run the rendered
barrel through the repo's Prettier config before writing so models:derive output
matches format:check and the auto-derived commit stays green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Introduces a new @gusto/embedded-api component entity (Department) into src so
CI's derive-models picks it up. Intentionally commits only the source import —
external.ts, the reference docs, and the API report are left for CI's
derive-commit to regenerate, to verify they all update in a single commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
deriveExternalModels now follows each referenced entity's type references —
same-file siblings and ./<module> imports within models/components — so sub-types
(e.g. a department's employees/contractors, an employee's jobs/garnishments) are
documented and linked in the APIModels reference instead of rendering bare.

Also reverts the temporary Department reference added to exercise the auto-derive
pipeline. external.ts, the reference docs, and the API report are left for CI's
derive-commit to regenerate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mariechatfield mariechatfield marked this pull request as ready for review June 30, 2026 17:39
@mariechatfield mariechatfield requested a review from a team as a code owner June 30, 2026 17:39
@mariechatfield mariechatfield added this pull request to the merge queue Jun 30, 2026
Merged via the queue into main with commit 6884330 Jun 30, 2026
34 checks passed
@mariechatfield mariechatfield deleted the marie/api-models-reference-docs branch June 30, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants