@vardum/shared 0.1.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/README.md +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/mime.d.ts +17 -0
- package/dist/mime.js +56 -0
- package/dist/wire.d.ts +48 -0
- package/dist/wire.js +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @vardum/shared
|
|
2
|
+
|
|
3
|
+
Wire types and the accepted-format tables shared by the Vardum API, dashboard,
|
|
4
|
+
CLI and MCP server. Published because `@vardum/cli` and `@vardum/mcp` depend on
|
|
5
|
+
it at runtime; it carries no dependencies of its own.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { mimeForFilename, supportedMimeTypes, type VardManifest } from "@vardum/shared";
|
|
9
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/mime.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place that decides which files Vardum accepts. The API validates
|
|
3
|
+
* uploads against these lists, the dashboard and the CLI pick a MIME type for
|
|
4
|
+
* a filename from them, and the accept attribute is derived from them — so a
|
|
5
|
+
* new format is added here and nowhere else.
|
|
6
|
+
*/
|
|
7
|
+
export declare const supportedImageMimeTypes: readonly ["image/avif", "image/gif", "image/jpeg", "image/png", "image/svg+xml", "image/tiff", "image/webp"];
|
|
8
|
+
export declare const supportedVideoMimeTypes: readonly ["video/mp4", "video/webm", "video/quicktime", "video/x-msvideo", "video/mpeg"];
|
|
9
|
+
export declare const supportedMimeTypes: readonly ["image/avif", "image/gif", "image/jpeg", "image/png", "image/svg+xml", "image/tiff", "image/webp", "video/mp4", "video/webm", "video/quicktime", "video/x-msvideo", "video/mpeg"];
|
|
10
|
+
export type SupportedMimeType = (typeof supportedMimeTypes)[number];
|
|
11
|
+
export declare const videoMimeSet: Set<string>;
|
|
12
|
+
export declare function isVideoMimeType(mimeType: string | null | undefined): boolean;
|
|
13
|
+
/** Extensions are the reliable signal: File.type is empty or non-canonical often enough. */
|
|
14
|
+
export declare const extensionMimeTypes: Record<string, SupportedMimeType>;
|
|
15
|
+
export declare function mimeForFilename(filename: string): SupportedMimeType | null;
|
|
16
|
+
/** Value for a file input's accept attribute, e.g. ".avif,.gif,…". */
|
|
17
|
+
export declare const uploadAccept: string;
|
package/dist/mime.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place that decides which files Vardum accepts. The API validates
|
|
3
|
+
* uploads against these lists, the dashboard and the CLI pick a MIME type for
|
|
4
|
+
* a filename from them, and the accept attribute is derived from them — so a
|
|
5
|
+
* new format is added here and nowhere else.
|
|
6
|
+
*/
|
|
7
|
+
export const supportedImageMimeTypes = [
|
|
8
|
+
"image/avif",
|
|
9
|
+
"image/gif",
|
|
10
|
+
"image/jpeg",
|
|
11
|
+
"image/png",
|
|
12
|
+
"image/svg+xml",
|
|
13
|
+
"image/tiff",
|
|
14
|
+
"image/webp",
|
|
15
|
+
];
|
|
16
|
+
export const supportedVideoMimeTypes = [
|
|
17
|
+
"video/mp4",
|
|
18
|
+
"video/webm",
|
|
19
|
+
"video/quicktime",
|
|
20
|
+
"video/x-msvideo",
|
|
21
|
+
"video/mpeg",
|
|
22
|
+
];
|
|
23
|
+
export const supportedMimeTypes = [
|
|
24
|
+
...supportedImageMimeTypes,
|
|
25
|
+
...supportedVideoMimeTypes,
|
|
26
|
+
];
|
|
27
|
+
export const videoMimeSet = new Set(supportedVideoMimeTypes);
|
|
28
|
+
export function isVideoMimeType(mimeType) {
|
|
29
|
+
return Boolean(mimeType && videoMimeSet.has(mimeType));
|
|
30
|
+
}
|
|
31
|
+
/** Extensions are the reliable signal: File.type is empty or non-canonical often enough. */
|
|
32
|
+
export const extensionMimeTypes = {
|
|
33
|
+
avif: "image/avif",
|
|
34
|
+
gif: "image/gif",
|
|
35
|
+
jpeg: "image/jpeg",
|
|
36
|
+
jpg: "image/jpeg",
|
|
37
|
+
png: "image/png",
|
|
38
|
+
svg: "image/svg+xml",
|
|
39
|
+
tif: "image/tiff",
|
|
40
|
+
tiff: "image/tiff",
|
|
41
|
+
webp: "image/webp",
|
|
42
|
+
avi: "video/x-msvideo",
|
|
43
|
+
mov: "video/quicktime",
|
|
44
|
+
mp4: "video/mp4",
|
|
45
|
+
mpeg: "video/mpeg",
|
|
46
|
+
mpg: "video/mpeg",
|
|
47
|
+
webm: "video/webm",
|
|
48
|
+
};
|
|
49
|
+
export function mimeForFilename(filename) {
|
|
50
|
+
const extension = filename.toLowerCase().match(/\.([^.]+)$/)?.[1];
|
|
51
|
+
return (extension && extensionMimeTypes[extension]) || null;
|
|
52
|
+
}
|
|
53
|
+
/** Value for a file input's accept attribute, e.g. ".avif,.gif,…". */
|
|
54
|
+
export const uploadAccept = Object.keys(extensionMimeTypes)
|
|
55
|
+
.map((extension) => `.${extension}`)
|
|
56
|
+
.join(",");
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shapes the API sends over the wire, shared by every client (dashboard, CLI,
|
|
3
|
+
* MCP). The API validates its own input with zod; these describe the JSON that
|
|
4
|
+
* comes back, after serialization — dates are strings here.
|
|
5
|
+
*/
|
|
6
|
+
export type Transformation = {
|
|
7
|
+
w?: number;
|
|
8
|
+
h?: number;
|
|
9
|
+
fit?: "cover" | "contain" | "fill" | "inside" | "outside";
|
|
10
|
+
format?: "avif" | "jpeg" | "png" | "webp";
|
|
11
|
+
q?: number;
|
|
12
|
+
};
|
|
13
|
+
export type VardItem = {
|
|
14
|
+
id: string;
|
|
15
|
+
assetId: string;
|
|
16
|
+
key: string;
|
|
17
|
+
outputPath: string;
|
|
18
|
+
writable: boolean;
|
|
19
|
+
pinned: boolean;
|
|
20
|
+
transformation: Transformation | null;
|
|
21
|
+
versionId: string | null;
|
|
22
|
+
sourceChecksum: string | null;
|
|
23
|
+
mimeType: string | null;
|
|
24
|
+
size: number | null;
|
|
25
|
+
fingerprint: string | null;
|
|
26
|
+
downloadUrl: string | null;
|
|
27
|
+
};
|
|
28
|
+
export type VardManifest = {
|
|
29
|
+
schema: 1;
|
|
30
|
+
id: string;
|
|
31
|
+
workspaceId: string;
|
|
32
|
+
name: string;
|
|
33
|
+
isPublic: boolean;
|
|
34
|
+
updatedAt: string;
|
|
35
|
+
items: VardItem[];
|
|
36
|
+
};
|
|
37
|
+
export type SyncAsset = {
|
|
38
|
+
id: string;
|
|
39
|
+
key: string;
|
|
40
|
+
displayName: string;
|
|
41
|
+
versionId: string;
|
|
42
|
+
checksum: string | null;
|
|
43
|
+
mimeType: string;
|
|
44
|
+
size: number;
|
|
45
|
+
width: number | null;
|
|
46
|
+
height: number | null;
|
|
47
|
+
updatedAt: string;
|
|
48
|
+
};
|
package/dist/wire.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vardum/shared",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared Vardum wire types and accepted-format tables",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
|
|
20
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
21
|
+
"prepublishOnly": "pnpm build"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "5.9.3"
|
|
28
|
+
}
|
|
29
|
+
}
|