Check snapshot type and id from url

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-28 17:57:12 +02:00
parent 7d80a7d5f4
commit da4553beb2
16 changed files with 227 additions and 45 deletions

View File

@@ -15,7 +15,7 @@ export { certificationCategoryLabel, certifications } from "./certifications";
export { availableFrameworks } from "./frameworks";
export { getDocumentTypeLabel, documentTypes } from "./documents";
export { getAssetTypeVariant, getCriticityVariant } from "./assets";
export { getSnapshotTypeLabel, getSnapshotTypeUrlPath, snapshotTypes } from "./snapshots";
export { getSnapshotTypeLabel, getSnapshotTypeUrlPath, snapshotTypes, validateSnapshotConsistency } from "./snapshots";
export { getAuditStateLabel, getAuditStateVariant, auditStates } from "./audits";
export { getStatusVariant, getStatusLabel, getNonconformityRegistryStatusOptions, getComplianceRegistryStatusOptions, registryStatuses } from "./registryStatus";
export { promisifyMutation } from "./relay";

View File

@@ -38,3 +38,16 @@ export function getSnapshotTypeUrlPath(type?: string): string {
return "";
}
}
export interface SnapshotableResource {
snapshotId?: string | null | undefined;
}
export function validateSnapshotConsistency(
resource: SnapshotableResource | null | undefined,
urlSnapshotId?: string | null | undefined
): void {
if (resource && resource.snapshotId !== (urlSnapshotId ?? null)) {
throw new Error("PAGE_NOT_FOUND");
}
}