Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 84x 84x 5x 5x 5x 4x | /**
* Helpers shared by the application routes (Art. 67), kept out of the route
* files because Next.js allows only HTTP handlers to be exported there.
*/
import { IDENTIFIABILITY, type ApplicationItems } from "@/lib/permits";
export function text(
body: Record<string, unknown>,
key: string,
): string | null {
const v = body[key];
return typeof v === "string" && v.trim() ? v.trim() : null;
}
/** The Art. 67(2) items a request body carries, cleaned; absent ones null. */
export function itemsFromBody(body: Record<string, unknown>): ApplicationItems {
const identifiability = text(body, "identifiability")?.toUpperCase() ?? null;
const period = body.processingPeriodMonths ?? body.periodMonths;
return {
namedPersons: text(body, "namedPersons"),
intendedUse: text(body, "intendedUse"),
requestedData: text(body, "requestedData"),
dataTimeRange: text(body, "dataTimeRange"),
dataFormats: text(body, "dataFormats"),
identifiability:
identifiability &&
(IDENTIFIABILITY as readonly string[]).includes(identifiability)
? identifiability
: null,
pseudonymisationJustification: text(body, "pseudonymisationJustification"),
datasetsBroughtIn: text(body, "datasetsBroughtIn"),
safeguards: text(body, "safeguards"),
processingPeriodMonths:
period === undefined || period === null || period === ""
? null
: Math.min(60, Math.max(1, Math.round(Number(period)) || 12)),
speTools: text(body, "speTools"),
ethicsCommitteeRef: text(body, "ethicsCommitteeRef"),
art71Exception:
typeof body.art71Exception === "boolean"
? body.art71Exception
: body.art71Exception === "true"
? true
: body.art71Exception === "false"
? false
: null,
art71ExceptionJustification: text(body, "art71ExceptionJustification"),
};
}
/** Every row carries these; the inbox and the register read them. */
export const APPLICATION_FIELDS = `
app.namedPersons AS namedPersons,
app.intendedUse AS intendedUse,
app.requestedData AS requestedData,
app.dataTimeRange AS dataTimeRange,
app.dataFormats AS dataFormats,
app.identifiability AS identifiability,
app.pseudonymisationJustification AS pseudonymisationJustification,
app.datasetsBroughtIn AS datasetsBroughtIn,
app.safeguards AS safeguards,
app.speTools AS speTools,
app.art71Exception AS art71Exception,
app.art71ExceptionJustification AS art71ExceptionJustification,
app.applicantCategory AS applicantCategory,
app.dataMinimisationStatement AS dataMinimisationStatement,
toString(app.completedAt) AS completedAt,
toString(app.extendedAt) AS extendedAt,
app.extensionReason AS extensionReason,
toString(app.incompleteNoticeAt) AS incompleteNoticeAt,
app.incompleteReason AS incompleteReason,
toString(app.completeBy) AS completeBy`;
export interface InboxRow extends ApplicationItems {
applicationId: string;
name: string | null;
applicant: string | null;
applicantName: string | null;
applicantCategory: string | null;
datasetId: string | null;
datasetTitle: string | null;
purpose: string | null;
status: string | null;
submittedAt: string | null;
justification: string | null;
dataMinimisationStatement: string | null;
periodMonths: number | null;
completedAt: string | null;
extendedAt: string | null;
extensionReason: string | null;
incompleteNoticeAt: string | null;
incompleteReason: string | null;
completeBy: string | null;
permitId: string | null;
decision: string | null;
decidedAt: string | null;
validUntil: string | null;
decisionJustification: string | null;
statisticalAlternativeOffered: boolean | null;
}
|