@solidxai/core 0.1.13-beta.20 → 0.1.13-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +590 -0
  2. package/CLAUDE.md +5 -6
  3. package/dist/constants/media-file-types.d.ts.map +1 -1
  4. package/dist/constants/media-file-types.js +1 -0
  5. package/dist/constants/media-file-types.js.map +1 -1
  6. package/dist/dtos/create-field-metadata.dto.d.ts +1 -0
  7. package/dist/dtos/create-field-metadata.dto.d.ts.map +1 -1
  8. package/dist/dtos/create-field-metadata.dto.js +12 -1
  9. package/dist/dtos/create-field-metadata.dto.js.map +1 -1
  10. package/dist/entities/field-metadata.entity.d.ts +1 -0
  11. package/dist/entities/field-metadata.entity.d.ts.map +1 -1
  12. package/dist/entities/field-metadata.entity.js +5 -1
  13. package/dist/entities/field-metadata.entity.js.map +1 -1
  14. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.d.ts +6 -0
  15. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.d.ts.map +1 -1
  16. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.js +54 -27
  17. package/dist/helpers/field-crud-managers/MediaFieldCrudManager.js.map +1 -1
  18. package/dist/services/chatter-message.service.d.ts +1 -0
  19. package/dist/services/chatter-message.service.d.ts.map +1 -1
  20. package/dist/services/chatter-message.service.js +44 -12
  21. package/dist/services/chatter-message.service.js.map +1 -1
  22. package/dist/services/crud.service.d.ts.map +1 -1
  23. package/dist/services/crud.service.js +1 -0
  24. package/dist/services/crud.service.js.map +1 -1
  25. package/dist/services/field-metadata.service.d.ts.map +1 -1
  26. package/dist/services/field-metadata.service.js +2 -0
  27. package/dist/services/field-metadata.service.js.map +1 -1
  28. package/dist/services/media.service.d.ts.map +1 -1
  29. package/dist/services/media.service.js +1 -0
  30. package/dist/services/media.service.js.map +1 -1
  31. package/dist/services/module-metadata.service.d.ts.map +1 -1
  32. package/dist/services/module-metadata.service.js +7 -0
  33. package/dist/services/module-metadata.service.js.map +1 -1
  34. package/dist/services/setting.service.d.ts.map +1 -1
  35. package/dist/services/setting.service.js +4 -0
  36. package/dist/services/setting.service.js.map +1 -1
  37. package/dist/services/settings/default-settings-provider.service.d.ts +20 -0
  38. package/dist/services/settings/default-settings-provider.service.d.ts.map +1 -1
  39. package/dist/services/settings/default-settings-provider.service.js +14 -0
  40. package/dist/services/settings/default-settings-provider.service.js.map +1 -1
  41. package/dist/solid-core.module.d.ts.map +1 -1
  42. package/dist/solid-core.module.js +6 -0
  43. package/dist/solid-core.module.js.map +1 -1
  44. package/package.json +1 -1
  45. package/src/constants/media-file-types.ts +1 -0
  46. package/src/dtos/create-field-metadata.dto.ts +14 -1
  47. package/src/entities/field-metadata.entity.ts +3 -0
  48. package/src/helpers/field-crud-managers/MediaFieldCrudManager.ts +73 -34
  49. package/src/services/chatter-message.service.ts +56 -14
  50. package/src/services/crud.service.ts +1 -0
  51. package/src/services/field-metadata.service.ts +2 -0
  52. package/src/services/media.service.ts +1 -0
  53. package/src/services/module-metadata.service.ts +7 -0
  54. package/src/services/setting.service.ts +5 -0
  55. package/src/services/settings/default-settings-provider.service.ts +14 -0
  56. package/src/solid-core.module.ts +13 -0
  57. package/postman/mpin.postman_collection.json +0 -1045
