Skip to content

fix: register path-style menu item routes and wrap menu item creation…#1078

Open
Rimander wants to merge 1 commit into
emdash-cms:mainfrom
Rimander:fix/menu-create-item-race-and-cleanup
Open

fix: register path-style menu item routes and wrap menu item creation…#1078
Rimander wants to merge 1 commit into
emdash-cms:mainfrom
Rimander:fix/menu-create-item-race-and-cleanup

Conversation

@Rimander
Copy link
Copy Markdown
Contributor

@Rimander Rimander commented May 17, 2026

What does this PR do?

Follow-up to #1052 (menu REST API with camelCase responses):

  1. MenuRepository.createItem race fix. When sortOrder is omitted, the SELECT max(sort_order) and the subsequent INSERT now run in a single withTransaction. Two concurrent calls can no longer compute the same next index.
  2. MenuRepository.findMany cleanup. Replaced the manual column-by-column re-spelling that fed rowToMenu with a destructure-and-spread. Adding a column to MenuTable no longer requires updating this mapping in lockstep.
  3. resolveMenu intent. After the length === 0 / length > 1 guards, matches[0] is replaced with const [menu] = matches so the non-null intent is obvious to readers used to the stricter base noUncheckedIndexedAccess: true setting.
  4. injectCoreRoutes coverage. Added a unit test in tests/unit/astro/routes.test.ts that asserts injectCoreRoutes actually registers /_emdash/api/menus/[name]/items/[id] — closing the loop on the route-injection bug fix(api): menu REST API with camelCase responses #1052 fixed (the existing structural test only checked that the module exports PUT/DELETE).

No database schema, API surface, or response shape changes. Existing menu tests (menu-repository.test.ts, menus-handlers.test.ts) continue to pass unchanged.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.7

Screenshots / test output

Test Files  208 passed (208)
     Tests  3294 passed (3294)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

⚠️ No Changeset found

Latest commit: 9ee99e9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 17, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1078

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1078

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1078

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1078

emdash

npm i https://pkg.pr.new/emdash@1078

create-emdash

npm i https://pkg.pr.new/create-emdash@1078

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1078

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1078

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1078

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1078

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1078

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1078

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1078

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1078

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1078

commit: 9ee99e9

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.

1 participant