Files
b55b031c61 feat(api): EN-1023 expose connector capabilities on v3 (#727)
* feat(api): EN-1023 expose connector capabilities on v3

Add `GET /v3/connectors/capabilities` (full catalog, ETag-cached for the
stateless console) and `GET /v3/connectors/{connectorID}/capabilities`,
and inline a `capabilities` field on each row of `v3ListConnectors` so
platform-ui can gate per-connector submenus (Accounts/Payments/Transfers)
on what the underlying plugin actually supports.

Capability owns its JSON wire encoding (MarshalJSON/UnmarshalJSON) so
the format stays aligned with the DB Value/Scan representation.

Co-authored-by: Cursor <[email protected]>

* fix(api): EN-1023 address CodeRabbit review

- Replace `new(value)` with the local-variable `&v` pattern used elsewhere
  in v3 for `api.BaseResponse.Data`.
- Service: drop the registry error from the 404 translation, honouring
  the comment's non-leak intent.
- List handler: normalise the storage provider through `ToV3Provider`
  before looking up capabilities so legacy v2 rows (`"STRIPE"`, etc.) hit
  the registry's lowercase keys; test now exercises that path.
- Registry: clone capability slices in `GetAllCapabilities` so callers
  can't mutate plugin registrations through the returned map.
- E2E: wait for the uninstall workflow via the shared helper and assert a
  concrete capability instead of just non-nil.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
2026-06-11 13:12:20 +00:00

72 lines
2.3 KiB
Go

// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
package components
import (
"encoding/json"
"fmt"
)
// V3Capability - Plugin capability advertised by a connector. Distinct from the Formance gateway "module capabilities" (which are version-gated); these reflect what the underlying PSP integration actually exposes.
type V3Capability string
const (
V3CapabilityFetchAccounts V3Capability = "FETCH_ACCOUNTS"
V3CapabilityFetchBalances V3Capability = "FETCH_BALANCES"
V3CapabilityFetchExternalAccounts V3Capability = "FETCH_EXTERNAL_ACCOUNTS"
V3CapabilityFetchPayments V3Capability = "FETCH_PAYMENTS"
V3CapabilityFetchOthers V3Capability = "FETCH_OTHERS"
V3CapabilityFetchOrders V3Capability = "FETCH_ORDERS"
V3CapabilityFetchConversions V3Capability = "FETCH_CONVERSIONS"
V3CapabilityCreateWebhooks V3Capability = "CREATE_WEBHOOKS"
V3CapabilityTranslateWebhooks V3Capability = "TRANSLATE_WEBHOOKS"
V3CapabilityCreateBankAccount V3Capability = "CREATE_BANK_ACCOUNT"
V3CapabilityCreateTransfer V3Capability = "CREATE_TRANSFER"
V3CapabilityCreatePayout V3Capability = "CREATE_PAYOUT"
V3CapabilityAllowFormanceAccountCreation V3Capability = "ALLOW_FORMANCE_ACCOUNT_CREATION"
V3CapabilityAllowFormancePaymentCreation V3Capability = "ALLOW_FORMANCE_PAYMENT_CREATION"
)
func (e V3Capability) ToPointer() *V3Capability {
return &e
}
func (e *V3Capability) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "FETCH_ACCOUNTS":
fallthrough
case "FETCH_BALANCES":
fallthrough
case "FETCH_EXTERNAL_ACCOUNTS":
fallthrough
case "FETCH_PAYMENTS":
fallthrough
case "FETCH_OTHERS":
fallthrough
case "FETCH_ORDERS":
fallthrough
case "FETCH_CONVERSIONS":
fallthrough
case "CREATE_WEBHOOKS":
fallthrough
case "TRANSLATE_WEBHOOKS":
fallthrough
case "CREATE_BANK_ACCOUNT":
fallthrough
case "CREATE_TRANSFER":
fallthrough
case "CREATE_PAYOUT":
fallthrough
case "ALLOW_FORMANCE_ACCOUNT_CREATION":
fallthrough
case "ALLOW_FORMANCE_PAYMENT_CREATION":
*e = V3Capability(v)
return nil
default:
return fmt.Errorf("invalid value for V3Capability: %v", v)
}
}