Skip to content

Updated invites service to TypeScript - #32153

Merged
ErisDS merged 1 commit into
mainfrom
codex/invites-typescript
Oct 22, 2026
Merged

ErisDS merged 1 commit into
mainfrom
codex/invites-typescript

Conversation

@ErisDS

@ErisDS ErisDS commented Oct 22, 2026

Copy link
Copy Markdown
Member

Converts invite delivery and acceptance to TypeScript, with explicit request, model and dependency types backed by the published @tryghost/security declarations.

Keeps the existing boot-owned service API, delivery ordering and transactional acceptance flow. Tests, documentation and inventory paths follow the renamed files.

Validation

  • Passed: NX_PARALLEL=1 pnpm check in a clean checkout. The default parallel run hit test timeouts.
  • Passed: pnpm nx run-many -t test:types -p ghost --parallel=2.
  • Passed: 63 focused tests with pnpm --filter ghost exec vitest run test/unit/server/services/invites/ test/unit/server/models/invite.test.js test/unit/server/auth/passwordreset.test.ts test/unit/lib/generate-password.test.ts test/unit/boot/init-core.test.ts --maxWorkers=2.

Checklist

  • I've read and followed the Contributor Guide
  • I've explained my change
  • I've written an automated test to prove my change works

no ref

Make invitation inputs and dependencies explicit while preserving the existing delivery, acceptance, and boot contracts.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between c6cebcd and bdc5932.

📒 Files selected for processing: 7
  • ghost/core/server/services/README.md
  • ghost/core/server/services/invites/accept.ts
  • ghost/core/server/services/invites/index.ts
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/service-inventory.yaml
  • ghost/test/unit/server/services/invites/accept.test.ts
  • ghost/test/unit/server/services/invites/index.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 4
  • GitHub Check: Setup
  • GitHub Check: Detect Tinybird changes
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (actions)
🧰 Additional context used
📚 Code guidelines: 5
tools/README.md — configured
docs/contributing/testing.md — configured
docs/codebase/monorepo-structure.md — configured
docs/codebase/jobs.md — configured
docs/practices/error-handling.md — configured
📓 Path-based instructions: 9
Review new or changed service boundaries for explicit dependency ownership, deterministic/idempotent initialisation, boot ordering, transaction and event semantics, cache coherence, and restart/multi-instance safety.

⚙️ CodeRabbit configuration file

Files:

  • ghost/core/server/services/invites/index.ts
  • ghost/core/server/services/README.md
  • ghost/core/server/services/service-inventory.yaml
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/invites/accept.ts
Review whether tests prove changed behaviour, meaningful error/edge paths, and externally observable contracts without coupling to implementation details.

⚙️ CodeRabbit configuration file

Files:

  • ghost/test/unit/server/services/invites/index.test.ts
  • ghost/test/unit/server/services/invites/accept.test.ts
Review lens: "where does this data become trusted?" Boundary data (HTTP input, external API/SDK responses, env/config, DB/filesystem reads, queue/webhook/event payloads) is `unknown` until validated — Zod by default.

⚙️ CodeRabbit configuration file

Files:

  • ghost/core/server/services/invites/index.ts
  • ghost/test/unit/server/services/invites/index.test.ts
  • ghost/test/unit/server/services/invites/accept.test.ts
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/invites/accept.ts
Prioritise concrete correctness, security, data-integrity, compatibility, and regression risks.

⚙️ CodeRabbit configuration file

Files:

  • ghost/core/server/services/invites/index.ts
  • ghost/test/unit/server/services/invites/index.test.ts
  • ghost/core/server/services/README.md
  • ghost/test/unit/server/services/invites/accept.test.ts
  • ghost/core/server/services/service-inventory.yaml
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/invites/accept.ts
Applicability reference: AGENTS.md: # AGENTS.md **Repository tooling:** read the [tooling ownership guide](tools/README.md) Source excerpt: JavaScript configuration entrypoints and loader adapters can remain JavaScript whe...

📄 CodeRabbit inference engine (tools/README.md)

