From a289b573624adf4328dc54044899521b02628251 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 10:16:54 -0500 Subject: [PATCH] feat(trust): auto-enable frameworks in trust record for backward compatibility for old organizations (#1873) Co-authored-by: Tofik Hasanov Co-authored-by: Mariano Fuentes --- .../src/trust-portal/trust-access.service.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/apps/api/src/trust-portal/trust-access.service.ts b/apps/api/src/trust-portal/trust-access.service.ts index 8fe183e48..7311b2c8f 100644 --- a/apps/api/src/trust-portal/trust-access.service.ts +++ b/apps/api/src/trust-portal/trust-access.service.ts @@ -1099,6 +1099,7 @@ export class TrustAccessService { }, }); + // Return all resources - the download endpoint will auto-enable frameworks as needed return complianceResources.map((resource) => ({ framework: resource.framework, fileName: resource.fileName, @@ -1139,6 +1140,45 @@ export class TrustAccessService { ); } + // Check if framework is enabled in Trust record and auto-enable if not (for backward compatibility) + const trustRecord = await db.trust.findUnique({ + where: { organizationId: grant.accessRequest.organizationId }, + }); + + const frameworkFieldMap: Record< + TrustFramework, + | 'iso27001' + | 'iso42001' + | 'gdpr' + | 'hipaa' + | 'soc2type1' + | 'soc2type2' + | 'pci_dss' + | 'nen7510' + | 'iso9001' + > = { + [TrustFramework.iso_27001]: 'iso27001', + [TrustFramework.iso_42001]: 'iso42001', + [TrustFramework.gdpr]: 'gdpr', + [TrustFramework.hipaa]: 'hipaa', + [TrustFramework.soc2_type1]: 'soc2type1', + [TrustFramework.soc2_type2]: 'soc2type2', + [TrustFramework.pci_dss]: 'pci_dss', + [TrustFramework.nen_7510]: 'nen7510', + [TrustFramework.iso_9001]: 'iso9001', + }; + + const enabledField = frameworkFieldMap[framework]; + if (trustRecord && !trustRecord[enabledField]) { + // Auto-enable the framework for backward compatibility with old organizations + await db.trust.update({ + where: { organizationId: grant.accessRequest.organizationId }, + data: { + [enabledField]: true, + }, + }); + } + // Download the original PDF from S3 const getCommand = new GetObjectCommand({ Bucket: APP_AWS_ORG_ASSETS_BUCKET,