Refactor and centralize file mimeType integrity check and sanitization (#20889)

# Introduction
closes https://github.com/twentyhq/private-issues/issues/484

This PR refactors the writeFile API to never expect to be passed a
mimetype, its extract is done programmatically low level so any callers
will pass through
Same for the file sanitization

## IANA override
Disclaimer for consistency we existing behavior we wanted to always have
`application/typescript`
- should we rather consider fallbacking to octect-steam instead ?
- Any pulbic assets that has .ts will now also fallback to
`application/typescript` instead of the official IANA

## Integration
Added coverage
This commit is contained in:
Paul Rastoin
2026-05-26 17:10:52 +02:00
committed by GitHub
parent c74337978b
commit b8de469f37
30 changed files with 958 additions and 142 deletions
@@ -83,7 +83,6 @@ export class PrefillFrontComponentService {
fileFolder: FileFolder.Source,
resourcePath: sourceComponentPath,
sourceFile: sourceFile.content,
mimeType: 'application/typescript',
settings: {
isTemporaryFile: false,
toDelete: false,
@@ -97,7 +96,6 @@ export class PrefillFrontComponentService {
fileFolder: FileFolder.BuiltFrontComponent,
resourcePath: builtComponentPath,
sourceFile: builtFile.content,
mimeType: 'application/javascript',
settings: {
isTemporaryFile: false,
toDelete: false,