@vardum/shared 0.2.0 → 0.4.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 CHANGED
@@ -1,9 +1,32 @@
1
1
  # @vardum/shared
2
2
 
3
- Wire types and the accepted-format tables shared by the Vardum API, dashboard,
3
+ Wire types and 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.4.0**, used by CLI **0.8.0** and MCP **0.4.0**.
8
+ Check [release status and compatibility](https://github.com/f-tuma/vardum/blob/main/docs/npm-release.md)
9
+ to confirm npm availability before installing this version. The historical
10
+ server compatibility fixture continues to use shared 0.2.0.
11
+
12
+ Shared 0.4.0 adds the guarded-editor wire contract: `VardEditorDefinition`
13
+ requires the opaque `revision` and each manual item's literal nullable
14
+ `pinnedVersionId`; `VardEditorItemInput` requires an existing mapping `id` or
15
+ `null`, plus an explicit nullable `versionId`. Keep saved pins separate from
16
+ resolved delivery versions. It retains `mediaStem`, `mediaOutputPath`, format
17
+ tables. This client batch keeps CLI schema 2 snapshots; the wire manifest remains
18
+ schema 1. It does not introduce schema 3.
19
+
20
+ CLI 0.8.0 and MCP 0.4.0 retain `workspace:^` dependencies in source; their release
21
+ archives require `@vardum/shared: ^0.4.0`, which npm resolves transitively.
22
+
23
+ For a direct consumer, **this installation targets shared 0.4.0** once the
24
+ release-status page confirms it is available:
25
+
26
+ ```sh
27
+ npm install --save-exact @vardum/shared@0.4.0
28
+ ```
29
+
7
30
  ```ts
8
- import { mimeForFilename, supportedMimeTypes, type VardManifest } from "@vardum/shared";
31
+ import { mimeForFilename, supportedMimeTypes, type VardEditorDefinition } from "@vardum/shared";
9
32
  ```
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.js CHANGED
@@ -48,7 +48,9 @@ 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)
@@ -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
@@ -17,9 +17,13 @@ export type VardItem = {
17
17
  outputPath: string;
18
18
  writable: boolean;
19
19
  pinned: boolean;
20
+ /** Literal saved pin, supplied by the guarded editor even when the version is unavailable. */
21
+ pinnedVersionId?: string | null;
20
22
  transformation: Transformation | null;
21
23
  versionId: string | null;
22
24
  sourceChecksum: string | null;
25
+ /** Original selected version's type, before any output transformation. */
26
+ sourceMimeType?: string | null;
23
27
  mimeType: string | null;
24
28
  size: number | null;
25
29
  fingerprint: string | null;
@@ -42,6 +46,24 @@ export type VardFolderRule = {
42
46
  /** Editable configuration: items are manual mappings only, never expanded outputs. */
43
47
  export type VardDefinition = VardManifest & {
44
48
  folderRules: VardFolderRule[];
49
+ /** Opaque state-equivalence token supplied by guarded editor endpoints. */
50
+ revision?: string;
51
+ };
52
+ /** The dedicated editor always supplies its revision and literal pin IDs. */
53
+ export type VardEditorDefinition = VardDefinition & {
54
+ revision: string;
55
+ items: (VardItem & {
56
+ pinnedVersionId: string | null;
57
+ })[];
58
+ };
59
+ export type VardEditorItemInput = {
60
+ /** Existing manual mapping ID, or null to allocate a new mapping. */
61
+ id: string | null;
62
+ assetId: string;
63
+ versionId: string | null;
64
+ outputPath: string;
65
+ transformation: Transformation | null;
66
+ writable: boolean;
45
67
  };
46
68
  export type SyncAsset = {
47
69
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vardum/shared",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shared Vardum wire types and accepted-format tables",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
25
- "url": "git+https://github.com/frgtn-dot-dev/vardum.git",
25
+ "url": "git+https://github.com/f-tuma/vardum.git",
26
26
  "directory": "packages/shared"
27
27
  },
28
- "homepage": "https://github.com/frgtn-dot-dev/vardum/tree/main/packages/shared#readme",
28
+ "homepage": "https://github.com/f-tuma/vardum/tree/main/packages/shared#readme",
29
29
  "bugs": {
30
- "url": "https://github.com/frgtn-dot-dev/vardum/issues"
30
+ "url": "https://github.com/f-tuma/vardum/issues"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsc -p tsconfig.json",