Skip to content

refactor(integrations): simplify integration creator typing - #6259

Open
ajnart wants to merge 2 commits into
devfrom
feat/fix-ugly-code
Open

refactor(integrations): simplify integration creator typing#6259
ajnart wants to merge 2 commits into
devfrom
feat/fix-ugly-code

Conversation

@ajnart

@ajnart ajnart commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Normalize integration creators behind a create method
  • Replace the nested conditional type with a mapped return-type lookup
  • Remove the array runtime special-case for async factories

Verification

  • pnpm -F @homarr/integrations exec oxlint src/base/creator.ts
  • pnpm -F @homarr/request-handler typecheck
  • pnpm -F @homarr/api typecheck

Known unrelated failures

  • pnpm -F @homarr/integrations typecheck currently fails in src/synology/test/synology-integration.spec.ts because fixtures are missing status/cached fields
  • pnpm -F @homarr/integrations lint currently has existing errors in src/synology/synology-client.ts

Summary by CodeRabbit

  • New Features
    • Added a new documentation page for Synology integration.
  • Bug Fixes
    • Improved integration creation handling for more consistent loading of supported integrations.
    • Updated documentation routing so widget and integration pages resolve correctly.

@ajnart
ajnart requested a review from a team as a code owner July 9, 2026 16:56
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 483b96d9-773f-46d3-a643-043734c2080d

📥 Commits

Reviewing files that changed from the base of the PR and between 65ba866 and 7cecd58.

📒 Files selected for processing (2)
  • packages/definitions/src/docs/homarr-docs-sitemap.ts
  • packages/integrations/src/base/creator.ts

📝 Walkthrough

Walkthrough

The integration creator module is refactored to normalize class-based and factory-based integration creators into a uniform { create } wrapper interface via new fromClass/fromFactory helpers, replacing prior array/constructor branching. Additionally, the auto-generated documentation sitemap type gains a new path and reorders several widget path entries.

Changes

Integration Creator Refactor

Layer / File(s) Summary
Creator types, helper wrappers, and record
packages/integrations/src/base/creator.ts
Introduces IntegrationConstructor, IntegrationFactory, IntegrationCreator types and fromClass/fromFactory helpers to normalize integration creators into { create } objects; rewrites integrationCreators using these wrappers with a satisfies Record<IntegrationKind, IntegrationCreator> constraint, and introduces IntegrationInstanceByKind to derive return types from create.
Unified invocation in createIntegrationAsync
packages/integrations/src/base/creator.ts
createIntegrationAsync now calls integrationCreators[integration.kind].create(integration) directly instead of branching on Array.isArray to distinguish factories from class constructors.

Documentation Sitemap Path Type Update

Layer / File(s) Summary
Sitemap path union changes
packages/definitions/src/docs/homarr-docs-sitemap.ts
Adds /docs/integrations/synology to HomarrDocumentationPath and reorders /docs/widgets/system-disks, /docs/widgets/system-resources, and /docs/widgets/coolify entries within the union.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Yagni / Over-Engineering ⚠️ Warning The refactor adds wrapper/type machinery around the factory, but there’s no focused runnable check for the central creator path. Add one tiny spec for createIntegrationAsync covering a class-backed kind and an async-factory kind; drop helpers only if the test shows they’re unnecessary.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: simplifying integration creator typing in integrations.
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.
Docs Are Up To Date ✅ Passed Docs pages already exist for Synology, Coolify, and the related widgets; the PR only refreshed the generated sitemap type, so docs are up to date.
✨ 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 feat/fix-ugly-code

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

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