Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+21
@@ -1,4 +1,5 @@
|
||||
import { Event } from "@hivegrid/db/prisma-browser";
|
||||
import { neutralizeSpreadsheetFormula } from "@hivegrid/foundation/spreadsheet-safety";
|
||||
import { FiltersDto } from "~/application/dtos/data/FiltersDto";
|
||||
import { PaginationResultDto } from "~/application/dtos/data/PaginationResultDto";
|
||||
import { db } from "~/utils/db.server";
|
||||
@@ -82,6 +83,26 @@ export async function getEvents(
|
||||
};
|
||||
}
|
||||
|
||||
const EVENTS_CSV_HEADERS = ["createdAt", "event", "description", "user", "tenant", "data"];
|
||||
|
||||
function escapeCsvCell(value: string | null | undefined): string {
|
||||
const safeValue = neutralizeSpreadsheetFormula(value ?? "");
|
||||
if (/[",\n\r]/.test(safeValue)) {
|
||||
return `"${safeValue.replace(/"/g, '""')}"`;
|
||||
}
|
||||
return safeValue;
|
||||
}
|
||||
|
||||
export function serializeEventsCsv(items: readonly EventWithAttempts[]): string {
|
||||
const lines = [EVENTS_CSV_HEADERS.map(escapeCsvCell).join(",")];
|
||||
for (const item of items) {
|
||||
lines.push(
|
||||
[item.createdAt.toISOString(), item.name, item.description, item.user?.email, item.tenant?.name, item.data].map(escapeCsvCell).join(",")
|
||||
);
|
||||
}
|
||||
return `${lines.join("\n")}\n`;
|
||||
}
|
||||
|
||||
export async function getEvent(id: string, tenantId?: string | null): Promise<EventWithDetails | null> {
|
||||
return await db.event.findFirst({
|
||||
where: {
|
||||
|
||||
Reference in new issue
Block a user