Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -24,10 +24,10 @@ function getDsgvoCliMocks(): DsgvoCliMocks {
return global.__dsgvoCliMocks__;
}
vi.mock("@toolctrl/db/client.server", () => ({
vi.mock("@hivegrid/db/client.server", () => ({
getDbClient: () => getDsgvoCliMocks().db,
}));
vi.mock("@toolctrl/db/audit-events.server", () => ({
vi.mock("@hivegrid/db/audit-events.server", () => ({
createAuditEvent: getDsgvoCliMocks().createAuditEvent,
}));
vi.mock("consola", () => ({
@@ -47,8 +47,8 @@ export const dsgvoDeleteCommand = defineCommand({
const requestId = randomUUID();
const [{ getDbClient }, { createAuditEvent }] = await Promise.all([
import("@toolctrl/db/client.server"),
import("@toolctrl/db/audit-events.server"),
import("@hivegrid/db/client.server"),
import("@hivegrid/db/audit-events.server"),
]);
const prisma = getDbClient();
await prisma.user.update({
@@ -0,0 +1,107 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
type AuditEventInput = {
tenantId: string | null;
actorId: string;
actorType: string;
action: string;
targetType: string;
targetId: string;
regulatoryScope: string[];
dataSensitivity: string;
outcome: string;
metadata: { requestId: string; intent: string; source: string };
};
const createAuditEvent = vi.fn<(input: AuditEventInput) => Promise<{ id: string }>>();
vi.mock("@hivegrid/db/audit-events.server", () => ({
createAuditEvent: (...args: unknown[]) => createAuditEvent(...(args as [AuditEventInput])),
}));
vi.mock("consola", () => ({
default: {
success: vi.fn(),
},
}));
import consola from "consola";
import { dsgvoExportCommand } from "./export.js";
import { dsgvoVerifyCommand } from "./verify.js";
const consoleMock = vi.mocked(consola);
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
describe("dsgvo export command", () => {
beforeEach(() => {
vi.clearAllMocks();
createAuditEvent.mockResolvedValue({ id: "audit_1" });
});
it("writes a REQUEST_PERSONAL_DATA_EXPORT audit row with explicit tenant and actor", async () => {
await dsgvoExportCommand.run?.({
args: { user: "user_1", tenant: "tenant_1", actor: "admin_1" },
} as never);
expect(createAuditEvent).toHaveBeenCalledTimes(1);
const payload = createAuditEvent.mock.calls[0]![0];
expect(payload).toMatchObject({
tenantId: "tenant_1",
actorId: "admin_1",
action: "REQUEST_PERSONAL_DATA_EXPORT",
targetType: "User",
targetId: "user_1",
regulatoryScope: ["gdpr"],
dataSensitivity: "pii",
outcome: "success",
});
expect(payload.metadata.intent).toBe("export");
expect(payload.metadata.source).toBe("cli");
expect(payload.metadata.requestId).toMatch(UUID_RE);
expect(consoleMock.success).toHaveBeenCalledWith(
`Personal-data export queued for user=user_1 requestId=${payload.metadata.requestId}`,
);
});
it("defaults the actor to cli-operator and tenant to null when omitted", async () => {
await dsgvoExportCommand.run?.({ args: { user: "user_2" } } as never);
expect(createAuditEvent).toHaveBeenCalledWith(
expect.objectContaining({ tenantId: null, actorId: "cli-operator" }),
);
});
});
describe("dsgvo verify command", () => {
beforeEach(() => {
vi.clearAllMocks();
createAuditEvent.mockResolvedValue({ id: "audit_1" });
});
it("writes a VERIFY_USER_DELETION audit row with verify intent", async () => {
await dsgvoVerifyCommand.run?.({
args: { user: "user_1", tenant: "tenant_1", actor: "admin_1" },
} as never);
const payload = createAuditEvent.mock.calls[0]![0];
expect(payload).toMatchObject({
tenantId: "tenant_1",
actorId: "admin_1",
action: "VERIFY_USER_DELETION",
targetType: "User",
targetId: "user_1",
});
expect(payload.metadata.intent).toBe("verify");
expect(payload.metadata.requestId).toMatch(UUID_RE);
expect(consoleMock.success).toHaveBeenCalledWith(
`Verifier-pass queued for user=user_1 requestId=${payload.metadata.requestId}`,
);
});
it("defaults the actor and tenant when only the user id is given", async () => {
await dsgvoVerifyCommand.run?.({ args: { user: "user_9" } } as never);
expect(createAuditEvent).toHaveBeenCalledWith(
expect.objectContaining({ tenantId: null, actorId: "cli-operator" }),
);
});
});
@@ -23,7 +23,7 @@ export const dsgvoExportCommand = defineCommand({
const actorId = args.actor ? String(args.actor) : "cli-operator";
const requestId = randomUUID();
const { createAuditEvent } = await import("@toolctrl/db/audit-events.server");
const { createAuditEvent } = await import("@hivegrid/db/audit-events.server");
await createAuditEvent({
tenantId,
actorId,
@@ -23,8 +23,8 @@ export const dsgvoReactivateCommand = defineCommand({
const requestId = randomUUID();
const [{ getDbClient }, { createAuditEvent }] = await Promise.all([
import("@toolctrl/db/client.server"),
import("@toolctrl/db/audit-events.server"),
import("@hivegrid/db/client.server"),
import("@hivegrid/db/audit-events.server"),
]);
const prisma = getDbClient();
const existing = await prisma.user.findUnique({
@@ -25,7 +25,7 @@ export const dsgvoVerifyCommand = defineCommand({
const tenantId = args.tenant ? String(args.tenant) : null;
const actorId = args.actor ? String(args.actor) : "cli-operator";
const requestId = randomUUID();
const { createAuditEvent } = await import("@toolctrl/db/audit-events.server");
const { createAuditEvent } = await import("@hivegrid/db/audit-events.server");
await createAuditEvent({
tenantId,
actorId,