Skip to content

Commit 70582a3

Browse files
committed
chore: merge main into release for new releases
2 parents c40c52b + a289b57 commit 70582a3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

apps/api/src/trust-portal/trust-access.service.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ export class TrustAccessService {
10991099
},
11001100
});
11011101

1102+
// Return all resources - the download endpoint will auto-enable frameworks as needed
11021103
return complianceResources.map((resource) => ({
11031104
framework: resource.framework,
11041105
fileName: resource.fileName,
@@ -1139,6 +1140,45 @@ export class TrustAccessService {
11391140
);
11401141
}
11411142

1143+
// Check if framework is enabled in Trust record and auto-enable if not (for backward compatibility)
1144+
const trustRecord = await db.trust.findUnique({
1145+
where: { organizationId: grant.accessRequest.organizationId },
1146+
});
1147+
1148+
const frameworkFieldMap: Record<
1149+
TrustFramework,
1150+
| 'iso27001'
1151+
| 'iso42001'
1152+
| 'gdpr'
1153+
| 'hipaa'
1154+
| 'soc2type1'
1155+
| 'soc2type2'
1156+
| 'pci_dss'
1157+
| 'nen7510'
1158+
| 'iso9001'
1159+
> = {
1160+
[TrustFramework.iso_27001]: 'iso27001',
1161+
[TrustFramework.iso_42001]: 'iso42001',
1162+
[TrustFramework.gdpr]: 'gdpr',
1163+
[TrustFramework.hipaa]: 'hipaa',
1164+
[TrustFramework.soc2_type1]: 'soc2type1',
1165+
[TrustFramework.soc2_type2]: 'soc2type2',
1166+
[TrustFramework.pci_dss]: 'pci_dss',
1167+
[TrustFramework.nen_7510]: 'nen7510',
1168+
[TrustFramework.iso_9001]: 'iso9001',
1169+
};
1170+
1171+
const enabledField = frameworkFieldMap[framework];
1172+
if (trustRecord && !trustRecord[enabledField]) {
1173+
// Auto-enable the framework for backward compatibility with old organizations
1174+
await db.trust.update({
1175+
where: { organizationId: grant.accessRequest.organizationId },
1176+
data: {
1177+
[enabledField]: true,
1178+
},
1179+
});
1180+
}
1181+
11421182
// Download the original PDF from S3
11431183
const getCommand = new GetObjectCommand({
11441184
Bucket: APP_AWS_ORG_ASSETS_BUCKET,

0 commit comments

Comments
 (0)