mirror of
https://github.com/logto-io/logto.git
synced 2025-03-31 22:51:25 -05:00
chore(core): remove dev features flag from core (#5371)
chore(console): remove dev features flag from core
This commit is contained in:
parent
de46b3d3f4
commit
936a8733cf
5 changed files with 23 additions and 68 deletions
|
@ -4,6 +4,7 @@ import {
|
|||
buildDemoAppDataForTenant,
|
||||
InternalRole,
|
||||
ApplicationType,
|
||||
Applications,
|
||||
} from '@logto/schemas';
|
||||
import { generateStandardId, generateStandardSecret } from '@logto/shared';
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
|
@ -18,11 +19,7 @@ import { parseSearchParamsForSearch } from '#src/utils/search.js';
|
|||
|
||||
import type { AuthedRouter, RouterInitArgs } from '../types.js';
|
||||
|
||||
import {
|
||||
applicationResponseGuard,
|
||||
applicationCreateGuard,
|
||||
applicationPatchGuard,
|
||||
} from './types.js';
|
||||
import { applicationCreateGuard, applicationPatchGuard } from './types.js';
|
||||
|
||||
const includesInternalAdminRole = (roles: Readonly<Array<{ role: Role }>>) =>
|
||||
roles.some(({ role: { name } }) => name === InternalRole.Admin);
|
||||
|
@ -81,7 +78,7 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
|||
excludeRoleId: string().optional(),
|
||||
isThirdParty: z.union([z.literal('true'), z.literal('false')]).optional(),
|
||||
}),
|
||||
response: z.array(applicationResponseGuard),
|
||||
response: z.array(Applications.guard),
|
||||
status: 200,
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
|
@ -131,7 +128,7 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
|||
'/applications',
|
||||
koaGuard({
|
||||
body: applicationCreateGuard,
|
||||
response: applicationResponseGuard,
|
||||
response: Applications.guard,
|
||||
status: [200, 400, 422],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
|
@ -194,7 +191,7 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
|||
'/applications/:id',
|
||||
koaGuard({
|
||||
params: object({ id: string().min(1) }),
|
||||
response: applicationResponseGuard.merge(z.object({ isAdmin: z.boolean() })),
|
||||
response: Applications.guard.merge(z.object({ isAdmin: z.boolean() })),
|
||||
status: [200, 404],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
|
@ -230,7 +227,7 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
|||
isAdmin: boolean().optional(),
|
||||
})
|
||||
),
|
||||
response: applicationResponseGuard,
|
||||
response: Applications.guard,
|
||||
status: [200, 404, 422, 500],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
|
|
|
@ -1,29 +1,10 @@
|
|||
import {
|
||||
Applications,
|
||||
applicationCreateGuard as originalApplicationCreateGuard,
|
||||
applicationPatchGuard as originalApplicationPatchGuard,
|
||||
} from '@logto/schemas';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { EnvSet } from '#src/env-set/index.js';
|
||||
|
||||
enum OriginalApplicationType {
|
||||
Native = 'Native',
|
||||
SPA = 'SPA',
|
||||
Traditional = 'Traditional',
|
||||
MachineToMachine = 'MachineToMachine',
|
||||
}
|
||||
|
||||
// FIXME: @wangsijie Remove this guard once protected app is ready
|
||||
// @ts-expect-error -- hide the dev feature field from the guard type, but always return the full type to make the api logic simpler
|
||||
export const applicationResponseGuard: typeof Applications.guard = EnvSet.values
|
||||
.isDevFeaturesEnabled
|
||||
? Applications.guard
|
||||
: Applications.guard
|
||||
.omit({ type: true, protectedAppMetadata: true })
|
||||
.extend({ type: z.nativeEnum(OriginalApplicationType) });
|
||||
|
||||
const applicationCreateGuardWithProtectedAppMetadata = originalApplicationCreateGuard
|
||||
export const applicationCreateGuard = originalApplicationCreateGuard
|
||||
.omit({
|
||||
protectedAppMetadata: true,
|
||||
})
|
||||
|
@ -36,7 +17,7 @@ const applicationCreateGuardWithProtectedAppMetadata = originalApplicationCreate
|
|||
.optional(),
|
||||
});
|
||||
|
||||
const applicationPatchGuardWithProtectedAppMetadata = originalApplicationPatchGuard
|
||||
export const applicationPatchGuard = originalApplicationPatchGuard
|
||||
.deepPartial()
|
||||
.omit({
|
||||
protectedAppMetadata: true,
|
||||
|
@ -57,19 +38,3 @@ const applicationPatchGuardWithProtectedAppMetadata = originalApplicationPatchGu
|
|||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
// FIXME: @wangsijie Remove this guard once protected app is ready
|
||||
// @ts-expect-error -- hide the dev feature field from the guard type, but always return the full type to make the api logic simpler
|
||||
export const applicationCreateGuard: typeof applicationCreateGuardWithProtectedAppMetadata = EnvSet
|
||||
.values.isDevFeaturesEnabled
|
||||
? applicationCreateGuardWithProtectedAppMetadata
|
||||
: applicationCreateGuardWithProtectedAppMetadata
|
||||
.omit({ type: true, protectedAppMetadata: true })
|
||||
.extend({ type: z.nativeEnum(OriginalApplicationType) });
|
||||
|
||||
// FIXME: @wangsijie Remove this guard once protected app is ready
|
||||
// @ts-expect-error -- hide the dev feature field from the guard type, but always return the full type to make the api logic simpler
|
||||
export const applicationPatchGuard: typeof applicationPatchGuardWithProtectedAppMetadata = EnvSet
|
||||
.values.isDevFeaturesEnabled
|
||||
? applicationPatchGuardWithProtectedAppMetadata
|
||||
: applicationPatchGuardWithProtectedAppMetadata.omit({ protectedAppMetadata: true });
|
||||
|
|
|
@ -56,10 +56,7 @@ const createRouters = (tenant: TenantContext) => {
|
|||
applicationSignInExperienceRoutes(managementRouter, tenant);
|
||||
applicationUserConsentOrganizationRoutes(managementRouter, tenant);
|
||||
|
||||
// FIXME: @wangsijie: remove this after the feature is enabled by default
|
||||
if (!EnvSet.values.isCloud) {
|
||||
applicationProtectedAppMetadataRoutes(managementRouter, tenant);
|
||||
}
|
||||
applicationProtectedAppMetadataRoutes(managementRouter, tenant);
|
||||
|
||||
logtoConfigRoutes(managementRouter, tenant);
|
||||
connectorRoutes(managementRouter, tenant);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Applications } from '@logto/schemas';
|
||||
import { generateStandardId } from '@logto/shared';
|
||||
import { tryThat } from '@silverhand/essentials';
|
||||
import { object, string } from 'zod';
|
||||
|
@ -7,7 +8,6 @@ import koaGuard from '#src/middleware/koa-guard.js';
|
|||
import koaPagination from '#src/middleware/koa-pagination.js';
|
||||
import { parseSearchParamsForSearch } from '#src/utils/search.js';
|
||||
|
||||
import { applicationResponseGuard } from './applications/types.js';
|
||||
import type { AuthedRouter, RouterInitArgs } from './types.js';
|
||||
|
||||
export default function roleApplicationRoutes<T extends AuthedRouter>(
|
||||
|
@ -29,7 +29,7 @@ export default function roleApplicationRoutes<T extends AuthedRouter>(
|
|||
koaPagination(),
|
||||
koaGuard({
|
||||
params: object({ id: string().min(1) }),
|
||||
response: applicationResponseGuard.array(),
|
||||
response: Applications.guard.array(),
|
||||
status: [200, 204, 400, 404],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { object, string } from 'zod';
|
||||
|
||||
import { EnvSet } from '#src/env-set/index.js';
|
||||
import koaGuard from '#src/middleware/koa-guard.js';
|
||||
|
||||
import type { AuthedRouter, RouterInitArgs } from './types.js';
|
||||
|
@ -13,21 +12,18 @@ export default function systemRoutes<T extends AuthedRouter>(
|
|||
},
|
||||
]: RouterInitArgs<T>
|
||||
) {
|
||||
// FIXME: @wangsijie
|
||||
if (EnvSet.values.isDevFeaturesEnabled) {
|
||||
router.get(
|
||||
'/systems/application',
|
||||
koaGuard({
|
||||
response: object({ protectedApps: object({ defaultDomain: string() }) }),
|
||||
status: [200, 501],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
const defaultDomain = await protectedApps.getDefaultDomain();
|
||||
router.get(
|
||||
'/systems/application',
|
||||
koaGuard({
|
||||
response: object({ protectedApps: object({ defaultDomain: string() }) }),
|
||||
status: [200, 501],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
const defaultDomain = await protectedApps.getDefaultDomain();
|
||||
|
||||
ctx.body = { protectedApps: { defaultDomain } };
|
||||
ctx.body = { protectedApps: { defaultDomain } };
|
||||
|
||||
return next();
|
||||
}
|
||||
);
|
||||
}
|
||||
return next();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue