@putkoff/abstract-utilities 0.1.240 → 0.1.242

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/dist/index.d.ts CHANGED
@@ -269,10 +269,12 @@ declare function get_splitext(filePath: string | null): {
269
269
  * make_path(['/foo','bar','baz'])
270
270
  */
271
271
  declare function make_path(...paths: Array<string | string[]>): string;
272
+ declare function makePath(...paths: any[]): string;
272
273
  declare function sanitizeFilename(filename: string): string;
273
274
  declare function get_relative_path(directory: string, fullPath: string): string;
274
275
  declare function get_safe_path(p: string): string;
275
276
  declare function make_sanitized_path(...paths: string[]): string;
277
+ /** FIXED: your regexes were strings. This correctly joins without duplicate slashes. */
276
278
  declare function normalizeUrl(base: string, p?: string): string;
277
279
 
278
280
  /**
@@ -381,6 +383,187 @@ declare function getNums(): string;
381
383
  declare function isNum(obj: any): boolean;
382
384
  declare function getAlphas(): string;
383
385
 
386
+ /** ---- Types ---- */
387
+ type MimeByExt = Record<string, string>;
388
+ type MediaMap = Record<string, MimeByExt>;
389
+ type MediaCategory = keyof typeof MIME_TYPES;
390
+ interface MediaOptions {
391
+ /** Alias to mirror the Python **kwargs['media_types'] behavior */
392
+ media_types?: Iterable<string> | string[] | null;
393
+ }
394
+ /** ---- Data: large but explicit, mirrors your Python mapping ---- */
395
+ declare const MIME_TYPES: {
396
+ readonly image: {
397
+ readonly ".jpg": "image/jpeg";
398
+ readonly ".jpeg": "image/jpeg";
399
+ readonly ".png": "image/png";
400
+ readonly ".gif": "image/gif";
401
+ readonly ".bmp": "image/bmp";
402
+ readonly ".tiff": "image/tiff";
403
+ readonly ".webp": "image/webp";
404
+ readonly ".svg": "image/svg+xml";
405
+ readonly ".ico": "image/vnd.microsoft.icon";
406
+ readonly ".heic": "image/heic";
407
+ readonly ".psd": "image/vnd.adobe.photoshop";
408
+ readonly ".raw": "image/x-raw";
409
+ };
410
+ readonly video: {
411
+ readonly ".mp4": "video/mp4";
412
+ readonly ".webm": "video/webm";
413
+ readonly ".ogg": "video/ogg";
414
+ readonly ".mov": "video/quicktime";
415
+ readonly ".avi": "video/x-msvideo";
416
+ readonly ".mkv": "video/x-matroska";
417
+ readonly ".flv": "video/x-flv";
418
+ readonly ".wmv": "video/x-ms-wmv";
419
+ readonly ".3gp": "video/3gpp";
420
+ readonly ".ts": "video/mp2t";
421
+ readonly ".mpeg": "video/mpeg";
422
+ readonly ".mpg": "video/mpg";
423
+ };
424
+ readonly audio: {
425
+ readonly ".mp3": "audio/mpeg";
426
+ readonly ".wav": "audio/wav";
427
+ readonly ".flac": "audio/flac";
428
+ readonly ".aac": "audio/aac";
429
+ readonly ".ogg": "audio/ogg";
430
+ readonly ".m4a": "audio/mp4";
431
+ readonly ".opus": "audio/opus";
432
+ };
433
+ readonly document: {
434
+ readonly ".pdf": "application/pdf";
435
+ readonly ".doc": "application/msword";
436
+ readonly ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
437
+ readonly ".odt": "application/vnd.oasis.opendocument.text";
438
+ readonly ".txt": "text/plain";
439
+ readonly ".rtf": "application/rtf";
440
+ readonly ".md": "text/markdown";
441
+ readonly ".markdown": "text/markdown";
442
+ readonly ".tex": "application/x-tex";
443
+ readonly ".log": "text/plain";
444
+ readonly ".json": "application/json";
445
+ readonly ".xml": "application/xml";
446
+ readonly ".yaml": "application/x-yaml";
447
+ readonly ".yml": "application/x-yaml";
448
+ readonly ".ini": "text/plain";
449
+ readonly ".cfg": "text/plain";
450
+ readonly ".toml": "application/toml";
451
+ readonly ".csv": "text/csv";
452
+ readonly ".tsv": "text/tab-separated-values";
453
+ };
454
+ readonly presentation: {
455
+ readonly ".ppt": "application/vnd.ms-powerpoint";
456
+ readonly ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation";
457
+ readonly ".odp": "application/vnd.oasis.opendocument.presentation";
458
+ };
459
+ readonly spreadsheet: {
460
+ readonly ".xls": "application/vnd.ms-excel";
461
+ readonly ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
462
+ readonly ".ods": "application/vnd.oasis.opendocument.spreadsheet";
463
+ readonly ".csv": "text/csv";
464
+ readonly ".tsv": "text/tab-separated-values";
465
+ };
466
+ readonly code: {
467
+ readonly ".py": "text/x-python";
468
+ readonly ".java": "text/x-java-source";
469
+ readonly ".c": "text/x-c";
470
+ readonly ".cpp": "text/x-c++";
471
+ readonly ".h": "text/x-c";
472
+ readonly ".hpp": "text/x-c++";
473
+ readonly ".js": "application/javascript";
474
+ readonly ".cjs": "application/javascript";
475
+ readonly ".mjs": "application/javascript";
476
+ readonly ".jsx": "application/javascript";
477
+ readonly ".ts": "application/typescript";
478
+ readonly ".tsx": "application/typescript";
479
+ readonly ".rb": "text/x-ruby";
480
+ readonly ".php": "application/x-php";
481
+ readonly ".go": "text/x-go";
482
+ readonly ".rs": "text/rust";
483
+ readonly ".swift": "text/x-swift";
484
+ readonly ".kt": "text/x-kotlin";
485
+ readonly ".sh": "application/x-shellscript";
486
+ readonly ".bash": "application/x-shellscript";
487
+ readonly ".ps1": "application/x-powershell";
488
+ readonly ".sql": "application/sql";
489
+ readonly ".yml": "application/x-yaml";
490
+ readonly ".coffee": "text/coffeescript";
491
+ readonly ".lua": "text/x-lua";
492
+ };
493
+ readonly archive: {
494
+ readonly ".zip": "application/zip";
495
+ readonly ".tar": "application/x-tar";
496
+ readonly ".gz": "application/gzip";
497
+ readonly ".tgz": "application/gzip";
498
+ readonly ".bz2": "application/x-bzip2";
499
+ readonly ".xz": "application/x-xz";
500
+ readonly ".rar": "application/vnd.rar";
501
+ readonly ".7z": "application/x-7z-compressed";
502
+ readonly ".iso": "application/x-iso9660-image";
503
+ readonly ".dmg": "application/x-apple-diskimage";
504
+ readonly ".jar": "application/java-archive";
505
+ readonly ".war": "application/java-archive";
506
+ readonly ".whl": "application/python-wheel";
507
+ readonly ".egg": "application/python-egg";
508
+ };
509
+ readonly font: {
510
+ readonly ".ttf": "font/ttf";
511
+ readonly ".otf": "font/otf";
512
+ readonly ".woff": "font/woff";
513
+ readonly ".woff2": "font/woff2";
514
+ readonly ".eot": "application/vnd.ms-fontobject";
515
+ };
516
+ readonly executable: {
517
+ readonly ".exe": "application/vnd.microsoft.portable-executable";
518
+ readonly ".dll": "application/vnd.microsoft.portable-executable";
519
+ readonly ".bin": "application/octet-stream";
520
+ readonly ".deb": "application/vnd.debian.binary-package";
521
+ readonly ".rpm": "application/x-rpm";
522
+ };
523
+ };
524
+ /** Mirror of MEDIA_TYPES in Python: category -> Set of extensions */
525
+ declare const MEDIA_TYPES: Record<MediaCategory, Set<string>>;
526
+ /** ---- API (Python parity) ---- */
527
+ /**
528
+ * Return a sub-map of MEDIA_TYPES for the given categories.
529
+ * If categories is falsy, returns all categories.
530
+ */
531
+ declare function getMediaMap(categories?: Iterable<string> | string[] | null, opts?: MediaOptions): Partial<Record<MediaCategory, Set<string>>>;
532
+ /**
533
+ * Return a flat, sorted list of all extensions for the given categories.
534
+ */
535
+ declare function getMediaExts(categories?: Iterable<string> | string[] | null, opts?: MediaOptions): string[];
536
+ /**
537
+ * Given a file path or extension, return its media category (e.g. "image") or null.
538
+ * Mirrors Python's confirm_type.
539
+ */
540
+ declare function confirmType(pathOrExt: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): MediaCategory | null;
541
+ /**
542
+ * True if the given file path or extension belongs to one of the categories.
543
+ */
544
+ declare function isMediaType(pathOrExt: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): boolean;
545
+ /**
546
+ * Look up the MIME type by extension; fall back to 'application/octet-stream'.
547
+ */
548
+ declare function getMimeType(pathOrExt: string): string;
549
+ /**
550
+ * Recursively collect files under `directory` whose extension is in `categories`.
551
+ * Synchronous version.
552
+ */
553
+ declare function getAllFileTypesSync(directory: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): string[];
554
+ /**
555
+ * Recursively collect files under `directory` whose extension is in `categories`.
556
+ * Async/Promise version.
557
+ */
558
+ declare function getAllFileTypes(directory: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): Promise<string[]>;
559
+ /** Optional convenience re-exports that mirror your Python names */
560
+ declare const get_all_file_types: typeof getAllFileTypes;
561
+ declare const get_media_map: typeof getMediaMap;
562
+ declare const get_media_exts: typeof getMediaExts;
563
+ declare const confirm_type: typeof confirmType;
564
+ declare const is_media_type: typeof isMediaType;
565
+ declare const get_mime_type: typeof getMimeType;
566
+
384
567
  declare function Button({ children, color, variant, className, ...rest }: React.ButtonHTMLAttributes<HTMLButtonElement> & {
385
568
  color?: 'gray' | 'green' | 'blue';
386
569
  variant?: 'default' | 'icon' | 'primary' | 'secondary';
@@ -444,5 +627,5 @@ declare const encodeTextForUrl: (text: string) => string;
444
627
  /** Quick helper: decode long blobs coming from share-intents/UTMs */
445
628
  declare const decodeShareBlob: (blob: string) => string;
446
629
 
447
- export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertIt, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, buildUrl, callStorage, callWindowMethod, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, create_list_string, currentUsername, currentUsernames, decodeFormComponent, decodeJwt, decodeMaybeDouble, decodeSafe, decodeShareBlob, eatAll, eatEnd, eatInner, eatOuter, encode, encodeTextForUrl, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, formatNumber, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAlphaNum, getAlphas, getAuthorizationHeader, getBaseDir, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfigContent, getConfigJson, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMethod, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_relative_path, get_result, get_safe_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isNum, isStrInString, isTokenExpired, isType, make_path, make_sanitized_path, normalizeUrl, parseQuery, parseResult, path_to_url, processKeywords, readJsonFile, removeToken, requireToken, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse, urlJoin, url_to_path };
448
- export type { ApiRow, AppConfig, ChangePasswordFormProps, ChangePasswordProps, FetchVariables, FileItem, FileListResponse, InputProps, JwtPayload, LoginFormProps, LoginProps, LogoutButtonProps, Promise$1 as Promise, UrlKey };
630
+ export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, MEDIA_TYPES, MIME_TYPES, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertIt, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, buildUrl, callStorage, callWindowMethod, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, confirmType, confirm_type, create_list_string, currentUsername, currentUsernames, decodeFormComponent, decodeJwt, decodeMaybeDouble, decodeSafe, decodeShareBlob, eatAll, eatEnd, eatInner, eatOuter, encode, encodeTextForUrl, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, formatNumber, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAllFileTypes, getAllFileTypesSync, getAlphaNum, getAlphas, getAuthorizationHeader, getBaseDir, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfigContent, getConfigJson, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMediaExts, getMediaMap, getMethod, getMimeType, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_all_file_types, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_media_exts, get_media_map, get_mime_type, get_relative_path, get_result, get_safe_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isMediaType, isNum, isStrInString, isTokenExpired, isType, is_media_type, makePath, make_path, make_sanitized_path, normalizeUrl, parseQuery, parseResult, path_to_url, processKeywords, readJsonFile, removeToken, requireToken, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse, urlJoin, url_to_path };
631
+ export type { ApiRow, AppConfig, ChangePasswordFormProps, ChangePasswordProps, FetchVariables, FileItem, FileListResponse, InputProps, JwtPayload, LoginFormProps, LoginProps, LogoutButtonProps, MediaCategory, MediaMap, MediaOptions, MimeByExt, Promise$1 as Promise, UrlKey };
@@ -19,8 +19,10 @@ export declare function get_splitext(filePath: string | null): {
19
19
  * make_path(['/foo','bar','baz'])
20
20
  */
21
21
  export declare function make_path(...paths: Array<string | string[]>): string;
22
+ export declare function makePath(...paths: any[]): string;
22
23
  export declare function sanitizeFilename(filename: string): string;
23
24
  export declare function get_relative_path(directory: string, fullPath: string): string;
24
25
  export declare function get_safe_path(p: string): string;
25
26
  export declare function make_sanitized_path(...paths: string[]): string;
27
+ /** FIXED: your regexes were strings. This correctly joins without duplicate slashes. */
26
28
  export declare function normalizeUrl(base: string, p?: string): string;
@@ -2,3 +2,4 @@ export * from './clean_utils';
2
2
  export * from './ensure_utils';
3
3
  export * from './json_utils';
4
4
  export * from './type_utils';
5
+ export * from './mime_utils';
@@ -0,0 +1,180 @@
1
+ /** ---- Types ---- */
2
+ export type MimeByExt = Record<string, string>;
3
+ export type MediaMap = Record<string, MimeByExt>;
4
+ export type MediaCategory = keyof typeof MIME_TYPES;
5
+ export interface MediaOptions {
6
+ /** Alias to mirror the Python **kwargs['media_types'] behavior */
7
+ media_types?: Iterable<string> | string[] | null;
8
+ }
9
+ /** ---- Data: large but explicit, mirrors your Python mapping ---- */
10
+ export declare const MIME_TYPES: {
11
+ readonly image: {
12
+ readonly ".jpg": "image/jpeg";
13
+ readonly ".jpeg": "image/jpeg";
14
+ readonly ".png": "image/png";
15
+ readonly ".gif": "image/gif";
16
+ readonly ".bmp": "image/bmp";
17
+ readonly ".tiff": "image/tiff";
18
+ readonly ".webp": "image/webp";
19
+ readonly ".svg": "image/svg+xml";
20
+ readonly ".ico": "image/vnd.microsoft.icon";
21
+ readonly ".heic": "image/heic";
22
+ readonly ".psd": "image/vnd.adobe.photoshop";
23
+ readonly ".raw": "image/x-raw";
24
+ };
25
+ readonly video: {
26
+ readonly ".mp4": "video/mp4";
27
+ readonly ".webm": "video/webm";
28
+ readonly ".ogg": "video/ogg";
29
+ readonly ".mov": "video/quicktime";
30
+ readonly ".avi": "video/x-msvideo";
31
+ readonly ".mkv": "video/x-matroska";
32
+ readonly ".flv": "video/x-flv";
33
+ readonly ".wmv": "video/x-ms-wmv";
34
+ readonly ".3gp": "video/3gpp";
35
+ readonly ".ts": "video/mp2t";
36
+ readonly ".mpeg": "video/mpeg";
37
+ readonly ".mpg": "video/mpg";
38
+ };
39
+ readonly audio: {
40
+ readonly ".mp3": "audio/mpeg";
41
+ readonly ".wav": "audio/wav";
42
+ readonly ".flac": "audio/flac";
43
+ readonly ".aac": "audio/aac";
44
+ readonly ".ogg": "audio/ogg";
45
+ readonly ".m4a": "audio/mp4";
46
+ readonly ".opus": "audio/opus";
47
+ };
48
+ readonly document: {
49
+ readonly ".pdf": "application/pdf";
50
+ readonly ".doc": "application/msword";
51
+ readonly ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
52
+ readonly ".odt": "application/vnd.oasis.opendocument.text";
53
+ readonly ".txt": "text/plain";
54
+ readonly ".rtf": "application/rtf";
55
+ readonly ".md": "text/markdown";
56
+ readonly ".markdown": "text/markdown";
57
+ readonly ".tex": "application/x-tex";
58
+ readonly ".log": "text/plain";
59
+ readonly ".json": "application/json";
60
+ readonly ".xml": "application/xml";
61
+ readonly ".yaml": "application/x-yaml";
62
+ readonly ".yml": "application/x-yaml";
63
+ readonly ".ini": "text/plain";
64
+ readonly ".cfg": "text/plain";
65
+ readonly ".toml": "application/toml";
66
+ readonly ".csv": "text/csv";
67
+ readonly ".tsv": "text/tab-separated-values";
68
+ };
69
+ readonly presentation: {
70
+ readonly ".ppt": "application/vnd.ms-powerpoint";
71
+ readonly ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation";
72
+ readonly ".odp": "application/vnd.oasis.opendocument.presentation";
73
+ };
74
+ readonly spreadsheet: {
75
+ readonly ".xls": "application/vnd.ms-excel";
76
+ readonly ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
77
+ readonly ".ods": "application/vnd.oasis.opendocument.spreadsheet";
78
+ readonly ".csv": "text/csv";
79
+ readonly ".tsv": "text/tab-separated-values";
80
+ };
81
+ readonly code: {
82
+ readonly ".py": "text/x-python";
83
+ readonly ".java": "text/x-java-source";
84
+ readonly ".c": "text/x-c";
85
+ readonly ".cpp": "text/x-c++";
86
+ readonly ".h": "text/x-c";
87
+ readonly ".hpp": "text/x-c++";
88
+ readonly ".js": "application/javascript";
89
+ readonly ".cjs": "application/javascript";
90
+ readonly ".mjs": "application/javascript";
91
+ readonly ".jsx": "application/javascript";
92
+ readonly ".ts": "application/typescript";
93
+ readonly ".tsx": "application/typescript";
94
+ readonly ".rb": "text/x-ruby";
95
+ readonly ".php": "application/x-php";
96
+ readonly ".go": "text/x-go";
97
+ readonly ".rs": "text/rust";
98
+ readonly ".swift": "text/x-swift";
99
+ readonly ".kt": "text/x-kotlin";
100
+ readonly ".sh": "application/x-shellscript";
101
+ readonly ".bash": "application/x-shellscript";
102
+ readonly ".ps1": "application/x-powershell";
103
+ readonly ".sql": "application/sql";
104
+ readonly ".yml": "application/x-yaml";
105
+ readonly ".coffee": "text/coffeescript";
106
+ readonly ".lua": "text/x-lua";
107
+ };
108
+ readonly archive: {
109
+ readonly ".zip": "application/zip";
110
+ readonly ".tar": "application/x-tar";
111
+ readonly ".gz": "application/gzip";
112
+ readonly ".tgz": "application/gzip";
113
+ readonly ".bz2": "application/x-bzip2";
114
+ readonly ".xz": "application/x-xz";
115
+ readonly ".rar": "application/vnd.rar";
116
+ readonly ".7z": "application/x-7z-compressed";
117
+ readonly ".iso": "application/x-iso9660-image";
118
+ readonly ".dmg": "application/x-apple-diskimage";
119
+ readonly ".jar": "application/java-archive";
120
+ readonly ".war": "application/java-archive";
121
+ readonly ".whl": "application/python-wheel";
122
+ readonly ".egg": "application/python-egg";
123
+ };
124
+ readonly font: {
125
+ readonly ".ttf": "font/ttf";
126
+ readonly ".otf": "font/otf";
127
+ readonly ".woff": "font/woff";
128
+ readonly ".woff2": "font/woff2";
129
+ readonly ".eot": "application/vnd.ms-fontobject";
130
+ };
131
+ readonly executable: {
132
+ readonly ".exe": "application/vnd.microsoft.portable-executable";
133
+ readonly ".dll": "application/vnd.microsoft.portable-executable";
134
+ readonly ".bin": "application/octet-stream";
135
+ readonly ".deb": "application/vnd.debian.binary-package";
136
+ readonly ".rpm": "application/x-rpm";
137
+ };
138
+ };
139
+ /** Mirror of MEDIA_TYPES in Python: category -> Set of extensions */
140
+ export declare const MEDIA_TYPES: Record<MediaCategory, Set<string>>;
141
+ /** ---- API (Python parity) ---- */
142
+ /**
143
+ * Return a sub-map of MEDIA_TYPES for the given categories.
144
+ * If categories is falsy, returns all categories.
145
+ */
146
+ export declare function getMediaMap(categories?: Iterable<string> | string[] | null, opts?: MediaOptions): Partial<Record<MediaCategory, Set<string>>>;
147
+ /**
148
+ * Return a flat, sorted list of all extensions for the given categories.
149
+ */
150
+ export declare function getMediaExts(categories?: Iterable<string> | string[] | null, opts?: MediaOptions): string[];
151
+ /**
152
+ * Given a file path or extension, return its media category (e.g. "image") or null.
153
+ * Mirrors Python's confirm_type.
154
+ */
155
+ export declare function confirmType(pathOrExt: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): MediaCategory | null;
156
+ /**
157
+ * True if the given file path or extension belongs to one of the categories.
158
+ */
159
+ export declare function isMediaType(pathOrExt: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): boolean;
160
+ /**
161
+ * Look up the MIME type by extension; fall back to 'application/octet-stream'.
162
+ */
163
+ export declare function getMimeType(pathOrExt: string): string;
164
+ /**
165
+ * Recursively collect files under `directory` whose extension is in `categories`.
166
+ * Synchronous version.
167
+ */
168
+ export declare function getAllFileTypesSync(directory: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): string[];
169
+ /**
170
+ * Recursively collect files under `directory` whose extension is in `categories`.
171
+ * Async/Promise version.
172
+ */
173
+ export declare function getAllFileTypes(directory: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): Promise<string[]>;
174
+ /** Optional convenience re-exports that mirror your Python names */
175
+ export declare const get_all_file_types: typeof getAllFileTypes;
176
+ export declare const get_media_map: typeof getMediaMap;
177
+ export declare const get_media_exts: typeof getMediaExts;
178
+ export declare const confirm_type: typeof confirmType;
179
+ export declare const is_media_type: typeof isMediaType;
180
+ export declare const get_mime_type: typeof getMimeType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putkoff/abstract-utilities",
3
- "version": "0.1.240",
3
+ "version": "0.1.242",
4
4
  "description": "Reusable abstract utility functions and components for both Node and React.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",