Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: mikro-orm 7.1.x scaffold hardening — AnyMikroORM, readonly options, age-gate healing - #246

Merged
RohinBhargava merged 1 commit into
mainfrom
rohin/scaffold-mikroorm-71x
Aug 11, 2026
Merged

fix: mikro-orm 7.1.x scaffold hardening — AnyMikroORM, readonly options, age-gate healing#246
RohinBhargava merged 1 commit into
mainfrom
rohin/scaffold-mikroorm-71x

Conversation

@RohinBhargava

@RohinBhargava RohinBhargava commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Response to the four reported scaffold bugs on mikro-orm 7.1.x (readonly entities generics).

Audit result first: bugs 1–3 as filed do not reproduce on current main + current published packages — a fresh init application -m billing-stripe -m iam-base typechecks with zero errors, because the entity/constraint alignment (nullable drift, DTO/schema optionality) and the AnyMikroORM relaxations shipped across framework 1.5.11–1.5.12 / implementation 1.0.30/1.1.30 / CLI 1.4.4. The reporter was on the pre-alignment versions. What remains valid from the report is the requested hardening, all implemented here:

  • Bug 1 (requested alias): @forklaunch/[email protected] exports AnyMikroORM from /persistence — the documented type for ORM-valued params/fields that must accept MikroORM.init() instances
  • Bug 2: @forklaunch/[email protected] adds AnyMikroOrmOptions (accepts defineConfig's readonly entities) for BlueprintTestHarness.getConfig and MikroOrmTestConfig, and exports AnyMikroORM/AnyMikroOrmOptions at package level; service/worker test-utils templates now type orm as AnyMikroORM
  • Bug 3: not reproducible (see audit); billing templates already carry the constraint alignment
  • Bug 4: forklaunch upgrade/minimumReleaseAgeExclude generation is not in this repo (platform-side), but every CLI workspace-yaml rewrite now heals stale entries: versioned @forklaunch/*@x.y.z exclusions normalize to bare package names (first-party packages are always exempt from the age gate), deduped, third-party entries untouched. Unit-tested and verified live: injected @forklaunch/[email protected] pins normalized on the next init service

Verification

  • Fresh scaffold (billing-stripe module): tsgo --noEmit clean in core and billing including __test__
  • Live healing repro: stale pins → bare names after init service, [email protected] preserved
  • cargo test: 335 passed (2 new); core 371 tests pass; scaffold floors synced via check_blueprint_deps --fix

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for flexible ORM configurations and entity definitions in database testing utilities.
    • Improved compatibility of generated service and worker test helpers with configured ORM instances.
    • Workspace package exclusions now automatically normalize versioned entries and remove duplicates.
  • Maintenance

    • Updated core and testing components to their latest patch releases across project blueprints and generated projects.
    • Refreshed generated dependency versions to keep new projects aligned with current framework releases.

… options, age-gate exclusion healing

Addresses the four reported scaffold bugs on mikro-orm 7.1.x. Bugs 1-3
no longer reproduce on current published packages (verified: fresh
scaffold with billing-stripe + iam-base typechecks clean), but the
report's requested hardening is real:

- @forklaunch/core exports AnyMikroORM (persistence) so user-authored
  helpers have a readonly-accepting ORM type instead of hand-rolling
  MikroORM<any, any, any> (published as [email protected])
- @forklaunch/testing: AnyMikroOrmOptions accepts defineConfig's
  readonly entities in BlueprintTestHarness.getConfig and
  MikroOrmTestConfig; AnyMikroORM/AnyMikroOrmOptions exported at the
  package level (published as [email protected])
- service/worker test-utils templates type orm as AnyMikroORM from
  @forklaunch/testing instead of bare MikroORM
- pnpm-workspace rewrites normalize versioned @forklaunch/*@x.y.z
  entries in minimumReleaseAgeExclude to bare package names, healing
  the stale-pin ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION loop after
  upgrades (first-party packages are always exempt from the age gate);
  covered by unit tests and verified live on a scaffold
- CLI scaffold floors synced (core ~1.5.13, testing ~1.2.25)

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds generalized MikroORM types, updates database-enabled templates, normalizes minimumReleaseAgeExclude entries during workspace operations, and upgrades Forklaunch core and testing package versions across framework, CLI, and blueprint metadata.

Changes

Forklaunch release and typing updates

Layer / File(s) Summary
Generalized MikroORM contracts
framework/core/src/persistence/*, framework/testing/src/*
Adds and exports AnyMikroORM and AnyMikroOrmOptions. Testing configuration and harness contracts use the new types.
Template ORM compatibility
cli/src/templates/project/service/__test__/test-utils.ts, cli/src/templates/project/worker/__test__/test-utils.ts
Database cleanup helpers accept AnyMikroORM.
Workspace exclusion normalization
cli/src/core/pnpm_workspace.rs
Workspace rendering, project addition, and project removal sanitize Forklaunch entries, remove duplicates, preserve unrelated values, and retain non-string values. Tests cover these cases.
Package version alignment
framework/*/package.json, cli/src/core/package_json/package_json_constants.rs, blueprint/*
Updates core references to 1.5.13 and testing references to 1.2.25. Updates the blueprint workspace override.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the MikroORM type hardening and CLI age-gate normalization changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ 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 rohin/scaffold-mikroorm-71x

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/src/core/pnpm_workspace.rs`:
- Around line 209-210: Update the error context in the workspace serialization
return path to use the removal-specific error message constant instead of
ERROR_FAILED_TO_ADD_PROJECT_METADATA_TO_PNPM_WORKSPACE, so failures during
project removal identify the correct operation.

In `@cli/src/templates/project/worker/__test__/test-utils.ts`:
- Line 10: Close the is_database_enabled template block in the worker test
utility immediately after the conditional import, matching the closure pattern
used by the service template so rendering remains reliable.

In `@framework/testing/src/database.ts`:
- Around line 20-22: Update AnyMikroOrmOptions to omit and explicitly override
both entities and entitiesTs, allowing readonly entity configurations for each
while preserving their element types. Add a type-level test covering readonly
entities and readonly entitiesTs.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51b957af-3670-4ca6-9ee7-47f6f7fde636

📥 Commits

Reviewing files that changed from the base of the PR and between 8f1e212 and 95a942f.

⛔ Files ignored due to path filters (1)
  • blueprint/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (30)
  • blueprint/billing-base/package.json
  • blueprint/billing-stripe/package.json
  • blueprint/client-sdk/package.json
  • blueprint/core/package.json
  • blueprint/ecommerce-stripe/package.json
  • blueprint/iam-base/package.json
  • blueprint/iam-better-auth/package.json
  • blueprint/implementations/billing/base/package.json
  • blueprint/implementations/billing/stripe/package.json
  • blueprint/implementations/ecommerce/base/package.json
  • blueprint/implementations/iam/base/package.json
  • blueprint/implementations/worker/bullmq/package.json
  • blueprint/implementations/worker/database/package.json
  • blueprint/implementations/worker/kafka/package.json
  • blueprint/implementations/worker/redis/package.json
  • blueprint/monitoring/package.json
  • blueprint/package.json
  • blueprint/pnpm-workspace.yaml
  • blueprint/sample-worker/package.json
  • cli/src/core/package_json/package_json_constants.rs
  • cli/src/core/pnpm_workspace.rs
  • cli/src/templates/project/service/__test__/test-utils.ts
  • cli/src/templates/project/worker/__test__/test-utils.ts
  • framework/core/package.json
  • framework/core/src/persistence/index.ts
  • framework/core/src/persistence/mikroOrm.types.ts
  • framework/testing/package.json
  • framework/testing/src/database.ts
  • framework/testing/src/harness.ts
  • framework/testing/src/index.ts

Comment on lines 209 to 210
Ok(to_string(&pnpm_workspace)
.with_context(|| ERROR_FAILED_TO_ADD_PROJECT_METADATA_TO_PNPM_WORKSPACE)?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the removal error context.

If workspace serialization fails during project removal, this function reports that project metadata could not be added. Use the removal-specific error context so the failure message identifies the operation correctly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/core/pnpm_workspace.rs` around lines 209 - 210, Update the error
context in the workspace serialization return path to use the removal-specific
error message constant instead of
ERROR_FAILED_TO_ADD_PROJECT_METADATA_TO_PNPM_WORKSPACE, so failures during
project removal identify the correct operation.

TestSetupResult
} from '@forklaunch/testing';
{{#is_database_enabled}}import { EntityManager, MikroORM } from '@mikro-orm/core';
{{#is_database_enabled}}import { EntityManager } from '@mikro-orm/core';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Close the is_database_enabled template block.

Line 10 opens a template conditional and never closes it. The worker test utility cannot be rendered reliably. Add the closing tag, as the service template does.

Proposed fix
-{{`#is_database_enabled`}}import { EntityManager } from '`@mikro-orm/core`';
+{{`#is_database_enabled`}}import { EntityManager } from '`@mikro-orm/core`';{{/is_database_enabled}}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{#is_database_enabled}}import { EntityManager } from '@mikro-orm/core';
{{`#is_database_enabled`}}import { EntityManager } from '`@mikro-orm/core`';{{/is_database_enabled}}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/templates/project/worker/__test__/test-utils.ts` at line 10, Close
the is_database_enabled template block in the worker test utility immediately
after the conditional import, matching the closure pattern used by the service
template so rendering remains reliable.

Comment on lines +20 to +22
export type AnyMikroOrmOptions = Partial<Omit<Options, 'entities'>> & {
entities?: readonly NonNullable<Options['entities']>[number][];
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
rg -n -C 4 '\bentitiesTs\b' framework cli blueprint --glob '*.ts' --glob '*.tsx'

Repository: forklaunch/forklaunch

Length of output: 159


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

file="$(fd -t f '^database\.ts$' . | grep -F 'framework/testing/src/database.ts' | head -n 1)"
printf '%s\n' "FILE=$file"
wc -l "$file"
ast-grep outline "$file"
sed -n '1,180p' "$file"

printf '%s\n' '--- usages ---'
rg -n -C 5 'AnyMikroOrmOptions|MikroOrmTestConfig|setupTestORM|entitiesTs|defineConfig' framework cli blueprint --glob '*.ts' --glob '*.tsx' || true

printf '%s\n' '--- MikroORM version/source references ---'
rg -n -C 3 '"`@mikro-orm/core`"|mikro-orm' --glob 'package.json' --glob 'pnpm-lock.yaml' --glob 'yarn.lock' --glob 'package-lock.json' .

Repository: forklaunch/forklaunch

Length of output: 50377


🌐 Web query:

MikroORM v7.1.11 Configuration.ts Options entitiesTs Entities generic readonly source

💡 Result:

In MikroORM v7.1.11, the entitiesTs option is a configuration property used during folder-based entity discovery to specify the paths to TypeScript source files [1][2]. Key details regarding this option include: Purpose: When your application runs in a TypeScript environment (such as using tsx, swc, or during testing), MikroORM needs to discover and load your entities from.ts files rather than the compiled.js files [1][3]. The entitiesTs option informs the ORM where to find these source files [2][4]. Usage: You should provide this option whenever you use glob patterns or folder paths for entity discovery in your configuration [1][3]. For example, you would typically set entities to point to your build output (e.g.,./dist//.entity.js) and entitiesTs to point to your source code (e.g.,./src//.entity.ts) [3][5]. Behavior: MikroORM automatically detects when the application is running in TypeScript mode and will prioritize the paths provided in entitiesTs [3][6]. If you are using direct class references (e.g., entities: [User, Post]), this option is not required, as the class references already point to the correct files [7]. Configuration Example: import { defineConfig } from '@mikro-orm/sqlite'; export default defineConfig({ entities: ['./dist//.entity.js'], entitiesTs: ['./src//.entity.ts'], }); It is important not to mix compiled JS paths and TS source paths in the same array; always separate them using the appropriate configuration keys [3][5]. The entitiesTs property accepts an array of strings (paths or globs) or entity class references, matching the type signature of the main entities option [2][4].

Citations:


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

url='https://raw.githubusercontent.com/mikro-orm/mikro-orm/v7.1.11/packages/core/src/utils/Configuration.ts'
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT
curl -fsSL "$url" -o "$tmp"

printf '%s\n' '--- Options and entitiesTs declarations ---'
rg -n -C 12 'interface Options|type Options|entitiesTs|entities\??:' "$tmp"

printf '%s\n' '--- Entities generic declarations ---'
rg -n -C 8 'Entities extends|type Entities|export type Entity|EntityClass' "$tmp" | head -n 160

Repository: forklaunch/forklaunch

Length of output: 7328


Widen entitiesTs for readonly configurations.

Options uses the same Entities generic for entities and entitiesTs. Since AnyMikroOrmOptions overrides only entities, entitiesTs retains the mutable default array type. Omit and override entitiesTs too, then add a type-level test for readonly entities and entitiesTs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@framework/testing/src/database.ts` around lines 20 - 22, Update
AnyMikroOrmOptions to omit and explicitly override both entities and entitiesTs,
allowing readonly entity configurations for each while preserving their element
types. Add a type-level test covering readonly entities and readonly entitiesTs.

@RohinBhargava
RohinBhargava merged commit 966ba8a into main Aug 11, 2026
16 checks passed
@RohinBhargava
RohinBhargava deleted the rohin/scaffold-mikroorm-71x branch August 11, 2026 21:07
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