All files / src/lib supervision.ts

88.88% Statements 8/9
57.14% Branches 4/7
100% Functions 3/3
100% Lines 8/8

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                4x     4x                 4x                                                                                                       3x             2x 2x 2x       3x                  
/**
 * The access body's supervision of data users and holders, Regulation (EU)
 * 2025/327 Art. 63: a finding of non-compliance, the party's right to state
 * its views, the measures the body may take, and requests for information.
 * Shared by the routes and the pages. Issue #206, M4.
 */
 
/** Art. 63(2): the party states its views within four weeks at most. */
export const RESPONSE_WEEKS = 4;
 
/** Art. 63(3): revoke the permit, exclude the party for up to five years; fines under Art. 64. */
export const MEASURES = [
  "NONE",
  "WARNING",
  "REVOCATION",
  "EXCLUSION",
  "FINE",
] as const;
export type Measure = (typeof MEASURES)[number];
 
export const MEASURE_LABELS: Record<Measure, string> = {
  NONE: "no measure; the finding is closed",
  WARNING: "written warning",
  REVOCATION: "data permit revoked (Art. 63(3))",
  EXCLUSION: "excluded from access for a period, up to five years (Art. 63(3))",
  FINE: "administrative fine (Art. 64)",
};
 
export type FindingStatus = "OPEN" | "VIEWS_RECEIVED" | "CLOSED";
 
export interface Finding {
  findingId: string;
  party: string | null;
  partyName: string | null;
  partyType: string | null;
  permitId: string | null;
  description: string;
  gdprBreach: boolean;
  supervisoryAuthorityInformed: boolean;
  status: FindingStatus | string;
  notifiedAt: string | null;
  respondBy: string | null;
  daysToRespond: number | null;
  views: string | null;
  respondedAt: string | null;
  measure: string | null;
  measureNote: string | null;
  exclusionMonths: number | null;
  fineEur: number | null;
  closedAt: string | null;
  foundBy: string | null;
  accessBody: string | null;
}
 
export interface InformationRequest {
  requestId: string;
  party: string | null;
  partyName: string | null;
  permitId: string | null;
  findingId: string | null;
  question: string;
  status: "OPEN" | "ANSWERED" | string;
  requestedAt: string | null;
  answerBy: string | null;
  daysToAnswer: number | null;
  answer: string | null;
  answeredAt: string | null;
  requestedBy: string | null;
  accessBody: string | null;
}
 
export function weeksFrom(d: Date, weeks: number): Date {
  return new Date(d.getTime() + weeks * 7 * 86_400_000);
}
 
export function daysLeft(
  deadline: string | null | undefined,
  now = Date.now(),
): number | null {
  Iif (!deadline) return null;
  const t = Date.parse(deadline.replace(/(\.\d{3})\d+/, "$1"));
  return Number.isNaN(t) ? null : Math.ceil((t - now) / 86_400_000);
}
 
export function slugOf(did: string): string {
  return (
    did
      .replace(/^did:web:/, "")
      .split(":")[0]
      .split(".")[0]
      .replace(/[^a-z0-9-]/gi, "")
      .toLowerCase() || "party"
  );
}