Files:

  • ghost/core/server/services/invites/index.ts
  • ghost/test/unit/server/services/invites/index.test.ts
  • ghost/core/server/services/README.md
  • ghost/test/unit/server/services/invites/accept.test.ts
  • ghost/core/server/services/service-inventory.yaml
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/invites/accept.ts
Applicability reference: AGENTS.md: # AGENTS.md Start with: [Testing](docs/contributing/testing.md) Source excerpt: Put tests as close as possible to the code and behavior under test: **Ghost Core integration tests** cover...

📄 CodeRabbit inference engine (docs/contributing/testing.md)

Files:

  • ghost/test/unit/server/services/invites/index.test.ts
  • ghost/test/unit/server/services/invites/accept.test.ts
Applicability reference: AGENTS.md: # AGENTS.md Start with: [Monorepo structure](docs/codebase/monorepo-structure.md) AGENTS.md: # AGENTS.md **Ghost Core:** use the [server map](docs/codebase/monorepo-structure.md#ghost-core) Source excerpt...

📄 CodeRabbit inference engine (docs/codebase/monorepo-structure.md)

Files:

  • ghost/core/server/services/invites/index.ts
  • ghost/test/unit/server/services/invites/index.test.ts
  • ghost/core/server/services/README.md
  • ghost/test/unit/server/services/invites/accept.test.ts
  • ghost/core/server/services/service-inventory.yaml
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/invites/accept.ts
Source excerpt: Jobs run in-process and share the main process's initialized services.

📄 CodeRabbit inference engine (docs/codebase/jobs.md)

Files:

  • ghost/core/server/services/invites/index.ts
  • ghost/core/server/services/README.md
  • ghost/core/server/services/service-inventory.yaml
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/invites/accept.ts
Source excerpt: Use that fallback when there is no safe, useful message.

📄 CodeRabbit inference engine (docs/practices/error-handling.md)

Files:

  • ghost/core/server/services/invites/index.ts
  • ghost/core/server/services/README.md
  • ghost/core/server/services/service-inventory.yaml
  • ghost/core/server/services/invites/invites.ts
  • ghost/core/server/services/invites/accept.ts
🔇 Additional comments: 7
ghost/core/server/services/invites/accept.ts: 1

1-37: LGTM!

Also applies to: 49-52, 57-61

ghost/core/server/services/invites/invites.ts: 1

1-70: LGTM!

Also applies to: 81-96, 105-105, 109-111, 202-209, 214-216

ghost/core/server/services/invites/index.ts: 1

2-2: LGTM!

ghost/core/server/services/service-inventory.yaml: 1

5517-5518: LGTM!

Also applies to: 5540-5541, 5573-5574, 5576-5576, 5586-5587, 5611-5611, 5613-5613, 5618-5618, 5630-5630, 5646-5646, 5668-5668, 5690-5690, 5692-5692, 5711-5711, 5716-5716, 5721-5721, 5737-5737, 5742-5742, 5747-5747, 5770-5770, 5773-5773, 5780-5780, 12282-12282

ghost/core/server/services/README.md: 1

52-52: LGTM!

ghost/test/unit/server/services/invites/accept.test.ts: 1

1-4: LGTM!

Also applies to: 9-24, 46-46, 52-54, 56-60, 89-89, 194-195, 217-218, 273-278

ghost/test/unit/server/services/invites/index.test.ts: 1

5-5: LGTM!

Also applies to: 16-16, 19-21, 36-36

Walkthrough

The invitation service and acceptance action now use typed TypeScript imports and exports. The changes add invitation, dependency, and request types; update service inventory and documentation references; and adapt unit tests to typed fixtures. The email-send error handler checks an error’s shape before formatting and logging its message. The acceptance transaction setup retains its internal context, active transaction, and row-lock options.

Priority: ⬇️ Low

Change: Refactor

Merge Risk: ⚪ Minimal · up to bdc59

The invitation service conversion appears ready to merge after normal checks; no actionable regression was established.

