feat: improve admin panel (#14180)

This commit is contained in:
DarkSky
2025-12-30 05:22:54 +08:00
committed by GitHub
parent d6b380aee5
commit 95a5e941e7
94 changed files with 3146 additions and 1114 deletions
@@ -1,16 +0,0 @@
import { ModuleRef } from '@nestjs/core';
import { PrismaClient } from '@prisma/client';
import { FeatureModel } from '../../models';
export class RefreshFeatures0001 {
static always = true;
// do the migration
static async up(_db: PrismaClient, ref: ModuleRef) {
await ref.get(FeatureModel, { strict: false }).refreshFeatures();
}
// revert the migration
static async down(_db: PrismaClient) {}
}
@@ -1,57 +0,0 @@
import { PrismaClient } from '@prisma/client';
import { FeatureConfigs, FeatureName, FeatureType } from '../../models';
export class FeatureRedundant1738590347632 {
// do the migration
static async up(db: PrismaClient) {
const features = await db.feature.findMany();
const validFeatures = new Map<
number,
{
name: string;
type: FeatureType;
}
>();
for (const feature of features) {
const def = FeatureConfigs[feature.name as FeatureName];
if (!def || def.deprecatedVersion !== feature.deprecatedVersion) {
await db.feature.delete({
where: { id: feature.id },
});
} else {
validFeatures.set(feature.id, {
name: feature.name,
type: def.type,
});
}
}
for (const [id, def] of validFeatures.entries()) {
await db.userFeature.updateMany({
where: {
featureId: id,
},
data: {
name: def.name,
type: def.type,
},
});
await db.workspaceFeature.updateMany({
where: {
featureId: id,
},
data: {
name: def.name,
type: def.type,
},
});
}
}
// revert the migration
static async down(_db: PrismaClient) {
// noop
}
}
@@ -1,9 +1,7 @@
export * from './0001-refresh-features';
export * from './1698398506533-guid';
export * from './1703756315970-unamed-account';
export * from './1721299086340-refresh-unnamed-user';
export * from './1732861452428-migrate-invite-status';
export * from './1733125339942-universal-subscription';
export * from './1738590347632-feature-redundant';
export * from './1745211351719-create-indexer-tables';
export * from './1751966744168-correct-session-update-time';