style: satisfy housekeeping biome gate
This commit is contained in:
1 parent
d1160eb65a
commit
08358b8aa4
62 files changed
+2024
-773
No files matched your search
@@ -2,10 +2,7 @@ import "server-only";
|
||||
|
||||
import { eq } from "drizzle-orm";
|
||||
import { Ban, type Db, SupportTickets, User } from "@/lib/db";
|
||||
import type {
|
||||
AuditEntry,
|
||||
HousekeepingAuditWriter,
|
||||
} from "@/lib/services/audit";
|
||||
import type { AuditEntry, HousekeepingAuditWriter } from "@/lib/services/audit";
|
||||
import type {
|
||||
ModerationAction,
|
||||
ModerationActionTransport,
|
||||
@@ -55,10 +52,7 @@ export interface PeopleModerationMutationDependencies {
|
||||
snapshot: PeopleModerationMutationSnapshot,
|
||||
outcome: AuditOutcome,
|
||||
) => AuditEntry;
|
||||
readonly failure: (
|
||||
code: HousekeepingErrorCode,
|
||||
messageKey: string,
|
||||
) => Error;
|
||||
readonly failure: (code: HousekeepingErrorCode, messageKey: string) => Error;
|
||||
readonly record: (input: unknown) => Record<string, unknown>;
|
||||
readonly positiveInteger: (value: unknown) => number;
|
||||
readonly nonNegativeInteger: (value: unknown) => number;
|
||||
@@ -328,14 +322,7 @@ export function createPeopleModerationMutationExecutor(
|
||||
},
|
||||
};
|
||||
await writeAudit(
|
||||
auditEntry(
|
||||
context,
|
||||
operation,
|
||||
"Ban",
|
||||
banId,
|
||||
snapshot,
|
||||
"intent",
|
||||
),
|
||||
auditEntry(context, operation, "Ban", banId, snapshot, "intent"),
|
||||
tx,
|
||||
);
|
||||
});
|
||||
@@ -380,14 +367,7 @@ export function createPeopleModerationMutationExecutor(
|
||||
await tx.delete(Ban).where(eq(Ban.id, id));
|
||||
snapshot = { before: existing ?? null, after: null };
|
||||
await writeAudit(
|
||||
auditEntry(
|
||||
context,
|
||||
operation,
|
||||
"Ban",
|
||||
id,
|
||||
snapshot,
|
||||
"intent",
|
||||
),
|
||||
auditEntry(context, operation, "Ban", id, snapshot, "intent"),
|
||||
tx,
|
||||
);
|
||||
});
|
||||
|
||||
+65
-14
@@ -1012,25 +1012,62 @@ describe("People production workflow adapter", () => {
|
||||
{
|
||||
operation: "ticket-template.change",
|
||||
input: { action: "update", id: 88, title: "Updated" },
|
||||
rows: [[{ id: 88, title: "Greeting", content: "Hello", category: "general", sortOrder: 0 }]],
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
id: 88,
|
||||
title: "Greeting",
|
||||
content: "Hello",
|
||||
category: "general",
|
||||
sortOrder: 0,
|
||||
},
|
||||
],
|
||||
],
|
||||
transactional: true,
|
||||
},
|
||||
{
|
||||
operation: "help-ticket.reply",
|
||||
input: { ticketId: "9007199254740993", content: "Handled" },
|
||||
rows: [[{ id: 9_007_199_254_740_993n, userId: 7, open: true, title: "Appeal" }]],
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
id: 9_007_199_254_740_993n,
|
||||
userId: 7,
|
||||
open: true,
|
||||
title: "Appeal",
|
||||
},
|
||||
],
|
||||
],
|
||||
transactional: true,
|
||||
},
|
||||
{
|
||||
operation: "help-ticket.status",
|
||||
input: { ticketId: "9007199254740993", status: "close" },
|
||||
rows: [[{ id: 9_007_199_254_740_993n, userId: 7, open: true, title: "Appeal" }]],
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
id: 9_007_199_254_740_993n,
|
||||
userId: 7,
|
||||
open: true,
|
||||
title: "Appeal",
|
||||
},
|
||||
],
|
||||
],
|
||||
transactional: true,
|
||||
},
|
||||
{
|
||||
operation: "help-ticket.unban",
|
||||
input: { ticketId: "9007199254740993" },
|
||||
rows: [[{ id: 9_007_199_254_740_993n, userId: 7, open: true, title: "Appeal" }]],
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
id: 9_007_199_254_740_993n,
|
||||
userId: 7,
|
||||
open: true,
|
||||
title: "Appeal",
|
||||
},
|
||||
],
|
||||
],
|
||||
transactional: true,
|
||||
},
|
||||
{
|
||||
@@ -1041,20 +1078,32 @@ describe("People production workflow adapter", () => {
|
||||
},
|
||||
{
|
||||
operation: "cfh.sanction",
|
||||
input: { ticketId: 9, action: "alert", userId: 7, reason: "Repeated abuse" },
|
||||
input: {
|
||||
ticketId: 9,
|
||||
action: "alert",
|
||||
userId: 7,
|
||||
reason: "Repeated abuse",
|
||||
},
|
||||
rows: [[{ id: 9, state: 1, modId: 8 }]],
|
||||
transactional: true,
|
||||
},
|
||||
{
|
||||
operation: "ban.create",
|
||||
input: { userId: 7, hours: 24, type: "account", reason: "Repeated abuse" },
|
||||
input: {
|
||||
userId: 7,
|
||||
hours: 24,
|
||||
type: "account",
|
||||
reason: "Repeated abuse",
|
||||
},
|
||||
rows: [[{ username: "Alice" }]],
|
||||
transactional: true,
|
||||
},
|
||||
{
|
||||
operation: "ban.lift",
|
||||
input: { id: 12 },
|
||||
rows: [[{ id: 12, userId: 7, reason: "Repeated abuse", type: "account" }]],
|
||||
rows: [
|
||||
[{ id: 12, userId: 7, reason: "Repeated abuse", type: "account" }],
|
||||
],
|
||||
transactional: true,
|
||||
},
|
||||
{
|
||||
@@ -1082,11 +1131,7 @@ describe("People production workflow adapter", () => {
|
||||
action: `people.${operation}`,
|
||||
correlationId: `task13-${operation}`,
|
||||
}),
|
||||
...(
|
||||
transactional
|
||||
? [expect.any(Object)]
|
||||
: []
|
||||
),
|
||||
...(transactional ? [expect.any(Object)] : []),
|
||||
);
|
||||
if (transactional) expect(mocks.transaction).toHaveBeenCalledTimes(1);
|
||||
},
|
||||
@@ -1121,7 +1166,11 @@ describe("People production workflow adapter", () => {
|
||||
["unmute", { action: "unmute", userId: 7 }, "unmuteUser"],
|
||||
["alert", { action: "alert", userId: 7, message: "Stop" }, "alertUser"],
|
||||
["room-kick", { action: "room-kick", roomId: 12 }, "kickAll"],
|
||||
["broadcast", { action: "broadcast", message: "Notice", type: "staff" }, "staffAlert"],
|
||||
[
|
||||
"broadcast",
|
||||
{ action: "broadcast", message: "Notice", type: "staff" },
|
||||
"staffAlert",
|
||||
],
|
||||
] as const)(
|
||||
"preserves legacy confirmed-false success for %s while recording an observed outcome",
|
||||
async (_label, input, transport) => {
|
||||
@@ -1163,7 +1212,9 @@ describe("People production workflow adapter", () => {
|
||||
vi.clearAllMocks();
|
||||
mocks.resolveServerContext.mockResolvedValue(context());
|
||||
mocks.audit.mockResolvedValue(undefined);
|
||||
mocks.rcon.disconnectUser.mockRejectedValueOnce(new Error("RCON unavailable"));
|
||||
mocks.rcon.disconnectUser.mockRejectedValueOnce(
|
||||
new Error("RCON unavailable"),
|
||||
);
|
||||
await expect(
|
||||
peopleMutationService.execute(
|
||||
{ ...invocation, correlationId: "legacy-throw" },
|
||||
|
||||
@@ -11,10 +11,7 @@ import {
|
||||
WebsiteTicketMessage,
|
||||
WebsiteTicketTemplate,
|
||||
} from "@/lib/db";
|
||||
import type {
|
||||
AuditEntry,
|
||||
HousekeepingAuditWriter,
|
||||
} from "@/lib/services/audit";
|
||||
import type { AuditEntry, HousekeepingAuditWriter } from "@/lib/services/audit";
|
||||
import type {
|
||||
HousekeepingCapabilityContext,
|
||||
HousekeepingErrorCode,
|
||||
@@ -62,10 +59,7 @@ export interface PeopleSupportMutationDependencies {
|
||||
snapshot: PeopleSupportMutationSnapshot,
|
||||
outcome: AuditOutcome,
|
||||
) => AuditEntry;
|
||||
readonly failure: (
|
||||
code: HousekeepingErrorCode,
|
||||
messageKey: string,
|
||||
) => Error;
|
||||
readonly failure: (code: HousekeepingErrorCode, messageKey: string) => Error;
|
||||
readonly record: (input: unknown) => Record<string, unknown>;
|
||||
readonly positiveInteger: (value: unknown) => number;
|
||||
readonly nonNegativeInteger: (value: unknown) => number;
|
||||
@@ -74,9 +68,7 @@ export interface PeopleSupportMutationDependencies {
|
||||
max: number,
|
||||
required?: boolean,
|
||||
) => string;
|
||||
readonly canonicalTicketId: (
|
||||
value: string | number | bigint,
|
||||
) => bigint;
|
||||
readonly canonicalTicketId: (value: string | number | bigint) => bigint;
|
||||
readonly auditTargetId: (value: bigint) => number | undefined;
|
||||
}
|
||||
|
||||
@@ -299,19 +291,14 @@ export function createPeopleSupportMutationExecutor(
|
||||
}
|
||||
|
||||
async function executeHelpTicketMutation(
|
||||
operation: Extract<
|
||||
PeopleSupportMutationOperation,
|
||||
`help-ticket.${string}`
|
||||
>,
|
||||
operation: Extract<PeopleSupportMutationOperation, `help-ticket.${string}`>,
|
||||
input: unknown,
|
||||
context: PeopleSupportMutationContext,
|
||||
): Promise<PeopleSupportMutationSnapshot> {
|
||||
const data = record(input);
|
||||
let ticketId: bigint;
|
||||
try {
|
||||
ticketId = canonicalTicketId(
|
||||
data.ticketId as string | number | bigint,
|
||||
);
|
||||
ticketId = canonicalTicketId(data.ticketId as string | number | bigint);
|
||||
} catch {
|
||||
throw failure("VALIDATION", "errors.housekeeping.validation");
|
||||
}
|
||||
@@ -354,11 +341,7 @@ export function createPeopleSupportMutationExecutor(
|
||||
} else if (operation === "help-ticket.status") {
|
||||
const status = normalizedText(data.status, 16);
|
||||
const open =
|
||||
status === "reopen"
|
||||
? true
|
||||
: status === "close"
|
||||
? false
|
||||
: null;
|
||||
status === "reopen" ? true : status === "close" ? false : null;
|
||||
if (open === null) {
|
||||
throw failure("VALIDATION", "errors.housekeeping.validation");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user