--- phase: 13-add-remaining-rclone-remotes plan: 01 subsystem: api tags: [rclone, typescript, zod, registry, backend-expansion] requires: - phase: 09-md3-components provides: FieldDef interface and TextFieldMD3 rendering contract used for field helpText guidance - phase: 06-rclone-generator provides: buildRcloneConf, RCLONE_TYPE_MAP, BACKEND_SCHEMAS patterns used throughout provides: - "18-backend BACKEND_REGISTRY with category field as single source of truth" - "BackendType derived from keyof typeof BACKEND_REGISTRY (no manual union)" - "BackendCategory type with 3 valid values" - "BACKEND_SCHEMAS auto-generated from registry keys via Object.fromEntries" - "RCLONE_TYPE_MAP covering all 18 backends with verified rclone type strings" affects: - 13-02 (UI - BackendSelectionStep overhaul, categories, search) - 13-03 (RemoteConfigStep - new backend config forms) - any future phase adding rclone backends tech-stack: added: [] patterns: - "BackendType derived from keyof typeof BACKEND_REGISTRY — no manual union maintenance" - "BACKEND_SCHEMAS auto-generated via Object.fromEntries over registry keys — zero per-backend boilerplate" - "BackendMeta interface types individual entries; registry uses as const for keyof narrowing" - "RCLONE_TYPE_MAP exported for direct test coverage" key-files: created: [] modified: - src/schemas/registry.ts - src/schemas/registry.test.ts - src/schemas/index.ts - src/schemas/index.test.ts - src/generators/rclone-conf.ts - src/generators/rclone-conf.test.ts - src/components/wizard/BackendSelectionStep.test.tsx key-decisions: - "BackendType is derived from keyof typeof BACKEND_REGISTRY — eliminates manual union maintenance at 18+ backends" - "Registry uses as const (not a Record cast) — the cast was circular when BackendType derived from registry" - "BACKEND_SCHEMAS auto-generated from Object.keys(BACKEND_REGISTRY) — no per-backend buildZodSchema call needed" - "Google Drive supports both OAuth token and service account paths via two optional fields — GdriveAuthToggle deferred to 13-03" - "Registry has 18 backends (not 17 as plan stated) — research doc listed http and seafile as separate items making count 18" - "RCLONE_TYPE_MAP exported for exhaustiveness testing" patterns-established: - "Registry-driven type derivation: add backend once in BACKEND_REGISTRY, all downstream (BackendType, BACKEND_SCHEMAS) auto-update" - "BackendCategory field in registry entry — single source of truth for UI grouping (no separate category map)" requirements-completed: [REMOTE-01, REMOTE-02, REMOTE-06] duration: 10min completed: 2026-04-01 --- # Phase 13 Plan 01: Registry Refactor and 18-Backend Expansion Summary **BACKEND_REGISTRY expanded from 7 to 18 backends with derived BackendType, BackendCategory, and auto-generated BACKEND_SCHEMAS — zero per-backend boilerplate for future additions** ## Performance - **Duration:** ~10 min - **Started:** 2026-04-01T16:13:00Z - **Completed:** 2026-04-01T16:20:00Z - **Tasks:** 2 - **Files modified:** 7 ## Accomplishments - Registry expanded with 11 new backends: azure-files, swift, gdrive, dropbox, box, pcloud, ftp, webdav, smb, http, seafile - BackendType now derived from `keyof typeof BACKEND_REGISTRY` — adding a backend no longer requires touching a manual union type - BACKEND_SCHEMAS auto-generated from registry keys — no per-backend `buildZodSchema()` call needed - RCLONE_TYPE_MAP covers all 18 backends with verified rclone type strings - Test count grew from 63 to 266 (all green, no regressions) ## Task Commits Each task was committed atomically: 1. **Task 1: Refactor registry types and add all 10 new backend entries** - `b8c6493` (feat) 2. **Task 2: Auto-generate BACKEND_SCHEMAS, update RCLONE_TYPE_MAP, update tests** - `3010cdb` (feat) ## Files Created/Modified - `src/schemas/registry.ts` - Added BackendCategory type, BackendMeta interface, category field on all entries, 11 new backends, BackendType derived from keyof - `src/schemas/registry.test.ts` - Expanded from 24 to 48 tests; covers all 18 backends, category assertions, new backend field validation - `src/schemas/index.ts` - Replaced explicit BACKEND_SCHEMAS object with Object.fromEntries auto-generation - `src/schemas/index.test.ts` - Added 3 auto-generation tests + 4 new backend schema smoke tests (ftp, smb, seafile, dropbox) - `src/generators/rclone-conf.ts` - RCLONE_TYPE_MAP expanded to 18 entries, exported for test access - `src/generators/rclone-conf.test.ts` - Added RCLONE_TYPE_MAP exhaustiveness test + gdrive/ftp/smb conf output tests - `src/components/wizard/BackendSelectionStep.test.tsx` - Fixed /next/i button selector ambiguity (Rule 1 bug fix) ## Decisions Made - BackendType is derived from `keyof typeof BACKEND_REGISTRY` — eliminates manual union maintenance at 18+ backends - The `as Record` cast at the bottom of the registry was circular when BackendType derived from registry keys — removed it; `as const` provides full inference - Google Drive supports both OAuth token and service account auth paths via two optional fields (`token` and `service_account_credentials`) — GdriveAuthToggle component deferred to plan 13-03 (UI work) - Registry ended up with 18 backends (plan said 17) — research doc listed `http` and `seafile` as separate entries making the correct count 18; test assertions updated to match reality - RCLONE_TYPE_MAP exported for direct exhaustiveness testing ## Deviations from Plan ### Auto-fixed Issues **1. [Rule 1 - Bug] Fixed BackendSelectionStep test broken by WebDAV "NextCloud" description** - **Found during:** Task 2 (full test suite run) - **Issue:** Test used `getByRole('button', { name: /next/i })` — matched both the WebDAV card (description contains "NextCloud") and the actual Next submit button after new backends were added - **Fix:** Changed to `getByRole('button', { name: 'Next' })` (exact match) to target only the submit button - **Files modified:** `src/components/wizard/BackendSelectionStep.test.tsx` - **Verification:** All 266 tests pass, full suite green - **Committed in:** `3010cdb` (Task 2 commit) --- **Total deviations:** 1 auto-fixed (Rule 1 - bug triggered by new data) **Impact on plan:** Minor test fix required by our own data addition. No scope creep. ## Issues Encountered - Registry backend count was 18 not 17 — research doc included both `http` and `seafile` as separate entries, the "17" in the plan was a counting error. Updated test assertions and SUMMARY to reflect the actual correct count. ## User Setup Required None - no external service configuration required. ## Next Phase Readiness - Registry foundation complete — all 18 backends have entries, types are derived, schemas auto-generate - Plan 13-02 can now proceed with BackendSelectionStep UI overhaul (category headings, search filter, backend cards for all 18) - Plan 13-03 can proceed with RemoteConfigStep new backend config forms - BackendType is now available as a union of 18 values wherever `import type { BackendType } from '../schemas/registry'` is used --- *Phase: 13-add-remaining-rclone-remotes* *Completed: 2026-04-01*