Derive panel syncable types from connection declarations

JA
5d ago
+49-56

Summary

Provider kit Track A, A2: Settings::ProvidersController::PANEL_SYNCABLE_TYPES is derived from the adapters' connection declarations instead of hand-kept.

Part of jaysbeekay/sure#670. Stacked on jaysbeekay/sure#684 (A1); built on the fork first and sent upstream as part of Track A's native stack on top of we-promise/sure#5005.

Upstream: we-promise/sure#5079 (same commits), in Track A's native stack we-promise/sure#5087.

What changed

  • PANEL_SYNCABLE_TYPES = the connection declarations whose key is in FAMILY_PANEL_KEYS, as key => item class. FAMILY_PANELS itself stays hand-kept until A3.
  • #sync finds the key instead of indexing the hash with params[:provider_key], the pattern connect_form already uses for FAMILY_PANELS: once the hash is not a literal, Brakeman flags the indexed lookup as UnsafeReflection (the class name never comes from the param).
  • The provider:family generator no longer patches the hash (append_panel_syncable_type removed); a generated adapter already declares its connection. Its two tests now cover family_panel_items only; docs/api/rails_provider_generator.md updated.

No visible change.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Old vs new (Rails runner against the removed literal): 26 = 26 entries, equal as a hash.
  • New tests: every family panel maps to its own Syncable <key>_items model; POST sync for a provider without a panel (Plaid) schedules nothing. The Plaid test is a boundary guard for the new lookup and passes before the change too.
  • Mutations, each caught: no panel filter (all 28 declarations); a panel provider without a declaration; the wrong declaration field as the type; Brex declaring Mercury's item class.
  • eager_load! then PANEL_SYNCABLE_TYPES.size = 26.
  • bin/rails test (full): 15,867 runs, 0 failures; 8 errors in ReleaseNotesWorkflowTest from node missing in the test image.
  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings.

Blast radius

  • PANEL_SYNCABLE_TYPES readers: #sync (unknown or panel-less keys still redirect with no notice) and compute_provider_sync_health (iterates pairs; order irrelevant).
  • The generator: one fewer patched list; FAMILY_PANELS, family_panel_items and provider_summary are still patched until their own Track A changes.

Summary by CodeRabbit

  • Bug Fixes
    • Provider sync requests now match the configured family panel before starting a sync. Requests for providers without a family panel no longer enqueue a sync job or display a success notice.
  • Refactor
    • Syncable models are derived from provider connection declarations, reducing the need for manual configuration when adding providers.
  • Documentation
    • Updated provider setup guidance to describe the connection declaration used for sync configuration.