@tmlmobilidade/utils 20250730.1829.32 → 20250730.2348.33

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.
@@ -12,7 +12,13 @@ export declare class Files {
12
12
  */
13
13
  static blobToFile(blob: Blob, fileName: string): File;
14
14
  static getFileExtension(fileName: string): string;
15
- static getMimeType(fileName: string): string;
15
+ /**
16
+ * Gets the file extension from a MIME type.
17
+ * @param mimeType The MIME type to get the file extension for.
18
+ * @returns The file extension, or an empty string if not found.
19
+ */
20
+ static getFileExtensionFromMimeType(mimeType: string): string;
21
+ static getMimeTypeFromFileExtension(fileName: string): string;
16
22
  /**
17
23
  * Parses a CSV string into an array of objects using PapaParse.
18
24
  * @param csvString - The CSV string to parse
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-extraneous-class */
2
1
  /* * */
3
2
  import { mimeTypes } from '@tmlmobilidade/lib';
4
3
  import JSZip from 'jszip';
@@ -7,10 +6,6 @@ import { fetchZipFromUrl, isBrowser, normalizeFileContent, readZipFromFile } fro
7
6
  /* * */
8
7
  export class Files {
9
8
  //
10
- //
11
- // Static properties
12
- //
13
- // Static methods
14
9
  /**
15
10
  * Blob to JS File
16
11
  */
@@ -28,7 +23,20 @@ export class Files {
28
23
  }
29
24
  return extension;
30
25
  }
31
- static getMimeType(fileName) {
26
+ /**
27
+ * Gets the file extension from a MIME type.
28
+ * @param mimeType The MIME type to get the file extension for.
29
+ * @returns The file extension, or an empty string if not found.
30
+ */
31
+ static getFileExtensionFromMimeType(mimeType) {
32
+ if (!mimeType)
33
+ return '';
34
+ const extension = Object.keys(mimeTypes).find(key => mimeTypes[key] === mimeType);
35
+ if (!extension)
36
+ return '';
37
+ return extension;
38
+ }
39
+ static getMimeTypeFromFileExtension(fileName) {
32
40
  const extension = Files.getFileExtension(fileName);
33
41
  return mimeTypes[extension];
34
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/utils",
3
- "version": "20250730.1829.32",
3
+ "version": "20250730.2348.33",
4
4
  "author": "João de Vasconcelos & Jusi Monteiro",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "homepage": "https://github.com/tmlmobilidade/services#readme",