Fix agent-auth back-compat defaults

Co-Authored-By: madison@stack-auth.com <madison.w.kennedy@gmail.com>
This commit is contained in:
Devin AI 2026-07-08 07:17:53 +00:00
parent 6c75d8ff43
commit a845c87242
3 changed files with 35 additions and 1 deletions

View File

@ -47,6 +47,7 @@ type App = {
stage: "alpha" | "beta" | "stable",
parentAppId?: ParentAppId,
independentlyEnableable?: boolean,
includedInDefaultInstalledApps?: boolean,
};
export type AppId = keyof typeof ALL_APPS;
@ -71,6 +72,7 @@ export const ALL_APPS = {
stage: "alpha",
parentAppId: "authentication",
independentlyEnableable: true,
includedInDefaultInstalledApps: false,
},
"fraud-protection": {
displayName: "Fraud Protection",

View File

@ -0,0 +1,24 @@
import { ALL_APPS } from "../apps/apps-config";
import { applyOrganizationDefaults } from "./schema";
import { expect } from "vitest";
import.meta.vitest?.test("agent-auth is absent from default installed apps", () => {
const defaults = applyOrganizationDefaults({});
expect(Object.keys(defaults.apps.installed)).not.toContain("agent-auth");
});
import.meta.vitest?.test("agent-auth stays explicitly enableable", () => {
const defaults = applyOrganizationDefaults({
apps: {
installed: {
"agent-auth": {
enabled: true,
},
},
},
});
expect(defaults.apps.installed["agent-auth"].enabled).toBe(true);
expect(ALL_APPS["agent-auth"].independentlyEnableable).toBe(true);
});

View File

@ -293,6 +293,14 @@ const branchOnboardingSchema = yupObject({
requireEmailVerification: yupBoolean(),
});
const installedAppIdsByDefault = typedEntries(ALL_APPS)
.filter(([, app]) => {
if ("includedInDefaultInstalledApps" in app) {
return false;
}
return true;
})
.map(([appId]) => appId);
export const branchConfigSchema = canNoLongerBeOverridden(projectConfigSchema, [
"sourceOfTruth",
@ -745,7 +753,7 @@ const organizationConfigDefaults = {
},
apps: {
installed: typedFromEntries(appIds.map(appId => [appId, { enabled: false }])) as Record<string, { enabled: boolean } | undefined>,
installed: typedFromEntries(installedAppIdsByDefault.map((appId) => [appId, { enabled: false }])),
},
teams: {