IAV-857/feat(types): strengthen credential validation type system with Map, new enum value & typed responses
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: CredentialTypefield — 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-platformsendpoint response, replacing the previously untyped return shape.
CredentialValidationState
- Changed
validationResults: Record<string, CredentialValidationResponse>→validatedCredentials: Map<CredentialType, CredentialValidationResponse>- Enforces that only valid
CredentialTypekeys can be used as cache keys. - Eliminates silent string mismatches (e.g.
"freshdesk"vs"FRESHDESK").
- Enforces that only valid
- Removed
isValidating: booleananderrorfrom 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.validationResultshas been renamed tovalidatedCredentialsand its type changed — consumers (store, selectors) must be updated accordingly. -
Breaking:
isValidatinganderrorremoved fromCredentialValidationState— store implementation needs to manage these locally. -
Additive:
WHATSAPP_OAUTHenum value,platformfield on response,SupportedPlatformsResponseinterface.
Checklist
-
Store updated to use Map<CredentialType, ...>and new state shape -
Selectors updated ( selectValidationByPlatform,selectIsValidForPlatform,selectHasAllPermissions) -
getSupportedPlatforms()return type updated toSupportedPlatformsResponse -
WHATSAPP_OAUTHadded toSUPPORTED_PLATFORMSorMETA_PLATFORMSas appropriate -
No hardcoded string keys remaining for platform lookup
Related Issues
Closes IAV-857