Skip to content

IAV-857/feat(types): strengthen credential validation type system with Map, new enum value & typed responses

salaheddine zidani a demandé de fusionner feature/IAV-857 vers develop

Summary

This MR refactors the credential validation type definitions to improve type safety, reduce runtime ambiguity, and better reflect the actual data contracts used across the credential validation flow.


Changes

agent-credential-validation.types.ts

CredentialType enum

  • Added WHATSAPP_OAUTH = 'WHATSAPP_OAUTH' to support the WhatsApp OAuth authentication flow introduced in the wizard store.

CredentialValidationResponse

  • Added platform: CredentialType field — responses are now self-describing, removing the need for callers to track which platform a result belongs to out-of-band.

SupportedPlatformsResponse

  • Introduced a dedicated interface for the /supported-platforms endpoint response, replacing the previously untyped return shape.

CredentialValidationState

  • Changed validationResults: Record<string, CredentialValidationResponse>validatedCredentials: Map<CredentialType, CredentialValidationResponse>
    • Enforces that only valid CredentialType keys can be used as cache keys.
    • Eliminates silent string mismatches (e.g. "freshdesk" vs "FRESHDESK").
  • Removed isValidating: boolean and error from the state interface — these are transient UI concerns and should be managed at the store/hook level, not baked into the core state shape.

Motivation

Before After
Record<string, CredentialValidationResponse> — any string accepted as key Map<CredentialType, CredentialValidationResponse> — only valid enum values
No platform field on response — callers must track context externally platform: CredentialType on response — self-describing
WHATSAPP_OAUTH missing from enum — used in wizard store without type coverage Added to enum
SupportedPlatformsResponse untyped Explicit interface
isValidating / error in core state shape Removed — transient concerns belong at store level

Impact

  • Breaking: CredentialValidationState.validationResults has been renamed to validatedCredentials and its type changed — consumers (store, selectors) must be updated accordingly.
  • Breaking: isValidating and error removed from CredentialValidationState — store implementation needs to manage these locally.
  • Additive: WHATSAPP_OAUTH enum value, platform field on response, SupportedPlatformsResponse interface.

Checklist

  • Store updated to use Map<CredentialType, ...> and new state shape
  • Selectors updated (selectValidationByPlatform, selectIsValidForPlatform, selectHasAllPermissions)
  • getSupportedPlatforms() return type updated to SupportedPlatformsResponse
  • WHATSAPP_OAUTH added to SUPPORTED_PLATFORMS or META_PLATFORMS as appropriate
  • No hardcoded string keys remaining for platform lookup

Related Issues

Closes IAV-857

Rapports de requête de fusion