Refine connector provider registry per review
Three follow-ups from review of the registry consolidation:
- Build Vercel's authorization URL with net/url instead of a
hand-rolled "{integration_slug}" placeholder resolved by
strings.ReplaceAll. The slug is escaped via url.PathEscape in a
per-provider Registration.BuildAuthURL closure, and the unused
AuthURLParams plumbing on Registration and OAuth2Connector is
removed (OAuth2Connector now carries a typed IntegrationSlug).
- Drop the SettingsInput union type and the per-provider
MarshalSettings closures. The create resolvers now build the typed
coredata.*ConnectorSettings directly from the gqlgen input, the
same way the OAuth callback path already does, so there is no
shared catch-all DTO and no stringly-typed boundary.
- Restore ConnectorProviders() to a plain ordered slice literal; the
intermediate map + slices.Sort added nondeterminism and a sort for
no benefit.
Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,6 @@ package coredata
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type ConnectorProvider string
|
||||
@@ -58,50 +57,35 @@ var (
|
||||
_ encoding.TextUnmarshaler = (*ConnectorProvider)(nil)
|
||||
)
|
||||
|
||||
// providerStringMap is the single source of truth that connects the
|
||||
// wire/string form of a ConnectorProvider to its typed constant. Both
|
||||
// ConnectorProviders() and Scan() read from it; adding a new provider
|
||||
// is one constant + one map entry.
|
||||
var providerStringMap = map[string]ConnectorProvider{
|
||||
"SLACK": ConnectorProviderSlack,
|
||||
"GOOGLE_WORKSPACE": ConnectorProviderGoogleWorkspace,
|
||||
"LINEAR": ConnectorProviderLinear,
|
||||
"ONE_PASSWORD": ConnectorProviderOnePassword,
|
||||
"HUBSPOT": ConnectorProviderHubSpot,
|
||||
"DOCUSIGN": ConnectorProviderDocuSign,
|
||||
"NOTION": ConnectorProviderNotion,
|
||||
"BREX": ConnectorProviderBrex,
|
||||
"TALLY": ConnectorProviderTally,
|
||||
"CLOUDFLARE": ConnectorProviderCloudflare,
|
||||
"OPENAI": ConnectorProviderOpenAI,
|
||||
"SENTRY": ConnectorProviderSentry,
|
||||
"SUPABASE": ConnectorProviderSupabase,
|
||||
"GITHUB": ConnectorProviderGitHub,
|
||||
"INTERCOM": ConnectorProviderIntercom,
|
||||
"RESEND": ConnectorProviderResend,
|
||||
"MICROSOFT_365": ConnectorProviderMicrosoft365,
|
||||
"GITLAB": ConnectorProviderGitLab,
|
||||
"BITBUCKET": ConnectorProviderBitbucket,
|
||||
"HEROKU": ConnectorProviderHeroku,
|
||||
"PAGERDUTY": ConnectorProviderPagerDuty,
|
||||
"ASANA": ConnectorProviderAsana,
|
||||
"NETLIFY": ConnectorProviderNetlify,
|
||||
"CLICKUP": ConnectorProviderClickUp,
|
||||
"VERCEL": ConnectorProviderVercel,
|
||||
"MONDAY": ConnectorProviderMonday,
|
||||
}
|
||||
|
||||
func ConnectorProviders() []ConnectorProvider {
|
||||
out := make([]ConnectorProvider, 0, len(providerStringMap))
|
||||
for _, v := range providerStringMap {
|
||||
out = append(out, v)
|
||||
return []ConnectorProvider{
|
||||
ConnectorProviderSlack,
|
||||
ConnectorProviderGoogleWorkspace,
|
||||
ConnectorProviderLinear,
|
||||
ConnectorProviderOnePassword,
|
||||
ConnectorProviderHubSpot,
|
||||
ConnectorProviderDocuSign,
|
||||
ConnectorProviderNotion,
|
||||
ConnectorProviderBrex,
|
||||
ConnectorProviderTally,
|
||||
ConnectorProviderCloudflare,
|
||||
ConnectorProviderOpenAI,
|
||||
ConnectorProviderSentry,
|
||||
ConnectorProviderSupabase,
|
||||
ConnectorProviderGitHub,
|
||||
ConnectorProviderIntercom,
|
||||
ConnectorProviderResend,
|
||||
ConnectorProviderMicrosoft365,
|
||||
ConnectorProviderGitLab,
|
||||
ConnectorProviderBitbucket,
|
||||
ConnectorProviderHeroku,
|
||||
ConnectorProviderPagerDuty,
|
||||
ConnectorProviderAsana,
|
||||
ConnectorProviderNetlify,
|
||||
ConnectorProviderClickUp,
|
||||
ConnectorProviderVercel,
|
||||
ConnectorProviderMonday,
|
||||
}
|
||||
|
||||
// Map iteration order is nondeterministic; sort so callers (e.g. the
|
||||
// connectorProviderInfos API/UI listing) get a stable order.
|
||||
slices.Sort(out)
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func (v ConnectorProvider) IsValid() bool {
|
||||
|
||||
Reference in New Issue
Block a user