@putkoff/abstract-utilities 1.0.65 → 1.0.66

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.
@@ -1 +1 @@
1
- export * from './';
1
+ export * from './src';
@@ -0,0 +1,2 @@
1
+ import 'server-only';
2
+ export * from './src';
@@ -0,0 +1,2 @@
1
+ import 'server-only';
2
+ export * from './mime_utils';
@@ -0,0 +1,172 @@
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
+ export declare function getAllFileTypesSync(directory: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): string[];
165
+ export declare function getAllFileTypes(directory: string, categories?: Iterable<string> | string[] | null, opts?: MediaOptions): Promise<string[]>;
166
+ /** Optional convenience re-exports that mirror your Python names */
167
+ export declare const get_all_file_types: typeof getAllFileTypes;
168
+ export declare const get_media_map: typeof getMediaMap;
169
+ export declare const get_media_exts: typeof getMediaExts;
170
+ export declare const confirm_type: typeof confirmType;
171
+ export declare const is_media_type: typeof isMediaType;
172
+ 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": "1.0.65",
3
+ "version": "1.0.66",
4
4
  "type": "module",
5
5
  "description": "A reusable React Login component with JWT authentication",
6
6
  "main": "dist/cjs/index.js",
@@ -99,6 +99,16 @@
99
99
  "import": "./dist/esm/client/*/index.js",
100
100
  "require": "./dist/cjs/client/*/index.js"
101
101
  },
102
+ "./server": {
103
+ "types": "./dist/types/server/index.d.ts",
104
+ "import": "./dist/esm/server/index.js",
105
+ "require": "./dist/cjs/server/index.js"
106
+ },
107
+ "./server/*": {
108
+ "types": "./dist/types/server/*/index.d.ts",
109
+ "import": "./dist/esm/server/*/index.js",
110
+ "require": "./dist/cjs/server/*/index.js"
111
+ },
102
112
  "./package.json": "./package.json"
103
113
  },
104
114
  "files": [