@putkoff/abstract-utilities 1.0.135 → 1.0.139
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/cjs/client.js +1 -2
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/functions.js +3 -7
- package/dist/cjs/functions.js.map +1 -1
- package/dist/cjs/index.js +3 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mime_utils-C53pEVr1.js +835 -0
- package/dist/cjs/mime_utils-C53pEVr1.js.map +1 -0
- package/dist/cjs/print_utils-D85MeEz4.js +1948 -0
- package/dist/cjs/print_utils-D85MeEz4.js.map +1 -0
- package/dist/cjs/server.js +28 -139
- package/dist/cjs/server.js.map +1 -1
- package/dist/esm/client.js +1 -2
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/functions.js +3 -4
- package/dist/esm/functions.js.map +1 -1
- package/dist/esm/index.js +3 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mime_utils-D3LjiFgN.js +815 -0
- package/dist/esm/mime_utils-D3LjiFgN.js.map +1 -0
- package/dist/esm/print_utils-DlZVeNG9.js +1706 -0
- package/dist/esm/print_utils-DlZVeNG9.js.map +1 -0
- package/dist/esm/server.js +29 -116
- package/dist/esm/server.js.map +1 -1
- package/dist/types/browser/mediaTypes.fs.d.ts +0 -0
- package/dist/types/functions/type_utils/src/mime_utils.d.ts +4 -25
- package/dist/types/server/src/mediaTypes.core.d.ts +37 -0
- package/dist/types/server/src/mime_utils.d.ts +4 -25
- package/package.json +1 -1
|
@@ -3,10 +3,9 @@ export type MimeByExt = Record<string, string>;
|
|
|
3
3
|
export type MediaMap = Record<string, MimeByExt>;
|
|
4
4
|
export type MediaCategory = keyof typeof MIME_TYPES;
|
|
5
5
|
export interface MediaOptions {
|
|
6
|
-
/** Alias to mirror the Python **kwargs['media_types'] behavior */
|
|
7
6
|
media_types?: Iterable<string> | string[] | null;
|
|
8
7
|
}
|
|
9
|
-
/** ---- Data
|
|
8
|
+
/** ---- Data ---- */
|
|
10
9
|
export declare const MIME_TYPES: {
|
|
11
10
|
readonly image: {
|
|
12
11
|
readonly ".jpg": "image/jpeg";
|
|
@@ -136,35 +135,15 @@ export declare const MIME_TYPES: {
|
|
|
136
135
|
readonly ".rpm": "application/x-rpm";
|
|
137
136
|
};
|
|
138
137
|
};
|
|
139
|
-
/**
|
|
138
|
+
/** category -> Set of extensions */
|
|
140
139
|
export declare const MEDIA_TYPES: Record<MediaCategory, Set<string>>;
|
|
141
|
-
/** ---- API
|
|
142
|
-
/**
|
|
143
|
-
* Return a sub-map of MEDIA_TYPES for the given categories.
|
|
144
|
-
* If categories is falsy, returns all categories.
|
|
145
|
-
*/
|
|
140
|
+
/** ---- API ---- */
|
|
146
141
|
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
142
|
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
143
|
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
144
|
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
145
|
export declare function getMimeType(pathOrExt: string): string;
|
|
164
|
-
|
|
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;
|
|
146
|
+
/** snake_case aliases */
|
|
168
147
|
export declare const get_media_map: typeof getMediaMap;
|
|
169
148
|
export declare const get_media_exts: typeof getMediaExts;
|
|
170
149
|
export declare const confirm_type: typeof confirmType;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
media_types?: Iterable<string> | string[] | null;
|
|
7
|
+
}
|
|
8
|
+
/** ---- MIME TYPES ---- */
|
|
9
|
+
export declare const MIME_TYPES: {
|
|
10
|
+
readonly image: {
|
|
11
|
+
readonly ".jpg": "image/jpeg";
|
|
12
|
+
readonly ".png": "image/png";
|
|
13
|
+
readonly ".webp": "image/webp";
|
|
14
|
+
};
|
|
15
|
+
readonly video: {
|
|
16
|
+
readonly ".mp4": "video/mp4";
|
|
17
|
+
readonly ".webm": "video/webm";
|
|
18
|
+
};
|
|
19
|
+
readonly audio: {
|
|
20
|
+
readonly ".mp3": "audio/mpeg";
|
|
21
|
+
readonly ".wav": "audio/wav";
|
|
22
|
+
};
|
|
23
|
+
readonly document: {
|
|
24
|
+
readonly ".pdf": "application/pdf";
|
|
25
|
+
readonly ".txt": "text/plain";
|
|
26
|
+
};
|
|
27
|
+
readonly code: {
|
|
28
|
+
readonly ".ts": "application/typescript";
|
|
29
|
+
readonly ".js": "application/javascript";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/** ---- Derived ---- */
|
|
33
|
+
export declare const MEDIA_TYPES: Record<MediaCategory, Set<string>>;
|
|
34
|
+
/** ---- API ---- */
|
|
35
|
+
export declare function confirmType(pathOrExt: string, categories?: Iterable<string> | string[] | null): MediaCategory | null;
|
|
36
|
+
export declare function isMediaType(pathOrExt: string, categories?: Iterable<string> | string[] | null): boolean;
|
|
37
|
+
export declare function getMimeType(pathOrExt: string): string;
|
|
@@ -3,10 +3,9 @@ export type MimeByExt = Record<string, string>;
|
|
|
3
3
|
export type MediaMap = Record<string, MimeByExt>;
|
|
4
4
|
export type MediaCategory = keyof typeof MIME_TYPES;
|
|
5
5
|
export interface MediaOptions {
|
|
6
|
-
/** Alias to mirror the Python **kwargs['media_types'] behavior */
|
|
7
6
|
media_types?: Iterable<string> | string[] | null;
|
|
8
7
|
}
|
|
9
|
-
/** ---- Data
|
|
8
|
+
/** ---- Data ---- */
|
|
10
9
|
export declare const MIME_TYPES: {
|
|
11
10
|
readonly image: {
|
|
12
11
|
readonly ".jpg": "image/jpeg";
|
|
@@ -136,35 +135,15 @@ export declare const MIME_TYPES: {
|
|
|
136
135
|
readonly ".rpm": "application/x-rpm";
|
|
137
136
|
};
|
|
138
137
|
};
|
|
139
|
-
/**
|
|
138
|
+
/** category -> Set of extensions */
|
|
140
139
|
export declare const MEDIA_TYPES: Record<MediaCategory, Set<string>>;
|
|
141
|
-
/** ---- API
|
|
142
|
-
/**
|
|
143
|
-
* Return a sub-map of MEDIA_TYPES for the given categories.
|
|
144
|
-
* If categories is falsy, returns all categories.
|
|
145
|
-
*/
|
|
140
|
+
/** ---- API ---- */
|
|
146
141
|
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
142
|
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
143
|
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
144
|
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
145
|
export declare function getMimeType(pathOrExt: string): string;
|
|
164
|
-
|
|
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;
|
|
146
|
+
/** snake_case aliases */
|
|
168
147
|
export declare const get_media_map: typeof getMediaMap;
|
|
169
148
|
export declare const get_media_exts: typeof getMediaExts;
|
|
170
149
|
export declare const confirm_type: typeof confirmType;
|