10000 docs: Autogenerate list of connector capabilities for docs generation by laouji · Pull Request #466 · formancehq/payments · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

docs: Autogenerate list of connector capabilities for docs generation #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set dotenv-load
default:
@just --list

pre-commit: tidy generate lint openapi compile-plugins
pre-commit: tidy generate lint openapi compile-plugins compile-connector-capabilities
pc: pre-commit

lint:
Expand All @@ -21,6 +21,11 @@ compile-connector-configs:
./compile-configs --path {{justfile_directory()}}/internal/connectors/plugins/public --output {{justfile_directory()}}/openapi/v3/v3-connectors-config.yaml
@rm ./compile-configs

compile-connector-capabilities:
@go build -o compile-capabilities {{justfile_directory()}}/tools/compile-capabilities
./compile-capabilities --path {{justfile_directory()}}/internal/connectors/plugins/public --output {{justfile_directory()}}/docs/other/connector-capabilities.json
@rm ./compile-capabilities

[group('openapi')]
compile-api-yaml: compile-connector-configs
@npx openapi-merge-cli --config {{justfile_directory()}}/openapi/openapi-merge.json
Expand Down
1 change: 1 addition & 0 deletions docs/other/connector-capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"adyen":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_CREATE_WEBHOOKS","CAPABILITY_TRANSLATE_WEBHOOKS"],"atlar":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_FETCH_OTHERS"],"bankingcircle":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_CREATE_BANK_ACCOUNT","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT"],"column":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_CREATE_BANK_ACCOUNT","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT","CAPABILITY_CREATE_WEBHOOKS","CAPABILITY_TRANSLATE_WEBHOOKS"],"currencycloud":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT"],"dummypay":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_ALLOW_FORMANCE_ACCOUNT_CREATION","CAPABILITY_ALLOW_FORMANCE_PAYMENT_CREATION","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT"],"generic":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_ALLOW_FORMANCE_ACCOUNT_CREATION","CAPABILITY_ALLOW_FORMANCE_PAYMENT_CREATION"],"increase":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT","CAPABILITY_CREATE_BANK_ACCOUNT","CAPABILITY_TRANSLATE_WEBHOOKS","CAPABILITY_CREATE_WEBHOOKS"],"mangopay":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_FETCH_OTHERS","CAPABILITY_CREATE_BANK_ACCOUNT","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT","CAPABILITY_CREATE_WEBHOOKS","CAPABILITY_TRANSLATE_WEBHOOKS"],"modulr":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT"],"moneycorp":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT"],"qonto":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS"],"stripe":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT"],"wise":["CAPABILITY_FETCH_ACCOUNTS","CAPABILITY_FETCH_BALANCES","CAPABILITY_FETCH_EXTERNAL_ACCOUNTS","CAPABILITY_FETCH_PAYMENTS","CAPABILITY_FETCH_OTHERS","CAPABILITY_CREATE_TRANSFER","CAPABILITY_CREATE_PAYOUT","CAPABILITY_CREATE_WEBHOOKS","CAPABILITY_TRANSLATE_WEBHOOKS"]}
73 changes: 73 additions & 0 deletions tools/compile-capabilities/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"log"
"os"

_ "github.com/formancehq/payments/internal/connectors/plugins/public"
"github.com/formancehq/payments/internal/connectors/plugins/registry"
"github.com/formancehq/payments/internal/models"
)

var (
connectorCapabilities map[string][]string

path = flag.String("path", "./", "Path to the directory")
outputFilename = flag.String("output", "connector-capabilities.json", "Name of the output file to write")
)

func main() {
flag.Parse()
if *path == "" {
log.Fatal("path flag is required")
}
if *outputFilename == "" {
log.Fatal("output flag is required")
}

entries, err := os.ReadDir(*path)
if err != nil {
log.Fatal(err)
}

connectorCapabilities = make(map[string][]string)
for _, e := range entries {
if !e.IsDir() {
continue
}

capabilities, err := registry.GetCapabilities(e.Name())
if err != nil {
log.Fatal(err)
}

connectorCapabilities[e.Name()] = toString(capabilities)
}

d, err := json.Marshal(&connectorCapabilities)
if err != nil {
log.Fatalf("error: %v", err)
}

f, err := os.Create(*outputFilename)
if err != nil {
log.Fatalf("error: %v", err)
}
defer f.Close()

_, err = f.Write(d)
if err != nil {
log.Fatalf("error: %v", err)
}
}

func toString(list []models.Capability) []string {
result := make([]string, len(list))
for i, item := range list {
result[i] = fmt.Sprintf("CAPABILITY_%s", item.String())
}
return result
}
Loading
0