fix(core): type the managed MikroORM reads in TenantSettingService so core compiles

Merged
EV
10d ago
+22-17

Problem

nx build core fails on develop since #10992 (18b93cf413, merged without a Build check; every develop Build run since has been cancelled or queued, so nothing caught it):

packages/core/src/lib/tenant/tenant-setting/tenant-setting.service.ts:119:5 - error TS2322:
  Type 'Loaded<TenantSetting, any, any, any>[]' is not assignable to type 'TenantSetting[]'.
packages/core/src/lib/tenant/tenant-setting/tenant-setting.service.ts:248:5 - error TS2322: (same)

parseTypeORMFindToMikroOrm types its options as FindOptions<T, any, any, any>, so mikroOrmRepository.find(where, mikroOptions) returns Loaded<TenantSetting, any, any, any>[]. The other call sites in the file serialize the result (as TenantSetting[]); #10992 deliberately keeps the managed entities for the write-back, and assigned them straight to settings: TenantSetting[].

This blocks yarn build:package:all and therefore the API/worker Docker images (stage cascade) and every local production build.

Fix

Cast the options to FindOptions<TenantSetting> at the two managed reads, so find infers its default load hints and returns Loaded<TenantSetting>[], which is the entity. One import added. Behaviour unchanged: the managed entities are still what persistAndFlush receives โ€” tenant-setting.service.mikro-orm-save.spec.ts (from #10992) passes.

Verification

  • nx run core:build โ€” passes (fails on develop without this change, reproduced locally).
  • jest -c packages/core/jest.config.ts packages/core/src/lib/tenant/tenant-setting/tenant-setting.service.mikro-orm-save.spec.ts โ€” passes.

Per the owner's rule for Gauzy API/UI: develop โ†’ stage only.

๐Ÿค– Generated with Claude Code


Summary by cubic

Fixes nx build core failing on develop with TS2322 in TenantSettingService, and makes the MikroORM save spec compile.

  • Casts the managed reads' options to FindOptions<TenantSetting> so find returns Loaded<TenantSetting>[] instead of the unassignable Loaded<TenantSetting, any, any, any>[].
  • Switches the spec input to ITenantSetting-shaped values so ts-jest accepts it.
  • Behavior is unchanged: the managed entities are still written back via persistAndFlush.