Pre-merge checks: Passed 7
Check name Status Explanation
Description check Passed The description clearly explains the TypeScript conversion, preserved service behavior, updated tests, documentation, inventory paths, and validation results.
Title check Passed The title clearly and concisely identifies the primary change: updating the invites service to TypeScript.
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 No explicit type-safe-boundary failure is introduced. The diff adds TypeScript types but no any, unchecked as, @ts-nocheck, or @ts-ignore. The HTTP invitation path still runs the existing `inv…
New Files Are Typescript Passed The PR adds no .js, .jsx, .cjs, or .mjs files. The diff records the JavaScript files as renames to .ts files, and no added path has a prohibited extension.
Tooling Ownership Passed The pull request changes only the invites service, its service inventory/documentation, and adjacent unit tests. It adds or moves no scripts, tools, shared configuration, or tooling folders, so the to…
Full details: Type-Safe Boundaries

Explanation

No explicit type-safe-boundary failure is introduced. The diff adds TypeScript types but no any, unchecked as, @ts-nocheck, or @ts-ignore. The HTTP invitation path still runs the existing invitations validator before service.accept; that validator and the endpoint are unchanged. No invite Zod schema exists that the new types duplicate. The changed mail-error handler narrows unknown errors before reading errorType or message. The model and service calls retain pre-existing internal behavior.

Full details: Tooling Ownership

Explanation

The pull request changes only the invites service, its service inventory/documentation, and adjacent unit tests. It adds or moves no scripts, tools, shared configuration, or tooling folders, so the tooling-ownership placement rules do not apply.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@nx-cloud

nx-cloud Bot commented Oct 22, 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 bdc5932

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 22s View ↗
nx run ghost:test:integration ✅ Succeeded 1m 54s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 4m 58s View ↗
nx run ghost:test:e2e ✅ Succeeded 3m 46s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 22s View ↗
nx run ghost:test:ci:unit ✅ Succeeded 1m 23s View ↗
nx run-many -t test:unit -p ghost,@internal/scr... ✅ Succeeded 57s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 14s View ↗
Additional runs (6) ✅ Succeeded ... View ↗

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


☁️ Nx Cloud last updated this comment at 2026-10-22 09:03:02 UTC

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.30%. Comparing base (11af3e1) to head (bdc5932).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
ghost/core/server/services/invites/invites.ts 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #32153      +/-   ##
==========================================
- Coverage   85.56%   85.30%   -0.27%     
==========================================
  Files        1398     1398              
  Lines       52426    52419       -7     
  Branches     9006     9006              
==========================================
- Hits        44860    44716     -144     
- Misses       6487     6613     +126     
- Partials     1079     1090      +11     
Flag Coverage Δ
e2e-tests 72.53% <60.00%> (-0.08%) ⬇️
unit-tests 67.87% <90.00%> (-0.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ErisDS
ErisDS merged commit e7ab0fe into main Oct 22, 2026
61 checks passed
@ErisDS
ErisDS deleted the codex/invites-typescript branch October 22, 2026 11:41
ErisDS added a commit that referenced this pull request Oct 26, 2026
## Why

Part of the ongoing JavaScript to TypeScript migration, one small PR at
a time. The subject of this test,
`ghost/core/server/services/machine-payments/content-loader.ts`, is
already TypeScript, so its unit test can be converted to use the real
types with no suppressions, no `any`, and no behaviour change.
Developers editing the content loader now get type checking on its test
fakes too.

## What

- Renamed
`ghost/test/unit/server/services/machine-payments/content-loader.test.js`
to `content-loader.test.ts` (git rename, 83% similarity).
- Switched `require` to `import`.
- Added a small local `FakePostModel` type alias for the fake post model
passed to `ContentLoader`.
- Added `assert.ok(entry)` before reading properties of the
`loadFullEntry` result, which is typed `Record<string, unknown> | null`.
This narrows the type and is a strictly stronger assertion than the
original.
- Updated the one `service-inventory.yaml` test path for the
machine-payments entry, as the invites migration (#32153) did; the
inventory test asserts that every listed path exists.
- No tests were deleted. Test names, structure and assertions are
otherwise unchanged.

## How tested

From `ghost/`:

```
pnpm test:single test/unit/server/services/machine-payments/content-loader.test.ts   # 4 passed
pnpm test:types                                                                       # clean
pnpm lint:test                                                                        # clean
pnpm test:unit                                                                        # 756 files passed
```

The full unit run had two failing files,
`test/unit/server/lib/mailgun/mailgun-client.test.js` and
`test/unit/server/lib/mail/ghost-mailer.test.js` (`ERR_INVALID_URL`).
They fail identically on a pristine `origin/main` checkout in the same
sandbox, so they are an environment issue with the sandbox's HTTP proxy
and unrelated to this change.
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