@galaxy-tool-util/tool-xml 1.11.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.
@@ -0,0 +1,165 @@
1
+ import { parseDiscoverDatasets } from "@galaxy-tool-util/schema";
2
+ import { stringAsBool, xmlText, xmlTextOrNull } from "./element.js";
3
+ /**
4
+ * Port of ``XmlToolSource.parse_outputs`` + ``output_objects.from_tool_source``
5
+ * — turns an expanded ``<outputs>`` tree into the `ToolOutput` union from
6
+ * `@galaxy-tool-util/schema`. The `discover_datasets` translation reuses that
7
+ * package's shared descriptor parser (Galaxy shares `dataset_collection_description`
8
+ * across the XML and YAML paths too).
9
+ *
10
+ * Raw extraction: the collection-structure invariants Python's
11
+ * `ToolOutputCollectionStructure.__init__` raises on (e.g. both `type` and
12
+ * `type_source`) are not enforced here; those land with `ParsedTool` assembly.
13
+ */
14
+ export function parseOutputs(root, profile) {
15
+ const outElem = root.findChild("outputs");
16
+ if (outElem === null)
17
+ return [];
18
+ // ``legacy_defaults = Version(parse_profile()) == Version("16.01")``.
19
+ const legacy = profile === "16.01";
20
+ const dataDict = new Map();
21
+ const collections = new Map();
22
+ const expressionDict = new Map();
23
+ // Pass 1 mirrors Python's initial ``for _ in out_elem.findall("data")``.
24
+ for (const dataEl of outElem.findChildren("data")) {
25
+ const out = parseOutputData(dataEl, legacy, profile);
26
+ dataDict.set(out.name, out);
27
+ }
28
+ // Main pass over direct children in document order.
29
+ for (const child of outElem.children) {
30
+ if (child.tag === "data") {
31
+ const out = parseOutputData(child, legacy, profile);
32
+ dataDict.set(out.name, out);
33
+ }
34
+ else if (child.tag === "collection") {
35
+ const coll = parseOutputCollection(child);
36
+ collections.set(coll.name, coll);
37
+ }
38
+ else if (child.tag === "output") {
39
+ const outputType = child.attrs.get("type");
40
+ if (outputType === "data") {
41
+ const out = parseOutputData(child, legacy, profile);
42
+ dataDict.set(out.name, out);
43
+ }
44
+ else if (outputType === "collection") {
45
+ // Python remaps collection_type/collection_type_source onto type/type_source.
46
+ // Note: this form is effectively unusable upstream — Python assigns
47
+ // `unicodify(None)` into an ElementTree attribute and raises TypeError
48
+ // when either is absent (and ValueError when both are set). We handle it
49
+ // gracefully instead of reproducing that breakage.
50
+ const coll = parseOutputCollection(child, {
51
+ collectionType: child.attrs.get("collection_type") ?? null,
52
+ collectionTypeSource: child.attrs.get("collection_type_source") ?? null,
53
+ });
54
+ collections.set(coll.name, coll);
55
+ }
56
+ else {
57
+ const expr = parseExpressionOutput(child);
58
+ expressionDict.set(expr.name, expr);
59
+ }
60
+ }
61
+ // Unknown tags are skipped (Python logs a warning).
62
+ }
63
+ // Final order: collections (document order), then data, then expression —
64
+ // Python builds `outputs` with collections during the loop, then
65
+ // `chain(data_dict.values(), expression_dict.values())`.
66
+ const outputs = new Map(collections);
67
+ for (const out of dataDict.values())
68
+ outputs.set(out.name, out);
69
+ for (const out of expressionDict.values())
70
+ outputs.set(out.name, out);
71
+ return [...outputs.values()];
72
+ }
73
+ function parseOutputData(el, legacy, profile) {
74
+ let format = el.attrs.get("format") ?? "data";
75
+ const autoFormat = stringAsBool(el.attrs.get("auto_format"));
76
+ if (autoFormat && format !== "data") {
77
+ throw new Error("Setting format and auto_format is not supported at this time.");
78
+ }
79
+ if (autoFormat)
80
+ format = "_sniff_";
81
+ let fromWorkDir = el.attrs.get("from_work_dir") ?? null;
82
+ // Pre-21.09 tools quoted from_work_dir without stripping; keep them working.
83
+ if (fromWorkDir && profileLt(profile, "21.09"))
84
+ fromWorkDir = fromWorkDir.trim();
85
+ return {
86
+ name: el.attrs.get("name") ?? "",
87
+ label: xmlTextOrNull(el, "label"),
88
+ hidden: stringAsBool(el.attrs.get("hidden")),
89
+ type: "data",
90
+ format,
91
+ format_source: el.attrs.get("format_source") ?? null,
92
+ metadata_source: el.attrs.get("metadata_source") ?? null,
93
+ discover_datasets: parseDataDiscover(el, legacy),
94
+ from_work_dir: fromWorkDir,
95
+ precreate_directory: stringAsBool(el.attrs.get("precreate_directory")),
96
+ };
97
+ }
98
+ function parseOutputCollection(el, override) {
99
+ const structure = {
100
+ collection_type: override ? override.collectionType : (el.attrs.get("type") ?? null),
101
+ collection_type_source: override
102
+ ? override.collectionTypeSource
103
+ : (el.attrs.get("type_source") ?? null),
104
+ collection_type_from_rules: el.attrs.get("type_from_rules") ?? null,
105
+ structured_like: el.attrs.get("structured_like") ?? null,
106
+ // <collection> discover_datasets are always parsed non-legacy.
107
+ discover_datasets: parseDataDiscover(el, false),
108
+ };
109
+ return {
110
+ name: el.attrs.get("name") ?? "",
111
+ // _parse_collection uses xml_text (default ""), unlike data's None default.
112
+ label: xmlText(el, "label"),
113
+ // Python's _parse_collection never reads a hidden attribute on collections.
114
+ hidden: false,
115
+ type: "collection",
116
+ ...structure,
117
+ };
118
+ }
119
+ const EXPRESSION_TYPES = new Set(["integer", "float", "boolean", "text"]);
120
+ function parseExpressionOutput(el) {
121
+ const type = el.attrs.get("type");
122
+ if (type === undefined || !EXPRESSION_TYPES.has(type)) {
123
+ throw new Error(`Unknown output type encountered [${type ?? ""}]`);
124
+ }
125
+ return {
126
+ name: el.attrs.get("name") ?? "",
127
+ label: xmlTextOrNull(el, "label"),
128
+ hidden: stringAsBool(el.attrs.get("hidden")),
129
+ type,
130
+ };
131
+ }
132
+ /**
133
+ * Port of ``dataset_collector_descriptions_from_elem`` — collect the
134
+ * ``<discover_datasets>`` blocks (inheriting the element's ``format`` attribute
135
+ * when a block sets neither ``format`` nor ``ext``), or the single default
136
+ * collector when there are none and the tool is legacy (profile 16.01).
137
+ */
138
+ function parseDataDiscover(el, legacy) {
139
+ const blocks = el.findChildren("discover_datasets");
140
+ if (blocks.length === 0 && legacy) {
141
+ return parseDiscoverDatasets([{}]) ?? [];
142
+ }
143
+ const defaultFormat = el.attrs.get("format");
144
+ const dicts = blocks.map((block) => {
145
+ const attrs = Object.fromEntries(block.attrs);
146
+ if (defaultFormat && !("format" in attrs) && !("ext" in attrs)) {
147
+ attrs.format = defaultFormat;
148
+ }
149
+ return attrs;
150
+ });
151
+ return parseDiscoverDatasets(dicts) ?? [];
152
+ }
153
+ /** ``Version(a) < Version(b)`` for dotted numeric tool profile strings. */
154
+ function profileLt(a, b) {
155
+ const pa = a.split(".").map(Number);
156
+ const pb = b.split(".").map(Number);
157
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
158
+ const x = pa[i] ?? 0;
159
+ const y = pb[i] ?? 0;
160
+ if (x !== y)
161
+ return x < y;
162
+ }
163
+ return false;
164
+ }
165
+ //# sourceMappingURL=outputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputs.js","sourceRoot":"","sources":["../src/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AASjE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGpE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,IAAgB,EAAE,OAAe;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAChC,sEAAsE;IACtE,MAAM,MAAM,GAAG,OAAO,KAAK,OAAO,CAAC;IAEnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAC;IACtD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IAClD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAsB,CAAC;IAErD,yEAAyE;IACzE,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACrD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,oDAAo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,17 @@
1
+ import type { ParsedTool as ParsedToolType } from "@galaxy-tool-util/schema";
2
+ import type { ImportResolver } from "./macros.js";
3
+ import type { XmlToolSource } from "./tool-source.js";
4
+ export declare function parsedToolFromSource(src: XmlToolSource): ParsedToolType;
5
+ /** Parse XML tool text into a validated {@link ParsedToolType} (macros expanded via `importResolver`). */
6
+ export declare function parseXmlTool(text: string, importResolver: ImportResolver): ParsedToolType;
7
+ /** Load an XML tool file from disk and parse it into a validated {@link ParsedToolType}. */
8
+ export declare function loadXmlTool(path: string): ParsedToolType;
9
+ /**
10
+ * Load a tool file from disk and parse it into a validated {@link ParsedToolType},
11
+ * dispatching on extension like Galaxy's ``get_tool_source``: ``.yml`` is a YAML
12
+ * tool source, everything else is XML. CWL (``.cwl``/``.json``) is not supported.
13
+ */
14
+ export declare function loadToolFile(path: string): ParsedToolType;
15
+ /** Load a YAML tool file from disk and parse it into a validated {@link ParsedToolType}. */
16
+ export declare function loadYamlTool(path: string): ParsedToolType;
17
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYtD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAgBvE;AAED,0GAA0G;AAC1G,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,cAAc,CAEzF;AAED,4FAA4F;AAC5F,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAExD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAQzD;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAUzD"}
package/dist/parse.js ADDED
@@ -0,0 +1,66 @@
1
+ import { readFileSync } from "node:fs";
2
+ import * as S from "effect/Schema";
3
+ import * as yaml from "yaml";
4
+ import { ParsedTool, parseYamlTool } from "@galaxy-tool-util/schema";
5
+ import { loadXmlToolSource, xmlToolSourceFromString } from "./tool-source.js";
6
+ /**
7
+ * Public XML tool-parsing entry — the TS mirror of Python's
8
+ * ``parse_tool(get_tool_source(path))``. Assembles the `ParsedTool` fields off
9
+ * an {@link XmlToolSource} and decodes them through the `ParsedTool` schema, so
10
+ * a non-tool root (`<toolbox>`, …) is rejected here exactly as Python's pydantic
11
+ * model rejects it (a missing `id`/`name` is not a valid `ParsedTool`).
12
+ */
13
+ const decodeParsedTool = S.decodeUnknownSync(ParsedTool);
14
+ export function parsedToolFromSource(src) {
15
+ return decodeParsedTool({
16
+ id: src.parseId(),
17
+ version: src.parseVersion(),
18
+ name: src.parseName(),
19
+ description: src.parseDescription() || null,
20
+ profile: src.parseProfile(),
21
+ license: src.parseLicense(),
22
+ edam_operations: src.parseEdamOperations(),
23
+ edam_topics: src.parseEdamTopics(),
24
+ xrefs: src.parseXrefs(),
25
+ citations: src.parseCitations(),
26
+ help: src.parseHelp(),
27
+ inputs: src.parseInputs(),
28
+ outputs: src.parseOutputs(),
29
+ });
30
+ }
31
+ /** Parse XML tool text into a validated {@link ParsedToolType} (macros expanded via `importResolver`). */
32
+ export function parseXmlTool(text, importResolver) {
33
+ return parsedToolFromSource(xmlToolSourceFromString(text, importResolver));
34
+ }
35
+ /** Load an XML tool file from disk and parse it into a validated {@link ParsedToolType}. */
36
+ export function loadXmlTool(path) {
37
+ return parsedToolFromSource(loadXmlToolSource(path));
38
+ }
39
+ /**
40
+ * Load a tool file from disk and parse it into a validated {@link ParsedToolType},
41
+ * dispatching on extension like Galaxy's ``get_tool_source``: ``.yml`` is a YAML
42
+ * tool source, everything else is XML. CWL (``.cwl``/``.json``) is not supported.
43
+ */
44
+ export function loadToolFile(path) {
45
+ if (path.endsWith(".cwl") || path.endsWith(".json")) {
46
+ throw new Error(`CWL tools are not supported: ${path}`);
47
+ }
48
+ if (path.endsWith(".yml")) {
49
+ return loadYamlTool(path);
50
+ }
51
+ return loadXmlTool(path);
52
+ }
53
+ /** Load a YAML tool file from disk and parse it into a validated {@link ParsedToolType}. */
54
+ export function loadYamlTool(path) {
55
+ const text = readFileSync(path, "utf-8");
56
+ const repr = yaml.parse(text);
57
+ // PyYAML renders a float version (`1.0`) as "1.0"; JS yaml collapses it to the
58
+ // number 1, so `String(version)` would yield "1". Recover the written token.
59
+ if (repr && typeof repr === "object" && typeof repr.version === "number") {
60
+ const node = yaml.parseDocument(text).get("version", true);
61
+ if (node && typeof node.source === "string")
62
+ repr.version = node.source;
63
+ }
64
+ return parseYamlTool(repr);
65
+ }
66
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAEzD,MAAM,UAAU,oBAAoB,CAAC,GAAkB;IACrD,OAAO,gBAAgB,CAAC;QACtB,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE;QACjB,OAAO,EAAE,GAAG,CAAC,YAAY,EAAE;QAC3B,IAAI,EAAE,GAAG,CAAC,SAAS,EAAE;QAC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Y,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;IACzD,+EAA+E;IAC/E,6EAA6E;IAC7E,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzE,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAqC,CAAC;QAC/F,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ;YAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1E,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { Citation, HelpContent, ToolOutput, ToolParameterModel, XrefDict } from "@galaxy-tool-util/schema";
2
+ import type { XmlElement } from "./element.js";
3
+ import { type ImportResolver } from "./macros.js";
4
+ /**
5
+ * Port of the metadata-reading half of ``galaxy.tool_util.parser.xml.XmlToolSource``.
6
+ *
7
+ * Wraps an already-macro-expanded {@link XmlElement} tool tree and exposes the
8
+ * ``parse_*`` accessors that don't depend on the input-parameter tree (that
9
+ * lives behind the ``InputSource`` seam and is added later). Extraction is raw
10
+ * and does not yet apply the model-level validation/normalization Python's
11
+ * pydantic models run when the `ParsedTool` is assembled — e.g. citation
12
+ * `doi:`-prefix stripping, DOI/BibTeX shape checks, and the profile-gated skip
13
+ * of malformed citations. Those land with the `ParsedTool` assembly step.
14
+ */
15
+ export declare class XmlToolSource {
16
+ static readonly language = "xml";
17
+ readonly root: XmlElement;
18
+ constructor(root: XmlElement);
19
+ parseId(): string | null;
20
+ parseVersion(): string | null;
21
+ parseName(): string | null;
22
+ parseToolType(): string | null;
23
+ parseDescription(): string;
24
+ parseProfile(): string;
25
+ parseLicense(): string | null;
26
+ parseEdamOperations(): string[];
27
+ parseEdamTopics(): string[];
28
+ private edamChildTexts;
29
+ parseXrefs(): XrefDict[];
30
+ parseCitations(): Citation[];
31
+ parseHelp(): HelpContent | null;
32
+ parseCommand(): string | null;
33
+ parseOutputs(): ToolOutput[];
34
+ parseInputs(): ToolParameterModel[];
35
+ }
36
+ /** Build an {@link XmlToolSource} from raw XML text with a caller-supplied import resolver. */
37
+ export declare function xmlToolSourceFromString(text: string, importResolver: ImportResolver): XmlToolSource;
38
+ /** Load a tool XML file from disk, expand its macros, and wrap it as an {@link XmlToolSource}. */
39
+ export declare function loadXmlToolSource(path: string): XmlToolSource;
40
+ /** Read raw XML text without resolving any ``<import>`` (throws if one is present). */
41
+ export declare function xmlToolSourceFromStringNoImports(text: string): XmlToolSource;
42
+ //# sourceMappingURL=tool-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-source.d.ts","sourceRoot":"","sources":["../src/tool-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAKhE;;;;;;;;;;GAUG;AACH,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAS;IAEjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;gBAEd,IAAI,EAAE,UAAU;IAI5B,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB,YAAY,IAAI,MAAM,GAAG,IAAI;IAI7B,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,gBAAgB,IAAI,MAAM;IAI1B,YAAY,IAAI,MAAM;IAKtB,YAAY,IAAI,MAAM,GAAG,IAAI;IAI7B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,eAAe,IAAI,MAAM,EAAE;IAI3B,OAAO,CAAC,cAAc;IAMtB,UAAU,IAAI,QAAQ,EAAE;IAcxB,cAAc,IAAI,QAAQ,EAAE;IAmB5B,SAAS,IAAI,WAAW,GAAG,IAAI;IAO/B,YAAY,IAAI,MAAM,GAAG,IAAI;IAK7B,YAAY,IAAI,UAAU,EAAE;IAI5B,WAAW,IAAI,kBAAkB,EAAE;CAGpC;AAED,+FAA+F;AAC/F,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc,GAC7B,aAAa,CAEf;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAE7D;AAED,uFAAuF;AACvF,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAI5E"}
@@ -0,0 +1,124 @@
1
+ import { parseXmlToTree, xmlText } from "./element.js";
2
+ import { expandMacros } from "./macros.js";
3
+ import { loadTool } from "./loader.js";
4
+ import { parseInputs } from "./inputs.js";
5
+ import { parseOutputs } from "./outputs.js";
6
+ /**
7
+ * Port of the metadata-reading half of ``galaxy.tool_util.parser.xml.XmlToolSource``.
8
+ *
9
+ * Wraps an already-macro-expanded {@link XmlElement} tool tree and exposes the
10
+ * ``parse_*`` accessors that don't depend on the input-parameter tree (that
11
+ * lives behind the ``InputSource`` seam and is added later). Extraction is raw
12
+ * and does not yet apply the model-level validation/normalization Python's
13
+ * pydantic models run when the `ParsedTool` is assembled — e.g. citation
14
+ * `doi:`-prefix stripping, DOI/BibTeX shape checks, and the profile-gated skip
15
+ * of malformed citations. Those land with the `ParsedTool` assembly step.
16
+ */
17
+ export class XmlToolSource {
18
+ static language = "xml";
19
+ root;
20
+ constructor(root) {
21
+ this.root = root;
22
+ }
23
+ parseId() {
24
+ return this.root.attrs.get("id") ?? null;
25
+ }
26
+ parseVersion() {
27
+ return this.root.attrs.get("version") ?? null;
28
+ }
29
+ parseName() {
30
+ return this.root.attrs.get("name") || this.parseId();
31
+ }
32
+ parseToolType() {
33
+ return this.root.attrs.get("tool_type") ?? null;
34
+ }
35
+ parseDescription() {
36
+ return xmlText(this.root, "description");
37
+ }
38
+ parseProfile() {
39
+ // XML default differs from YAML's — pre-16.04 behaviour is the classic default.
40
+ return this.root.attrs.get("profile") ?? "16.01";
41
+ }
42
+ parseLicense() {
43
+ return this.root.attrs.get("license") ?? null;
44
+ }
45
+ parseEdamOperations() {
46
+ return this.edamChildTexts("edam_operations", "edam_operation");
47
+ }
48
+ parseEdamTopics() {
49
+ return this.edamChildTexts("edam_topics", "edam_topic");
50
+ }
51
+ edamChildTexts(containerTag, itemTag) {
52
+ const container = this.root.findChild(containerTag);
53
+ if (container === null)
54
+ return [];
55
+ return container.findChildren(itemTag).map((el) => el.text);
56
+ }
57
+ parseXrefs() {
58
+ const xrefs = this.root.findChild("xrefs");
59
+ if (xrefs === null)
60
+ return [];
61
+ const out = [];
62
+ for (const xref of xrefs.findChildren("xref")) {
63
+ const type = xref.attrs.get("type");
64
+ // Mirror the `if xref.get("type") and xref.text` guard.
65
+ if (type && xref.text) {
66
+ out.push({ value: xref.text.trim(), type });
67
+ }
68
+ }
69
+ return out;
70
+ }
71
+ parseCitations() {
72
+ const citationsEl = this.root.findChild("citations");
73
+ if (citationsEl === null)
74
+ return [];
75
+ const out = [];
76
+ for (const child of citationsEl.children) {
77
+ // `parse_citation_elem` ignores non-<citation> children.
78
+ if (child.tag !== "citation")
79
+ continue;
80
+ const content = child.text.trim();
81
+ // Raw extraction: skip empty content (Python's model asserts it) but do
82
+ // NOT yet apply DOI/BibTeX shape validation, `doi:` normalization, or the
83
+ // profile-gated skip of malformed citations — a `type`-less or malformed
84
+ // citation is passed through here rather than dropped. See class docstring.
85
+ if (!content)
86
+ continue;
87
+ const type = child.attrs.get("type") ?? "";
88
+ out.push({ type, content });
89
+ }
90
+ return out;
91
+ }
92
+ parseHelp() {
93
+ const helpEl = this.root.findChild("help");
94
+ if (helpEl === null)
95
+ return null;
96
+ const format = helpEl.attrs.get("format") ?? "restructuredtext";
97
+ return { format, content: helpEl.text || "" };
98
+ }
99
+ parseCommand() {
100
+ const commandEl = this.root.findChild("command");
101
+ return (commandEl && commandEl.text) || null;
102
+ }
103
+ parseOutputs() {
104
+ return parseOutputs(this.root, this.parseProfile());
105
+ }
106
+ parseInputs() {
107
+ return parseInputs(this.root);
108
+ }
109
+ }
110
+ /** Build an {@link XmlToolSource} from raw XML text with a caller-supplied import resolver. */
111
+ export function xmlToolSourceFromString(text, importResolver) {
112
+ return new XmlToolSource(expandMacros(parseXmlToTree(text), importResolver));
113
+ }
114
+ /** Load a tool XML file from disk, expand its macros, and wrap it as an {@link XmlToolSource}. */
115
+ export function loadXmlToolSource(path) {
116
+ return new XmlToolSource(loadTool(path));
117
+ }
118
+ /** Read raw XML text without resolving any ``<import>`` (throws if one is present). */
119
+ export function xmlToolSourceFromStringNoImports(text) {
120
+ return xmlToolSourceFromString(text, (relPath) => {
121
+ throw new Error(`<import> not supported without a resolver: ${relPath}`);
122
+ });
123
+ }
124
+ //# sourceMappingURL=tool-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-source.js","sourceRoot":"","sources":["../src/tool-source.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAa;IACxB,MAAM,CAAU,QAAQ,GAAG,KAAK,CAAC;IAExB,IAAI,CAAa;IAE1B,YAAY,IAAgB;QAC1B,IAAI,CAAC,IA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,EAAE,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,8CAA8C,OAAO,EAAE,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@galaxy-tool-util/tool-xml",
3
+ "version": "1.11.0",
4
+ "description": "XML tool-source layer for Galaxy tools \u2014 macro expansion (port of galaxy.util.xml_macros) and XML parsing into ParsedTool",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/jmchilton/galaxy-tool-util-ts",
22
+ "directory": "packages/tool-xml"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "provenance": false
27
+ },
28
+ "keywords": [
29
+ "galaxy",
30
+ "tool",
31
+ "xml",
32
+ "macros"
33
+ ],
34
+ "license": "MIT",
35
+ "dependencies": {
36
+ "fast-xml-parser": "^5.10.1",
37
+ "yaml": "^2.8.3",
38
+ "@galaxy-tool-util/schema": "1.12.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^25.5.0",
42
+ "effect": "^3.21.0"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc",
46
+ "typecheck": "tsc --noEmit",
47
+ "test": "tsc --noEmit && vitest run",
48
+ "test:watch": "vitest",
49
+ "lint": "eslint src/ test/",
50
+ "format": "prettier --check 'src/**/*.ts' 'test/**/*.ts'",
51
+ "format-fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'"
52
+ }
53
+ }