style: clean up code with prettier and eslint
This commit is contained in:
1 parent
60278b9e71
commit
fb8e77bb68
378 files changed
+22407
-20689
No files matched your search
@@ -1,26 +1,26 @@
|
||||
import { withAdmin } from '@/lib/api-handler'
|
||||
import { apiError } from '@/lib/api-response'
|
||||
import { PERMS } from '@/lib/permissions'
|
||||
import { logAudit } from '@/lib/services/audit'
|
||||
import { ensureEffectDirs, importSingleEffect } from '@/lib/services/effect-import'
|
||||
import { runSseBatch } from '@/lib/services/import/core/sse-batch'
|
||||
import type { EffectMapEntry } from '@/types/effects'
|
||||
import { withAdmin } from "@/lib/api-handler";
|
||||
import { apiError } from "@/lib/api-response";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import { logAudit } from "@/lib/services/audit";
|
||||
import { ensureEffectDirs, importSingleEffect } from "@/lib/services/effect-import";
|
||||
import { runSseBatch } from "@/lib/services/import/core/sse-batch";
|
||||
import type { EffectMapEntry } from "@/types/effects";
|
||||
|
||||
export const POST = withAdmin({ permission: PERMS.ASSETS_IMPORT }, async (request, ctx) => {
|
||||
const body = await request.json()
|
||||
const rawItems: EffectMapEntry[] = body.items || []
|
||||
const concurrency = body.concurrency || 3
|
||||
if (rawItems.length === 0) return apiError('No effects to import', 400)
|
||||
const body = await request.json();
|
||||
const rawItems: EffectMapEntry[] = body.items || [];
|
||||
const concurrency = body.concurrency || 3;
|
||||
if (rawItems.length === 0) return apiError("No effects to import", 400);
|
||||
|
||||
// Dedupe by lib (the .nitro filename) to avoid double work in one request.
|
||||
const seen = new Set<string>()
|
||||
const seen = new Set<string>();
|
||||
const items = rawItems.filter((it) => {
|
||||
if (seen.has(it.lib)) return false
|
||||
seen.add(it.lib)
|
||||
return true
|
||||
})
|
||||
if (seen.has(it.lib)) return false;
|
||||
seen.add(it.lib);
|
||||
return true;
|
||||
});
|
||||
|
||||
await ensureEffectDirs()
|
||||
await ensureEffectDirs();
|
||||
|
||||
return runSseBatch<EffectMapEntry>({
|
||||
items,
|
||||
@@ -33,17 +33,17 @@ export const POST = withAdmin({ permission: PERMS.ASSETS_IMPORT }, async (reques
|
||||
type: it.type,
|
||||
revision: it.revision,
|
||||
onProgress: report,
|
||||
})
|
||||
});
|
||||
if (r.ok) {
|
||||
logAudit({
|
||||
userId: ctx.session.user.id,
|
||||
action: 'effect_import',
|
||||
target: 'EffectMap',
|
||||
action: "effect_import",
|
||||
target: "EffectMap",
|
||||
targetId: 0,
|
||||
after: { id: it.id, lib: it.lib, type: it.type, batch: true },
|
||||
})
|
||||
});
|
||||
}
|
||||
return { ok: r.ok, warnings: r.warnings, error: r.error }
|
||||
return { ok: r.ok, warnings: r.warnings, error: r.error };
|
||||
},
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -1,30 +1,30 @@
|
||||
import { withAdmin } from '@/lib/api-handler'
|
||||
import { apiError, apiOk } from '@/lib/api-response'
|
||||
import { PERMS } from '@/lib/permissions'
|
||||
import { logAudit } from '@/lib/services/audit'
|
||||
import { deleteImportedEffect, getEffectList, getEffectStats } from '@/lib/services/effect-import'
|
||||
import { withAdmin } from "@/lib/api-handler";
|
||||
import { apiError, apiOk } from "@/lib/api-response";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import { logAudit } from "@/lib/services/audit";
|
||||
import { deleteImportedEffect, getEffectList, getEffectStats } from "@/lib/services/effect-import";
|
||||
|
||||
export const GET = withAdmin({ permission: PERMS.ASSETS_IMPORT }, async (request) => {
|
||||
const action = request.nextUrl.searchParams.get('action')
|
||||
if (action === 'stats') {
|
||||
return apiOk(await getEffectStats())
|
||||
const action = request.nextUrl.searchParams.get("action");
|
||||
if (action === "stats") {
|
||||
return apiOk(await getEffectStats());
|
||||
}
|
||||
const search = request.nextUrl.searchParams.get('search') || ''
|
||||
const effects = await getEffectList(search)
|
||||
return apiOk({ effects })
|
||||
})
|
||||
const search = request.nextUrl.searchParams.get("search") || "";
|
||||
const effects = await getEffectList(search);
|
||||
return apiOk({ effects });
|
||||
});
|
||||
|
||||
export const DELETE = withAdmin({ permission: PERMS.ASSETS_IMPORT }, async (request, ctx) => {
|
||||
const idOrLib = request.nextUrl.searchParams.get('lib') || request.nextUrl.searchParams.get('id')
|
||||
if (!idOrLib) return apiError('Missing lib/id', 400)
|
||||
const { removed, deletedFile } = await deleteImportedEffect(idOrLib)
|
||||
if (!removed && !deletedFile) return apiError(`Effect "${idOrLib}" not found`, 404)
|
||||
const idOrLib = request.nextUrl.searchParams.get("lib") || request.nextUrl.searchParams.get("id");
|
||||
if (!idOrLib) return apiError("Missing lib/id", 400);
|
||||
const { removed, deletedFile } = await deleteImportedEffect(idOrLib);
|
||||
if (!removed && !deletedFile) return apiError(`Effect "${idOrLib}" not found`, 404);
|
||||
logAudit({
|
||||
userId: ctx.session.user.id,
|
||||
action: 'effect_delete',
|
||||
target: 'EffectMap',
|
||||
action: "effect_delete",
|
||||
target: "EffectMap",
|
||||
targetId: 0,
|
||||
after: { idOrLib, removed, deletedFile },
|
||||
})
|
||||
return apiOk({ idOrLib, removed, deletedFile })
|
||||
})
|
||||
});
|
||||
return apiOk({ idOrLib, removed, deletedFile });
|
||||
});
|
||||
Reference in new issue
Block a user