refactor(plugins): move provider onboarding auth into plugins

This commit is contained in:
Peter Steinberger
2026-03-15 22:42:58 -07:00
parent 0b58a1cc13
commit 55cbfb6e6a
12 changed files with 420 additions and 34 deletions

View File

@@ -61,6 +61,17 @@ function resolveMethodById(
return provider.auth.find((method) => method.id.trim().toLowerCase() === normalizedMethodId);
}
function listMethodWizardSetups(provider: ProviderPlugin): Array<{
method: ProviderAuthMethod;
wizard: ProviderPluginWizardSetup;
}> {
return provider.auth
.map((method) => (method.wizard ? { method, wizard: method.wizard } : null))
.filter((entry): entry is { method: ProviderAuthMethod; wizard: ProviderPluginWizardSetup } =>
Boolean(entry),
);
}
function buildSetupOptionForMethod(params: {
provider: ProviderPlugin;
wizard: ProviderPluginWizardSetup;
@@ -93,6 +104,20 @@ export function resolveProviderWizardOptions(params: {
const options: ProviderWizardOption[] = [];
for (const provider of providers) {
const methodSetups = listMethodWizardSetups(provider);
for (const { method, wizard } of methodSetups) {
options.push(
buildSetupOptionForMethod({
provider,
wizard,
method,
value: wizard.choiceId?.trim() || buildProviderPluginMethodChoice(provider.id, method.id),
}),
);
}
if (methodSetups.length > 0) {
continue;
}
const setup = provider.wizard?.setup;
if (!setup) {
continue;
@@ -187,6 +212,13 @@ export function resolveProviderPluginChoice(params: {
}
for (const provider of params.providers) {
for (const { method, wizard } of listMethodWizardSetups(provider)) {
const choiceId =
wizard.choiceId?.trim() || buildProviderPluginMethodChoice(provider.id, method.id);
if (normalizeChoiceId(choiceId) === choice) {
return { provider, method };
}
}
const setup = provider.wizard?.setup;
if (setup) {
const setupChoiceId = resolveWizardSetupChoiceId(provider, setup);