Skip to content

Add local mock for Artifacts REST control plane - #209

Merged
kentcdodds merged 1 commit into
mainfrom
cursor/mock-artifacts-local-8d84
Apr 18, 2026
Merged

kentcdodds merged 1 commit into
mainfrom
cursor/mock-artifacts-local-8d84

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Apr 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add Artifacts REST endpoints to the existing Cloudflare mock worker for local development and tests
  • persist mock Artifacts repo state in a dedicated Durable Object so create/get/list/token/fork flows behave consistently
  • document that local dev uses the mock for Artifacts REST calls while full Git transport is still not simulated

Testing

  • npm run test -- --run packages/worker/src/repo/artifacts.node.test.ts packages/worker/src/repo/artifacts-mock-cloudflare.node.test.ts packages/worker/src/mcp/cloudflare/cloudflare-rest-client.node.test.ts packages/worker/src/app/email/cloudflare-email.node.test.ts
  • npm run typecheck
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Documentation

    • Enhanced local development guides to clarify that Artifacts repository operations are mocked during npm run dev without contacting live endpoints.
  • New Features

    • Added comprehensive mock support for Artifacts REST control-plane endpoints (create, list, get, fork, tokens) in local development.
  • Tests

    • Added integration test for local Artifacts mock functionality.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6022ad7f-b2f4-4597-ae25-a3bd936973b6

📥 Commits

Reviewing files that changed from the base of the PR and between aa669bf and 6866af7.

📒 Files selected for processing (8)
  • docs/contributing/architecture/data-storage.md
  • docs/contributing/environment-variables.md
  • docs/contributing/mock-api-servers.md
  • docs/contributing/setup.md
  • packages/mock-servers/cloudflare/src/mock-artifacts-do.ts
  • packages/mock-servers/cloudflare/src/worker.ts
  • packages/mock-servers/cloudflare/wrangler.jsonc
  • packages/worker/src/repo/artifacts-mock-cloudflare.node.test.ts

📝 Walkthrough

Walkthrough

Added a mock Cloudflare Artifacts Durable Object with repo metadata management, REST endpoints for create/get/list/fork/token operations, wrangler binding configuration, worker integration, and integration tests. Documentation updated to clarify mock server scope during local development.

Changes

Cohort / File(s) Summary
Documentation
docs/contributing/architecture/data-storage.md, docs/contributing/environment-variables.md, docs/contributing/mock-api-servers.md, docs/contributing/setup.md
Updated multiple documentation files to clarify that the local Cloudflare mock Worker now routes Artifacts REST control-plane endpoints (repos, tokens, fork) in addition to existing API v4 and email endpoints, and that Git-capable remote operations remain unmocked.
Mock Artifacts Durable Object
packages/mock-servers/cloudflare/src/mock-artifacts-do.ts
New Durable Object implementation with in-memory storage, command dispatch (list, get, create, fork, createToken, count), cursor-based pagination, and a MockCloudflareArtifactsState wrapper class for client interaction.
Worker Integration
packages/mock-servers/cloudflare/src/worker.ts
Extended mock worker to expose Artifacts REST endpoints: list repos, create repo, get repo info, create repo token, and fork repo. Added dashboard display of artifact repo count and new route handling with validation and persistence.
Durable Object Registration
packages/mock-servers/cloudflare/wrangler.jsonc
Registered MockCloudflareArtifactsDurableObject in migrations and added MOCK_CLOUDFLARE_ARTIFACTS_STATE binding across all environments (production, preview, test).
Integration Test
packages/mock-servers/cloudflare/src/worker.ts.node.test.ts
New Vitest integration test that boots local mock with wrangler dev, verifies repo lifecycle (create, get, fork, list) and token generation, validates read-only and remote settings, and confirms metadata counts.

Sequence Diagram

sequenceDiagram
    actor Client
    participant MockWorker as Mock<br/>Worker
    participant DO as Artifacts<br/>Durable Object
    participant Storage as In-Memory<br/>Storage

    Client->>MockWorker: POST /repos<br/>(create repo)
    MockWorker->>DO: fetch with<br/>create command
    DO->>Storage: readStorage()
    Storage-->>DO: load repos
    DO->>Storage: append new repo<br/>+ timestamps
    Storage-->>DO: persisted
    DO-->>MockWorker: repo + token
    MockWorker-->>Client: 200 + repo data

    Client->>MockWorker: GET /repos<br/>(list repos)
    MockWorker->>DO: fetch with<br/>list command
    DO->>Storage: readStorage()
    Storage-->>DO: all repos
    DO-->>DO: sort + paginate
    DO-->>MockWorker: repos array
    MockWorker-->>Client: 200 + repos

    Client->>MockWorker: POST /repos/fork<br/>(fork repo)
    MockWorker->>DO: fetch with<br/>fork command
    DO->>Storage: readStorage()
    Storage-->>DO: verify source exists
    DO->>Storage: append forked repo
    Storage-->>DO: persisted
    DO-->>MockWorker: forked repo
    MockWorker-->>Client: 200 + fork data
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through Artifacts so fine,
Mock repos, tokens, forks in perfect line,
Storage persists what the Worker sends,
Local development magic—no remote depends! ✨

✨ 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 cursor/mock-artifacts-local-8d84

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@kentcdodds
kentcdodds marked this pull request as ready for review April 18, 2026 16:54
@kentcdodds
kentcdodds merged commit 73c8b40 into main Apr 18, 2026
14 of 16 checks passed
@kentcdodds
kentcdodds deleted the cursor/mock-artifacts-local-8d84 branch April 18, 2026 16:55
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