@juspay/neurolink 10.10.11 → 10.11.0
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.
- package/CHANGELOG.md +12 -0
- package/dist/adapters/imageFormatSupport.d.ts +75 -0
- package/dist/adapters/imageFormatSupport.js +283 -0
- package/dist/adapters/video/ffmpegAdapter.d.ts +6 -0
- package/dist/adapters/video/ffmpegAdapter.js +1 -1
- package/dist/browser/neurolink.min.js +399 -398
- package/dist/lib/adapters/imageFormatSupport.d.ts +75 -0
- package/dist/lib/adapters/imageFormatSupport.js +284 -0
- package/dist/lib/adapters/video/ffmpegAdapter.d.ts +6 -0
- package/dist/lib/adapters/video/ffmpegAdapter.js +1 -1
- package/dist/lib/processors/config/fileExtensions.d.ts +32 -15
- package/dist/lib/processors/config/fileExtensions.js +27 -66
- package/dist/lib/processors/config/fileTypeRegistry.d.ts +106 -0
- package/dist/lib/processors/config/fileTypeRegistry.js +702 -0
- package/dist/lib/processors/config/index.d.ts +2 -1
- package/dist/lib/processors/config/index.js +5 -1
- package/dist/lib/processors/config/mimeConstants.d.ts +22 -7
- package/dist/lib/processors/config/mimeConstants.js +45 -66
- package/dist/lib/processors/media/AudioProcessor.js +16 -38
- package/dist/lib/processors/media/VideoProcessor.js +11 -32
- package/dist/lib/providers/googleAiStudio/client.js +12 -1
- package/dist/lib/providers/googleVertex/client.js +123 -66
- package/dist/lib/types/file.d.ts +41 -0
- package/dist/lib/utils/fileDetector.js +367 -251
- package/dist/lib/utils/imageProcessor.js +14 -17
- package/dist/lib/utils/markupSniff.d.ts +37 -0
- package/dist/lib/utils/markupSniff.js +125 -0
- package/dist/lib/utils/messageBuilder.d.ts +14 -0
- package/dist/lib/utils/messageBuilder.js +287 -74
- package/dist/processors/config/fileExtensions.d.ts +32 -15
- package/dist/processors/config/fileExtensions.js +27 -66
- package/dist/processors/config/fileTypeRegistry.d.ts +106 -0
- package/dist/processors/config/fileTypeRegistry.js +701 -0
- package/dist/processors/config/index.d.ts +2 -1
- package/dist/processors/config/index.js +5 -1
- package/dist/processors/config/mimeConstants.d.ts +22 -7
- package/dist/processors/config/mimeConstants.js +45 -66
- package/dist/processors/media/AudioProcessor.js +16 -38
- package/dist/processors/media/VideoProcessor.js +11 -32
- package/dist/providers/googleAiStudio/client.js +12 -1
- package/dist/providers/googleVertex/client.js +123 -66
- package/dist/types/file.d.ts +41 -0
- package/dist/utils/fileDetector.js +367 -251
- package/dist/utils/imageProcessor.js +14 -17
- package/dist/utils/markupSniff.d.ts +37 -0
- package/dist/utils/markupSniff.js +124 -0
- package/dist/utils/messageBuilder.d.ts +14 -0
- package/dist/utils/messageBuilder.js +287 -74
- package/package.json +3 -2
|
@@ -2,20 +2,34 @@
|
|
|
2
2
|
* File Extension Constants
|
|
3
3
|
* Centralized file extension definitions organized by category for file processing
|
|
4
4
|
*
|
|
5
|
+
* The media/document/data/archive categories are derived from
|
|
6
|
+
* {@link FILE_TYPE_REGISTRY} rather than typed out here — they used to be a
|
|
7
|
+
* second hand-maintained list that drifted from both the registry-equivalent
|
|
8
|
+
* MIME map and the detector, so formats appeared "supported" in one place and
|
|
9
|
+
* were invisible in another. Source-code and text categories, which carry no
|
|
10
|
+
* modality, are still enumerated below.
|
|
11
|
+
*
|
|
5
12
|
* @module processors/config/fileTypes
|
|
6
13
|
*/
|
|
7
14
|
/**
|
|
8
|
-
* Image file extensions supported by the platform
|
|
15
|
+
* Image file extensions supported by the platform.
|
|
16
|
+
* Includes `.svg`, which is processed as sanitized markup rather than raster.
|
|
9
17
|
*/
|
|
10
|
-
export declare const IMAGE_EXTENSIONS: readonly [
|
|
18
|
+
export declare const IMAGE_EXTENSIONS: readonly string[];
|
|
11
19
|
/**
|
|
12
|
-
*
|
|
20
|
+
* Image extensions every vision-capable provider accepts as-is.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately NOT derived from the registry: this is the intersection of what
|
|
23
|
+
* OpenAI, Anthropic, Google and Bedrock all accept, not the set NeuroLink can
|
|
24
|
+
* identify. Anything else the registry knows about (BMP, TIFF, AVIF, ICO,
|
|
25
|
+
* HEIC/HEIF) is transcoded to PNG before dispatch — see
|
|
26
|
+
* `adapters/imageFormatSupport.ts`.
|
|
13
27
|
*/
|
|
14
28
|
export declare const AI_VISION_EXTENSIONS: readonly [".jpg", ".jpeg", ".png", ".gif", ".webp"];
|
|
15
29
|
/**
|
|
16
30
|
* Document file extensions for office documents and PDFs
|
|
17
31
|
*/
|
|
18
|
-
export declare const DOCUMENT_EXTENSIONS: readonly [
|
|
32
|
+
export declare const DOCUMENT_EXTENSIONS: readonly string[];
|
|
19
33
|
/**
|
|
20
34
|
* PDF document extensions
|
|
21
35
|
*/
|
|
@@ -57,9 +71,12 @@ export declare const CSV_EXTENSIONS: readonly [".csv"];
|
|
|
57
71
|
*/
|
|
58
72
|
export declare const YAML_EXTENSIONS: readonly [".yaml", ".yml"];
|
|
59
73
|
/**
|
|
60
|
-
* All data format extensions combined
|
|
74
|
+
* All data format extensions combined.
|
|
75
|
+
*
|
|
76
|
+
* The tabular formats (.csv/.tsv) come from the registry; .json/.xml/.yaml are
|
|
77
|
+
* text formats with no modality of their own and stay listed here.
|
|
61
78
|
*/
|
|
62
|
-
export declare const DATA_EXTENSIONS: readonly [
|
|
79
|
+
export declare const DATA_EXTENSIONS: readonly string[];
|
|
63
80
|
/**
|
|
64
81
|
* Plain text file extensions
|
|
65
82
|
*/
|
|
@@ -173,15 +190,15 @@ export declare const CONFIG_EXTENSIONS: readonly [".env", ".ini", ".toml", ".cfg
|
|
|
173
190
|
/**
|
|
174
191
|
* Archive and compressed file extensions
|
|
175
192
|
*/
|
|
176
|
-
export declare const ARCHIVE_EXTENSIONS: readonly [
|
|
193
|
+
export declare const ARCHIVE_EXTENSIONS: readonly string[];
|
|
177
194
|
/**
|
|
178
195
|
* Video file extensions
|
|
179
196
|
*/
|
|
180
|
-
export declare const VIDEO_EXTENSIONS: readonly [
|
|
197
|
+
export declare const VIDEO_EXTENSIONS: readonly string[];
|
|
181
198
|
/**
|
|
182
199
|
* Audio file extensions
|
|
183
200
|
*/
|
|
184
|
-
export declare const AUDIO_EXTENSIONS: readonly [
|
|
201
|
+
export declare const AUDIO_EXTENSIONS: readonly string[];
|
|
185
202
|
/**
|
|
186
203
|
* Design and graphics file extensions
|
|
187
204
|
*/
|
|
@@ -198,16 +215,16 @@ export declare const EXECUTABLE_EXTENSIONS: readonly [".exe", ".dll", ".so", ".d
|
|
|
198
215
|
* File extensions grouped by category for easy access
|
|
199
216
|
*/
|
|
200
217
|
export declare const FILE_EXTENSIONS: {
|
|
201
|
-
readonly IMAGES: readonly [
|
|
218
|
+
readonly IMAGES: readonly string[];
|
|
202
219
|
readonly AI_VISION: readonly [".jpg", ".jpeg", ".png", ".gif", ".webp"];
|
|
203
|
-
readonly DOCUMENTS: readonly [
|
|
220
|
+
readonly DOCUMENTS: readonly string[];
|
|
204
221
|
readonly PDF: readonly [".pdf"];
|
|
205
222
|
readonly WORD: readonly [".docx", ".doc"];
|
|
206
223
|
readonly EXCEL: readonly [".xlsx", ".xls"];
|
|
207
224
|
readonly POWERPOINT: readonly [".pptx", ".ppt"];
|
|
208
225
|
readonly OPENDOCUMENT: readonly [".odt", ".ods", ".odp"];
|
|
209
226
|
readonly RTF: readonly [".rtf"];
|
|
210
|
-
readonly DATA: readonly [
|
|
227
|
+
readonly DATA: readonly string[];
|
|
211
228
|
readonly JSON: readonly [".json"];
|
|
212
229
|
readonly XML: readonly [".xml"];
|
|
213
230
|
readonly CSV: readonly [".csv"];
|
|
@@ -254,9 +271,9 @@ export declare const FILE_EXTENSIONS: {
|
|
|
254
271
|
};
|
|
255
272
|
readonly ALL_CODE: readonly [".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx", ".py", ".pyw", ".pyi", ".java", ".kt", ".kts", ".go", ".rs", ".c", ".h", ".cpp", ".hpp", ".cc", ".cxx", ".hxx", ".cs", ".rb", ".rake", ".php", ".phtml", ".php3", ".php4", ".php5", ".phps", ".sh", ".bash", ".zsh", ".fish", ".ksh", ".pl", ".pm", ".pod", ".t", ".lua", ".sql", ".swift", ".dart", ".m", ".mm", ".scala", ".sc", ".hs", ".lhs", ".ex", ".exs", ".erl", ".hrl", ".clj", ".cljs", ".cljc", ".edn", ".fs", ".fsx", ".fsi", ".ml", ".mli", ".lisp", ".lsp", ".cl", ".scm", ".ss", ".groovy", ".gvy", ".gy", ".gsh", ".ps1", ".psm1", ".psd1", ".r", ".rmd", ".jl", ".nim", ".nims", ".zig", ".v", ".cr", ".d", ".asm", ".s", ".f", ".f90", ".f95", ".f03", ".for", ".cob", ".cbl", ".cobol", ".pas", ".pp", ".p", ".ada", ".adb", ".ads", ".vue", ".svelte", ".hbs", ".handlebars", ".ejs", ".pug", ".jade", ".css", ".scss", ".sass", ".less", ".styl", ".stylus", ".dockerfile", ".mk"];
|
|
256
273
|
readonly CONFIG: readonly [".env", ".ini", ".toml", ".cfg", ".conf", ".config", ".properties", ".editorconfig", ".gitignore", ".gitattributes", ".npmrc", ".yarnrc", ".prettierrc", ".eslintrc", ".babelrc"];
|
|
257
|
-
readonly ARCHIVES: readonly [
|
|
258
|
-
readonly VIDEO: readonly [
|
|
259
|
-
readonly AUDIO: readonly [
|
|
274
|
+
readonly ARCHIVES: readonly string[];
|
|
275
|
+
readonly VIDEO: readonly string[];
|
|
276
|
+
readonly AUDIO: readonly string[];
|
|
260
277
|
readonly DESIGN: readonly [".psd", ".psb", ".ai", ".sketch", ".fig", ".xd"];
|
|
261
278
|
readonly DATABASE: readonly [".db", ".sqlite", ".sqlite3", ".mdb", ".accdb"];
|
|
262
279
|
readonly EXECUTABLE: readonly [".exe", ".dll", ".so", ".dylib", ".app", ".bat", ".cmd", ".vbs", ".ps1", ".msi", ".dmg", ".bin"];
|
|
@@ -2,31 +2,32 @@
|
|
|
2
2
|
* File Extension Constants
|
|
3
3
|
* Centralized file extension definitions organized by category for file processing
|
|
4
4
|
*
|
|
5
|
+
* The media/document/data/archive categories are derived from
|
|
6
|
+
* {@link FILE_TYPE_REGISTRY} rather than typed out here — they used to be a
|
|
7
|
+
* second hand-maintained list that drifted from both the registry-equivalent
|
|
8
|
+
* MIME map and the detector, so formats appeared "supported" in one place and
|
|
9
|
+
* were invisible in another. Source-code and text categories, which carry no
|
|
10
|
+
* modality, are still enumerated below.
|
|
11
|
+
*
|
|
5
12
|
* @module processors/config/fileTypes
|
|
6
13
|
*/
|
|
14
|
+
import { extensionsForModality } from "./fileTypeRegistry.js";
|
|
7
15
|
// =============================================================================
|
|
8
16
|
// IMAGE FILE EXTENSIONS
|
|
9
17
|
// =============================================================================
|
|
10
18
|
/**
|
|
11
|
-
* Image file extensions supported by the platform
|
|
19
|
+
* Image file extensions supported by the platform.
|
|
20
|
+
* Includes `.svg`, which is processed as sanitized markup rather than raster.
|
|
12
21
|
*/
|
|
13
|
-
export const IMAGE_EXTENSIONS =
|
|
14
|
-
".jpg",
|
|
15
|
-
".jpeg",
|
|
16
|
-
".png",
|
|
17
|
-
".gif",
|
|
18
|
-
".webp",
|
|
19
|
-
".svg",
|
|
20
|
-
".bmp",
|
|
21
|
-
".tiff",
|
|
22
|
-
".tif",
|
|
23
|
-
".avif",
|
|
24
|
-
".heic",
|
|
25
|
-
".heif",
|
|
26
|
-
".ico",
|
|
27
|
-
];
|
|
22
|
+
export const IMAGE_EXTENSIONS = extensionsForModality("image");
|
|
28
23
|
/**
|
|
29
|
-
*
|
|
24
|
+
* Image extensions every vision-capable provider accepts as-is.
|
|
25
|
+
*
|
|
26
|
+
* Deliberately NOT derived from the registry: this is the intersection of what
|
|
27
|
+
* OpenAI, Anthropic, Google and Bedrock all accept, not the set NeuroLink can
|
|
28
|
+
* identify. Anything else the registry knows about (BMP, TIFF, AVIF, ICO,
|
|
29
|
+
* HEIC/HEIF) is transcoded to PNG before dispatch — see
|
|
30
|
+
* `adapters/imageFormatSupport.ts`.
|
|
30
31
|
*/
|
|
31
32
|
export const AI_VISION_EXTENSIONS = [
|
|
32
33
|
".jpg",
|
|
@@ -41,19 +42,7 @@ export const AI_VISION_EXTENSIONS = [
|
|
|
41
42
|
/**
|
|
42
43
|
* Document file extensions for office documents and PDFs
|
|
43
44
|
*/
|
|
44
|
-
export const DOCUMENT_EXTENSIONS =
|
|
45
|
-
".pdf",
|
|
46
|
-
".docx",
|
|
47
|
-
".doc",
|
|
48
|
-
".xlsx",
|
|
49
|
-
".xls",
|
|
50
|
-
".pptx",
|
|
51
|
-
".ppt",
|
|
52
|
-
".odt",
|
|
53
|
-
".ods",
|
|
54
|
-
".odp",
|
|
55
|
-
".rtf",
|
|
56
|
-
];
|
|
45
|
+
export const DOCUMENT_EXTENSIONS = extensionsForModality("document");
|
|
57
46
|
/**
|
|
58
47
|
* PDF document extensions
|
|
59
48
|
*/
|
|
@@ -98,14 +87,17 @@ export const CSV_EXTENSIONS = [".csv"];
|
|
|
98
87
|
*/
|
|
99
88
|
export const YAML_EXTENSIONS = [".yaml", ".yml"];
|
|
100
89
|
/**
|
|
101
|
-
* All data format extensions combined
|
|
90
|
+
* All data format extensions combined.
|
|
91
|
+
*
|
|
92
|
+
* The tabular formats (.csv/.tsv) come from the registry; .json/.xml/.yaml are
|
|
93
|
+
* text formats with no modality of their own and stay listed here.
|
|
102
94
|
*/
|
|
103
95
|
export const DATA_EXTENSIONS = [
|
|
104
96
|
".json",
|
|
105
97
|
".xml",
|
|
106
|
-
".csv",
|
|
107
98
|
".yaml",
|
|
108
99
|
".yml",
|
|
100
|
+
...extensionsForModality("data"),
|
|
109
101
|
];
|
|
110
102
|
// =============================================================================
|
|
111
103
|
// TEXT FILE EXTENSIONS
|
|
@@ -346,49 +338,18 @@ export const CONFIG_EXTENSIONS = [
|
|
|
346
338
|
/**
|
|
347
339
|
* Archive and compressed file extensions
|
|
348
340
|
*/
|
|
349
|
-
export const ARCHIVE_EXTENSIONS =
|
|
350
|
-
".zip",
|
|
351
|
-
".tar",
|
|
352
|
-
".gz",
|
|
353
|
-
".tgz",
|
|
354
|
-
".tar.gz",
|
|
355
|
-
".tar.bz2",
|
|
356
|
-
".bz2",
|
|
357
|
-
".rar",
|
|
358
|
-
".7z",
|
|
359
|
-
".xz",
|
|
360
|
-
];
|
|
341
|
+
export const ARCHIVE_EXTENSIONS = extensionsForModality("archive");
|
|
361
342
|
// =============================================================================
|
|
362
343
|
// MULTIMEDIA FILE EXTENSIONS
|
|
363
344
|
// =============================================================================
|
|
364
345
|
/**
|
|
365
346
|
* Video file extensions
|
|
366
347
|
*/
|
|
367
|
-
export const VIDEO_EXTENSIONS =
|
|
368
|
-
".mp4",
|
|
369
|
-
".avi",
|
|
370
|
-
".mov",
|
|
371
|
-
".mkv",
|
|
372
|
-
".webm",
|
|
373
|
-
".flv",
|
|
374
|
-
".wmv",
|
|
375
|
-
".m4v",
|
|
376
|
-
".mpg",
|
|
377
|
-
".mpeg",
|
|
378
|
-
];
|
|
348
|
+
export const VIDEO_EXTENSIONS = extensionsForModality("video");
|
|
379
349
|
/**
|
|
380
350
|
* Audio file extensions
|
|
381
351
|
*/
|
|
382
|
-
export const AUDIO_EXTENSIONS =
|
|
383
|
-
".mp3",
|
|
384
|
-
".wav",
|
|
385
|
-
".aac",
|
|
386
|
-
".flac",
|
|
387
|
-
".ogg",
|
|
388
|
-
".m4a",
|
|
389
|
-
".wma",
|
|
390
|
-
".opus",
|
|
391
|
-
];
|
|
352
|
+
export const AUDIO_EXTENSIONS = extensionsForModality("audio");
|
|
392
353
|
// =============================================================================
|
|
393
354
|
// DESIGN FILE EXTENSIONS
|
|
394
355
|
// =============================================================================
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical file-format registry — the single source of truth for
|
|
3
|
+
* extension ↔ MIME ↔ FileType ↔ modality.
|
|
4
|
+
*
|
|
5
|
+
* ## Why this exists
|
|
6
|
+
*
|
|
7
|
+
* The same knowledge used to live in five hand-maintained tables that had no
|
|
8
|
+
* way of agreeing with each other:
|
|
9
|
+
*
|
|
10
|
+
* 1. `EXTENSION_MIME_MAP` (config/mimeConstants.ts)
|
|
11
|
+
* 2. the `*_EXTENSIONS` category arrays (config/fileExtensions.ts)
|
|
12
|
+
* 3. `ExtensionStrategy.typeMap` + `.mimeMap` (utils/fileDetector.ts)
|
|
13
|
+
* 4. `EXTENSION_TYPE_MAP` (utils/messageBuilder.ts)
|
|
14
|
+
* 5. each processor's `supportedExtensions` / `supportedMimeTypes`
|
|
15
|
+
*
|
|
16
|
+
* They drifted, and the drift was not cosmetic — a format that a processor
|
|
17
|
+
* declared it supported was routinely invisible to the detector standing in
|
|
18
|
+
* front of it, so the file never reached the processor at all. Measured on real
|
|
19
|
+
* ffmpeg-generated media before this registry existed:
|
|
20
|
+
*
|
|
21
|
+
* .aiff .m2ts .mts .vob .3g2 .3gp → "unknown" (downgraded to metadata text)
|
|
22
|
+
* .mpg .mpeg → "csv" (binary parsed as a spreadsheet)
|
|
23
|
+
* .ts → "text" (MPEG-TS inlined as source code)
|
|
24
|
+
*
|
|
25
|
+
* Deriving all five consumers from one table makes that class of drift
|
|
26
|
+
* structurally impossible rather than merely fixed once.
|
|
27
|
+
*
|
|
28
|
+
* ## Invariants
|
|
29
|
+
*
|
|
30
|
+
* - `extensions[0]` is canonical for the format; the rest are accepted aliases.
|
|
31
|
+
* - `mimeTypes[0]` is canonical; the rest are aliases seen in the wild
|
|
32
|
+
* (`audio/x-wav`, `image/x-icon`, vendor prefixes, …).
|
|
33
|
+
* - Every extension and every MIME type appears in exactly one entry. The
|
|
34
|
+
* `assertRegistryIsUnambiguous()` check below is executed at module load, so
|
|
35
|
+
* a duplicate is a startup failure rather than a silent last-write-wins.
|
|
36
|
+
* - `fileType` is the *routing* type the detector emits (what processor to
|
|
37
|
+
* use); `modality` is the *category* a human means. They deliberately differ:
|
|
38
|
+
* an .odt is `fileType: "docx"` (the Word processor handles it) but
|
|
39
|
+
* `modality: "document"`, and .svg is `fileType: "svg"` (sanitised as markup,
|
|
40
|
+
* never sent to a vision API) but `modality: "image"`.
|
|
41
|
+
*
|
|
42
|
+
* @module processors/config/fileTypeRegistry
|
|
43
|
+
*/
|
|
44
|
+
import type { FileFormatEntry, FileModality, FileType } from "../../types/index.js";
|
|
45
|
+
/**
|
|
46
|
+
* Every file format NeuroLink can identify, grouped by modality.
|
|
47
|
+
*
|
|
48
|
+
* Adding a format here is all that is required — the extension map, the MIME
|
|
49
|
+
* map, the detector's lookup tables, the category arrays and the media
|
|
50
|
+
* processors' supported-format lists are all derived from this array.
|
|
51
|
+
*/
|
|
52
|
+
export declare const FILE_TYPE_REGISTRY: readonly FileFormatEntry[];
|
|
53
|
+
/**
|
|
54
|
+
* Extensions that must NOT be treated as belonging to their registry entry's
|
|
55
|
+
* modality when only a filename is available.
|
|
56
|
+
*
|
|
57
|
+
* Derived from {@link EXTENSION_OVERRIDES}: `extensionsForModality("video")`
|
|
58
|
+
* feeds both `VIDEO_EXTENSIONS` and `VideoProcessor`'s supported list, and
|
|
59
|
+
* `BaseFileProcessor.isFileSupported` accepts a file when the *extension*
|
|
60
|
+
* matches even if the supplied mimetype says otherwise. Leaving `.ts` in that
|
|
61
|
+
* list made `isVideoFile("text/plain", "app.ts")` return true.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Extension → MIME for the overridden extensions only.
|
|
65
|
+
*
|
|
66
|
+
* Exported so `EXTENSION_MIME_MAP` can apply the override as its FINAL layer.
|
|
67
|
+
* That map is built by spreading the registry over the text map, so without
|
|
68
|
+
* this the registry's `.ts → video/mp2t` won again and `getMimeTypeForExtension`
|
|
69
|
+
* disagreed with `mimeTypeForExtension` about the very same file.
|
|
70
|
+
*/
|
|
71
|
+
export declare const EXTENSION_MIME_OVERRIDES: Readonly<Record<string, string>>;
|
|
72
|
+
/**
|
|
73
|
+
* Normalize an extension to the registry's key form: lowercased, with a leading
|
|
74
|
+
* dot. Accepts `"png"`, `".PNG"`, `"image.png"` and `"/tmp/a.png"` alike.
|
|
75
|
+
*
|
|
76
|
+
* Compound extensions (`.tar.gz`) are matched before the single-segment form so
|
|
77
|
+
* a `.tar.gz` resolves to the gzip entry rather than to `.gz` by accident —
|
|
78
|
+
* they happen to agree today, but the lookup should not depend on that.
|
|
79
|
+
*/
|
|
80
|
+
export declare function normalizeExtension(raw: string): string;
|
|
81
|
+
/** Look up the registry entry for a file extension, or undefined. */
|
|
82
|
+
export declare function lookupByExtension(ext: string): FileFormatEntry | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Look up the registry entry for a MIME type, or undefined. Any `;charset=…`
|
|
85
|
+
* parameter is stripped, matching how Content-Type headers arrive.
|
|
86
|
+
*/
|
|
87
|
+
export declare function lookupByMimeType(mime: string): FileFormatEntry | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Routing {@link FileType} for an extension, honouring {@link EXTENSION_OVERRIDES}.
|
|
90
|
+
* Returns undefined when the extension is not in the registry.
|
|
91
|
+
*/
|
|
92
|
+
export declare function fileTypeForExtension(ext: string): FileType | undefined;
|
|
93
|
+
/** Canonical MIME type for an extension, or undefined when unknown. */
|
|
94
|
+
export declare function mimeTypeForExtension(ext: string): string | undefined;
|
|
95
|
+
/** Canonical extension (with leading dot) for a MIME type, or undefined. */
|
|
96
|
+
export declare function extensionForMimeType(mime: string): string | undefined;
|
|
97
|
+
/** Every extension registered for a modality, in registry order. */
|
|
98
|
+
export declare function extensionsForModality(modality: FileModality): readonly string[];
|
|
99
|
+
/** Every MIME type registered for a modality, in registry order. */
|
|
100
|
+
export declare function mimeTypesForModality(modality: FileModality): readonly string[];
|
|
101
|
+
/**
|
|
102
|
+
* True when the extension belongs to the given modality. Uses the entry's
|
|
103
|
+
* modality, not its routing `fileType`, so `.svg` counts as an image and `.odt`
|
|
104
|
+
* counts as a document.
|
|
105
|
+
*/
|
|
106
|
+
export declare function isModalityExtension(ext: string, modality: FileModality): boolean;
|