@galaxy-tool-util/tool-cache-proxy 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 ADDED
@@ -0,0 +1,19 @@
1
+ # @galaxy-tool-util/tool-cache-proxy
2
+
3
+ Galaxy tool proxy server -- caches and serves tool schemas.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @galaxy-tool-util/tool-cache-proxy
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ galaxy-tool-proxy --help
15
+ ```
16
+
17
+ ## License
18
+
19
+ MIT
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=galaxy-tool-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"galaxy-tool-proxy.d.ts","sourceRoot":"","sources":["../../src/bin/galaxy-tool-proxy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync } from "node:fs";
3
+ import { loadConfig, defaultConfig } from "../config.js";
4
+ import { createProxyContext, createProxyServer } from "../router.js";
5
+ const args = process.argv.slice(2);
6
+ let configPath = null;
7
+ let port = null;
8
+ for (let i = 0; i < args.length; i++) {
9
+ if (args[i] === "--config" && args[i + 1]) {
10
+ configPath = args[++i];
11
+ }
12
+ else if (args[i] === "--port" && args[i + 1]) {
13
+ port = parseInt(args[++i], 10);
14
+ }
15
+ }
16
+ async function main() {
17
+ let config = configPath && existsSync(configPath) ? await loadConfig(configPath) : defaultConfig();
18
+ if (port !== null) {
19
+ config = { ...config, port };
20
+ }
21
+ const ctx = createProxyContext(config);
22
+ const server = createProxyServer(ctx);
23
+ server.listen(config.port, config.host, () => {
24
+ console.log(`galaxy-tool-proxy listening on ${config.host}:${config.port}`);
25
+ });
26
+ }
27
+ main().catch((err) => {
28
+ console.error("Failed to start server:", err);
29
+ process.exit(1);
30
+ });
31
+ //# sourceMappingURL=galax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G,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAEtC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QAC3C,OAAO,CAAC,GAAG,CAAC,kCAAkC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import * as S from "effect/Schema";
2
+ /** Schema for a tool source entry in the server config. */
3
+ export declare const ToolSource: S.Struct<{
4
+ type: S.Union<[S.Literal<["toolshed"]>, S.Literal<["galaxy"]>]>;
5
+ url: typeof S.String;
6
+ enabled: S.optionalWith<typeof S.Boolean, {
7
+ default: () => true;
8
+ }>;
9
+ }>;
10
+ export type ToolSource = S.Schema.Type<typeof ToolSource>;
11
+ export declare const CacheConfig: S.Struct<{
12
+ directory: S.optional<typeof S.String>;
13
+ }>;
14
+ /** Effect Schema for the proxy server YAML configuration file. */
15
+ export declare const ServerConfig: S.Struct<{
16
+ "galaxy.workflows.toolSources": S.optionalWith<S.Array$<S.Struct<{
17
+ type: S.Union<[S.Literal<["toolshed"]>, S.Literal<["galaxy"]>]>;
18
+ url: typeof S.String;
19
+ enabled: S.optionalWith<typeof S.Boolean, {
20
+ default: () => true;
21
+ }>;
22
+ }>>, {
23
+ default: () => never[];
24
+ }>;
25
+ "galaxy.workflows.toolCache": S.optionalWith<S.Struct<{
26
+ directory: S.optional<typeof S.String>;
27
+ }>, {
28
+ default: () => S.Schema.Type<typeof CacheConfig>;
29
+ }>;
30
+ port: S.optionalWith<typeof S.Number, {
31
+ default: () => number;
32
+ }>;
33
+ host: S.optionalWith<typeof S.String, {
34
+ default: () => string;
35
+ }>;
36
+ }>;
37
+ export type ServerConfig = S.Schema.Type<typeof ServerConfig>;
38
+ /** Load and validate a YAML config file against the {@link ServerConfig} schema. */
39
+ export declare function loadConfig(configPath: string): Promise<ServerConfig>;
40
+ /** Create a default server config (empty sources, port 8080, localhost). */
41
+ export declare function defaultConfig(): ServerConfig;
42
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAInC,2DAA2D;AAC3D,eAAO,MAAM,UAAU;;;;;;EAIrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE1D,eAAO,MAAM,WAAW;;EAEtB,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,YAAY;;;;;;;;;;;;;uBAKE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC;;;;;;;;EAI1D,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;AAE9D,oFAAoF;AACpF,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAI1E;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,IAAI,YAAY,CAE5C"}
package/dist/config.js ADDED
@@ -0,0 +1,34 @@
1
+ import * as S from "effect/Schema";
2
+ import { readFile } from "node:fs/promises";
3
+ import YAML from "yaml";
4
+ /** Schema for a tool source entry in the server config. */
5
+ export const ToolSource = S.Struct({
6
+ type: S.Union(S.Literal("toolshed"), S.Literal("galaxy")),
7
+ url: S.String,
8
+ enabled: S.optionalWith(S.Boolean, { default: () => true }),
9
+ });
10
+ export const CacheConfig = S.Struct({
11
+ directory: S.optional(S.String),
12
+ });
13
+ /** Effect Schema for the proxy server YAML configuration file. */
14
+ export const ServerConfig = S.Struct({
15
+ "galaxy.workflows.toolSources": S.optionalWith(S.Array(ToolSource), {
16
+ default: () => [],
17
+ }),
18
+ "galaxy.workflows.toolCache": S.optionalWith(CacheConfig, {
19
+ default: () => ({}),
20
+ }),
21
+ port: S.optionalWith(S.Number, { default: () => 8080 }),
22
+ host: S.optionalWith(S.String, { default: () => "127.0.0.1" }),
23
+ });
24
+ /** Load and validate a YAML config file against the {@link ServerConfig} schema. */
25
+ export async function loadConfig(configPath) {
26
+ const raw = await readFile(configPath, "utf-8");
27
+ const parsed = YAML.parse(raw);
28
+ return S.decodeUnknownSync(ServerConfig)(parsed);
29
+ }
30
+ /** Create a default server config (empty sources, port 8080, localhost). */
31
+ export function defaultConfig() {
32
+ return S.decodeUnknownSync(ServerConfig)({});
33
+ }
34
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzD,GAAG,EAAE,CAAC,CAAC,MAAM;IACb,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,C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ool-util/tool-cache-proxy
3
+ *
4
+ * HTTP proxy server mirroring a subset of the ToolShed API.
5
+ * Caches and serves tool schemas with CORS support.
6
+ */
7
+ /** Load a YAML config file and validate it against the ServerConfig schema. */
8
+ export { loadConfig, defaultConfig, ServerConfig, ToolSource } from "./config.js";
9
+ /** Create a proxy context (ToolInfoService + config) and HTTP server. */
10
+ export { createProxyContext, createProxyServer, createRequestHandler } from "./router.js";
11
+ export type { ProxyContext } from "./router.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+EAA+E;AAC/E,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClF,yEAAyE;AACzE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1F,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module @galaxy-tool-util/tool-cache-proxy
3
+ *
4
+ * HTTP proxy server mirroring a subset of the ToolShed API.
5
+ * Caches and serves tool schemas with CORS support.
6
+ */
7
+ /** Load a YAML config file and validate it against the ServerConfig schema. */
8
+ export { loadConfig, defaultConfig, ServerConfig, ToolSource } from "./config.js";
9
+ /** Create a proxy context (ToolInfoService + config) and HTTP server. */
10
+ export { createProxyContext, createProxyServer, createRequestHandler } from "./router.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+EAA+E;AAC/E,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClF,yEAAyE;AACzE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type IncomingMessage, type ServerResponse } from "node:http";
2
+ import { ToolInfoService } from "@galaxy-tool-util/core";
3
+ import type { ServerConfig } from "./config.js";
4
+ /** Shared context for the proxy server — holds config and the ToolInfoService. */
5
+ export interface ProxyContext {
6
+ config: ServerConfig;
7
+ service: ToolInfoService;
8
+ }
9
+ /** Build a ProxyContext from config — initializes ToolInfoService with configured sources. */
10
+ export declare function createProxyContext(config: ServerConfig): ProxyContext;
11
+ /** Create the async request handler that routes to tool cache/schema endpoints. */
12
+ export declare function createRequestHandler(ctx: ProxyContext): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
13
+ /** Create an HTTP server wired to the proxy request handler. */
14
+ export declare function createProxyServer(ctx: ProxyContext): import("node:http").Server<typeof IncomingMessage, typeof ServerResponse>;
15
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,eAAe,EAAqC,MAAM,wBAAwB,CAAC;AAQ5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAYrE;AAqED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,IACtC,KAAK,eAAe,EAAE,KAAK,cAAc,KAAG,OAAO,CAAC,IAAI,CAAC,CAgGxE;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,6EAKlD"}
package/dist/router.js ADDED
@@ -0,0 +1,170 @@
1
+ import { createServer } from "node:http";
2
+ import { ToolInfoService } from "@galaxy-tool-util/core";
3
+ import { createFieldModel, STATE_REPRESENTATIONS, } from "@galaxy-tool-util/schema";
4
+ import * as JSONSchema from "effect/JSONSchema";
5
+ /** Build a ProxyContext from config — initializes ToolInfoService with configured sources. */
6
+ export function createProxyContext(config) {
7
+ const enabledSources = config["galaxy.workflows.toolSources"].filter((s) => s.enabled);
8
+ const coreSources = enabledSources.map((s) => ({
9
+ type: s.type,
10
+ url: s.url,
11
+ }));
12
+ const service = new ToolInfoService({
13
+ cacheDir: config["galaxy.workflows.toolCache"]?.directory,
14
+ sources: coreSources,
15
+ });
16
+ return { config, service };
17
+ }
18
+ function matchRoute(method, url) {
19
+ const path = url.split("?")[0];
20
+ if (method === "GET" && path === "/api/tools") {
21
+ return { handler: "listTools", params: {} };
22
+ }
23
+ // /api/tools/:trs_id/versions/:version/schema
24
+ const schemaMatch = path.match(/^\/api\/tools\/([^/]+)\/versions\/([^/]+)\/schema$/);
25
+ if (method === "GET" && schemaMatch) {
26
+ return {
27
+ handler: "toolSchema",
28
+ params: {
29
+ trsId: decodeURIComponent(schemaMatch[1]),
30
+ version: decodeURIComponent(schemaMatch[2]),
31
+ schema: true,
32
+ },
33
+ };
34
+ }
35
+ // /api/tools/:trs_id/versions/:version
36
+ const versionMatch = path.match(/^\/api\/tools\/([^/]+)\/versions\/([^/]+)$/);
37
+ if (method === "GET" && versionMatch) {
38
+ return {
39
+ handler: "getTool",
40
+ params: {
41
+ trsId: decodeURIComponent(versionMatch[1]),
42
+ version: decodeURIComponent(versionMatch[2]),
43
+ },
44
+ };
45
+ }
46
+ if (method === "DELETE" && path === "/api/tools/cache") {
47
+ return { handler: "clearCache", params: {} };
48
+ }
49
+ return null;
50
+ }
51
+ function queryParam(url, key) {
52
+ const idx = url.indexOf("?");
53
+ if (idx === -1)
54
+ return undefined;
55
+ const params = new URLSearchParams(url.slice(idx));
56
+ return params.get(key) ?? undefined;
57
+ }
58
+ function json(res, status, body) {
59
+ const payload = JSON.stringify(body);
60
+ res.writeHead(status, {
61
+ "Content-Type": "application/json",
62
+ "Content-Length": Buffer.byteLength(payload),
63
+ });
64
+ res.end(payload);
65
+ }
66
+ function cors(res) {
67
+ res.setHeader("Access-Control-Allow-Origin", "*");
68
+ res.setHeader("Access-Control-Allow-Methods", "GET, DELETE, OPTIONS");
69
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
70
+ }
71
+ /** Create the async request handler that routes to tool cache/schema endpoints. */
72
+ export function createRequestHandler(ctx) {
73
+ return async (req, res) => {
74
+ cors(res);
75
+ if (req.method === "OPTIONS") {
76
+ res.writeHead(204);
77
+ res.end();
78
+ return;
79
+ }
80
+ const url = req.url ?? "/";
81
+ const method = req.method ?? "GET";
82
+ const route = matchRoute(method, url);
83
+ if (!route) {
84
+ json(res, 404, { error: "Not found" });
85
+ return;
86
+ }
87
+ try {
88
+ switch (route.handler) {
89
+ case "listTools": {
90
+ await ctx.service.cache.index.load();
91
+ const entries = ctx.service.cache.listCached();
92
+ json(res, 200, entries);
93
+ break;
94
+ }
95
+ case "getTool": {
96
+ const { trsId, version } = route.params;
97
+ if (!trsId || !version) {
98
+ json(res, 400, { error: "Missing trs_id or version" });
99
+ return;
100
+ }
101
+ const tool = await ctx.service.getToolInfo(trsId, version);
102
+ if (!tool) {
103
+ json(res, 404, { error: "Tool not found" });
104
+ return;
105
+ }
106
+ json(res, 200, tool);
107
+ break;
108
+ }
109
+ case "toolSchema": {
110
+ const { trsId, version } = route.params;
111
+ if (!trsId || !version) {
112
+ json(res, 400, { error: "Missing trs_id or version" });
113
+ return;
114
+ }
115
+ const repName = queryParam(url, "representation") ?? "workflow_step";
116
+ if (!STATE_REPRESENTATIONS.includes(repName)) {
117
+ json(res, 400, {
118
+ error: `Unknown representation: ${repName}`,
119
+ available: [...STATE_REPRESENTATIONS],
120
+ });
121
+ return;
122
+ }
123
+ const tool = await ctx.service.getToolInfo(trsId, version);
124
+ if (!tool) {
125
+ json(res, 404, { error: "Tool not found" });
126
+ return;
127
+ }
128
+ const bundle = {
129
+ parameters: tool.inputs,
130
+ };
131
+ const effectSchema = createFieldModel(bundle, repName);
132
+ if (!effectSchema) {
133
+ json(res, 500, {
134
+ error: "Could not generate schema — unsupported parameter types",
135
+ });
136
+ return;
137
+ }
138
+ try {
139
+ const jsonSchema = JSONSchema.make(effectSchema);
140
+ json(res, 200, jsonSchema);
141
+ }
142
+ catch (e) {
143
+ const msg = e instanceof Error ? e.message : String(e);
144
+ json(res, 500, { error: `JSON Schema generation failed: ${msg}` });
145
+ }
146
+ break;
147
+ }
148
+ case "clearCache": {
149
+ await ctx.service.cache.index.load();
150
+ const prefix = queryParam(url, "prefix");
151
+ await ctx.service.cache.clearCache(prefix ?? undefined);
152
+ json(res, 200, { status: "cleared" });
153
+ break;
154
+ }
155
+ }
156
+ }
157
+ catch (e) {
158
+ const msg = e instanceof Error ? e.message : String(e);
159
+ json(res, 500, { error: msg });
160
+ }
161
+ };
162
+ }
163
+ /** Create an HTTP server wired to the proxy request handler. */
164
+ export function createProxyServer(ctx) {
165
+ const handler = createRequestHandler(ctx);
166
+ return createServer((req, res) => {
167
+ void handler(req, res);
168
+ });
169
+ }
170
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,eAAe,EAAqC,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EACL,gBAAgB,EAChB,qBAAqB,GAGtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAShD,8FAA8F;AAC9F,MAAM,UAAU,kBAAkB,CAAC,MAAoB;IACrD,MAAM,cAAc,GAAG,MAAM,CAAC,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,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,iBAAiB,CAAC,GAAiB;IACjD,MAAM,OAAO,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/B,KAAK,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@galaxy-tool-util/tool-cache-proxy",
3
+ "version": "0.1.0",
4
+ "description": "Galaxy tool cache proxy server — caches and serves tool schemas over HTTP",
5
+ "type": "module",
6
+ "bin": {
7
+ "galaxy-tool-proxy": "dist/bin/galaxy-tool-proxy.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md", "LICENSE"],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/jmchilton/galaxy-tool-util-ts",
19
+ "directory": "packages/tool-cache-proxy"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "provenance": true
24
+ },
25
+ "scripts": {
26
+ "build": "tsc",
27
+ "typecheck": "tsc --noEmit",
28
+ "test": "tsc --noEmit && vitest run",
29
+ "test:watch": "vitest",
30
+ "lint": "eslint src/ test/",
31
+ "format": "prettier --check 'src/**/*.ts' 'test/**/*.ts'",
32
+ "format-fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'"
33
+ },
34
+ "license": "MIT",
35
+ "dependencies": {
36
+ "@galaxy-tool-util/core": "workspace:*",
37
+ "@galaxy-tool-util/schema": "workspace:*",
38
+ "effect": "^3.21.0",
39
+ "yaml": "^2.8.3"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^25.5.0"
43
+ }
44
+ }