Tango.Catalog (tango v0.3.0)

Copy Markdown View Source

Nango provider catalog integration.

Fetches and processes provider configurations from the official Nango provider catalog hosted on GitHub. Provides functions to integrate with the local Tango provider database.

Summary

Functions

Gets the complete Nango provider catalog from the official GitHub repository.

Gets a specific provider configuration from the catalog.

Resolves alias: entries the way Nango does.

Resolves a catalog template the way Nango does when a connection has no connection configuration.

Suggests similar provider names based on input.

Returns true when a value still contains a ${...} placeholder that only a connection configuration could fill, which Tango does not support.

Functions

get_catalog()

Gets the complete Nango provider catalog from the official GitHub repository.

Returns a map of provider configurations parsed from the YAML file.

Examples

iex> Tango.Catalog.get_catalog()
{:ok, %{"github" => %{...}, "google" => %{...}}}

get_provider(provider_name)

Gets a specific provider configuration from the catalog.

Examples

iex> Tango.Catalog.get_provider("github")
{:ok, %{"display_name" => "GitHub", ...}}

iex> Tango.Catalog.get_provider("nonexistent")
{:error, :not_found}

resolve_aliases(raw_providers)

Resolves alias: entries the way Nango does.

An entry such as google-calendar: {alias: google, display_name: ...} is replaced by a shallow merge of its parent's config with its own keys, so the child's top-level keys win and nested maps (proxy, authorization_params) are replaced, not merged. This mirrors loadProvidersYaml/0 in Nango's packages/providers/lib/index.ts ({ ...aliasData, ...overrides }). The alias key is kept so callers can see where the config came from.

Alias chains are followed regardless of file order. An entry whose parent is missing, or whose chain loops, is returned unchanged; such entries have no usable OAuth2 settings and are rejected when a provider is created.

resolve_template(value)

Resolves a catalog template the way Nango does when a connection has no connection configuration.

Nango's interpolateStringFromObject/2 (packages/shared/lib/utils/utils.ts) splits a || b on the first || only: it keeps the left side when interpolating it changed it and otherwise interpolates the right side. With no connection configuration nothing on the left can be interpolated, so the right side wins. A blank right side yields nil.

Strings without || are returned unchanged, including any ${...} placeholders; see unresolved_template?/1. Non-strings pass through.

Examples

iex> Tango.Catalog.resolve_template("https://${connectionConfig.host}/auth || https://login.example.com/auth")
"https://login.example.com/auth"

iex> Tango.Catalog.resolve_template("https://example.com/auth")
"https://example.com/auth"

suggest_similar(input)

Suggests similar provider names based on input.

Uses Jaro distance and substring matching to find similar providers.

Examples

iex> Tango.Catalog.suggest_similar("git")
["github"]

unresolved_template?(value)

Returns true when a value still contains a ${...} placeholder that only a connection configuration could fill, which Tango does not support.