@galaxy-tool-util/schema 1.1.0 → 1.5.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.
Files changed (118) hide show
  1. package/dist/index.d.ts +36 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +35 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/schema/parsed-tool.d.ts +349 -1
  6. package/dist/schema/parsed-tool.d.ts.map +1 -1
  7. package/dist/schema/parsed-tool.js +73 -2
  8. package/dist/schema/parsed-tool.js.map +1 -1
  9. package/dist/user-tool-parse/index.d.ts +12 -0
  10. package/dist/user-tool-parse/index.d.ts.map +1 -0
  11. package/dist/user-tool-parse/index.js +12 -0
  12. package/dist/user-tool-parse/index.js.map +1 -0
  13. package/dist/user-tool-parse/inputs.d.ts +13 -0
  14. package/dist/user-tool-parse/inputs.d.ts.map +1 -0
  15. package/dist/user-tool-parse/inputs.js +565 -0
  16. package/dist/user-tool-parse/inputs.js.map +1 -0
  17. package/dist/user-tool-parse/outputs.d.ts +10 -0
  18. package/dist/user-tool-parse/outputs.d.ts.map +1 -0
  19. package/dist/user-tool-parse/outputs.js +231 -0
  20. package/dist/user-tool-parse/outputs.js.map +1 -0
  21. package/dist/user-tool-parse/parse.d.ts +12 -0
  22. package/dist/user-tool-parse/parse.d.ts.map +1 -0
  23. package/dist/user-tool-parse/parse.js +98 -0
  24. package/dist/user-tool-parse/parse.js.map +1 -0
  25. package/dist/user-tool-source/index.d.ts +3 -0
  26. package/dist/user-tool-source/index.d.ts.map +1 -0
  27. package/dist/user-tool-source/index.js +3 -0
  28. package/dist/user-tool-source/index.js.map +1 -0
  29. package/dist/user-tool-source/schema.generated.d.ts +7298 -0
  30. package/dist/user-tool-source/schema.generated.d.ts.map +1 -0
  31. package/dist/user-tool-source/schema.generated.js +8851 -0
  32. package/dist/user-tool-source/schema.generated.js.map +1 -0
  33. package/dist/user-tool-source/semantic.d.ts +14 -0
  34. package/dist/user-tool-source/semantic.d.ts.map +1 -0
  35. package/dist/user-tool-source/semantic.js +137 -0
  36. package/dist/user-tool-source/semantic.js.map +1 -0
  37. package/dist/user-tool-source/validate.d.ts +37 -0
  38. package/dist/user-tool-source/validate.d.ts.map +1 -0
  39. package/dist/user-tool-source/validate.js +54 -0
  40. package/dist/user-tool-source/validate.js.map +1 -0
  41. package/dist/workflow/cytoscape-layout.d.ts +23 -0
  42. package/dist/workflow/cytoscape-layout.d.ts.map +1 -0
  43. package/dist/workflow/cytoscape-layout.js +115 -0
  44. package/dist/workflow/cytoscape-layout.js.map +1 -0
  45. package/dist/workflow/cytoscape-models.d.ts +67 -0
  46. package/dist/workflow/cytoscape-models.d.ts.map +1 -0
  47. package/dist/workflow/cytoscape-models.js +10 -0
  48. package/dist/workflow/cytoscape-models.js.map +1 -0
  49. package/dist/workflow/cytoscape.d.ts +29 -0
  50. package/dist/workflow/cytoscape.d.ts.map +1 -0
  51. package/dist/workflow/cytoscape.js +172 -0
  52. package/dist/workflow/cytoscape.js.map +1 -0
  53. package/dist/workflow/draft-checks.d.ts +205 -0
  54. package/dist/workflow/draft-checks.d.ts.map +1 -0
  55. package/dist/workflow/draft-checks.js +1151 -0
  56. package/dist/workflow/draft-checks.js.map +1 -0
  57. package/dist/workflow/edge-annotation.d.ts +24 -0
  58. package/dist/workflow/edge-annotation.d.ts.map +1 -0
  59. package/dist/workflow/edge-annotation.js +16 -0
  60. package/dist/workflow/edge-annotation.js.map +1 -0
  61. package/dist/workflow/index.d.ts +7 -1
  62. package/dist/workflow/index.d.ts.map +1 -1
  63. package/dist/workflow/index.js +7 -1
  64. package/dist/workflow/index.js.map +1 -1
  65. package/dist/workflow/mermaid.d.ts +6 -0
  66. package/dist/workflow/mermaid.d.ts.map +1 -1
  67. package/dist/workflow/mermaid.js +37 -4
  68. package/dist/workflow/mermaid.js.map +1 -1
  69. package/dist/workflow/normalized/format2.d.ts +1 -0
  70. package/dist/workflow/normalized/format2.d.ts.map +1 -1
  71. package/dist/workflow/normalized/format2.js +15 -2
  72. package/dist/workflow/normalized/format2.js.map +1 -1
  73. package/dist/workflow/normalized/native.d.ts +1 -1
  74. package/dist/workflow/normalized/toNative.js +29 -4
  75. package/dist/workflow/normalized/toNative.js.map +1 -1
  76. package/dist/workflow/promote-draft.d.ts +53 -0
  77. package/dist/workflow/promote-draft.d.ts.map +1 -0
  78. package/dist/workflow/promote-draft.js +133 -0
  79. package/dist/workflow/promote-draft.js.map +1 -0
  80. package/dist/workflow/raw/gxformat2-draft.d.ts +688 -0
  81. package/dist/workflow/raw/gxformat2-draft.d.ts.map +1 -0
  82. package/dist/workflow/raw/gxformat2-draft.effect.d.ts +4607 -0
  83. package/dist/workflow/raw/gxformat2-draft.effect.d.ts.map +1 -0
  84. package/dist/workflow/raw/gxformat2-draft.effect.js +778 -0
  85. package/dist/workflow/raw/gxformat2-draft.effect.js.map +1 -0
  86. package/dist/workflow/raw/gxformat2-draft.js +20 -0
  87. package/dist/workflow/raw/gxformat2-draft.js.map +1 -0
  88. package/dist/workflow/raw/gxformat2.d.ts +237 -13
  89. package/dist/workflow/raw/gxformat2.d.ts.map +1 -1
  90. package/dist/workflow/raw/gxformat2.effect.d.ts +1375 -177
  91. package/dist/workflow/raw/gxformat2.effect.d.ts.map +1 -1
  92. package/dist/workflow/raw/gxformat2.effect.js +355 -108
  93. package/dist/workflow/raw/gxformat2.effect.js.map +1 -1
  94. package/dist/workflow/raw/gxformat2.js +18 -1
  95. package/dist/workflow/raw/gxformat2.js.map +1 -1
  96. package/dist/workflow/raw/index.d.ts +2 -0
  97. package/dist/workflow/raw/index.d.ts.map +1 -1
  98. package/dist/workflow/raw/index.js +1 -0
  99. package/dist/workflow/raw/index.js.map +1 -1
  100. package/dist/workflow/raw/native.d.ts +51 -2
  101. package/dist/workflow/raw/native.d.ts.map +1 -1
  102. package/dist/workflow/raw/native.effect.d.ts +82 -30
  103. package/dist/workflow/raw/native.effect.d.ts.map +1 -1
  104. package/dist/workflow/raw/native.effect.js +67 -18
  105. package/dist/workflow/raw/native.effect.js.map +1 -1
  106. package/dist/workflow/raw/native.js.map +1 -1
  107. package/dist/workflow/report-models.d.ts +67 -0
  108. package/dist/workflow/report-models.d.ts.map +1 -1
  109. package/dist/workflow/report-models.js +81 -0
  110. package/dist/workflow/report-models.js.map +1 -1
  111. package/dist/workflow/semantic-validators.d.ts +18 -0
  112. package/dist/workflow/semantic-validators.d.ts.map +1 -0
  113. package/dist/workflow/semantic-validators.js +137 -0
  114. package/dist/workflow/semantic-validators.js.map +1 -0
  115. package/dist/workflow/validators.d.ts.map +1 -1
  116. package/dist/workflow/validators.js +7 -2
  117. package/dist/workflow/validators.js.map +1 -1
  118. package/package.json +1 -1
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Cross-language topological layout for Cytoscape elements.
3
+ *
4
+ * Spec: docs/architecture/cytoscape-layout.md. Any change here is a breaking
5
+ * visual diff and must land in lockstep with the gxformat2 port.
6
+ */
7
+ export const COL_STRIDE = 220;
8
+ export const ROW_STRIDE = 100;
9
+ export const LAYOUT_NAMES = [
10
+ "preset",
11
+ "topological",
12
+ "dagre",
13
+ "breadthfirst",
14
+ "grid",
15
+ "cose",
16
+ "random",
17
+ ];
18
+ export function isLayoutName(value) {
19
+ return LAYOUT_NAMES.includes(value);
20
+ }
21
+ /**
22
+ * Layouts that bake coordinates into `data.position`. All other layouts are
23
+ * hint-only and rely on the runtime renderer.
24
+ */
25
+ export function bakesCoordinates(layout) {
26
+ return layout === "preset" || layout === "topological";
27
+ }
28
+ /**
29
+ * Compute positions per the topological layering spec. Returns a map keyed by
30
+ * node `data.id` so callers can overwrite `node.position` in declaration order.
31
+ */
32
+ export function topologicalPositions(elements) {
33
+ const nodeIds = elements.nodes.map((n) => n.data.id);
34
+ const indexById = new Map();
35
+ nodeIds.forEach((id, i) => indexById.set(id, i));
36
+ const incoming = new Map();
37
+ for (const id of nodeIds)
38
+ incoming.set(id, []);
39
+ for (const edge of elements.edges) {
40
+ const { source, target } = edge.data;
41
+ if (!indexById.has(source) || !indexById.has(target))
42
+ continue;
43
+ incoming.get(target).push(source);
44
+ }
45
+ const inDegree = new Map();
46
+ for (const [id, srcs] of incoming)
47
+ inDegree.set(id, srcs.length);
48
+ // Kahn topo sort with declaration-index tie break. We avoid a heap to keep
49
+ // the algorithm trivially portable; node counts are tiny (workflows
50
+ // typically <100 steps).
51
+ const column = new Map();
52
+ const ready = nodeIds.filter((id) => inDegree.get(id) === 0);
53
+ const queue = [...ready];
54
+ // sort once by declaration index — entries already in declaration order, but
55
+ // keep the sort explicit so the contract stays obvious.
56
+ queue.sort((a, b) => indexById.get(a) - indexById.get(b));
57
+ const visited = new Set();
58
+ const dependents = new Map();
59
+ for (const id of nodeIds)
60
+ dependents.set(id, []);
61
+ for (const [target, sources] of incoming) {
62
+ for (const s of sources)
63
+ dependents.get(s).push(target);
64
+ }
65
+ while (queue.length > 0) {
66
+ // pop lowest declaration index
67
+ let bestIdx = 0;
68
+ for (let i = 1; i < queue.length; i++) {
69
+ if (indexById.get(queue[i]) < indexById.get(queue[bestIdx]))
70
+ bestIdx = i;
71
+ }
72
+ const id = queue.splice(bestIdx, 1)[0];
73
+ visited.add(id);
74
+ const sources = incoming.get(id);
75
+ if (sources.length === 0) {
76
+ column.set(id, 0);
77
+ }
78
+ else {
79
+ let max = 0;
80
+ for (const s of sources) {
81
+ const c = column.get(s);
82
+ if (c !== undefined && c + 1 > max)
83
+ max = c + 1;
84
+ }
85
+ column.set(id, max);
86
+ }
87
+ for (const dep of dependents.get(id)) {
88
+ const remaining = inDegree.get(dep) - 1;
89
+ inDegree.set(dep, remaining);
90
+ if (remaining === 0)
91
+ queue.push(dep);
92
+ }
93
+ }
94
+ // Cycle fallback: any node not visited gets column = declaration index.
95
+ for (const id of nodeIds) {
96
+ if (!visited.has(id))
97
+ column.set(id, indexById.get(id));
98
+ }
99
+ // Row assignment: per column, declaration order.
100
+ const rowsByColumn = new Map();
101
+ for (const id of nodeIds) {
102
+ const c = column.get(id);
103
+ if (!rowsByColumn.has(c))
104
+ rowsByColumn.set(c, []);
105
+ rowsByColumn.get(c).push(id);
106
+ }
107
+ const positions = new Map();
108
+ for (const [c, ids] of rowsByColumn) {
109
+ ids.forEach((id, row) => {
110
+ positions.set(id, { x: c * COL_STRIDE, y: row * ROW_STRIDE });
111
+ });
112
+ }
113
+ return positions;
114
+ }
115
+ //# sourceMappingURL=cytoscape-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cytoscape-layout.js","sourceRoot":"","sources":["../../src/workflow/cytoscape-layout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAC9B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAW9B,MAAM,CAAC,MAAM,YAAY,GAA0B;IACjD,QAAQ;IACR,aAAa;IACb,OAAO;IACP,cAAc;IACd,MAAM;IACN,MAAM;IACN,QAAQ;CACT,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAQ,YAAkC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAkB;IACjD,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,aAAa,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAA2B;IAC9D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAEjD,MAAM,QAAQ,G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E,GAAG,EAAE,EAAE;YACtB,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,GAAG,GAAG,UAAU,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Output-only TS interfaces for Cytoscape.js workflow visualization elements.
3
+ *
4
+ * Port of gxformat2/cytoscape/models.py. Field names stay snake_case so the
5
+ * emitted JSON is byte-identical to the Python builder.
6
+ */
7
+ export interface CytoscapePosition {
8
+ x: number;
9
+ y: number;
10
+ }
11
+ export interface CytoscapeNodeData {
12
+ id: string;
13
+ label: string;
14
+ doc: string | null;
15
+ tool_id: string | null;
16
+ step_type: string;
17
+ repo_link: string | null;
18
+ }
19
+ export interface CytoscapeEdgeData {
20
+ id: string;
21
+ source: string;
22
+ target: string;
23
+ input: string;
24
+ output: string | null;
25
+ /**
26
+ * Map-over depth applied at this connection, when annotated. Optional so the
27
+ * default emit shape stays byte-identical with the Python builder.
28
+ */
29
+ map_depth?: number;
30
+ /** True when the connection reduces a list-like source into a multi-data scalar input. */
31
+ reduction?: boolean;
32
+ /** Textual mapping (e.g. "list", "list:paired"); mirrors `ConnectionResult.mapping`. */
33
+ mapping?: string | null;
34
+ }
35
+ export interface CytoscapeNode {
36
+ group: "nodes";
37
+ data: CytoscapeNodeData;
38
+ classes: string[];
39
+ /**
40
+ * Present for `preset` and `topological` layouts; omitted for hint-only
41
+ * layouts (`dagre`, `breadthfirst`, `grid`, `cose`, `random`) so the runtime
42
+ * renderer is responsible for placement.
43
+ */
44
+ position?: CytoscapePosition;
45
+ }
46
+ export interface CytoscapeEdge {
47
+ group: "edges";
48
+ data: CytoscapeEdgeData;
49
+ /** Optional class hints (e.g. "mapover_2", "reduction") used by the HTML viewer's stylesheet. */
50
+ classes?: string[];
51
+ }
52
+ export interface CytoscapeLayoutHint {
53
+ name: string;
54
+ }
55
+ export interface CytoscapeElements {
56
+ nodes: CytoscapeNode[];
57
+ edges: CytoscapeEdge[];
58
+ /**
59
+ * Present only when the builder was invoked with a non-`preset` layout.
60
+ * Carried out-of-band so `elementsToList` keeps Python parity for the flat
61
+ * list shape.
62
+ */
63
+ layout?: CytoscapeLayoutHint;
64
+ }
65
+ export type CytoscapeListItem = CytoscapeNode | CytoscapeEdge;
66
+ export declare function elementsToList(els: CytoscapeElements): CytoscapeListItem[];
67
+ //# sourceMappingURL=cytoscape-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cytoscape-models.d.ts","sourceRoot":"","sources":["../../src/workflow/cytoscape-models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,iBAAiB,CAAC;IACxB,iGAAiG;IACjG,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAED,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,aAAa,CAAC;AAE9D,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAE1E"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Output-only TS interfaces for Cytoscape.js workflow visualization elements.
3
+ *
4
+ * Port of gxformat2/cytoscape/models.py. Field names stay snake_case so the
5
+ * emitted JSON is byte-identical to the Python builder.
6
+ */
7
+ export function elementsToList(els) {
8
+ return [...els.nodes, ...els.edges];
9
+ }
10
+ //# sourceMappingURL=cytoscape-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cytoscape-models.js","sourceRoot":"","sources":["../../src/workflow/cytoscape-models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqEH,MAAM,UAAU,cAAc,CAAC,GAAsB;IACnD,OAAO,CAAC,GAAG,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Build Cytoscape.js elements from a Galaxy workflow.
3
+ *
4
+ * Port of gxformat2/cytoscape/_builder.py. Snake_case field names + edge id
5
+ * format are preserved byte-for-byte to interop with the Python emitter and
6
+ * the standalone HTML template.
7
+ */
8
+ import type { CytoscapeElements } from "./cytoscape-models.js";
9
+ import type { LayoutName } from "./cytoscape-layout.js";
10
+ import type { EdgeAnnotation } from "./edge-annotation.js";
11
+ import type { NormalizedFormat2Workflow } from "./normalized/format2.js";
12
+ export interface CytoscapeOptions {
13
+ /**
14
+ * Optional `EdgeAnnotation` map keyed by `edgeAnnotationKey(...)`. When
15
+ * present, edges gain `data.map_depth`, `data.reduction`, `data.mapping`
16
+ * and class hints (`mapover_<n>`, `reduction`).
17
+ */
18
+ edgeAnnotations?: Map<string, EdgeAnnotation>;
19
+ /**
20
+ * Layout strategy. `preset` (default) keeps today's coordinate-from-NF2
21
+ * behavior with a `(10*i, 10*i)` fallback. `topological` overwrites
22
+ * coordinates per `cytoscape-layout.ts`. Hint-only layouts (`dagre`,
23
+ * `breadthfirst`, `grid`, `cose`, `random`) drop coordinates and emit a
24
+ * top-level `elements.layout = { name }` hint for the runtime renderer.
25
+ */
26
+ layout?: LayoutName;
27
+ }
28
+ export declare function cytoscapeElements(workflow: unknown | NormalizedFormat2Workflow, opts?: CytoscapeOptions): CytoscapeElements;
29
+ //# sourceMappingURL=cytoscape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cytoscape.d.ts","sourceRoot":"","sources":["../../src/workflow/cytoscape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAEV,iBAAiB,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,KAAK,EAGV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AAKjC,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC9C;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,OAAO,GAAG,yBAAyB,EAC7C,IAAI,GAAE,gBAAqB,GAC1B,iBAAiB,CAiDnB"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Build Cytoscape.js elements from a Galaxy workflow.
3
+ *
4
+ * Port of gxformat2/cytoscape/_builder.py. Snake_case field names + edge id
5
+ * format are preserved byte-for-byte to interop with the Python emitter and
6
+ * the standalone HTML template.
7
+ */
8
+ import { bakesCoordinates, topologicalPositions } from "./cytoscape-layout.js";
9
+ import { edgeAnnotationKey } from "./edge-annotation.js";
10
+ import { ensureFormat2 } from "./normalized/ensure.js";
11
+ import { isUnlabeledStep, resolveSourceReference } from "./normalized/labels.js";
12
+ const MAIN_TS_PREFIX = "toolshed.g2.bx.psu.edu/repos/";
13
+ export function cytoscapeElements(workflow, opts = {}) {
14
+ const wf = typeof workflow === "object" &&
15
+ workflow !== null &&
16
+ workflow.class === "GalaxyWorkflow" &&
17
+ Array.isArray(workflow.inputs) &&
18
+ "unique_tools" in workflow
19
+ ? workflow
20
+ : ensureFormat2(workflow);
21
+ const layout = opts.layout ?? "preset";
22
+ const nodes = [];
23
+ const edges = [];
24
+ wf.inputs.forEach((inp, i) => {
25
+ nodes.push(_inputNode(inp, i));
26
+ });
27
+ const inputsOffset = wf.inputs.length;
28
+ const knownLabels = new Set();
29
+ for (const inp of wf.inputs)
30
+ knownLabels.add(inp.id);
31
+ for (const step of wf.steps)
32
+ knownLabels.add(step.label || step.id);
33
+ wf.steps.forEach((step, i) => {
34
+ nodes.push(_stepNode(step, i + inputsOffset));
35
+ edges.push(..._stepEdges(step, knownLabels, opts.edgeAnnotations));
36
+ });
37
+ const elements = { nodes, edges };
38
+ if (layout === "preset") {
39
+ return elements;
40
+ }
41
+ if (bakesCoordinates(layout)) {
42
+ // Currently only `topological` reaches here; computed off the
43
+ // already-built elements per docs/architecture/cytoscape-layout.md.
44
+ const positions = topologicalPositions(elements);
45
+ for (const node of nodes) {
46
+ const p = positions.get(node.data.id);
47
+ if (p)
48
+ node.position = p;
49
+ }
50
+ }
51
+ else {
52
+ // Hint-only layout: positions are the renderer's job.
53
+ for (const node of nodes)
54
+ delete node.position;
55
+ }
56
+ elements.layout = { name: layout };
57
+ return elements;
58
+ }
59
+ function _fallbackPosition(orderIndex) {
60
+ return { x: 10 * orderIndex, y: 10 * orderIndex };
61
+ }
62
+ function _toPosition(raw, orderIndex) {
63
+ if (raw == null)
64
+ return _fallbackPosition(orderIndex);
65
+ const left = raw.left;
66
+ const top = raw.top;
67
+ const x = typeof left === "number" ? Math.trunc(left) : Number.parseInt(String(left ?? 0), 10);
68
+ const y = typeof top === "number" ? Math.trunc(top) : Number.parseInt(String(top ?? 0), 10);
69
+ return {
70
+ x: Number.isFinite(x) ? x : 0,
71
+ y: Number.isFinite(y) ? y : 0,
72
+ };
73
+ }
74
+ function _inputTypeStr(type) {
75
+ if (type == null)
76
+ return "input";
77
+ if (typeof type === "string")
78
+ return type;
79
+ return type.length > 0 ? `${type[0]}[]` : "input";
80
+ }
81
+ function _inputNode(inp, orderIndex) {
82
+ const inputId = inp.id || String(orderIndex);
83
+ const typeStr = _inputTypeStr(inp.type);
84
+ return {
85
+ group: "nodes",
86
+ data: {
87
+ id: inputId,
88
+ label: inputId,
89
+ doc: typeof inp.doc === "string" ? inp.doc : null,
90
+ tool_id: null,
91
+ step_type: typeStr,
92
+ repo_link: null,
93
+ },
94
+ classes: [`type_${typeStr}`, "input"],
95
+ position: _toPosition(inp.position, orderIndex),
96
+ };
97
+ }
98
+ function _stepNode(step, orderIndex) {
99
+ const stepId = step.label || step.id;
100
+ // The TS normalizer doesn't infer step.type the way gxformat2 does, so fall
101
+ // back to a `run`-derived hint for subworkflows (matches mermaid emitter).
102
+ const stepType = step.type || (step.run != null ? "subworkflow" : "tool");
103
+ let strippedToolId = step.tool_id ?? null;
104
+ if (strippedToolId && strippedToolId.startsWith(MAIN_TS_PREFIX)) {
105
+ strippedToolId = strippedToolId.slice(MAIN_TS_PREFIX.length);
106
+ }
107
+ const displayId = step.id && !isUnlabeledStep(step.id) ? step.id : null;
108
+ const label = step.label || displayId || (strippedToolId ? `tool:${strippedToolId}` : String(orderIndex));
109
+ let repoLink = null;
110
+ const repo = step.tool_shed_repository;
111
+ if (repo) {
112
+ const toolShed = repo.tool_shed;
113
+ const owner = repo.owner;
114
+ const name = repo.name;
115
+ const changesetRevision = repo.changeset_revision;
116
+ repoLink = `https://${toolShed}/view/${owner}/${name}/${changesetRevision}`;
117
+ }
118
+ return {
119
+ group: "nodes",
120
+ data: {
121
+ id: stepId,
122
+ label,
123
+ doc: typeof step.doc === "string" ? step.doc : null,
124
+ tool_id: step.tool_id ?? null,
125
+ step_type: stepType,
126
+ repo_link: repoLink,
127
+ },
128
+ classes: [`type_${stepType}`, "runnable"],
129
+ position: _toPosition(step.position, orderIndex),
130
+ };
131
+ }
132
+ function _stepEdges(step, knownLabels, edgeAnnotations) {
133
+ const stepId = step.label || step.id;
134
+ const edges = [];
135
+ for (const stepInput of step.in) {
136
+ if (stepInput.source == null)
137
+ continue;
138
+ const inputId = stepInput.id || "unknown";
139
+ const sources = Array.isArray(stepInput.source) ? stepInput.source : [stepInput.source];
140
+ for (const source of sources) {
141
+ const [sourceLabel, outputName] = resolveSourceReference(source, knownLabels);
142
+ const output = outputName === "output" ? null : outputName;
143
+ const edgeId = `${stepId}__${inputId}__from__${sourceLabel}`;
144
+ const edge = {
145
+ group: "edges",
146
+ data: {
147
+ id: edgeId,
148
+ source: sourceLabel,
149
+ target: stepId,
150
+ input: inputId,
151
+ output,
152
+ },
153
+ };
154
+ const annotation = edgeAnnotations?.get(edgeAnnotationKey(sourceLabel, outputName, stepId, inputId));
155
+ if (annotation) {
156
+ edge.data.map_depth = annotation.mapDepth;
157
+ edge.data.reduction = annotation.reduction;
158
+ edge.data.mapping = annotation.mapping ?? null;
159
+ const classes = [];
160
+ if (annotation.mapDepth > 0)
161
+ classes.push(`mapover_${annotation.mapDepth}`);
162
+ if (annotation.reduction)
163
+ classes.push("reduction");
164
+ if (classes.length > 0)
165
+ edge.classes = classes;
166
+ }
167
+ edges.push(edge);
168
+ }
169
+ }
170
+ return edges;
171
+ }
172
+ //# sourceMappingURL=cytoscape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cytoscape.js","sourceRoot":"","sources":["../../src/workflow/cytoscape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAMvD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,MAAM,cAAc,GAAG,+BAA+B,CAAC;AAmBvD,MAAM,UAAU,iBAAiB,CAC/B,QAA6C,EAC7C,OAAyB,EAAE;IAE3B,MAAM,EAAE,GACN,OAAO,QAAQ,KAAK,QAAQ;QAC5B,QAAQ,KAAK,IAAI;QAChB,QAAoC,CAAC,KAAK,KAAK,gBAAgB;QAChE,KAAK,CAAC,OAAO,CAAE,QAAoC,CAAC,MAAM,CAAC;QAC3D,cAAc,IAAK,QAAoC;QACrD,CAAC,CAAE,QAAsC;QACzC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAE9B,MAAM,MAAM,GAAe,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC;IACnD,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,MAAM,KAAK,GAAoB,EAAE,CAAC;IAElC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC3B,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAC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,CAC5D,CAAC;YACF,IAAI,UAAU,EAAE,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC;gBAC1C,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;gBAC3C,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC;gBAC/C,MAAM,OAAO,GAAa,EAAE,CAAC;gBAC7B,IAAI,UAAU,CAAC,QAAQ,GAAG,CAAC;oBAAE,OAAO,CAAC,IAAI,CAAC,WAAW,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC5E,IAAI,UAAU,CAAC,SAAS;oBAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACpD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;oBAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACjD,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Pure logic for Galaxy draft workflows (`class: GalaxyWorkflowDraft`).
3
+ *
4
+ * Substrate for the `gxwf draft-validate`, `gxwf draft-next-step`, and
5
+ * `gxwf _draft-extract` CLI commands. No I/O.
6
+ *
7
+ * The sentinel constants mirror `gxformat2/draft.py`. Drift is enforced by
8
+ * `make check-sync-draft-sentinel` against the JSON snapshot in
9
+ * `schema-sources/v19_09/draft_constants.json`.
10
+ */
11
+ export declare const TODO_SENTINEL_PATTERN: RegExp;
12
+ export declare const PLAN_FIELDS: readonly ["_plan_state", "_plan_context", "_plan_in", "_plan_out"];
13
+ export type PlanField = (typeof PLAN_FIELDS)[number];
14
+ export declare const DRAFT_CLASS = "GalaxyWorkflowDraft";
15
+ export declare function isTodoSentinel(value: unknown): value is string;
16
+ export declare function isDraftWorkflow(doc: unknown): boolean;
17
+ export type StepPath = string[];
18
+ export type TodoLocation = {
19
+ kind: "tool_id";
20
+ } | {
21
+ kind: "tool_version";
22
+ } | {
23
+ kind: "in_key";
24
+ key: string;
25
+ } | {
26
+ kind: "out_id";
27
+ id: string;
28
+ } | {
29
+ kind: "output_source";
30
+ output_label: string;
31
+ port: string;
32
+ };
33
+ export interface TodoHit {
34
+ path: StepPath;
35
+ location: TodoLocation;
36
+ sentinel: string;
37
+ }
38
+ export interface PlanHit {
39
+ path: StepPath;
40
+ field: PlanField;
41
+ value: string;
42
+ }
43
+ export interface DraftSurvey {
44
+ /** True iff `doc.class === "GalaxyWorkflowDraft"`. */
45
+ isDraft: boolean;
46
+ /** TODO sentinel hits in declaration order across the (sub)workflow tree. */
47
+ todos: TodoHit[];
48
+ /** `_plan_*` field hits on draft steps across the (sub)workflow tree. */
49
+ planFields: PlanHit[];
50
+ }
51
+ /**
52
+ * Walk a draft workflow once, returning every TODO sentinel and `_plan_*`
53
+ * field with its step path. Non-draft documents return `{ isDraft: false }`
54
+ * with empty arrays.
55
+ *
56
+ * Step paths are `[outerLabel, ..., innerStepLabel]`. Subworkflows recurse
57
+ * only when the inner `run:` block also carries `class: GalaxyWorkflowDraft`.
58
+ *
59
+ * Note: this survey is step-focused — it intentionally does NOT report
60
+ * top-level `_plan_*` fields on a draft workflow root. Those are flagged
61
+ * by `validateDraft` (a rules-focused walker); `detectDraft` exists to
62
+ * drive `nextDraftStep` / `extractConcreteSubset`, which only act on
63
+ * per-step state.
64
+ */
65
+ export declare function detectDraft(workflow: unknown): DraftSurvey;
66
+ export interface DraftValidationDiagnostic {
67
+ /** Step path; empty array for workflow-level diagnostics. */
68
+ path: StepPath;
69
+ message: string;
70
+ }
71
+ export interface DraftValidationResult {
72
+ ok: boolean;
73
+ structureErrors: DraftValidationDiagnostic[];
74
+ topologyErrors: DraftValidationDiagnostic[];
75
+ semanticErrors: DraftValidationDiagnostic[];
76
+ warnings: DraftValidationDiagnostic[];
77
+ survey: DraftSurvey;
78
+ }
79
+ /**
80
+ * Validate a draft Galaxy workflow. Collects all diagnostics — does not throw.
81
+ *
82
+ * structureErrors Effect Schema decode failures.
83
+ * topologyErrors Concrete-topology must hold even in drafts: workflow
84
+ * input labels, output labels, step labels, and step types
85
+ * cannot be TODO sentinels. Step/port edge refs must
86
+ * resolve to a declared step + declared port (TODO_*
87
+ * ports count if declared in the step's `out:`).
88
+ * semanticErrors TODO-shaped strings (start with `TODO`) that don't
89
+ * match the canonical sentinel form (e.g. `TODO-foo`,
90
+ * `TODOfoo`, `TODO_` trailing).
91
+ * warnings Bare `TODO` in port position; top-level `_plan_*`.
92
+ *
93
+ * The returned `survey` is the same shape detectDraft() returns and is
94
+ * usable by downstream nextDraftStep / extractConcreteSubset callers.
95
+ */
96
+ export declare function validateDraft(workflow: unknown): DraftValidationResult;
97
+ export type NextStepResult = {
98
+ draft: false;
99
+ } | {
100
+ draft: true;
101
+ step: StepPath;
102
+ work: string[];
103
+ };
104
+ /**
105
+ * Pick the next step a downstream agent should work on. Pure function;
106
+ * idempotent — same input → same output, byte-for-byte.
107
+ *
108
+ * Walks steps in topological order (steps with no draft-step source deps
109
+ * first), tie-breaking by alphabetical step label. The first step that
110
+ * carries any TODO sentinel or `_plan_*` field is returned with a
111
+ * prompt-shaped `work[]` array. Subworkflows (draft inner `run:`) are
112
+ * descended only after their outer step is itself fully concrete.
113
+ *
114
+ * Returns `{ draft: false }` when the workflow has no remaining work
115
+ * (this includes non-draft documents — there is nothing to do).
116
+ */
117
+ export declare function nextDraftStep(workflow: unknown): NextStepResult;
118
+ export type DropReason = {
119
+ kind: "step_has_todo";
120
+ locations: TodoLocation[];
121
+ } | {
122
+ kind: "step_has_plan_field";
123
+ fields: PlanField[];
124
+ } | {
125
+ kind: "cascade";
126
+ depends_on: StepPath[];
127
+ };
128
+ export interface DroppedStep {
129
+ path: StepPath;
130
+ reason: DropReason;
131
+ }
132
+ export interface DroppedOutput {
133
+ /**
134
+ * Step path of the workflow the output lives in. `[]` for the top-level
135
+ * document; `[outerStep, ...]` for inner subworkflow outputs.
136
+ */
137
+ path: StepPath;
138
+ label: string;
139
+ reason: DropReason;
140
+ }
141
+ export interface RewrittenStepInput {
142
+ path: StepPath;
143
+ in_key: string;
144
+ /** Dropped step/port refs removed from this input's `source:`. */
145
+ removed_refs: string[];
146
+ /** Surviving step/port refs after the rewrite. Empty when only a `default:` keeps the entry alive. */
147
+ surviving_refs: string[];
148
+ }
149
+ export interface ExtractResult {
150
+ /**
151
+ * Trimmed workflow dict. Still carries `class: GalaxyWorkflowDraft` —
152
+ * promoting to `GalaxyWorkflow` is the CLI command's call, not B's.
153
+ * `_plan_*` fields are preserved verbatim (including top-level fields and
154
+ * any survivor steps — though by construction survivor steps never have
155
+ * `_plan_*`, since carrying one is itself a drop trigger). Stripping lives
156
+ * in the `clean` module (E).
157
+ */
158
+ workflow: unknown;
159
+ /**
160
+ * Dropped steps across the (sub)workflow tree. Ordering within a single
161
+ * workflow level: by cascade round (round 0 = direct TODO/_plan_* drops;
162
+ * rounds 1+ = cascade drops), then by alphabetical step-path within a
163
+ * round. Across levels: a level's drops come first, then for each
164
+ * surviving subworkflow step (in source iteration order) its drops
165
+ * follow, recursively. Cascade rounds are local to a workflow level — not
166
+ * compared across nesting.
167
+ *
168
+ * `cascade.depends_on` paths point at the steps cited in the dead `in:`.
169
+ * In the common case these appear in `dropped_steps` themselves; in the
170
+ * subworkflow-port-loss case the cited path may be a *surviving* outer
171
+ * subworkflow step whose inner workflow lost the referenced port — look
172
+ * under that step's recursed inner drops for the underlying cause.
173
+ */
174
+ dropped_steps: DroppedStep[];
175
+ /**
176
+ * Workflow outputs dropped because their source step / port went away.
177
+ * Carries `path` to distinguish top-level outputs (`path: []`) from inner
178
+ * subworkflow outputs (`path: [outerStep, ...]`). Ordered alphabetically
179
+ * by label within a level; across levels, top-level first, then per
180
+ * surviving subworkflow step in iteration order.
181
+ */
182
+ dropped_outputs: DroppedOutput[];
183
+ /**
184
+ * Per-input rewrites where the source survived in part. Two cases:
185
+ * - Multi-source input lost some refs but kept others (rewritten to the
186
+ * surviving subset; string form if 1 left, list form if >1).
187
+ * - Single-source input lost its only ref but the input has a `default:`
188
+ * so the entry stays alive — `surviving_refs` is empty, the rewritten
189
+ * value retains the default and drops the `source:` key.
190
+ */
191
+ rewritten_step_inputs: RewrittenStepInput[];
192
+ }
193
+ /**
194
+ * Trim a draft workflow down to its concrete subset: drop any step that
195
+ * carries a TODO sentinel or `_plan_*` field, then cascade-drop steps whose
196
+ * `in:` becomes dead, then drop workflow outputs whose source went away.
197
+ * Multi-source inputs are rewritten in place to the surviving ref subset.
198
+ *
199
+ * Pure + idempotent. The result always carries `class: GalaxyWorkflowDraft`
200
+ * — promotion to concrete is a CLI-layer decision (E).
201
+ *
202
+ * Non-draft inputs pass through unchanged with empty drop / rewrite arrays.
203
+ */
204
+ export declare function extractConcreteSubset(workflow: unknown): ExtractResult;
205
+ //# sourceMappingURL=draft-checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-checks.d.ts","sourceRoot":"","sources":["../../src/workflow/draft-checks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,eAAO,MAAM,qBAAqB,QAA4B,CAAC;AAS/D,eAAO,MAAM,WAAW,oEAAqE,CAAC;AAC9F,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,eAAO,MAAM,WAAW,wBAAwB,CAAC;AAEjD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAErD;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC;AAEhC,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,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