@@ -1 +1 @@
1
- {"version":3,"file":"media-file-types.js","sourceRoot":"","sources":["../../src/constants/media-file-types.ts"],"names":[],"mappings":";;;AAoEA,8DAmBC;AAOD,8DASC;AAWD,8EAGC;AAUD,kDAEC;AAQD,oDAOC;AA9IY,QAAA,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAEpF,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9F,MAAM,gBAAgB,GAA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C,GAAG,EAAE,OAAgB,CAAC,CAAC,CAAC;IAC7E,GAAG,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAe,CAAC,CAAC,CAAC;IAC/E,CAAC,aAAa,CAAC,EAAE,KAAK;CACzB,CAAC;AAMW,QAAA,sBAAsB,GAAG,IAAI,GAAG,CAAS;IAClD,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;IACnB,aAAa;CAChB,CAAC,CAAC","sourcesContent":["export type MediaCategory = 'image' | 'audio' | 'video' | 'file' | 'pdf';\n\nexport const MEDIA_CATEGORIES = ['image', 'audio', 'video', 'file', 'pdf'] as const;\n\nconst IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif', 'bmp', 'tiff', 'heic', 'heif'];\nconst AUDIO_EXTENSIONS = ['mp3', 'wav', 'ogg', 'aac', 'm4a', 'flac', 'webm'];\nconst VIDEO_EXTENSIONS = ['mp4', 'mov', 'avi', 'mkv', 'mpeg', 'mpg', '3gp', '3g2', 'webm', 'ogg'];\nconst DOCUMENT_EXTENSIONS = ['txt', 'md', 'csv', 'json', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'zip', 'rar', '7z'];\nconst PDF_EXTENSION = 'pdf';\n\n/**\n * Extensions that must never be accepted as media uploads, regardless of declared mimetype or\n * admin-configured mediaTypes allowlist. Checked before any other resolution so a spoofed\n * Content-Type (e.g. application/octet-stream on an .html file) can't bypass this.\n */\nexport const DANGEROUS_EXTENSIONS = new Set([\n 'html', 'htm', 'xhtml', 'svg', 'xml',\n 'js', 'mjs', 'php', 'phtml', 'jsp', 'asp', 'aspx',\n 'exe', 'sh', 'bat', 'cmd', 'ps1', 'jar', 'dll',\n]);\n\n\n/**\n * Mimetypes that are never safe to accept, regardless of extension. These render as active\n * content in a browser (svg can carry <script>), so they are rejected even when the filename\n * looks harmless. Kept alongside DANGEROUS_EXTENSIONS so upload paths check both.\n */\nexport const DANGEROUS_MIME_TYPES = new Set([\n 'image/svg+xml', 'text/html', 'application/xhtml+xml',\n]);\n\n/**\n * Percent-decodes a filename, repeating a bounded number of times so a double-encoded payload\n * (`%252e` -> `%2e` -> `.`) survives a single pass through a proxy/framework that already\n * decoded once. Malformed escape sequences are left as-is rather than thrown, since this runs\n * on attacker-controlled input and a literal `%` in a filename (`100%done.pdf`) is legal.\n */\nfunction decodePercentEncodingSafely(name: string): string {\n let decoded = name;\n for (let i = 0; i < 3; i++) {\n let next: string;\n try {\n next = decodeURIComponent(decoded);\n } catch {\n return decoded;\n }\n if (next === decoded) {\n return decoded;\n }\n decoded = next;\n }\n return decoded;\n}\n\n/**\n * Reduces a client-supplied name to the name that will actually be resolved on disk, so\n * extension checks can't be dodged by decorating it. Each step defends a known bypass:\n *\n * - `evil.exe%2e` -> percent-encoding a trailing dot (or anything else) hides the real\n * extension from naive string matching; decode before inspecting it.\n * - `../../evil.exe` -> only the final path segment is the file name.\n * - `evil.exe\\0.png` -> a NUL truncates the name at the syscall/filesystem layer, so\n * anything after it is invisible to the OS but visible to naive\n * validation.\n * - `evil.exe::$DATA` -> NTFS alternate data stream suffix; the file on disk is evil.exe.\n * - `evil.exe.` / `.exe ` -> Windows silently strips trailing dots and spaces when resolving\n * a path, so these land on disk as evil.exe.\n */\nexport function normalizeUploadedFileName(fileName?: string | null): string {\n if (!fileName) {\n return '';\n }\n\n let name = decodePercentEncodingSafely(String(fileName));\n name = name.split(/[/\\\\]/).pop() ?? '';\n\n const nulIndex = name.indexOf('\\0');\n if (nulIndex >= 0) {\n name = name.slice(0, nulIndex);\n }\n\n const streamIndex = name.indexOf(':');\n if (streamIndex >= 0) {\n name = name.slice(0, streamIndex);\n }\n\n return name.replace(/[\\s.]+$/, '');\n}\n\n/**\n * The effective extension - what the OS/browser will treat the file as. Used for media\n * category resolution and inline-safety decisions. Always normalizes first, so\n * `evil.exe.` resolves to `exe` rather than to nothing.\n */\nexport function getLowercaseFileExtension(fileName?: string | null): string | undefined {\n const name = normalizeUploadedFileName(fileName);\n\n const lastDotIndex = name.lastIndexOf('.');\n if (lastDotIndex < 0 || lastDotIndex === name.length - 1) {\n return undefined;\n }\n\n return name.slice(lastDotIndex + 1).toLowerCase();\n}\n\n/**\n * Every dot-delimited segment after the stem, lowercased. The danger check uses this rather\n * than only the effective extension so a dangerous type buried in a double extension\n * (`evil.exe.png`, `shell.php.jpg`) is still caught - several servers and browsers resolve\n * such names by an earlier segment than the last one.\n *\n * The stem is skipped so an innocuous file that merely starts with a keyword (`exe.png`)\n * isn't rejected.\n */\nexport function getLowercaseFileExtensionSegments(fileName?: string | null): string[] {\n const segments = normalizeUploadedFileName(fileName).toLowerCase().split('.');\n return segments.slice(1).filter(segment => segment.length > 0);\n}\n\n/** Minimal shape of an uploaded file, so this module stays free of framework imports. */\nexport interface UploadedFileLike {\n mimetype?: string;\n originalname?: string;\n filename?: string;\n}\n\n/** originalname is the client-supplied name; filename is multer's on-disk name. */\nexport function getUploadedFileName(file?: UploadedFileLike | null): string {\n return file?.originalname ?? file?.filename ?? '';\n}\n\n/**\n * Single predicate for \"must never be stored\". Shared by every upload entry point\n * (MediaFieldCrudManager, chatter attachments) so the rules can't drift between them.\n * Extensions are checked before mimetype so a spoofed Content-Type (e.g.\n * application/octet-stream, or image/png, on an .html file) can't bypass it.\n */\nexport function isDangerousMediaFile(file?: UploadedFileLike | null): boolean {\n const segments = getLowercaseFileExtensionSegments(getUploadedFileName(file));\n if (segments.some(segment => DANGEROUS_EXTENSIONS.has(segment))) {\n return true;\n }\n\n return DANGEROUS_MIME_TYPES.has((file?.mimetype || '').toLowerCase().trim());\n}\n\n/**\n * Single source of truth for extension -> coarse media category. Shared by upload-time\n * validation (MediaFieldCrudManager) and serve-time header hardening (ServeStaticModule), so\n * both agree on which extensions belong to which category and neither drifts out of sync.\n * webm/ogg are shared between AUDIO_EXTENSIONS and VIDEO_EXTENSIONS - last one wins here, they\n * default to 'video' since that's the more common upload case.\n */\nexport const EXT_TO_MEDIA_TYPE: Record<string, MediaCategory> = {\n ...Object.fromEntries(IMAGE_EXTENSIONS.map((ext) => [ext, 'image' as const])),\n ...Object.fromEntries(AUDIO_EXTENSIONS.map((ext) => [ext, 'audio' as const])),\n ...Object.fromEntries(VIDEO_EXTENSIONS.map((ext) => [ext, 'video' as const])),\n ...Object.fromEntries(DOCUMENT_EXTENSIONS.map((ext) => [ext, 'file' as const])),\n [PDF_EXTENSION]: 'pdf',\n};\n\n/**\n * Extensions safe to serve inline with their natural Content-Type; everything else served from\n * media-files-storage is forced to application/octet-stream + Content-Disposition: attachment.\n */\nexport const INLINE_SAFE_EXTENSIONS = new Set<string>([\n ...IMAGE_EXTENSIONS,\n ...AUDIO_EXTENSIONS,\n ...VIDEO_EXTENSIONS,\n PDF_EXTENSION,\n]);\n"]}
1
+ {"version":3,"file":"media-file-types.js","sourceRoot":"","sources":["../../src/constants/media-file-types.ts"],"names":[],"mappings":";;;AAqEA,8DAmBC;AAOD,8DASC;AAWD,8EAGC;AAUD,kDAEC;AAQD,oDAOC;AA/IY,QAAA,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAEpF,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9F,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7E,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACl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CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAe,CAAC,CAAC,CAAC;IAC/E,CAAC,aAAa,CAAC,EAAE,KAAK;CACzB,CAAC;AAMW,QAAA,sBAAsB,GAAG,IAAI,GAAG,CAAS;IAClD,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;IACnB,aAAa;CAChB,CAAC,CAAC","sourcesContent":["export type MediaCategory = 'image' | 'audio' | 'video' | 'file' | 'pdf';\n\nexport const MEDIA_CATEGORIES = ['image', 'audio', 'video', 'file', 'pdf'] as const;\n\nconst IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif', 'bmp', 'tiff', 'heic', 'heif'];\nconst AUDIO_EXTENSIONS = ['mp3', 'wav', 'ogg', 'aac', 'm4a', 'flac', 'webm'];\nconst VIDEO_EXTENSIONS = ['mp4', 'mov', 'avi', 'mkv', 'mpeg', 'mpg', '3gp', '3g2', 'webm', 'ogg'];\nconst DOCUMENT_EXTENSIONS = ['txt', 'md', 'csv', 'json', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'zip', 'rar', '7z'];\nconst PDF_EXTENSION = 'pdf';\n\n/**\n * Extensions that must never be accepted as media uploads, regardless of declared mimetype or\n * admin-configured mediaTypes allowlist. Checked before any other resolution so a spoofed\n * Content-Type (e.g. application/octet-stream on an .html file) can't bypass this.\n */\nexport const DANGEROUS_EXTENSIONS = new Set([\n 'html', 'htm', 'xhtml', 'svg', 'xml',\n 'js', 'mjs', 'php', 'phtml', 'jsp', 'asp', 'aspx',\n 'exe', 'sh', 'bat', 'cmd', 'ps1', 'jar', 'dll',\n 'msi', 'msix', 'msp', 'com', 'scr', 'vbs', 'vbe', 'wsf', 'wsh', 'hta', 'cpl', 'pif', 'reg',\n]);\n\n\n/**\n * Mimetypes that are never safe to accept, regardless of extension. These render as active\n * content in a browser (svg can carry <script>), so they are rejected even when the filename\n * looks harmless. Kept alongside DANGEROUS_EXTENSIONS so upload paths check both.\n */\nexport const DANGEROUS_MIME_TYPES = new Set([\n 'image/svg+xml', 'text/html', 'application/xhtml+xml',\n]);\n\n/**\n * Percent-decodes a filename, repeating a bounded number of times so a double-encoded payload\n * (`%252e` -> `%2e` -> `.`) survives a single pass through a proxy/framework that already\n * decoded once. Malformed escape sequences are left as-is rather than thrown, since this runs\n * on attacker-controlled input and a literal `%` in a filename (`100%done.pdf`) is legal.\n */\nfunction decodePercentEncodingSafely(name: string): string {\n let decoded = name;\n for (let i = 0; i < 3; i++) {\n let next: string;\n try {\n next = decodeURIComponent(decoded);\n } catch {\n return decoded;\n }\n if (next === decoded) {\n return decoded;\n }\n decoded = next;\n }\n return decoded;\n}\n\n/**\n * Reduces a client-supplied name to the name that will actually be resolved on disk, so\n * extension checks can't be dodged by decorating it. Each step defends a known bypass:\n *\n * - `evil.exe%2e` -> percent-encoding a trailing dot (or anything else) hides the real\n * extension from naive string matching; decode before inspecting it.\n * - `../../evil.exe` -> only the final path segment is the file name.\n * - `evil.exe\\0.png` -> a NUL truncates the name at the syscall/filesystem layer, so\n * anything after it is invisible to the OS but visible to naive\n * validation.\n * - `evil.exe::$DATA` -> NTFS alternate data stream suffix; the file on disk is evil.exe.\n * - `evil.exe.` / `.exe ` -> Windows silently strips trailing dots and spaces when resolving\n * a path, so these land on disk as evil.exe.\n */\nexport function normalizeUploadedFileName(fileName?: string | null): string {\n if (!fileName) {\n return '';\n }\n\n let name = decodePercentEncodingSafely(String(fileName));\n name = name.split(/[/\\\\]/).pop() ?? '';\n\n const nulIndex = name.indexOf('\\0');\n if (nulIndex >= 0) {\n name = name.slice(0, nulIndex);\n }\n\n const streamIndex = name.indexOf(':');\n if (streamIndex >= 0) {\n name = name.slice(0, streamIndex);\n }\n\n return name.replace(/[\\s.]+$/, '');\n}\n\n/**\n * The effective extension - what the OS/browser will treat the file as. Used for media\n * category resolution and inline-safety decisions. Always normalizes first, so\n * `evil.exe.` resolves to `exe` rather than to nothing.\n */\nexport function getLowercaseFileExtension(fileName?: string | null): string | undefined {\n const name = normalizeUploadedFileName(fileName);\n\n const lastDotIndex = name.lastIndexOf('.');\n if (lastDotIndex < 0 || lastDotIndex === name.length - 1) {\n return undefined;\n }\n\n return name.slice(lastDotIndex + 1).toLowerCase();\n}\n\n/**\n * Every dot-delimited segment after the stem, lowercased. The danger check uses this rather\n * than only the effective extension so a dangerous type buried in a double extension\n * (`evil.exe.png`, `shell.php.jpg`) is still caught - several servers and browsers resolve\n * such names by an earlier segment than the last one.\n *\n * The stem is skipped so an innocuous file that merely starts with a keyword (`exe.png`)\n * isn't rejected.\n */\nexport function getLowercaseFileExtensionSegments(fileName?: string | null): string[] {\n const segments = normalizeUploadedFileName(fileName).toLowerCase().split('.');\n return segments.slice(1).filter(segment => segment.length > 0);\n}\n\n/** Minimal shape of an uploaded file, so this module stays free of framework imports. */\nexport interface UploadedFileLike {\n mimetype?: string;\n originalname?: string;\n filename?: string;\n}\n\n/** originalname is the client-supplied name; filename is multer's on-disk name. */\nexport function getUploadedFileName(file?: UploadedFileLike | null): string {\n return file?.originalname ?? file?.filename ?? '';\n}\n\n/**\n * Single predicate for \"must never be stored\". Shared by every upload entry point\n * (MediaFieldCrudManager, chatter attachments) so the rules can't drift between them.\n * Extensions are checked before mimetype so a spoofed Content-Type (e.g.\n * application/octet-stream, or image/png, on an .html file) can't bypass it.\n */\nexport function isDangerousMediaFile(file?: UploadedFileLike | null): boolean {\n const segments = getLowercaseFileExtensionSegments(getUploadedFileName(file));\n if (segments.some(segment => DANGEROUS_EXTENSIONS.has(segment))) {\n return true;\n }\n\n return DANGEROUS_MIME_TYPES.has((file?.mimetype || '').toLowerCase().trim());\n}\n\n/**\n * Single source of truth for extension -> coarse media category. Shared by upload-time\n * validation (MediaFieldCrudManager) and serve-time header hardening (ServeStaticModule), so\n * both agree on which extensions belong to which category and neither drifts out of sync.\n * webm/ogg are shared between AUDIO_EXTENSIONS and VIDEO_EXTENSIONS - last one wins here, they\n * default to 'video' since that's the more common upload case.\n */\nexport const EXT_TO_MEDIA_TYPE: Record<string, MediaCategory> = {\n ...Object.fromEntries(IMAGE_EXTENSIONS.map((ext) => [ext, 'image' as const])),\n ...Object.fromEntries(AUDIO_EXTENSIONS.map((ext) => [ext, 'audio' as const])),\n ...Object.fromEntries(VIDEO_EXTENSIONS.map((ext) => [ext, 'video' as const])),\n ...Object.fromEntries(DOCUMENT_EXTENSIONS.map((ext) => [ext, 'file' as const])),\n [PDF_EXTENSION]: 'pdf',\n};\n\n/**\n * Extensions safe to serve inline with their natural Content-Type; everything else served from\n * media-files-storage is forced to application/octet-stream + Content-Disposition: attachment.\n */\nexport const INLINE_SAFE_EXTENSIONS = new Set<string>([\n ...IMAGE_EXTENSIONS,\n ...AUDIO_EXTENSIONS,\n ...VIDEO_EXTENSIONS,\n PDF_EXTENSION,\n]);\n"]}
@@ -145,6 +145,7 @@ export declare class CreateFieldMetadataDto {
145
145
  private: boolean;
146
146
  mediaTypes: MediaType[];
147
147
  mediaMaxSizeKb: number;
148
+ mediaAllowedExtensions?: string[];
148
149
  mediaStorageProviderId?: number;
149
150
  mediaStorageProviderUserKey?: string;
150
151
  relationType: RelationType;
@@ -1 +1 @@
1
- {"version":3,"file":"create-field-metadata.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/create-field-metadata.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAahF,oBAAY,qBAAqB;IAC/B,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,oBAAY,cAAc;IAExB,GAAG,QAAQ;IACX,MAAM,WAAW;IAGjB,OAAO,YAAY;IAGnB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,IAAI,SAAS;IAGb,OAAO,YAAY;IAGnB,IAAI,SAAS;IACb,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CAAC;IAI7B,uBAAuB,EAAE,MAAM,CAAC;IAIhC,wBAAwB,EAAE,MAAM,CAAC;IAIjC,yBAAyB,EAAE,OAAO,CAAC;IAKnC,wBAAwB,EAAE,MAAM,CAAC;IAQjC,wBAAwB,EAAE,MAAM,CAAC;IAKjC,4BAA4B,EAAE,MAAM,CAAC;IAOrC,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAKhC,kBAAkB,EAAE,kBAAkB,CAAC;IAKvC,0BAA0B,EAAE,MAAM,CAAC;IAKnC,8BAA8B,EAAE,MAAM,CAAC;IAKvC,sBAAsB,EAAE,sBAAsB,CAAC;IAK/C,0BAA0B,EAAE,0BAA0B,EAAE,CAAC;IAMzD,IAAI,EAAE,MAAM,CAAC;IAKb,QAAQ,EAAE,OAAO,CAAC;IAKlB,kBAAkB,EAAE,OAAO,CAAC;IAK5B,UAAU,EAAE,MAAM,CAAA;IAKlB,yBAAyB,EAAE,MAAM,CAAA;IAKjC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAK3B,qBAAqB,EAAE,MAAM,CAAA;IAK7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAK9B,aAAa,EAAE,OAAO,CAAC;IAKvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
@@ -156,7 +156,7 @@ class ComputedFieldTriggerConfig {
156
156
  exports.ComputedFieldTriggerConfig = ComputedFieldTriggerConfig;
157
157
  class CreateFieldMetadataDto {
158
158
  static _OPENAPI_METADATA_FACTORY() {
159
- return { name: { required: true, type: () => String }, displayName: { required: true, type: () => String }, description: { required: true, type: () => String }, type: { required: true, enum: require("./create-field-metadata.dto").SolidFieldType }, modelId: { required: true, type: () => Number }, ormType: { required: true, type: () => Object, enum: exports.ALL_ORM_TYPES }, length: { required: true, type: () => Number }, defaultValue: { required: true, type: () => String }, regexPattern: { required: true, type: () => String }, regexPatternNotMatchingErrorMsg: { required: true, type: () => String }, required: { required: true, type: () => Boolean }, unique: { required: true, type: () => Boolean }, encrypt: { required: true, type: () => Boolean }, encryptionType: { required: true, enum: require("./create-field-metadata.dto").EncryptionType }, decryptWhen: { required: true, enum: require("./create-field-metadata.dto").DecryptWhenType }, index: { required: true, type: () => Boolean }, max: { required: true, type: () => Number }, min: { required: true, type: () => Number }, private: { required: true, type: () => Boolean }, mediaTypes: { required: true, type: () => [Object], enum: [...media_file_types_1.MEDIA_CATEGORIES] }, mediaMaxSizeKb: { required: true, type: () => Number }, mediaStorageProviderId: { required: false, type: () => Number }, mediaStorageProviderUserKey: { required: false, type: () => String }, relationType: { required: true, enum: require("./create-field-metadata.dto").RelationType }, relationCoModelSingularName: { required: true, type: () => String }, relationCreateInverse: { required: true, type: () => Boolean }, relationCascade: { required: true, enum: require("./create-field-metadata.dto").CascadeType }, relationModelModuleName: { required: true, type: () => String }, relationCoModelFieldName: { required: true, type: () => String }, isRelationManyToManyOwner: { required: true, type: () => Boolean }, relationFieldFixedFilter: { required: true, type: () => String }, selectionDynamicProvider: { required: true, type: () => String }, selectionDynamicProviderCtxt: { required: true, type: () => String }, selectionStaticValues: { required: true, type: () => [String] }, selectionValueType: { required: true, enum: require("./create-field-metadata.dto").SelectionValueType }, computedFieldValueProvider: { required: true, type: () => String }, computedFieldValueProviderCtxt: { required: true, type: () => String }, computedFieldValueType: { required: true, enum: require("./create-field-metadata.dto").ComputedFieldValueType }, computedFieldTriggerConfig: { required: true, type: () => [require("./create-field-metadata.dto").ComputedFieldTriggerConfig] }, uuid: { required: true, type: () => String }, isSystem: { required: true, type: () => Boolean }, isMarkedForRemoval: { required: true, type: () => Boolean }, columnName: { required: true, type: () => String }, relationCoModelColumnName: { required: true, type: () => String }, isUserKey: { required: true, type: () => Boolean }, relationJoinTableName: { required: true, type: () => String }, enableAuditTracking: { required: false, type: () => Boolean }, isMultiSelect: { required: true, type: () => Boolean }, isPrimaryKey: { required: false, type: () => Boolean } };
159
+ return { name: { required: true, type: () => String }, displayName: { required: true, type: () => String }, description: { required: true, type: () => String }, type: { required: true, enum: require("./create-field-metadata.dto").SolidFieldType }, modelId: { required: true, type: () => Number }, ormType: { required: true, type: () => Object, enum: exports.ALL_ORM_TYPES }, length: { required: true, type: () => Number }, defaultValue: { required: true, type: () => String }, regexPattern: { required: true, type: () => String }, regexPatternNotMatchingErrorMsg: { required: true, type: () => String }, required: { required: true, type: () => Boolean }, unique: { required: true, type: () => Boolean }, encrypt: { required: true, type: () => Boolean }, encryptionType: { required: true, enum: require("./create-field-metadata.dto").EncryptionType }, decryptWhen: { required: true, enum: require("./create-field-metadata.dto").DecryptWhenType }, index: { required: true, type: () => Boolean }, max: { required: true, type: () => Number }, min: { required: true, type: () => Number }, private: { required: true, type: () => Boolean }, mediaTypes: { required: true, type: () => [Object], enum: [...media_file_types_1.MEDIA_CATEGORIES] }, mediaMaxSizeKb: { required: true, type: () => Number }, mediaAllowedExtensions: { required: false, type: () => [String] }, mediaStorageProviderId: { required: false, type: () => Number }, mediaStorageProviderUserKey: { required: false, type: () => String }, relationType: { required: true, enum: require("./create-field-metadata.dto").RelationType }, relationCoModelSingularName: { required: true, type: () => String }, relationCreateInverse: { required: true, type: () => Boolean }, relationCascade: { required: true, enum: require("./create-field-metadata.dto").CascadeType }, relationModelModuleName: { required: true, type: () => String }, relationCoModelFieldName: { required: true, type: () => String }, isRelationManyToManyOwner: { required: true, type: () => Boolean }, relationFieldFixedFilter: { required: true, type: () => String }, selectionDynamicProvider: { required: true, type: () => String }, selectionDynamicProviderCtxt: { required: true, type: () => String }, selectionStaticValues: { required: true, type: () => [String] }, selectionValueType: { required: true, enum: require("./create-field-metadata.dto").SelectionValueType }, computedFieldValueProvider: { required: true, type: () => String }, computedFieldValueProviderCtxt: { required: true, type: () => String }, computedFieldValueType: { required: true, enum: require("./create-field-metadata.dto").ComputedFieldValueType }, computedFieldTriggerConfig: { required: true, type: () => [require("./create-field-metadata.dto").ComputedFieldTriggerConfig] }, uuid: { required: true, type: () => String }, isSystem: { required: true, type: () => Boolean }, isMarkedForRemoval: { required: true, type: () => Boolean }, columnName: { required: true, type: () => String }, relationCoModelColumnName: { required: true, type: () => String }, isUserKey: { required: true, type: () => Boolean }, relationJoinTableName: { required: true, type: () => String }, enableAuditTracking: { required: false, type: () => Boolean }, isMultiSelect: { required: true, type: () => Boolean }, isPrimaryKey: { required: false, type: () => Boolean } };
160
160
  }
161
161
  }
162
162
  exports.CreateFieldMetadataDto = CreateFieldMetadataDto;
@@ -279,6 +279,17 @@ __decorate([
279
279
  (0, class_validator_1.IsOptional)(),
280
280
  __metadata("design:type", Number)
281
281
  ], CreateFieldMetadataDto.prototype, "mediaMaxSizeKb", void 0);
282
+ __decorate([
283
+ (0, swagger_1.ApiProperty)({ description: 'Explicit allowlist of file extensions (e.g. ["pdf","xlsx","png"]) permitted for this field, checked in addition to any mediaTypes category restriction — both must pass if both are set. For a strict allowlist, leave mediaTypes empty and use this alone. Only for type=mediaSingle,mediaMultiple', }),
284
+ (0, class_transformer_1.Transform)(({ value }) => Array.isArray(value)
285
+ ? value.map((ext) => String(ext).toLowerCase().trim().replace(/^\./, ''))
286
+ : value),
287
+ (0, class_validator_1.IsArray)(),
288
+ (0, class_validator_1.IsString)({ each: true }),
289
+ (0, class_validator_1.IsNotIn)([...media_file_types_1.DANGEROUS_EXTENSIONS], { each: true }),
290
+ (0, class_validator_1.IsOptional)(),
291
+ __metadata("design:type", Array)
292
+ ], CreateFieldMetadataDto.prototype, "mediaAllowedExtensions", void 0);
282
293
  __decorate([
283
294
  (0, swagger_1.ApiProperty)({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple', }),
284
295
  (0, class_validator_1.IsInt)(),
@@ -1 +1 @@
1
- {"version":3,"file":"create-field-metadata.dto.js","sourceRoot":"","sources":["../../src/dtos/create-field-metadata.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,yDAAoD;AACpD,oEAAgF;AAEhF,qDAUyB;AACzB,IAAY,qBAQX;AARD,WAAY,qBAAqB;IAC/B,oCAAW,CAA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IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0DACK;AAKlB;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,uCAAuC,GAAG,CAAC;IACtE,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;yEACoB;AAKxB;IAHR,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;IAC3C,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;yDACe;AAK3B;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mCAAmC,GAAG,CAAC;IAClE,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACgB;AAK7B;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sCAAsC,GAAG,CAAC;IACrE,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;mEACkB;AAK9B;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,GAAG,CAAC;IACrD,IAAA,2BAAS,GAAE;;6DACW;AAKvB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,GAAG,CAAC;IACrD,IAAA,2BAAS,GAAE;;4DACW","sourcesContent":["import { ApiProperty } from '@nestjs/swagger';\nimport { Transform, Type } from 'class-transformer';\nimport { MEDIA_CATEGORIES, MediaCategory } from '../constants/media-file-types';\n\nimport {\n IsArray,\n IsBoolean,\n IsEnum,\n IsIn,\n IsInt,\n IsOptional,\n IsString,\n Matches,\n ValidateIf\n} from 'class-validator';\nexport enum RelationFieldsCommand {\n set = \"set\",\n clear = \"clear\",\n link = \"link\",\n unlink = \"unlink\",\n create = \"create\",\n update = \"update\",\n delete = \"delete\"\n}\n\nexport enum SolidFieldType {\n // numeric types\n int = 'int',\n bigint = 'bigint',\n // float = 'float',\n // double = 'double',\n decimal = 'decimal',\n\n // text types\n shortText = 'shortText',\n longtext = 'longText',\n richText = 'richText',\n json = 'json',\n\n // boolean types\n boolean = 'boolean',\n\n // date\n date = 'date',\n datetime = 'datetime',\n time = 'time',\n\n // relation\n relation = 'relation',\n\n // media\n mediaSingle = 'mediaSingle',\n mediaMultiple = 'mediaMultiple',\n\n email = 'email',\n password = 'password',\n\n // selection\n selectionStatic = 'selectionStatic',\n selectionDynamic = 'selectionDynamic',\n\n computed = 'computed',\n\n uuid = 'uuid'\n}\n\nexport enum MySQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n int = 'int',\n decimal = 'decimal',\n double = 'double',\n\n // Text types\n // fieldType=shortText\n varchar = 'varchar',\n // fieldType=longText\n text = 'shortText',\n mediumtext = 'mediumtext',\n longtext = 'longtext',\n\n // Boolean types\n // fieldType=boolean\n bool = 'bool',\n boolean = 'boolean',\n\n //Date Types\n date = 'date',\n datetime = 'datetime',\n timestamp = 'timestamp',\n time = 'time',\n\n // Other types\n json = 'json',\n\n}\n\nexport enum PSQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n integer = 'integer',\n decimal = 'decimal',\n bigint = 'bigint',\n\n // Text types\n varchar = 'varchar',\n text = 'text',\n\n // Boolean types\n boolean = 'boolean',\n\n // Date types\n timestamp = 'timestamp',\n timestamptz = 'timestamptz',\n time = 'time',\n date = 'date',\n\n // Other types\n json = 'json',\n jsonb = 'jsonb',\n simplejson = 'simple-json'\n}\n\nexport enum MSSQLType {\n int = \"int\",\n bigint = \"bigint\",\n decimal = \"decimal\",\n numeric = \"numeric\",\n varchar = \"varchar\",\n nvarchar = \"nvarchar\",\n simplejson = \"simple-json\",\n text = \"text\",\n bit = \"bit\",\n date = \"date\",\n datetime = \"datetime\",\n datetime2 = \"datetime2\",\n time = \"time\",\n uniqueidentifier = \"uniqueidentifier\"\n}\n\nexport const ALL_ORM_TYPES = [\n ...Object.values(PSQLType),\n ...Object.values(MSSQLType),\n ...Object.values(MySQLType),\n] as const;\n\nexport type OrmType = typeof ALL_ORM_TYPES[number];\n\n// export type OrmType = PSQLType | MySQLType | MSSQLType;\n\nexport enum EncryptionType {\n aes128 = 'aes-128',\n aes256 = 'aes-256',\n}\n\nexport enum DecryptWhenType {\n beforeTransit = 'before-transit',\n afterTransit = 'after-transit',\n}\n\nexport type MediaType = MediaCategory;\n\nexport enum RelationType {\n manyToOne = 'many-to-one',\n manyTomany = 'many-to-many',\n oneToMany = 'one-to-many',\n}\n\nexport enum CascadeType {\n setNull = 'set null',\n restrict = 'restrict',\n cascade = 'cascade',\n}\n\n// export enum MediaStorageProviderType {\n// database = 'database',\n// file = 'file',\n// s3 = 's3',\n// }\n\nexport enum SelectionValueType {\n string = 'string',\n int = 'int',\n}\n\nexport enum ComputedFieldValueType {\n string = 'string',\n int = 'int',\n decimal = 'decimal',\n boolean = 'boolean',\n date = 'date',\n datetime = 'datetime',\n}\n\nexport enum ComputedFieldTriggerOperation {\n beforeInsert = \"before-insert\",\n afterInsert = \"after-insert\",\n beforeUpdate = \"before-update\",\n afterUpdate = \"after-update\",\n beforeRemove = \"before-delete\",\n afterRemove = \"after-delete\",\n}\n\nexport class ComputedFieldTriggerConfig {\n moduleName: string; // Name of the module where the computed field is defined\n modelName: string;\n operations: ComputedFieldTriggerOperation[]; // List of operations where this computed field should be triggered\n}\n\nexport class CreateFieldMetadataDto {\n @ApiProperty({ description: 'Name of your field, this is also the name of the column or attribute', })\n // @Matches(/[a-z]+(_[a-z]+)*/, { message: 'Field name should follow snake case conventions only with all lower case.', })\n @IsString()\n name: string;\n\n @ApiProperty({ description: 'Display name of your field' })\n @IsString()\n readonly displayName: string;\n\n\n @ApiProperty({ description: 'Description of your field' })\n @IsOptional()\n @IsString()\n readonly description: string;\n\n // @ApiProperty({ description: \"Help text associated with this field\" })\n // @IsString()\n // readonly helpText: string;\n\n @ApiProperty({ description: 'Field can have types' })\n @IsEnum(SolidFieldType)\n readonly type: SolidFieldType;\n\n @ApiProperty({ description: 'Related model id' })\n @IsInt()\n @IsOptional()\n readonly modelId: number;\n\n //For all types of fields\n @ApiProperty({ description: 'Field can have orm types specific to your database', })\n @IsIn(ALL_ORM_TYPES)\n @IsOptional()\n readonly ormType: OrmType;\n\n @ApiProperty({ description: 'Length of the field. Only for type=text' })\n @IsInt()\n @IsOptional()\n readonly length: number;\n\n @ApiProperty({ description: 'Default value of the field' })\n @IsString()\n @IsOptional()\n readonly defaultValue: string;\n\n @ApiProperty({ description: 'Format regex pattern for the field. Only for type=text, longText, email, password', })\n @IsString()\n @IsOptional()\n readonly regexPattern: string;\n\n @ApiProperty({ description: 'If the regex pattern matching fails, then what is the error message to be displayed', })\n @IsString()\n @IsOptional()\n readonly regexPatternNotMatchingErrorMsg: string;\n\n @ApiProperty({ description: 'Is the field mandatory?' })\n @IsBoolean()\n readonly required: boolean;\n\n @ApiProperty({ description: 'Is the field value unique?' })\n @IsBoolean()\n @IsOptional()\n readonly unique: boolean;\n\n @ApiProperty({ description: 'Is the field symmetric encrypted?' })\n @IsBoolean()\n readonly encrypt: boolean;\n\n @ApiProperty({ description: 'Type of encryption. Only if encrypt=true' })\n @IsEnum(EncryptionType)\n @IsOptional()\n readonly encryptionType: EncryptionType;\n\n //Pending\n @ApiProperty({ description: 'At what point do we want to decrypt the data? Only if encrypt=true', })\n @IsEnum(DecryptWhenType)\n @IsOptional()\n decryptWhen: DecryptWhenType;\n\n @ApiProperty({ description: 'Is the field indexed? For all types, except:richText, longText', })\n @IsBoolean()\n index: boolean;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n max: number;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n min: number;\n\n @ApiProperty({ description: 'Is the field private?' })\n @IsBoolean()\n private: boolean;\n\n @ApiProperty({ description: 'Allowed media types for the field. Only for type=mediaSingle,mediaMultiple', })\n @IsIn([...MEDIA_CATEGORIES], { each: true })\n @IsOptional()\n mediaTypes: MediaType[];\n\n @ApiProperty({ description: 'Maximum size of the media in KB. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaMaxSizeKb: number;\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderId?: number;\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple. When you need to specify the storage provider by name.', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderUserKey?: string;\n\n // @ApiProperty({ description: 'Is the media embedded in the entity table? Only for type=mediaSingle', })\n // @IsBoolean()\n // @IsOptional()\n // mediaEmbedded: boolean;\n\n @ApiProperty({ description: 'Relation Type. Only for type=relation' })\n @IsEnum(RelationType)\n @IsOptional()\n relationType: RelationType;\n\n @ApiProperty({ description: 'Related model for the relation. Only for type=relation' })\n @IsString()\n @IsOptional()\n relationCoModelSingularName: string;\n\n @ApiProperty({ description: 'Create inverse relation. Only for type=relation', })\n @IsBoolean()\n @IsOptional()\n relationCreateInverse: boolean;\n\n @ApiProperty({ description: 'Cascade type. Only for type=relation' })\n @IsEnum(CascadeType)\n @IsOptional()\n relationCascade: CascadeType;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation, if the related field belongs to a different module' })\n @IsOptional()\n relationModelModuleName: string;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation and relationType=many-to-many, i.e if the related many to many field belongs to a different model' })\n @IsOptional()\n relationCoModelFieldName: string;\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to set the owner of the many-to-many relation' })\n @IsOptional()\n isRelationManyToManyOwner: boolean;\n\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to store fixed filters that needs to applied on related model' })\n @IsOptional()\n relationFieldFixedFilter: string;\n\n @ApiProperty({\n description:\n 'Dynamic provider for selection. Only for type=selectionDynamic',\n })\n @IsString()\n @IsOptional()\n selectionDynamicProvider: string;\n\n @ApiProperty({ description: 'Dynamic provider Context. Only for type=selectionDynamic', })\n @IsString()\n @IsOptional()\n selectionDynamicProviderCtxt: string;\n\n @ApiProperty({ description: 'Static values for selection. Only for type=selectionStatic', })\n @IsArray()\n @IsString({ each: true })\n // @Matches(/^[\\w\\s\\d\\-\\/]+:[\\w\\s\\-\\/]+$/, { each: true })\n @IsOptional()\n selectionStaticValues: string[];\n\n @ApiProperty({ description: 'Type of value for selection. Applicable for type=selectionStatic,selectionDynamic', })\n @IsEnum(SelectionValueType)\n @IsOptional()\n selectionValueType: SelectionValueType;\n\n @ApiProperty({ description: 'Computed Field Value Provider. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProvider: string;\n\n @ApiProperty({ description: 'Computed Field Value Provider Context. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProviderCtxt: string;\n\n @ApiProperty({ description: 'Computed field value type. Only for type=computed', })\n @IsEnum(ComputedFieldValueType)\n @IsOptional()\n computedFieldValueType: ComputedFieldValueType;\n\n @IsArray()\n @Type(() => ComputedFieldTriggerConfig)\n @IsOptional()\n computedFieldTriggerConfig: ComputedFieldTriggerConfig[];\n\n @IsOptional()\n @ApiProperty({ description: 'Uuid.', })\n @IsString()\n @IsOptional()\n uuid: string;\n\n @IsOptional()\n @ApiProperty({ description: 'System fields are not included in the code generation, the assumption being that system fields have manually written code.', })\n @IsBoolean()\n isSystem: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Marked for removal, this is used to soft delete the field.', })\n @IsBoolean()\n isMarkedForRemoval: boolean;\n\n @ApiProperty({ description: 'Column Name of Field', })\n @IsString()\n @IsOptional()\n columnName: string\n\n @ApiProperty({ description: 'Relation CoModel Column Name of Field', })\n @IsString()\n @IsOptional()\n relationCoModelColumnName: string\n\n @ApiProperty({ description: \"Is User Key\" })\n @IsOptional()\n @IsBoolean()\n readonly isUserKey: boolean\n\n @ApiProperty({ description: 'Relation Join Table Name of Field', })\n @IsString()\n @IsOptional()\n relationJoinTableName: string\n\n @ApiProperty({ description: 'Enable Audit Tracking for this field', })\n @IsOptional()\n @IsBoolean()\n enableAuditTracking?: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is MultiSelect Field', })\n @IsBoolean()\n isMultiSelect: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is Primary Key Field', })\n @IsBoolean()\n isPrimaryKey?: boolean;\n}\n"]}
1
+ {"version":3,"file":"create-field-metadata.dto.js","sourceRoot":"","sources":["../../src/dtos/create-field-metadata.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAC9C,yDAAoD;AACpD,oEAAsG;AAEtG,qDAWyB;AACzB,IAAY,qBAQX;AARD,WAAY,qBAAqB;IAC/B,oCAAW,CAAA;IACX,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;AACnB,CAAC,EARW,qBAAqB,qCAArB,qBAAqB,QAQhC;AAED,IAAY,cAuCX;AAvCD,WAAY,cAAc;IAExB,6BAAW,CAAA;IACX,mCAAiB,CAAA;IAGjB,qCAAmB,CAAA;IAGnB,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,+BAAa,CAAA;IAGb,qCAAmB,CAAA;IAGnB,+BAAa,CAAA;IACb,uCAAqB,CAAA;IACrB,+BAAa,CAAA;IAGb,uCAAqB,CAAA;IAGrB,6CAA2B,CAAA;IAC3B,iDAA+B,CAAA;IAE/B,iCAAe,CAAA;IACf,uCAAqB,CAAA;IAGrB,qDAAmC,CAAA;IACnC,uDAAqC,CAAA;IAErC,uCAAqB,CAAA;IAErB,+BAAa,CAAA;AACf,CAAC,EAvCW,cAAc,8BAAd,cAAc,QAuCzB;AAED,IAAY,SA4B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AAW,EAAC,EAAE,WAAW,EAAE,uCAAuC,GAAG,CAAC;IACtE,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;yEACoB;AAKxB;IAHR,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;IAC3C,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;yDACe;AAK3B;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mCAAmC,GAAG,CAAC;IAClE,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qEACgB;AAK7B;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sCAAsC,GAAG,CAAC;IACrE,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;mEACkB;AAK9B;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,GAAG,CAAC;IACrD,IAAA,2BAAS,GAAE;;6DACW;AAKvB;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sBAAsB,GAAG,CAAC;IACrD,IAAA,2BAAS,GAAE;;4DACW","sourcesContent":["import { ApiProperty } from '@nestjs/swagger';\nimport { Transform, Type } from 'class-transformer';\nimport { DANGEROUS_EXTENSIONS, MEDIA_CATEGORIES, MediaCategory } from '../constants/media-file-types';\n\nimport {\n IsArray,\n IsBoolean,\n IsEnum,\n IsIn,\n IsInt,\n IsNotIn,\n IsOptional,\n IsString,\n Matches,\n ValidateIf\n} from 'class-validator';\nexport enum RelationFieldsCommand {\n set = \"set\",\n clear = \"clear\",\n link = \"link\",\n unlink = \"unlink\",\n create = \"create\",\n update = \"update\",\n delete = \"delete\"\n}\n\nexport enum SolidFieldType {\n // numeric types\n int = 'int',\n bigint = 'bigint',\n // float = 'float',\n // double = 'double',\n decimal = 'decimal',\n\n // text types\n shortText = 'shortText',\n longtext = 'longText',\n richText = 'richText',\n json = 'json',\n\n // boolean types\n boolean = 'boolean',\n\n // date\n date = 'date',\n datetime = 'datetime',\n time = 'time',\n\n // relation\n relation = 'relation',\n\n // media\n mediaSingle = 'mediaSingle',\n mediaMultiple = 'mediaMultiple',\n\n email = 'email',\n password = 'password',\n\n // selection\n selectionStatic = 'selectionStatic',\n selectionDynamic = 'selectionDynamic',\n\n computed = 'computed',\n\n uuid = 'uuid'\n}\n\nexport enum MySQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n int = 'int',\n decimal = 'decimal',\n double = 'double',\n\n // Text types\n // fieldType=shortText\n varchar = 'varchar',\n // fieldType=longText\n text = 'shortText',\n mediumtext = 'mediumtext',\n longtext = 'longtext',\n\n // Boolean types\n // fieldType=boolean\n bool = 'bool',\n boolean = 'boolean',\n\n //Date Types\n date = 'date',\n datetime = 'datetime',\n timestamp = 'timestamp',\n time = 'time',\n\n // Other types\n json = 'json',\n\n}\n\nexport enum PSQLType { //FIXME Currently this type is being used in the definition, Need to use OrmType instead\n // Numeric types\n integer = 'integer',\n decimal = 'decimal',\n bigint = 'bigint',\n\n // Text types\n varchar = 'varchar',\n text = 'text',\n\n // Boolean types\n boolean = 'boolean',\n\n // Date types\n timestamp = 'timestamp',\n timestamptz = 'timestamptz',\n time = 'time',\n date = 'date',\n\n // Other types\n json = 'json',\n jsonb = 'jsonb',\n simplejson = 'simple-json'\n}\n\nexport enum MSSQLType {\n int = \"int\",\n bigint = \"bigint\",\n decimal = \"decimal\",\n numeric = \"numeric\",\n varchar = \"varchar\",\n nvarchar = \"nvarchar\",\n simplejson = \"simple-json\",\n text = \"text\",\n bit = \"bit\",\n date = \"date\",\n datetime = \"datetime\",\n datetime2 = \"datetime2\",\n time = \"time\",\n uniqueidentifier = \"uniqueidentifier\"\n}\n\nexport const ALL_ORM_TYPES = [\n ...Object.values(PSQLType),\n ...Object.values(MSSQLType),\n ...Object.values(MySQLType),\n] as const;\n\nexport type OrmType = typeof ALL_ORM_TYPES[number];\n\n// export type OrmType = PSQLType | MySQLType | MSSQLType;\n\nexport enum EncryptionType {\n aes128 = 'aes-128',\n aes256 = 'aes-256',\n}\n\nexport enum DecryptWhenType {\n beforeTransit = 'before-transit',\n afterTransit = 'after-transit',\n}\n\nexport type MediaType = MediaCategory;\n\nexport enum RelationType {\n manyToOne = 'many-to-one',\n manyTomany = 'many-to-many',\n oneToMany = 'one-to-many',\n}\n\nexport enum CascadeType {\n setNull = 'set null',\n restrict = 'restrict',\n cascade = 'cascade',\n}\n\n// export enum MediaStorageProviderType {\n// database = 'database',\n// file = 'file',\n// s3 = 's3',\n// }\n\nexport enum SelectionValueType {\n string = 'string',\n int = 'int',\n}\n\nexport enum ComputedFieldValueType {\n string = 'string',\n int = 'int',\n decimal = 'decimal',\n boolean = 'boolean',\n date = 'date',\n datetime = 'datetime',\n}\n\nexport enum ComputedFieldTriggerOperation {\n beforeInsert = \"before-insert\",\n afterInsert = \"after-insert\",\n beforeUpdate = \"before-update\",\n afterUpdate = \"after-update\",\n beforeRemove = \"before-delete\",\n afterRemove = \"after-delete\",\n}\n\nexport class ComputedFieldTriggerConfig {\n moduleName: string; // Name of the module where the computed field is defined\n modelName: string;\n operations: ComputedFieldTriggerOperation[]; // List of operations where this computed field should be triggered\n}\n\nexport class CreateFieldMetadataDto {\n @ApiProperty({ description: 'Name of your field, this is also the name of the column or attribute', })\n // @Matches(/[a-z]+(_[a-z]+)*/, { message: 'Field name should follow snake case conventions only with all lower case.', })\n @IsString()\n name: string;\n\n @ApiProperty({ description: 'Display name of your field' })\n @IsString()\n readonly displayName: string;\n\n\n @ApiProperty({ description: 'Description of your field' })\n @IsOptional()\n @IsString()\n readonly description: string;\n\n // @ApiProperty({ description: \"Help text associated with this field\" })\n // @IsString()\n // readonly helpText: string;\n\n @ApiProperty({ description: 'Field can have types' })\n @IsEnum(SolidFieldType)\n readonly type: SolidFieldType;\n\n @ApiProperty({ description: 'Related model id' })\n @IsInt()\n @IsOptional()\n readonly modelId: number;\n\n //For all types of fields\n @ApiProperty({ description: 'Field can have orm types specific to your database', })\n @IsIn(ALL_ORM_TYPES)\n @IsOptional()\n readonly ormType: OrmType;\n\n @ApiProperty({ description: 'Length of the field. Only for type=text' })\n @IsInt()\n @IsOptional()\n readonly length: number;\n\n @ApiProperty({ description: 'Default value of the field' })\n @IsString()\n @IsOptional()\n readonly defaultValue: string;\n\n @ApiProperty({ description: 'Format regex pattern for the field. Only for type=text, longText, email, password', })\n @IsString()\n @IsOptional()\n readonly regexPattern: string;\n\n @ApiProperty({ description: 'If the regex pattern matching fails, then what is the error message to be displayed', })\n @IsString()\n @IsOptional()\n readonly regexPatternNotMatchingErrorMsg: string;\n\n @ApiProperty({ description: 'Is the field mandatory?' })\n @IsBoolean()\n readonly required: boolean;\n\n @ApiProperty({ description: 'Is the field value unique?' })\n @IsBoolean()\n @IsOptional()\n readonly unique: boolean;\n\n @ApiProperty({ description: 'Is the field symmetric encrypted?' })\n @IsBoolean()\n readonly encrypt: boolean;\n\n @ApiProperty({ description: 'Type of encryption. Only if encrypt=true' })\n @IsEnum(EncryptionType)\n @IsOptional()\n readonly encryptionType: EncryptionType;\n\n //Pending\n @ApiProperty({ description: 'At what point do we want to decrypt the data? Only if encrypt=true', })\n @IsEnum(DecryptWhenType)\n @IsOptional()\n decryptWhen: DecryptWhenType;\n\n @ApiProperty({ description: 'Is the field indexed? For all types, except:richText, longText', })\n @IsBoolean()\n index: boolean;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n max: number;\n\n @ApiProperty({ description: 'for text fields, this is length. for numeric fields, this is the range of values allowed. Only for type=shortText,longText,richText,json,int,decimal,date,dateTime,time', })\n @IsInt()\n @IsOptional()\n min: number;\n\n @ApiProperty({ description: 'Is the field private?' })\n @IsBoolean()\n private: boolean;\n\n @ApiProperty({ description: 'Allowed media types for the field. Only for type=mediaSingle,mediaMultiple', })\n @IsIn([...MEDIA_CATEGORIES], { each: true })\n @IsOptional()\n mediaTypes: MediaType[];\n\n @ApiProperty({ description: 'Maximum size of the media in KB. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaMaxSizeKb: number;\n\n @ApiProperty({ description: 'Explicit allowlist of file extensions (e.g. [\"pdf\",\"xlsx\",\"png\"]) permitted for this field, checked in addition to any mediaTypes category restriction — both must pass if both are set. For a strict allowlist, leave mediaTypes empty and use this alone. Only for type=mediaSingle,mediaMultiple', })\n @Transform(({ value }) =>\n Array.isArray(value)\n ? value.map((ext: any) => String(ext).toLowerCase().trim().replace(/^\\./, ''))\n : value\n )\n @IsArray()\n @IsString({ each: true })\n @IsNotIn([...DANGEROUS_EXTENSIONS], { each: true })\n @IsOptional()\n mediaAllowedExtensions?: string[];\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderId?: number;\n\n @ApiProperty({ description: 'Configured Media storage provider. Only for type=mediaSingle,mediaMultiple. When you need to specify the storage provider by name.', })\n @IsInt()\n @IsOptional()\n mediaStorageProviderUserKey?: string;\n\n // @ApiProperty({ description: 'Is the media embedded in the entity table? Only for type=mediaSingle', })\n // @IsBoolean()\n // @IsOptional()\n // mediaEmbedded: boolean;\n\n @ApiProperty({ description: 'Relation Type. Only for type=relation' })\n @IsEnum(RelationType)\n @IsOptional()\n relationType: RelationType;\n\n @ApiProperty({ description: 'Related model for the relation. Only for type=relation' })\n @IsString()\n @IsOptional()\n relationCoModelSingularName: string;\n\n @ApiProperty({ description: 'Create inverse relation. Only for type=relation', })\n @IsBoolean()\n @IsOptional()\n relationCreateInverse: boolean;\n\n @ApiProperty({ description: 'Cascade type. Only for type=relation' })\n @IsEnum(CascadeType)\n @IsOptional()\n relationCascade: CascadeType;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation, if the related field belongs to a different module' })\n @IsOptional()\n relationModelModuleName: string;\n\n @ApiProperty({ description: 'Related field module. Only required for type=relation and relationType=many-to-many, i.e if the related many to many field belongs to a different model' })\n @IsOptional()\n relationCoModelFieldName: string;\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to set the owner of the many-to-many relation' })\n @IsOptional()\n isRelationManyToManyOwner: boolean;\n\n\n @ApiProperty({ description: 'Only for type=relation, many-to-many. This field is used to store fixed filters that needs to applied on related model' })\n @IsOptional()\n relationFieldFixedFilter: string;\n\n @ApiProperty({\n description:\n 'Dynamic provider for selection. Only for type=selectionDynamic',\n })\n @IsString()\n @IsOptional()\n selectionDynamicProvider: string;\n\n @ApiProperty({ description: 'Dynamic provider Context. Only for type=selectionDynamic', })\n @IsString()\n @IsOptional()\n selectionDynamicProviderCtxt: string;\n\n @ApiProperty({ description: 'Static values for selection. Only for type=selectionStatic', })\n @IsArray()\n @IsString({ each: true })\n // @Matches(/^[\\w\\s\\d\\-\\/]+:[\\w\\s\\-\\/]+$/, { each: true })\n @IsOptional()\n selectionStaticValues: string[];\n\n @ApiProperty({ description: 'Type of value for selection. Applicable for type=selectionStatic,selectionDynamic', })\n @IsEnum(SelectionValueType)\n @IsOptional()\n selectionValueType: SelectionValueType;\n\n @ApiProperty({ description: 'Computed Field Value Provider. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProvider: string;\n\n @ApiProperty({ description: 'Computed Field Value Provider Context. Only for type=computed', })\n @IsString()\n @IsOptional()\n computedFieldValueProviderCtxt: string;\n\n @ApiProperty({ description: 'Computed field value type. Only for type=computed', })\n @IsEnum(ComputedFieldValueType)\n @IsOptional()\n computedFieldValueType: ComputedFieldValueType;\n\n @IsArray()\n @Type(() => ComputedFieldTriggerConfig)\n @IsOptional()\n computedFieldTriggerConfig: ComputedFieldTriggerConfig[];\n\n @IsOptional()\n @ApiProperty({ description: 'Uuid.', })\n @IsString()\n @IsOptional()\n uuid: string;\n\n @IsOptional()\n @ApiProperty({ description: 'System fields are not included in the code generation, the assumption being that system fields have manually written code.', })\n @IsBoolean()\n isSystem: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Marked for removal, this is used to soft delete the field.', })\n @IsBoolean()\n isMarkedForRemoval: boolean;\n\n @ApiProperty({ description: 'Column Name of Field', })\n @IsString()\n @IsOptional()\n columnName: string\n\n @ApiProperty({ description: 'Relation CoModel Column Name of Field', })\n @IsString()\n @IsOptional()\n relationCoModelColumnName: string\n\n @ApiProperty({ description: \"Is User Key\" })\n @IsOptional()\n @IsBoolean()\n readonly isUserKey: boolean\n\n @ApiProperty({ description: 'Relation Join Table Name of Field', })\n @IsString()\n @IsOptional()\n relationJoinTableName: string\n\n @ApiProperty({ description: 'Enable Audit Tracking for this field', })\n @IsOptional()\n @IsBoolean()\n enableAuditTracking?: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is MultiSelect Field', })\n @IsBoolean()\n isMultiSelect: boolean;\n\n @IsOptional()\n @ApiProperty({ description: 'Is Primary Key Field', })\n @IsBoolean()\n isPrimaryKey?: boolean;\n}\n"]}
@@ -24,6 +24,7 @@ export declare class FieldMetadata extends CommonEntity {
24
24
  private: boolean;
25
25
  mediaTypes: string[];
26
26
  mediaMaxSizeKb: number;
27
+ mediaAllowedExtensions: string[];
27
28
  mediaStorageProvider: MediaStorageProviderMetadata;
28
29
  relationType: string;
29
30
  relationCoModelSingularName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"field-metadata.entity.d.ts","sourceRoot":"","sources":["../../src/entities/field-metadata.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,qBACa,aAAc,SAAQ,YAAY;IAI3C,IAAI,EAAE,MAAM,CAAC;IAIb,WAAW,E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U,EAAE,MAAM,EAAE,CAAC;IAGrB,cAAc,EAAE,MAAM,CAAC;IAGvB,sBAAsB,EAAE,MAAM,EAAE,CAAC;IAKjC,oBAAoB,EAAE,4BAA4B,CAAC;IAMnD,YAAY,EAAE,MAAM,CAAC;IAGrB,2BAA2B,EAAE,MAAM,CAAC;IAGpC,qBAAqB,EAAE,OAAO,CAAC;IAG/B,eAAe,EAAE,MAAM,CAAC;IAGxB,uBAAuB,EAAE,MAAM,CAAC;IAIhC,wBAAwB,EAAE,MAAM,CAAC;IAGjC,yBAAyB,EAAE,OAAO,CAAC;IAMnC,wBAAwB,EAAE,MAAM,CAAC;IAGjC,wBAAwB,EAAE,MAAM,CAAC;IAGjC,4BAA4B,EAAE,MAAM,CAAC;IAGrC,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAGhC,kBAAkB,EAAE,MAAM,CAAY;IAMtC,0BAA0B,EAAE,MAAM,CAAC;IAGnC,8BAA8B,EAAE,MAAM,CAAC;IAGvC,sBAAsB,EAAE,MAAM,CAAC;IAG/B,0BAA0B,EAAE,0BAA0B,EAAE,CAAC;IAGzD,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,EAAE,OAAO,CAAC;IAGlB,kBAAkB,EAAE,OAAO,CAAC;IAG5B,UAAU,EAAE,MAAM,CAAC;IAGnB,yBAAyB,EAAE,MAAM,CAAC;IAGlC,SAAS,EAAE,OAAO,CAAC;IAGnB,qBAAqB,EAAE,MAAM,CAAC;IAG9B,mBAAmB,EAAE,OAAO,CAAS;IAGrC,aAAa,EAAE,OAAO,CAAC;IAGvB,YAAY,EAAE,OAAO,CAAC;CACzB"}
@@ -23,7 +23,7 @@ let FieldMetadata = class FieldMetadata extends common_entity_1.CommonEntity {
23
23
  this.enableAuditTracking = false;
24
24
  }
25
25
  static _OPENAPI_METADATA_FACTORY() {
26
- return { name: { required: true, type: () => String }, displayName: { required: true, type: () => String }, description: { required: true, type: () => String }, type: { required: true, type: () => String }, ormType: { required: true, type: () => String }, model: { required: true, type: () => require("./model-metadata.entity").ModelMetadata }, defaultValue: { required: true, type: () => String }, regexPattern: { required: true, type: () => String }, regexPatternNotMatchingErrorMsg: { required: true, type: () => String }, required: { required: true, type: () => Boolean }, unique: { required: true, type: () => Boolean }, encrypt: { required: true, type: () => Boolean }, encryptionType: { required: true, type: () => String }, decryptWhen: { required: true, type: () => String }, index: { required: true, type: () => Boolean }, length: { required: true, type: () => Number }, max: { required: true, type: () => Number }, min: { required: true, type: () => Number }, private: { required: true, type: () => Boolean }, mediaTypes: { required: true, type: () => [String] }, mediaMaxSizeKb: { required: true, type: () => Number }, mediaStorageProvider: { required: true, type: () => require("./media-storage-provider-metadata.entity").MediaStorageProviderMetadata }, relationType: { required: true, type: () => String }, relationCoModelSingularName: { required: true, type: () => String }, relationCreateInverse: { required: true, type: () => Boolean }, relationCascade: { required: true, type: () => String }, relationModelModuleName: { required: true, type: () => String }, relationCoModelFieldName: { required: true, type: () => String }, isRelationManyToManyOwner: { required: true, type: () => Boolean }, relationFieldFixedFilter: { required: true, type: () => String }, selectionDynamicProvider: { required: true, type: () => String }, selectionDynamicProviderCtxt: { required: true, type: () => String }, selectionStaticValues: { required: true, type: () => [String] }, selectionValueType: { required: true, type: () => String, default: "string" }, computedFieldValueProvider: { required: true, type: () => String }, computedFieldValueProviderCtxt: { required: true, type: () => String }, computedFieldValueType: { required: true, type: () => String }, computedFieldTriggerConfig: { required: true, type: () => [require("../dtos/create-field-metadata.dto").ComputedFieldTriggerConfig] }, uuid: { required: true, type: () => String }, isSystem: { required: true, type: () => Boolean }, isMarkedForRemoval: { required: true, type: () => Boolean }, columnName: { required: true, type: () => String }, relationCoModelColumnName: { required: true, type: () => String }, isUserKey: { required: true, type: () => Boolean }, relationJoinTableName: { required: true, type: () => String }, enableAuditTracking: { required: true, type: () => Boolean, default: false }, isMultiSelect: { required: true, type: () => Boolean }, isPrimaryKey: { required: true, type: () => Boolean } };
26
+ return { name: { required: true, type: () => String }, displayName: { required: true, type: () => String }, description: { required: true, type: () => String }, type: { required: true, type: () => String }, ormType: { required: true, type: () => String }, model: { required: true, type: () => require("./model-metadata.entity").ModelMetadata }, defaultValue: { required: true, type: () => String }, regexPattern: { required: true, type: () => String }, regexPatternNotMatchingErrorMsg: { required: true, type: () => String }, required: { required: true, type: () => Boolean }, unique: { required: true, type: () => Boolean }, encrypt: { required: true, type: () => Boolean }, encryptionType: { required: true, type: () => String }, decryptWhen: { required: true, type: () => String }, index: { required: true, type: () => Boolean }, length: { required: true, type: () => Number }, max: { required: true, type: () => Number }, min: { required: true, type: () => Number }, private: { required: true, type: () => Boolean }, mediaTypes: { required: true, type: () => [String] }, mediaMaxSizeKb: { required: true, type: () => Number }, mediaAllowedExtensions: { required: true, type: () => [String] }, mediaStorageProvider: { required: true, type: () => require("./media-storage-provider-metadata.entity").MediaStorageProviderMetadata }, relationType: { required: true, type: () => String }, relationCoModelSingularName: { required: true, type: () => String }, relationCreateInverse: { required: true, type: () => Boolean }, relationCascade: { required: true, type: () => String }, relationModelModuleName: { required: true, type: () => String }, relationCoModelFieldName: { required: true, type: () => String }, isRelationManyToManyOwner: { required: true, type: () => Boolean }, relationFieldFixedFilter: { required: true, type: () => String }, selectionDynamicProvider: { required: true, type: () => String }, selectionDynamicProviderCtxt: { required: true, type: () => String }, selectionStaticValues: { required: true, type: () => [String] }, selectionValueType: { required: true, type: () => String, default: "string" }, computedFieldValueProvider: { required: true, type: () => String }, computedFieldValueProviderCtxt: { required: true, type: () => String }, computedFieldValueType: { required: true, type: () => String }, computedFieldTriggerConfig: { required: true, type: () => [require("../dtos/create-field-metadata.dto").ComputedFieldTriggerConfig] }, uuid: { required: true, type: () => String }, isSystem: { required: true, type: () => Boolean }, isMarkedForRemoval: { required: true, type: () => Boolean }, columnName: { required: true, type: () => String }, relationCoModelColumnName: { required: true, type: () => String }, isUserKey: { required: true, type: () => Boolean }, relationJoinTableName: { required: true, type: () => String }, enableAuditTracking: { required: true, type: () => Boolean, default: false }, isMultiSelect: { required: true, type: () => Boolean }, isPrimaryKey: { required: true, type: () => Boolean } };
27
27
  }
28
28
  };
29
29
  exports.FieldMetadata = FieldMetadata;
@@ -116,6 +116,10 @@ __decorate([
116
116
  (0, typeorm_1.Column)({ name: 'media_max_size_kb', nullable: true }),
117
117
  __metadata("design:type", Number)
118
118
  ], FieldMetadata.prototype, "mediaMaxSizeKb", void 0);
119
+ __decorate([
120
+ (0, typeorm_1.Column)({ name: 'media_allowed_extensions', nullable: true, type: "simple-json" }),
121
+ __metadata("design:type", Array)
122
+ ], FieldMetadata.prototype, "mediaAllowedExtensions", void 0);
119
123
  __decorate([
120
124
  (0, typeorm_1.Index)(),
121
125
  (0, typeorm_1.ManyToOne)(() => media_storage_provider_metadata_entity_1.MediaStorageProviderMetadata, { onDelete: 'SET NULL' }),
@@ -1 +1 @@
1
- {"version":3,"file":"field-metadata.entity.js","sourceRoot":"","sources":["../../src/entities/field-metadata.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,mDAA0D;AAC1D,qCAAuE;AACvE,qGAAwF;AACxF,mEAAwD;AACxD,gEAA8D;AAGvD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,4BAAY;IAAxC;;QAqHH,uBAAkB,GAAW,QAAQ,CAAC;QAuCtC,wBAAmB,GAAY,KAAK,CAAC;KAOxC;;gzFAPkC,KAAK;;CAOvC,CAAA;AAnKY,sCAAa;AAItB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CACZ;AAIb;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;;kDACb;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;kDAC1C;AAKpB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBA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,EAAE,KAAK,EAAE,CAAC;;mDAC7B;wBAlKb,aAAa;IADzB,IAAA,gBAAM,EAAC,mBAAmB,CAAC;GACf,aAAa,CAmKzB","sourcesContent":["import { ComputedFieldTriggerConfig } from \"src/dtos/create-field-metadata.dto\";\nimport { CommonEntity } from \"src/entities/common.entity\";\nimport { Column, Entity, Index, JoinColumn, ManyToOne } from \"typeorm\";\nimport { MediaStorageProviderMetadata } from \"./media-storage-provider-metadata.entity\";\nimport { ModelMetadata } from \"./model-metadata.entity\";\nimport { ERROR_MESSAGES } from \"src/constants/error-messages\";\n\n@Entity(\"ss_field_metadata\")\nexport class FieldMetadata extends CommonEntity {\n\n @Index()\n @Column({ name: \"name\" })\n name: string;\n\n @Index()\n @Column({ name: \"display_name\" })\n displayName: string;\n\n @Column({ name: \"description\", nullable: true, length: 1024 })\n description: string;\n\n /** int, char etc... */\n @Index()\n @Column({ name: 'type' })\n type: string;\n\n @Column({ name: 'orm_type', nullable: true })\n ormType: string;\n\n @Index()\n @ManyToOne(() => ModelMetadata, (model) => model.fields, { onDelete: 'CASCADE' })\n @JoinColumn({ name: 'model_id', referencedColumnName: 'id' })\n model: ModelMetadata;\n\n @Column({ name: 'default_value', nullable: true })\n defaultValue: string;\n\n @Column({ name: 'regex_pattern', nullable: true })\n regexPattern: string;\n\n @Column({ name: 'regex_pattern_not_matching_error_msg', nullable: true, default: ERROR_MESSAGES.DEFAULT_REGEX_PATTERN_NOT_MATCHING_ERROR_MSG })\n regexPatternNotMatchingErrorMsg: string;\n\n @Column({ name: \"required\", default: false })\n required: boolean;\n\n @Column({ name: \"unique\", default: false })\n unique: boolean;\n\n @Column({ name: \"encrypt\", default: false })\n encrypt: boolean;\n\n @Column({ name: 'encryption_type', nullable: true })\n encryptionType: string;\n\n @Column({ name: 'decrypt_when', nullable: true })\n decryptWhen: string;\n\n @Column({ name: \"index\", default: false })\n index: boolean;\n\n @Column({ name: 'length', nullable: true })\n length: number;\n\n @Column({ name: 'max', nullable: true })\n max: number;\n\n @Column({ name: 'min', nullable: true })\n min: number;\n\n @Column({ name: \"private\", default: false })\n private: boolean;\n\n @Column({ name: 'media_types', nullable: true, type: \"simple-json\" })\n mediaTypes: string[];\n\n @Column({ name: 'media_max_size_kb', nullable: true })\n mediaMaxSizeKb: number;\n\n @Index()\n @ManyToOne(() => MediaStorageProviderMetadata, { onDelete: 'SET NULL' })\n @JoinColumn({ name: 'media_storage_provider_id' })\n mediaStorageProvider: MediaStorageProviderMetadata;\n\n // @Column({ name: 'media_embedded', default: true })\n // mediaEmbedded: boolean;\n\n @Column({ name: 'relation_type', nullable: true })\n relationType: string;\n\n @Column({ name: 'relation_model_singular_name', nullable: true })\n relationCoModelSingularName: string;\n\n @Column({ name: \"relation_create_inverse\", default: false })\n relationCreateInverse: boolean;\n\n @Column({ name: \"relation_cascade\", nullable: true })\n relationCascade: string;\n\n @Column({ name: 'relation_model_module_name', nullable: true })\n relationModelModuleName: string;\n\n // This field will be used to set the inverse field name in the related model e.g required for many to many relation\n @Column({ name: 'relation_model_field_name', nullable: true })\n relationCoModelFieldName: string;\n\n @Column({ name: 'is_relation_many_to_many_owner', nullable: true })\n isRelationManyToManyOwner: boolean;\n\n // We can store a filter json like this {\"fieldName\": ${someVarWhichWillComeFromParentModel... or can be hard coded...}}\n // {\"type\": \"INDUSTRY\"} .... Eg. static fixedFilter \n // {\"country_id\", \"${country}\"} ... Eg. dynamic fixedFilter \n @Column({ name: 'relation_field_fixed_filter', nullable: true })\n relationFieldFixedFilter: string;\n\n @Column({ name: 'selection_dynamic_provider', nullable: true })\n selectionDynamicProvider: string;\n\n @Column({ name: 'selection_dynamic_provider_ctxt', nullable: true })\n selectionDynamicProviderCtxt: string;\n\n @Column({ name: 'selection_static_values', nullable: true, type: 'simple-array' })\n selectionStaticValues: string[];\n\n @Column({ name: 'selection_value_type', nullable: true, default: 'string' })\n selectionValueType: string = 'string';\n\n // @Column({ name: \"computed\", default: false })\n // computed: boolean;\n\n @Column({ name: 'computed_field_value_provider', nullable: true })\n computedFieldValueProvider: string;\n\n @Column({ name: 'computed_field_value_provider_ctxt', nullable: true })\n computedFieldValueProviderCtxt: string;\n\n @Column({ name: 'computed_field_value_type', nullable: true })\n computedFieldValueType: string;\n\n @Column({ name: 'computed_field_trigger_config', nullable: true, type: 'simple-json' })\n computedFieldTriggerConfig: ComputedFieldTriggerConfig[];\n\n @Column({ name: 'uuid', nullable: true })\n uuid: string;\n\n @Column({ default: false })\n isSystem: boolean;\n\n @Column({ default: false })\n isMarkedForRemoval: boolean;\n\n @Column({ name: 'column_name', nullable: true })\n columnName: string;\n\n @Column({ name: 'relation_co_model_column_name', nullable: true })\n relationCoModelColumnName: string;\n\n @Column({ name: \"is_user_key\", default: false })\n isUserKey: boolean;\n\n @Column({ name: 'relation_join_table_name', nullable: true })\n relationJoinTableName: string;\n\n @Column({ name: 'enable_audit_tracking', default: false })\n enableAuditTracking: boolean = false;\n\n @Column({ name: \"is_multiSelect\", default: false })\n isMultiSelect: boolean;\n\n @Column({ name: \"is_primary_key\", default: false })\n isPrimaryKey: boolean;\n}"]}
1
+ {"version":3,"file":"field-metadata.entity.js","sourceRoot":"","sources":["../../src/entities/field-metadata.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,mDAA0D;AAC1D,qCAAuE;AACvE,qGAAwF;AACxF,mEAAwD;AACxD,gEAA8D;AAGvD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,4BAAY;IAAxC;;QAwHH,uBAAkB,GAAW,QAAQ,CAAC;QAuCtC,wBAAmB,GAAY,KAAK,CAAC;KAOxC;;k3FAPkC,KAAK;;CAOvC,CAAA;AAtKY,sCAAa;AAItB;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CACZ;AAIb;IAFC,IAAA,eAAK,GAAE;IACP,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;;kDACb;AAGpB;IAD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CAAC;;4DAC/B;AAG9B;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;0DACrB;AAGrC;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;oDAC5B;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;mDAC7B;wBArKb,aAAa;IADzB,IAAA,gBAAM,EAAC,mBAAmB,CAAC;GACf,aAAa,CAsKzB","sourcesContent":["import { ComputedFieldTriggerConfig } from \"src/dtos/create-field-metadata.dto\";\nimport { CommonEntity } from \"src/entities/common.entity\";\nimport { Column, Entity, Index, JoinColumn, ManyToOne } from \"typeorm\";\nimport { MediaStorageProviderMetadata } from \"./media-storage-provider-metadata.entity\";\nimport { ModelMetadata } from \"./model-metadata.entity\";\nimport { ERROR_MESSAGES } from \"src/constants/error-messages\";\n\n@Entity(\"ss_field_metadata\")\nexport class FieldMetadata extends CommonEntity {\n\n @Index()\n @Column({ name: \"name\" })\n name: string;\n\n @Index()\n @Column({ name: \"display_name\" })\n displayName: string;\n\n @Column({ name: \"description\", nullable: true, length: 1024 })\n description: string;\n\n /** int, char etc... */\n @Index()\n @Column({ name: 'type' })\n type: string;\n\n @Column({ name: 'orm_type', nullable: true })\n ormType: string;\n\n @Index()\n @ManyToOne(() => ModelMetadata, (model) => model.fields, { onDelete: 'CASCADE' })\n @JoinColumn({ name: 'model_id', referencedColumnName: 'id' })\n model: ModelMetadata;\n\n @Column({ name: 'default_value', nullable: true })\n defaultValue: string;\n\n @Column({ name: 'regex_pattern', nullable: true })\n regexPattern: string;\n\n @Column({ name: 'regex_pattern_not_matching_error_msg', nullable: true, default: ERROR_MESSAGES.DEFAULT_REGEX_PATTERN_NOT_MATCHING_ERROR_MSG })\n regexPatternNotMatchingErrorMsg: string;\n\n @Column({ name: \"required\", default: false })\n required: boolean;\n\n @Column({ name: \"unique\", default: false })\n unique: boolean;\n\n @Column({ name: \"encrypt\", default: false })\n encrypt: boolean;\n\n @Column({ name: 'encryption_type', nullable: true })\n encryptionType: string;\n\n @Column({ name: 'decrypt_when', nullable: true })\n decryptWhen: string;\n\n @Column({ name: \"index\", default: false })\n index: boolean;\n\n @Column({ name: 'length', nullable: true })\n length: number;\n\n @Column({ name: 'max', nullable: true })\n max: number;\n\n @Column({ name: 'min', nullable: true })\n min: number;\n\n @Column({ name: \"private\", default: false })\n private: boolean;\n\n @Column({ name: 'media_types', nullable: true, type: \"simple-json\" })\n mediaTypes: string[];\n\n @Column({ name: 'media_max_size_kb', nullable: true })\n mediaMaxSizeKb: number;\n\n @Column({ name: 'media_allowed_extensions', nullable: true, type: \"simple-json\" })\n mediaAllowedExtensions: string[];\n\n @Index()\n @ManyToOne(() => MediaStorageProviderMetadata, { onDelete: 'SET NULL' })\n @JoinColumn({ name: 'media_storage_provider_id' })\n mediaStorageProvider: MediaStorageProviderMetadata;\n\n // @Column({ name: 'media_embedded', default: true })\n // mediaEmbedded: boolean;\n\n @Column({ name: 'relation_type', nullable: true })\n relationType: string;\n\n @Column({ name: 'relation_model_singular_name', nullable: true })\n relationCoModelSingularName: string;\n\n @Column({ name: \"relation_create_inverse\", default: false })\n relationCreateInverse: boolean;\n\n @Column({ name: \"relation_cascade\", nullable: true })\n relationCascade: string;\n\n @Column({ name: 'relation_model_module_name', nullable: true })\n relationModelModuleName: string;\n\n // This field will be used to set the inverse field name in the related model e.g required for many to many relation\n @Column({ name: 'relation_model_field_name', nullable: true })\n relationCoModelFieldName: string;\n\n @Column({ name: 'is_relation_many_to_many_owner', nullable: true })\n isRelationManyToManyOwner: boolean;\n\n // We can store a filter json like this {\"fieldName\": ${someVarWhichWillComeFromParentModel... or can be hard coded...}}\n // {\"type\": \"INDUSTRY\"} .... Eg. static fixedFilter \n // {\"country_id\", \"${country}\"} ... Eg. dynamic fixedFilter \n @Column({ name: 'relation_field_fixed_filter', nullable: true })\n relationFieldFixedFilter: string;\n\n @Column({ name: 'selection_dynamic_provider', nullable: true })\n selectionDynamicProvider: string;\n\n @Column({ name: 'selection_dynamic_provider_ctxt', nullable: true })\n selectionDynamicProviderCtxt: string;\n\n @Column({ name: 'selection_static_values', nullable: true, type: 'simple-array' })\n selectionStaticValues: string[];\n\n @Column({ name: 'selection_value_type', nullable: true, default: 'string' })\n selectionValueType: string = 'string';\n\n // @Column({ name: \"computed\", default: false })\n // computed: boolean;\n\n @Column({ name: 'computed_field_value_provider', nullable: true })\n computedFieldValueProvider: string;\n\n @Column({ name: 'computed_field_value_provider_ctxt', nullable: true })\n computedFieldValueProviderCtxt: string;\n\n @Column({ name: 'computed_field_value_type', nullable: true })\n computedFieldValueType: string;\n\n @Column({ name: 'computed_field_trigger_config', nullable: true, type: 'simple-json' })\n computedFieldTriggerConfig: ComputedFieldTriggerConfig[];\n\n @Column({ name: 'uuid', nullable: true })\n uuid: string;\n\n @Column({ default: false })\n isSystem: boolean;\n\n @Column({ default: false })\n isMarkedForRemoval: boolean;\n\n @Column({ name: 'column_name', nullable: true })\n columnName: string;\n\n @Column({ name: 'relation_co_model_column_name', nullable: true })\n relationCoModelColumnName: string;\n\n @Column({ name: \"is_user_key\", default: false })\n isUserKey: boolean;\n\n @Column({ name: 'relation_join_table_name', nullable: true })\n relationJoinTableName: string;\n\n @Column({ name: 'enable_audit_tracking', default: false })\n enableAuditTracking: boolean = false;\n\n @Column({ name: \"is_multiSelect\", default: false })\n isMultiSelect: boolean;\n\n @Column({ name: \"is_primary_key\", default: false })\n isPrimaryKey: boolean;\n}"]}
@@ -9,6 +9,7 @@ export interface MediaFieldOptions {
9
9
  fieldName: string | undefined | null;
10
10
  mediaMaxSizeKb: number | undefined | null;
11
11
  mediaTypes: string[];
12
+ mediaAllowedExtensions?: string[] | null;
12
13
  isUpdate: boolean | undefined | null;
13
14
  }
14
15
  export declare class MediaFieldCrudManager implements FieldCrudManager {
@@ -18,6 +19,11 @@ export declare class MediaFieldCrudManager implements FieldCrudManager {
18
19
  validate(dto: any, files: Array<Express.Multer.File>): ValidationError[];
19
20
  private applyValidations;
20
21
  private validateDangerousFiles;
22
+ private validateCommon;
23
+ private validateRequired;
24
+ private validateSize;
25
+ private validateTypes;
26
+ private validateAllowedExtensions;
21
27
  private validateMediaSingle;
22
28
  private validateMediaMultiple;
23
29
  transformForCreate(dto: any): any;
@@ -1 +1 @@
1
- {"version":3,"file":"MediaFieldCrudManager.d.ts","sourceRoot":"","sources":["../../../src/helpers/field-crud-managers/MediaFieldCrudManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGnE,oBAAY,cAAc;IACtB,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;CAClC;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACrC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;CACxC;AA6DD,qBAAa,qBAAsB,YAAW,gBAAgB;IAE9C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,iBAAiB;IAGvD,OAAO,CAAC,gBAAgB;IA2BxB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,eAAe,EAAE;IAKxE,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,mBAAmB;IAiD3B,OAAO,CAAC,qBAAqB;IAW7B,kBA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34 +61,31 @@ class MediaFieldCrudManager {
61
61
  return null;
62
62
  }
63
63
  const ext = (0, media_file_types_1.getLowercaseFileExtension)((0, media_file_types_1.getUploadedFileName)(file));
64
- const mt = (file.mimetype || '').toLowerCase().trim();
65
- if (mt && MIME_TO_MEDIA_TYPE[mt]) {
66
- return MIME_TO_MEDIA_TYPE[mt];
64
+ const extType = ext ? media_file_types_1.EXT_TO_MEDIA_TYPE[ext] : undefined;
65
+ if (!extType) {
66
+ return null;
67
67
  }
68
- if (mt.startsWith('image/'))
69
- return 'image';
70
- if (mt.startsWith('audio/'))
71
- return 'audio';
72
- if (mt.startsWith('video/'))
73
- return 'video';
74
- if (ext && media_file_types_1.EXT_TO_MEDIA_TYPE[ext]) {
75
- return media_file_types_1.EXT_TO_MEDIA_TYPE[ext];
68
+ const mt = (file.mimetype || '').toLowerCase().trim();
69
+ const mimeType = MIME_TO_MEDIA_TYPE[mt]
70
+ ?? (mt.startsWith('image/') ? 'image' : mt.startsWith('audio/') ? 'audio' : mt.startsWith('video/') ? 'video' : undefined);
71
+ if (mimeType && mimeType !== extType) {
72
+ return null;
76
73
  }
77
- return null;
74
+ return extType;
78
75
  }
79
76
  validate(dto, files) {
80
77
  const fieldFiles = files.filter(file => file.fieldname === this.options.fieldName);
81
78
  return this.applyValidations(fieldFiles);
82
79
  }
83
80
  applyValidations(fieldFiles) {
84
- const errors = this.validateDangerousFiles(fieldFiles);
81
+ const dangerousFileErrors = this.validateDangerousFiles(fieldFiles);
85
82
  switch (this.options.type) {
86
83
  case SolidMediaType.mediaSingle:
87
- return [...errors, ...this.validateMediaSingle(fieldFiles)];
84
+ return [...dangerousFileErrors, ...this.validateMediaSingle(fieldFiles)];
88
85
  case SolidMediaType.mediaMultiple:
89
- return [...errors, ...this.validateMediaMultiple(fieldFiles)];
86
+ return [...dangerousFileErrors, ...this.validateMediaMultiple(fieldFiles)];
90
87
  default:
91
- return errors;
88
+ return dangerousFileErrors;
92
89
  }
93
90
  }
94
91
  validateDangerousFiles(fieldFiles) {
@@ -100,7 +97,15 @@ class MediaFieldCrudManager {
100
97
  `${(0, media_file_types_1.getUploadedFileName)(fieldFile) || 'File'} is a potentially dangerous file type.`
101
98
  }));
102
99
  }
103
- validateMediaSingle(fieldFiles) {
100
+ validateCommon(fieldFiles) {
101
+ return [
102
+ ...this.validateRequired(fieldFiles),
103
+ ...this.validateSize(fieldFiles),
104
+ ...this.validateTypes(fieldFiles),
105
+ ...this.validateAllowedExtensions(fieldFiles),
106
+ ];
107
+ }
108
+ validateRequired(fieldFiles) {
104
109
  const errors = [];
105
110
  if (!this.options.isUpdate && this.options.required && fieldFiles.length === 0) {
106
111
  errors.push({
@@ -108,12 +113,10 @@ class MediaFieldCrudManager {
108
113
  error: `${this.options.fieldName} is required`
109
114
  });
110
115
  }
111
- if (fieldFiles.length > 1) {
112
- errors.push({
113
- field: this.options.fieldName,
114
- error: `${this.options.fieldName} must be a single file`
115
- });
116
- }
116
+ return errors;
117
+ }
118
+ validateSize(fieldFiles) {
119
+ const errors = [];
117
120
  if (this.options.mediaMaxSizeKb) {
118
121
  for (let i = 0; i < fieldFiles.length; i++) {
119
122
  const fieldFile = fieldFiles[i];
@@ -126,6 +129,10 @@ class MediaFieldCrudManager {
126
129
  }
127
130
  }
128
131
  }
132
+ return errors;
133
+ }
134
+ validateTypes(fieldFiles) {
135
+ const errors = [];
129
136
  if (this.options.mediaTypes && this.options.mediaTypes.length > 0) {
130
137
  const allowedFileTypes = this.options.mediaTypes;
131
138
  for (let i = 0; i < fieldFiles.length; i++) {
@@ -143,16 +150,36 @@ class MediaFieldCrudManager {
143
150
  }
144
151
  return errors;
145
152
  }
146
- validateMediaMultiple(fieldFiles) {
147
- const errors = [];
148
- if (!this.options.isUpdate && this.options.required && fieldFiles.length === 0) {
153
+ validateAllowedExtensions(fieldFiles) {
154
+ const allowed = this.options.mediaAllowedExtensions;
155
+ if (!allowed || allowed.length === 0) {
156
+ return [];
157
+ }
158
+ const normalizedAllowed = new Set(allowed.map(ext => ext.toLowerCase().replace(/^\./, '')));
159
+ return fieldFiles
160
+ .filter(fieldFile => {
161
+ const ext = (0, media_file_types_1.getLowercaseFileExtension)((0, media_file_types_1.getUploadedFileName)(fieldFile));
162
+ return !ext || !normalizedAllowed.has(ext);
163
+ })
164
+ .map(fieldFile => ({
165
+ field: this.options.fieldName,
166
+ error: `${this.options.fieldName} file type not allowed. ` +
167
+ `Allowed extensions: ${[...normalizedAllowed].join(', ')}.`
168
+ }));
169
+ }
170
+ validateMediaSingle(fieldFiles) {
171
+ const errors = this.validateCommon(fieldFiles);
172
+ if (fieldFiles.length > 1) {
149
173
  errors.push({
150
174
  field: this.options.fieldName,
151
- error: `${this.options.fieldName} is required`
175
+ error: `${this.options.fieldName} must be a single file`
152
176
  });
153
177
  }
154
178
  return errors;
155
179
  }
180
+ validateMediaMultiple(fieldFiles) {
181
+ return this.validateCommon(fieldFiles);
182
+ }
156
183
  transformForCreate(dto) {
157
184
  return dto;
158
185
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MediaFieldCrudManager.js","sourceRoot":"","sources":["../../../src/helpers/field-crud-managers/MediaFieldCrudManager.ts"],"names":[],"mappings":";;;AACA,uEAAwJ;AAExJ,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,6CAA2B,CAAA;IAC3B,iDAA+B,CAAA;AACnC,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAaD,MAAM,kBAAkB,GAA8B;IAElD,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,OAAO;IACrB,YAAY,EAAE,OAAO;IACrB,YAAY,EAAE,OAAO;IAGrB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,OAAO;IACpB,aAAa,EAAE,OAAO;IACtB,YAAY,EAAE,OAAO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AsB,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7E,MAAM,CAAC,IAAI,CAAC;gBACR,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;gBAC7B,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,cAAc;aACjD,CAAC,CAAC;QACP,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,kBAAkB,CAAC,GAAQ;QACvB,OAAO,GAAG,CAAC;IACf,CAAC;CAGJ;AAhID,sDAgIC","sourcesContent":["import { FieldCrudManager, ValidationError } from \"src/interfaces\";\nimport { EXT_TO_MEDIA_TYPE, getLowercaseFileExtension, getUploadedFileName, isDangerousMediaFile, MediaCategory } from \"src/constants/media-file-types\";\n\nexport enum SolidMediaType {\n mediaSingle = 'mediaSingle',\n mediaMultiple = 'mediaMultiple'\n}\n\nexport interface MediaFieldOptions {\n type: SolidMediaType;\n required: boolean | undefined | null;\n fieldName: string | undefined | null;\n mediaMaxSizeKb: number | undefined | null;\n mediaTypes: string[];\n isUpdate: boolean | undefined | null;\n}\n\ntype MediaType = MediaCategory;\n\nconst MIME_TO_MEDIA_TYPE: Record<string, MediaType> = {\n // Images\n 'image/png': 'image',\n 'image/jpeg': 'image',\n 'image/jpg': 'image',\n 'image/webp': 'image',\n 'image/gif': 'image',\n 'image/bmp': 'image',\n 'image/tiff': 'image',\n 'image/heic': 'image',\n 'image/heif': 'image',\n\n // Audio\n 'audio/mpeg': 'audio', // mp3\n 'audio/mp3': 'audio',\n 'audio/wav': 'audio',\n 'audio/x-wav': 'audio',\n 'audio/webm': 'audio',\n 'audio/ogg': 'audio',\n 'audio/aac': 'audio',\n 'audio/mp4': 'audio', // m4a often shows as audio/mp4\n 'audio/x-m4a': 'audio',\n 'audio/flac': 'audio',\n\n // Video\n 'video/mp4': 'video',\n 'video/mpeg': 'video',\n 'video/webm': 'video',\n 'video/ogg': 'video',\n 'video/quicktime': 'video', // mov\n 'video/x-msvideo': 'video', // avi\n 'video/x-matroska': 'video',// mkv\n 'video/3gpp': 'video',\n 'video/3gpp2': 'video',\n\n // Documents / files (treat as \"file\")\n 'application/pdf': 'pdf',\n 'text/plain': 'file',\n 'text/markdown': 'file',\n 'application/json': 'file',\n 'text/csv': 'file',\n\n // Office\n 'application/msword': 'file', // doc\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'file', // docx\n 'application/vnd.ms-excel': 'file', // xls\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'file', // xlsx\n 'application/vnd.ms-powerpoint': 'file', // ppt\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'file', // pptx,\n\n // Archives (optional)\n 'application/zip': 'file',\n 'application/x-zip-compressed': 'file',\n 'application/x-rar-compressed': 'file',\n 'application/x-7z-compressed': 'file',\n};\n\nexport class MediaFieldCrudManager implements FieldCrudManager {\n\n constructor(private readonly options: MediaFieldOptions) {\n }\n\n private resolveMediaType(file: Express.Multer.File): MediaType | null {\n // Belt-and-braces: dangerous files are already rejected outright by\n // validateDangerousFiles, but never let one resolve to a usable category.\n if (isDangerousMediaFile(file)) {\n return null;\n }\n\n const ext = getLowercaseFileExtension(getUploadedFileName(file));\n const mt = (file.mimetype || '').toLowerCase().trim();\n if (mt && MIME_TO_MEDIA_TYPE[mt]) {\n return MIME_TO_MEDIA_TYPE[mt];\n }\n\n // Some libs may send \"image/*\" etc. Treat broad families safely.\n if (mt.startsWith('image/')) return 'image';\n if (mt.startsWith('audio/')) return 'audio';\n if (mt.startsWith('video/')) return 'video';\n\n // Fallback to extension if provided (also covers generic/unrecognized\n // mimetypes such as application/octet-stream).\n if (ext && EXT_TO_MEDIA_TYPE[ext]) {\n return EXT_TO_MEDIA_TYPE[ext];\n }\n\n return null;\n }\n\n validate(dto: any, files: Array<Express.Multer.File>): ValidationError[] {\n const fieldFiles = files.filter(file => file.fieldname === this.options.fieldName);\n return this.applyValidations(fieldFiles);\n }\n\n private applyValidations(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n // Runs for every media field type and regardless of the admin-configured mediaTypes\n // allowlist - a dangerous upload is never acceptable, so this must not sit behind\n // the optional type checks below.\n const errors = this.validateDangerousFiles(fieldFiles);\n\n switch (this.options.type) {\n case SolidMediaType.mediaSingle:\n return [...errors, ...this.validateMediaSingle(fieldFiles)];\n case SolidMediaType.mediaMultiple:\n return [...errors, ...this.validateMediaMultiple(fieldFiles)];\n default:\n return errors;\n }\n }\n\n private validateDangerousFiles(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n return fieldFiles\n .filter(fieldFile => isDangerousMediaFile(fieldFile))\n .map(fieldFile => ({\n field: this.options.fieldName,\n error: `${this.options.fieldName} file type not allowed. ` +\n `${getUploadedFileName(fieldFile) || 'File'} is a potentially dangerous file type.`\n }));\n }\n\n private validateMediaSingle(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n const errors: ValidationError[] = [];\n if (!this.options.isUpdate && this.options.required && fieldFiles.length === 0) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} is required`\n });\n }\n if (fieldFiles.length > 1) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} must be a single file`\n });\n }\n // validate size\n if (this.options.mediaMaxSizeKb) {\n for (let i = 0; i < fieldFiles.length; i++) {\n const fieldFile = fieldFiles[i];\n const fieldFileSizeInBytes = Math.ceil(fieldFile.size / 1024);\n if (fieldFileSizeInBytes > this.options.mediaMaxSizeKb) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} with size ${fieldFileSizeInBytes} KB exceeds max size limit of ${this.options.mediaMaxSizeKb} KB`\n });\n }\n }\n }\n // validate type\n if (this.options.mediaTypes && this.options.mediaTypes.length > 0) {\n const allowedFileTypes = this.options.mediaTypes as MediaType[];\n\n for (let i = 0; i < fieldFiles.length; i++) {\n const fieldFile = fieldFiles[i];\n\n const resolvedType = this.resolveMediaType(fieldFile);\n if (!resolvedType || !allowedFileTypes.includes(resolvedType)) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} file type not allowed. ` +\n `Allowed: ${allowedFileTypes.join(', ')}. ` +\n `Received mimetype: ${fieldFile.mimetype}${resolvedType ? ` (mapped to ${resolvedType})` : ''}`\n });\n }\n }\n }\n\n return errors;\n }\n\n private validateMediaMultiple(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n const errors: ValidationError[] = [];\n if (!this.options.isUpdate && this.options.required && fieldFiles.length === 0) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} is required`\n });\n }\n return errors;\n }\n\n transformForCreate(dto: any): any {\n return dto;\n }\n\n // Validation to be applied\n}\n"]}
1
+ {"version":3,"file":"MediaFieldCrudManager.js","sourceRoot":"","sources":["../../../src/helpers/field-crud-managers/MediaFieldCrudManager.ts"],"names":[],"mappings":";;;AACA,uEAAwJ;AAExJ,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,6CAA2B,CAAA;IAC3B,iDAA+B,CAAA;AACnC,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAcD,MAAM,kBAAkB,GAA8B;IAElD,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,OAAO;IACpB,YAAY,EAAE,OAAO;IACrB,YAAY,EAAE,OAAO;IACrB,YAAY,EAAE,OAAO;IAGrB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,OAAO;IACpB,aAAa,EAAE,OAAO;IACtB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,OAAO;IACpB,aAAa,EAAE,OAAO;IACtB,YAAY,EAAE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EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC;gBACR,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;gBAC7B,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,wBAAwB;aAC3D,CAAC,CAAC;QACP,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEO,qBAAqB,CAAC,UAAsC;QAChE,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,kBAAkB,CAAC,GAAQ;QACvB,OAAO,GAAG,CAAC;IACf,CAAC;CAGJ;AAtKD,sDAsKC","sourcesContent":["import { FieldCrudManager, ValidationError } from \"src/interfaces\";\nimport { EXT_TO_MEDIA_TYPE, getLowercaseFileExtension, getUploadedFileName, isDangerousMediaFile, MediaCategory } from \"src/constants/media-file-types\";\n\nexport enum SolidMediaType {\n mediaSingle = 'mediaSingle',\n mediaMultiple = 'mediaMultiple'\n}\n\nexport interface MediaFieldOptions {\n type: SolidMediaType;\n required: boolean | undefined | null;\n fieldName: string | undefined | null;\n mediaMaxSizeKb: number | undefined | null;\n mediaTypes: string[];\n mediaAllowedExtensions?: string[] | null;\n isUpdate: boolean | undefined | null;\n}\n\ntype MediaType = MediaCategory;\n\nconst MIME_TO_MEDIA_TYPE: Record<string, MediaType> = {\n // Images\n 'image/png': 'image',\n 'image/jpeg': 'image',\n 'image/jpg': 'image',\n 'image/webp': 'image',\n 'image/gif': 'image',\n 'image/bmp': 'image',\n 'image/tiff': 'image',\n 'image/heic': 'image',\n 'image/heif': 'image',\n\n // Audio\n 'audio/mpeg': 'audio', // mp3\n 'audio/mp3': 'audio',\n 'audio/wav': 'audio',\n 'audio/x-wav': 'audio',\n 'audio/webm': 'audio',\n 'audio/ogg': 'audio',\n 'audio/aac': 'audio',\n 'audio/mp4': 'audio', // m4a often shows as audio/mp4\n 'audio/x-m4a': 'audio',\n 'audio/flac': 'audio',\n\n // Video\n 'video/mp4': 'video',\n 'video/mpeg': 'video',\n 'video/webm': 'video',\n 'video/ogg': 'video',\n 'video/quicktime': 'video', // mov\n 'video/x-msvideo': 'video', // avi\n 'video/x-matroska': 'video',// mkv\n 'video/3gpp': 'video',\n 'video/3gpp2': 'video',\n\n // Documents / files (treat as \"file\")\n 'application/pdf': 'pdf',\n 'text/plain': 'file',\n 'text/markdown': 'file',\n 'application/json': 'file',\n 'text/csv': 'file',\n\n // Office\n 'application/msword': 'file', // doc\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'file', // docx\n 'application/vnd.ms-excel': 'file', // xls\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'file', // xlsx\n 'application/vnd.ms-powerpoint': 'file', // ppt\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'file', // pptx,\n\n // Archives (optional)\n 'application/zip': 'file',\n 'application/x-zip-compressed': 'file',\n 'application/x-rar-compressed': 'file',\n 'application/x-7z-compressed': 'file',\n};\n\nexport class MediaFieldCrudManager implements FieldCrudManager {\n\n constructor(private readonly options: MediaFieldOptions) {\n }\n\n private resolveMediaType(file: Express.Multer.File): MediaType | null {\n // Belt-and-braces: dangerous files are already rejected outright by\n // validateDangerousFiles, but never let one resolve to a usable category.\n if (isDangerousMediaFile(file)) {\n return null;\n }\n\n // Extension is authoritative: a declared mimetype is fully attacker-controlled and\n // proved insufficient on its own (a .msi uploaded as image/png previously resolved to\n // 'image', since the mimetype match short-circuited before the extension was ever\n // checked). The extension must independently resolve to a known-safe category before\n // anything is accepted - not merely \"not on the denylist\".\n const ext = getLowercaseFileExtension(getUploadedFileName(file));\n const extType = ext ? EXT_TO_MEDIA_TYPE[ext] : undefined;\n if (!extType) {\n return null;\n }\n\n // The mimetype may only confirm or veto what the extension already established, never\n // grant a category on its own. A mimetype that doesn't resolve to anything (e.g.\n // application/octet-stream) has no opinion and is treated as agreeing.\n const mt = (file.mimetype || '').toLowerCase().trim();\n const mimeType = MIME_TO_MEDIA_TYPE[mt]\n ?? (mt.startsWith('image/') ? 'image' : mt.startsWith('audio/') ? 'audio' : mt.startsWith('video/') ? 'video' : undefined);\n if (mimeType && mimeType !== extType) {\n return null;\n }\n\n return extType;\n }\n\n validate(dto: any, files: Array<Express.Multer.File>): ValidationError[] {\n const fieldFiles = files.filter(file => file.fieldname === this.options.fieldName);\n return this.applyValidations(fieldFiles);\n }\n\n private applyValidations(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n // A dangerous upload is never acceptable, regardless of admin config, so this is the\n // only check that sits outside validateCommon() and can't be skipped either way below.\n const dangerousFileErrors = this.validateDangerousFiles(fieldFiles);\n\n switch (this.options.type) {\n case SolidMediaType.mediaSingle:\n return [...dangerousFileErrors, ...this.validateMediaSingle(fieldFiles)];\n case SolidMediaType.mediaMultiple:\n return [...dangerousFileErrors, ...this.validateMediaMultiple(fieldFiles)];\n default:\n return dangerousFileErrors;\n }\n }\n\n private validateDangerousFiles(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n return fieldFiles\n .filter(fieldFile => isDangerousMediaFile(fieldFile))\n .map(fieldFile => ({\n field: this.options.fieldName,\n error: `${this.options.fieldName} file type not allowed. ` +\n `${getUploadedFileName(fieldFile) || 'File'} is a potentially dangerous file type.`\n }));\n }\n\n // Every optional, admin-configured, per-field check - no-ops when its setting is unset -\n // shared between mediaSingle and mediaMultiple so neither can drift out of sync with it.\n private validateCommon(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n return [\n ...this.validateRequired(fieldFiles),\n ...this.validateSize(fieldFiles),\n ...this.validateTypes(fieldFiles),\n ...this.validateAllowedExtensions(fieldFiles),\n ];\n }\n\n private validateRequired(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n const errors: ValidationError[] = [];\n if (!this.options.isUpdate && this.options.required && fieldFiles.length === 0) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} is required`\n });\n }\n return errors;\n }\n\n private validateSize(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n const errors: ValidationError[] = [];\n if (this.options.mediaMaxSizeKb) {\n for (let i = 0; i < fieldFiles.length; i++) {\n const fieldFile = fieldFiles[i];\n const fieldFileSizeInBytes = Math.ceil(fieldFile.size / 1024);\n if (fieldFileSizeInBytes > this.options.mediaMaxSizeKb) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} with size ${fieldFileSizeInBytes} KB exceeds max size limit of ${this.options.mediaMaxSizeKb} KB`\n });\n }\n }\n }\n return errors;\n }\n\n private validateTypes(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n const errors: ValidationError[] = [];\n if (this.options.mediaTypes && this.options.mediaTypes.length > 0) {\n const allowedFileTypes = this.options.mediaTypes as MediaType[];\n\n for (let i = 0; i < fieldFiles.length; i++) {\n const fieldFile = fieldFiles[i];\n\n const resolvedType = this.resolveMediaType(fieldFile);\n if (!resolvedType || !allowedFileTypes.includes(resolvedType)) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} file type not allowed. ` +\n `Allowed: ${allowedFileTypes.join(', ')}. ` +\n `Received mimetype: ${fieldFile.mimetype}${resolvedType ? ` (mapped to ${resolvedType})` : ''}`\n });\n }\n }\n }\n return errors;\n }\n\n private validateAllowedExtensions(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n const allowed = this.options.mediaAllowedExtensions;\n if (!allowed || allowed.length === 0) {\n return [];\n }\n\n const normalizedAllowed = new Set(allowed.map(ext => ext.toLowerCase().replace(/^\\./, '')));\n return fieldFiles\n .filter(fieldFile => {\n const ext = getLowercaseFileExtension(getUploadedFileName(fieldFile));\n return !ext || !normalizedAllowed.has(ext);\n })\n .map(fieldFile => ({\n field: this.options.fieldName,\n error: `${this.options.fieldName} file type not allowed. ` +\n `Allowed extensions: ${[...normalizedAllowed].join(', ')}.`\n }));\n }\n\n private validateMediaSingle(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n const errors = this.validateCommon(fieldFiles);\n if (fieldFiles.length > 1) {\n errors.push({\n field: this.options.fieldName,\n error: `${this.options.fieldName} must be a single file`\n });\n }\n return errors;\n }\n\n private validateMediaMultiple(fieldFiles: Array<Express.Multer.File>): ValidationError[] {\n return this.validateCommon(fieldFiles);\n }\n\n transformForCreate(dto: any): any {\n return dto;\n }\n\n // Validation to be applied\n}\n"]}