Skip to content

Added public api surfaces to the admin domains - #30317

Merged
9larsons merged 2 commits into
mainfrom
slars/domain-api-surfaces
Aug 26, 2026
Merged

9larsons merged 2 commits into
mainfrom
slars/domain-api-surfaces

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

The shell (routes.tsx, layout/) deep-imported domain internals, and only analytics had a declared public surface. Every domain now exposes an api.ts mirroring analytics/api.ts, and dependency-cruiser keeps it that way.

  • Per-domain api.ts: members and posts/analytics also gain their own routes.tsx fragments (their route definitions move out of the shell table, mirroring analytics); tags/comments/automations/onboarding/whats-new/settings export exactly what the shell and other domains consume. Lazy entries are exported thunks — dynamic import()s stay inside the domains, so code-splitting is preserved: 358 chunks before and after, name multiset identical (entry +0.4 kB from the small members helpers now in the entry graph). Settings internals untouched beyond import lines (draft Changed settings screens to read the framework data hooks #30285 owns them).
  • Strays re-homed: buildMembersUrl + member-format helpers + shared-views parsing → via members/api (posts/comments/settings/layout consumers updated); whats-new pieces → whats-new/api; BrandIcon + its 20 SVGs → src/shared/brand-icon/ (git-mv, history preserved); AccessRule/AccessRouteHandle → new src/route-access.ts types module; NotFound → src/shared/. One upward import deliberately left: latest-post.tsx → useIsEmberOwnedRoute from @/routes (moving it drags the routes table; dies with Ember).
  • depcruise: admin-domains-cross-via-api-only (domain → other domain only via api.ts, own-domain exempt via group capture) and admin-shell-into-domains-via-api-only (src-root + layout → domains via api.ts). Both cover the @/ specifier and resolved-path shapes; proven firing with three deliberate violations (both rules, both shapes), then reverted — and the clean pass over ~870 same-domain self-imports proves the exemption.

67 files, +255/−117.

Verification: tsc -b clean; eslint 0 errors; test:unit 140 files / 1644; acceptance across route-access/settings-routing/home/tags/members/analytics/automations/whats-new 8 files / 41, no flakes; pnpm lint:boundaries clean (5,285 modules); production-build chunk comparison as above; oxfmt clean on touched files.

no ref

The admin shell (routes.tsx), the layout, and several domains deep-imported
other domains' internals, so every screen move risked breaking unrelated
folders. Each domain (members, tags, comments, automations, posts, onboarding,
whats-new, settings) now exposes an api.ts mirroring analytics/api.ts, and the
shell, layout, and cross-domain consumers import only those surfaces. Route
definitions the shell held inline (members children, the posts analytics
subtree) moved into their domains; lazy entries stay dynamic imports inside the
domains so route-level code-splitting is unchanged (production build emits an
identical chunk inventory).

Cross-domain strays were re-homed: buildMembersUrl, the member formatting
helpers, and the shared-views parsing now flow through members/api.ts; the
whats-new dialog, banner, and hooks through whats-new/api.ts; BrandIcon and its
svg set moved from settings to src/shared/brand-icon; the AccessRule types
moved to src/route-access.ts and NotFound to src/shared so domains no longer
import shell files.

Two dependency-cruiser rules keep it that way: domains may import a different
domain only via its api.ts, and the shell and layout may import domains only
via api.ts. Both rules were proven to fire on deliberate violations in the
unresolved @/-specifier and resolved relative shapes, then the violations were
reverted.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Pro Plus

Run ID: bc7dd04d-177f-49f4-b34e-5697ad9b4bb6

📥 Commits

Reviewing files that changed from the base of the PR and between c63173f and 83838e2.

📒 Files selected for processing (1)
  • .dependency-cruiser.cjs

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Setup
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
.dependency-cruiser.cjs (2)

144-162: LGTM!


163-181: LGTM!


Walkthrough

The admin application now exposes domain functionality through public api.ts modules. Routes and modal hosts use centralized lazy loaders and route-child configurations. Shared route-access types and a shared NotFound component were added. Existing consumers now import members and brand-icon functionality through public or shared modules. Dependency-cruiser rules enforce API-only imports between domains and from the admin shell.

Suggested reviewers: erisds

Merge Risk: ⚪ Minimal · up to 83838

This PR reorganizes admin domain exports and imports while preserving code-splitting and existing production behavior; no actionable merge-blocking risk remains after the reported checks.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding public API surfaces to the admin domains. It is concise and specific.
Description check ✅ Passed The description directly explains the domain API surfaces, import changes, dependency-cruiser rules, code-splitting preservation, and verification results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Type-Safe Boundaries ✅ Passed PASS — The PR diff adds API re-exports, lazy dynamic imports, route definitions, and import-path changes. It adds no HTTP/SDK, environment, database/filesystem, queue, webhook, or event-payload consum…
New Files Are Typescript ✅ Passed PASS. In the full PR diff (HEAD^^..HEAD), all added source files use .ts or .tsx. No new .js, .jsx, .cjs, or .mjs file was added. .dependency-cruiser.cjs was pre-existing and modified …
Full details: Type-Safe Boundaries

Explanation

PASS — The PR diff adds API re-exports, lazy dynamic imports, route definitions, and import-path changes. It adds no HTTP/SDK, environment, database/filesystem, queue, webhook, or event-payload consumption. The added source contains no any, unknown, @ts-ignore, @ts-nocheck, or unchecked as cast, and it adds no Zod-shaped duplicate type. The existing route-handle cast remains unchanged and concerns internal route metadata.

Full details: New Files Are Typescript

Explanation

PASS. In the full PR diff (HEAD^^..HEAD), all added source files use .ts or .tsx. No new .js, .jsx, .cjs, or .mjs file was added. .dependency-cruiser.cjs was pre-existing and modified as a configuration file, which is exempt.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slars/domain-api-surfaces

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit c63173f

Command Status Duration Result
nx run @tryghost/admin:test:acceptance ✅ Succeeded 7m 44s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 19s View ↗
nx run @tryghost/admin:build ✅ Succeeded 5s View ↗
nx run-many -t test:unit -p @tryghost/admin ✅ Succeeded 6s View ↗
nx run-many -t lint -p ghost-monorepo,@tryghost... ✅ Succeeded 4s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-26 13:11:39 UTC

no ref

Review follow-up: the shell-into-domains rule policed only top-level src
files and layout/; hooks/, providers/, ember-bridge/, utils/ and schemas/
could still deep-import domain internals. The from-clause now covers the
non-domain support folders; proven firing from hooks/ with a deliberate
violation, then reverted.
@github-actions

Copy link
Copy Markdown
Contributor

E2E Tests Failed

To view the Playwright test report locally, run:

REPORT_DIR=$(mktemp -d) && gh run download 32970642110 -n playwright-report -D "$REPORT_DIR" && npx playwright show-report "$REPORT_DIR"

@9larsons
9larsons merged commit bfdfe58 into main Aug 26, 2026
50 checks passed
@9larsons
9larsons deleted the slars/domain-api-surfaces branch August 26, 2026 15:21
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.

1 participant