@vardum/shared 0.1.0 → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vardum contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,6 +4,15 @@ Wire types and the accepted-format tables shared by the Vardum API, dashboard,
4
4
  CLI and MCP server. Published because `@vardum/cli` and `@vardum/mcp` depend on
5
5
  it at runtime; it carries no dependencies of its own.
6
6
 
7
+ This README describes shared **0.3.0**. It adds the exported `mediaStem` and `mediaOutputPath`
8
+ helpers used by the CLI and API for consistent media names and output suffixes.
9
+ The published client baseline uses shared **0.2.0**; see
10
+ [release compatibility](https://github.com/f-tuma/vardum/blob/main/docs/npm-release.md#compatibility)
11
+ for the corresponding CLI/MCP versions and unreleased candidates.
12
+
13
+ CLI 0.7.0 and MCP 0.3.0 retain `workspace:^` dependencies in source; the release
14
+ archives require `@vardum/shared: ^0.3.0`, which npm resolves transitively.
15
+
7
16
  ```ts
8
17
  import { mimeForFilename, supportedMimeTypes, type VardManifest } from "@vardum/shared";
9
18
  ```
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./mime.js";
2
+ export * from "./naming.js";
2
3
  export * from "./wire.js";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./mime.js";
2
+ export * from "./naming.js";
2
3
  export * from "./wire.js";
package/dist/mime.d.ts CHANGED
@@ -15,3 +15,11 @@ export declare const extensionMimeTypes: Record<string, SupportedMimeType>;
15
15
  export declare function mimeForFilename(filename: string): SupportedMimeType | null;
16
16
  /** Value for a file input's accept attribute, e.g. ".avif,.gif,…". */
17
17
  export declare const uploadAccept: string;
18
+ /** Per-kind upload ceilings in bytes, as the API reports them. */
19
+ export type UploadLimits = {
20
+ image: number;
21
+ video: number;
22
+ file: number;
23
+ };
24
+ /** Files are the future generic kind: whatever is neither image nor video. */
25
+ export declare function uploadLimitFor(limits: UploadLimits, mimeType: string): number;
package/dist/mime.js CHANGED
@@ -48,9 +48,19 @@ export const extensionMimeTypes = {
48
48
  };
49
49
  export function mimeForFilename(filename) {
50
50
  const extension = filename.toLowerCase().match(/\.([^.]+)$/)?.[1];
51
- return (extension && extensionMimeTypes[extension]) || null;
51
+ return extension && Object.hasOwn(extensionMimeTypes, extension)
52
+ ? extensionMimeTypes[extension]
53
+ : null;
52
54
  }
53
55
  /** Value for a file input's accept attribute, e.g. ".avif,.gif,…". */
54
56
  export const uploadAccept = Object.keys(extensionMimeTypes)
55
57
  .map((extension) => `.${extension}`)
56
58
  .join(",");
59
+ /** Files are the future generic kind: whatever is neither image nor video. */
60
+ export function uploadLimitFor(limits, mimeType) {
61
+ return videoMimeSet.has(mimeType)
62
+ ? limits.video
63
+ : mimeType.startsWith("image/")
64
+ ? limits.image
65
+ : limits.file;
66
+ }
@@ -0,0 +1,4 @@
1
+ /** Strip the final supported media suffix, never dots in a directory or stem. */
2
+ export declare function mediaStem(path: string): string;
3
+ /** Project files keep one suffix for their output format; library names do not. */
4
+ export declare function mediaOutputPath(path: string, mimeType: string): string;
package/dist/naming.js ADDED
@@ -0,0 +1,22 @@
1
+ import { mimeForFilename } from "./mime.js";
2
+ /** Strip the final supported media suffix, never dots in a directory or stem. */
3
+ export function mediaStem(path) {
4
+ const start = path.lastIndexOf("/") + 1;
5
+ const dot = path.lastIndexOf(".");
6
+ return dot > start && mimeForFilename(path.slice(start))
7
+ ? path.slice(0, dot)
8
+ : path;
9
+ }
10
+ const mimeExtensions = {
11
+ "image/avif": "avif", "image/gif": "gif", "image/jpeg": "jpg",
12
+ "image/png": "png", "image/svg+xml": "svg", "image/tiff": "tiff",
13
+ "image/webp": "webp", "video/mp4": "mp4", "video/webm": "webm",
14
+ "video/quicktime": "mov", "video/x-msvideo": "avi", "video/mpeg": "mpeg",
15
+ };
16
+ /** Project files keep one suffix for their output format; library names do not. */
17
+ export function mediaOutputPath(path, mimeType) {
18
+ const extension = Object.hasOwn(mimeExtensions, mimeType)
19
+ ? mimeExtensions[mimeType]
20
+ : undefined;
21
+ return extension ? `${mediaStem(path)}.${extension}` : path;
22
+ }
package/dist/wire.d.ts CHANGED
@@ -20,6 +20,8 @@ export type VardItem = {
20
20
  transformation: Transformation | null;
21
21
  versionId: string | null;
22
22
  sourceChecksum: string | null;
23
+ /** Original selected version's type, before any output transformation. */
24
+ sourceMimeType?: string | null;
23
25
  mimeType: string | null;
24
26
  size: number | null;
25
27
  fingerprint: string | null;
@@ -34,10 +36,20 @@ export type VardManifest = {
34
36
  updatedAt: string;
35
37
  items: VardItem[];
36
38
  };
39
+ /** Literal recursive inclusion of ready current originals; empty prefixes mean root. */
40
+ export type VardFolderRule = {
41
+ sourcePrefix: string;
42
+ outputPrefix: string;
43
+ };
44
+ /** Editable configuration: items are manual mappings only, never expanded outputs. */
45
+ export type VardDefinition = VardManifest & {
46
+ folderRules: VardFolderRule[];
47
+ };
37
48
  export type SyncAsset = {
38
49
  id: string;
39
50
  key: string;
40
51
  displayName: string;
52
+ isPublic: boolean;
41
53
  versionId: string;
42
54
  checksum: string | null;
43
55
  mimeType: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vardum/shared",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared Vardum wire types and accepted-format tables",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,16 +14,24 @@
14
14
  "default": "./dist/index.js"
15
15
  }
16
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
17
  "publishConfig": {
24
18
  "access": "public"
25
19
  },
26
20
  "devDependencies": {
27
21
  "typescript": "5.9.3"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/f-tuma/vardum.git",
26
+ "directory": "packages/shared"
27
+ },
28
+ "homepage": "https://github.com/f-tuma/vardum/tree/main/packages/shared#readme",
29
+ "bugs": {
30
+ "url": "https://github.com/f-tuma/vardum/issues"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.json",
34
+ "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
35
+ "typecheck": "tsc -p tsconfig.json --noEmit"
28
36
  }
29
- }
37
+ }