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
@@ -94,7 +94,6 @@ export class LogicFunctionResourceService {
fileFolder: FileFolder.Source,
resourcePath: sourceHandlerPath,
sourceFile: sourceFile.content,
mimeType: 'application/typescript',
settings: {
isTemporaryFile: false,
toDelete: false,
@@ -107,7 +106,6 @@ export class LogicFunctionResourceService {
fileFolder: FileFolder.BuiltLogicFunction,
resourcePath: builtHandlerPath,
sourceFile: builtFile.content,
mimeType: 'application/javascript',
settings: {
isTemporaryFile: false,
toDelete: false,
@@ -139,7 +137,6 @@ export class LogicFunctionResourceService {
resourcePath: sourceHandlerPath,
sourceFile: sourceHandlerCode,
settings: { isTemporaryFile: false, toDelete: false },
mimeType: 'application/typescript',
queryRunner,
});
}
@@ -172,7 +169,6 @@ export class LogicFunctionResourceService {
fileFolder: FileFolder.BuiltLogicFunction,
resourcePath: builtHandlerPath,
sourceFile: builtCode,
mimeType: 'application/javascript',
settings: {
isTemporaryFile: false,
toDelete: false,