@galaxy-tool-util/schema 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +87 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -1
- package/dist/index.js.map +1 -1
- package/dist/schema/type-guards.d.ts +14 -0
- package/dist/schema/type-guards.d.ts.map +1 -0
- package/dist/schema/type-guards.js +25 -0
- package/dist/schema/type-guards.js.map +1 -0
- package/dist/test-format/cross-check/check.d.ts +18 -0
- package/dist/test-format/cross-check/check.d.ts.map +1 -0
- package/dist/test-format/cross-check/check.js +89 -0
- package/dist/test-format/cross-check/check.js.map +1 -0
- package/dist/test-format/cross-check/extract-format2.d.ts +13 -0
- package/dist/test-format/cross-check/extract-format2.d.ts.map +1 -0
- package/dist/test-format/cross-check/extract-format2.js +98 -0
- package/dist/test-format/cross-check/extract-format2.js.map +1 -0
- package/dist/test-format/cross-check/extract-native.d.ts +4 -0
- package/dist/test-format/cross-check/extract-native.d.ts.map +1 -0
- package/dist/test-format/cross-check/extract-native.js +89 -0
- package/dist/test-format/cross-check/extract-native.js.map +1 -0
- package/dist/test-format/cross-check/extract.d.ts +9 -0
- package/dist/test-format/cross-check/extract.d.ts.map +1 -0
- package/dist/test-format/cross-check/extract.js +16 -0
- package/dist/test-format/cross-check/extract.js.map +1 -0
- package/dist/test-format/cross-check/index.d.ts +7 -0
- package/dist/test-format/cross-check/index.d.ts.map +1 -0
- package/dist/test-format/cross-check/index.js +6 -0
- package/dist/test-format/cross-check/index.js.map +1 -0
- package/dist/test-format/cross-check/type-compat.d.ts +23 -0
- package/dist/test-format/cross-check/type-compat.d.ts.map +1 -0
- package/dist/test-format/cross-check/type-compat.js +48 -0
- package/dist/test-format/cross-check/type-compat.js.map +1 -0
- package/dist/test-format/cross-check/types.d.ts +23 -0
- package/dist/test-format/cross-check/types.d.ts.map +1 -0
- package/dist/test-format/cross-check/types.js +10 -0
- package/dist/test-format/cross-check/types.js.map +1 -0
- package/dist/test-format/index.d.ts +3 -0
- package/dist/test-format/index.d.ts.map +1 -0
- package/dist/test-format/index.js +3 -0
- package/dist/test-format/index.js.map +1 -0
- package/dist/test-format/tests.schema.generated.d.ts +5610 -0
- package/dist/test-format/tests.schema.generated.d.ts.map +1 -0
- package/dist/test-format/tests.schema.generated.js +6899 -0
- package/dist/test-format/tests.schema.generated.js.map +1 -0
- package/dist/test-format/validate.d.ts +20 -0
- package/dist/test-format/validate.d.ts.map +1 -0
- package/dist/test-format/validate.js +41 -0
- package/dist/test-format/validate.js.map +1 -0
- package/dist/tool-state-validator.d.ts +23 -0
- package/dist/tool-state-validator.d.ts.map +1 -0
- package/dist/tool-state-validator.js +59 -0
- package/dist/tool-state-validator.js.map +1 -0
- package/dist/workflow/clean.d.ts +56 -3
- package/dist/workflow/clean.d.ts.map +1 -1
- package/dist/workflow/clean.js +227 -27
- package/dist/workflow/clean.js.map +1 -1
- package/dist/workflow/coercions.d.ts +22 -0
- package/dist/workflow/coercions.d.ts.map +1 -0
- package/dist/workflow/coercions.js +67 -0
- package/dist/workflow/coercions.js.map +1 -0
- package/dist/workflow/index.d.ts +17 -4
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +18 -3
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/lint-profiles.d.ts +27 -0
- package/dist/workflow/lint-profiles.d.ts.map +1 -0
- package/dist/workflow/lint-profiles.js +49 -0
- package/dist/workflow/lint-profiles.js.map +1 -0
- package/dist/workflow/lint-rules.d.ts +15 -0
- package/dist/workflow/lint-rules.d.ts.map +1 -0
- package/dist/workflow/lint-rules.js +15 -0
- package/dist/workflow/lint-rules.js.map +1 -0
- package/dist/workflow/lint.d.ts +4 -18
- package/dist/workflow/lint.d.ts.map +1 -1
- package/dist/workflow/lint.js +9 -30
- package/dist/workflow/lint.js.map +1 -1
- package/dist/workflow/lint_profiles.yml +41 -0
- package/dist/workflow/linting.d.ts +54 -0
- package/dist/workflow/linting.d.ts.map +1 -0
- package/dist/workflow/linting.js +71 -0
- package/dist/workflow/linting.js.map +1 -0
- package/dist/workflow/normalized/index.d.ts +5 -2
- package/dist/workflow/normalized/index.d.ts.map +1 -1
- package/dist/workflow/normalized/index.js +2 -0
- package/dist/workflow/normalized/index.js.map +1 -1
- package/dist/workflow/normalized/stateful-runner.d.ts +82 -0
- package/dist/workflow/normalized/stateful-runner.d.ts.map +1 -0
- package/dist/workflow/normalized/stateful-runner.js +122 -0
- package/dist/workflow/normalized/stateful-runner.js.map +1 -0
- package/dist/workflow/normalized/toFormat2.d.ts +19 -1
- package/dist/workflow/normalized/toFormat2.d.ts.map +1 -1
- package/dist/workflow/normalized/toFormat2.js +47 -16
- package/dist/workflow/normalized/toFormat2.js.map +1 -1
- package/dist/workflow/normalized/toFormat2Stateful.d.ts +30 -0
- package/dist/workflow/normalized/toFormat2Stateful.d.ts.map +1 -0
- package/dist/workflow/normalized/toFormat2Stateful.js +58 -0
- package/dist/workflow/normalized/toFormat2Stateful.js.map +1 -0
- package/dist/workflow/normalized/toNative.d.ts +10 -1
- package/dist/workflow/normalized/toNative.d.ts.map +1 -1
- package/dist/workflow/normalized/toNative.js +24 -8
- package/dist/workflow/normalized/toNative.js.map +1 -1
- package/dist/workflow/normalized/toNativeStateful.d.ts +31 -0
- package/dist/workflow/normalized/toNativeStateful.d.ts.map +1 -0
- package/dist/workflow/normalized/toNativeStateful.js +55 -0
- package/dist/workflow/normalized/toNativeStateful.js.map +1 -0
- package/dist/workflow/param-navigation.d.ts +26 -0
- package/dist/workflow/param-navigation.d.ts.map +1 -0
- package/dist/workflow/param-navigation.js +60 -0
- package/dist/workflow/param-navigation.js.map +1 -0
- package/dist/workflow/precheck.d.ts +54 -0
- package/dist/workflow/precheck.d.ts.map +1 -0
- package/dist/workflow/precheck.js +91 -0
- package/dist/workflow/precheck.js.map +1 -0
- package/dist/workflow/raw/gxformat2.effect.d.ts +97 -97
- package/dist/workflow/raw/gxformat2.effect.d.ts.map +1 -1
- package/dist/workflow/raw/gxformat2.effect.js +98 -88
- package/dist/workflow/raw/gxformat2.effect.js.map +1 -1
- package/dist/workflow/raw/native.d.ts +2 -2
- package/dist/workflow/raw/native.d.ts.map +1 -1
- package/dist/workflow/raw/native.effect.d.ts +33 -33
- package/dist/workflow/raw/native.effect.d.ts.map +1 -1
- package/dist/workflow/raw/native.effect.js +42 -32
- package/dist/workflow/raw/native.effect.js.map +1 -1
- package/dist/workflow/report-models.d.ts +412 -0
- package/dist/workflow/report-models.d.ts.map +1 -0
- package/dist/workflow/report-models.js +342 -0
- package/dist/workflow/report-models.js.map +1 -0
- package/dist/workflow/roundtrip.d.ts +77 -0
- package/dist/workflow/roundtrip.d.ts.map +1 -0
- package/dist/workflow/roundtrip.js +597 -0
- package/dist/workflow/roundtrip.js.map +1 -0
- package/dist/workflow/runtime-markers.d.ts +20 -0
- package/dist/workflow/runtime-markers.d.ts.map +1 -0
- package/dist/workflow/runtime-markers.js +26 -0
- package/dist/workflow/runtime-markers.js.map +1 -0
- package/dist/workflow/schema-rules.d.ts +38 -0
- package/dist/workflow/schema-rules.d.ts.map +1 -0
- package/dist/workflow/schema-rules.js +28 -0
- package/dist/workflow/schema-rules.js.map +1 -0
- package/dist/workflow/schema_rules.yml +69 -0
- package/dist/workflow/serialize.d.ts +30 -0
- package/dist/workflow/serialize.d.ts.map +1 -0
- package/dist/workflow/serialize.js +37 -0
- package/dist/workflow/serialize.js.map +1 -0
- package/dist/workflow/stale-keys.d.ts +16 -0
- package/dist/workflow/stale-keys.d.ts.map +1 -0
- package/dist/workflow/stale-keys.js +43 -0
- package/dist/workflow/stale-keys.js.map +1 -0
- package/dist/workflow/state-merge.d.ts +15 -32
- package/dist/workflow/state-merge.d.ts.map +1 -1
- package/dist/workflow/state-merge.js +31 -225
- package/dist/workflow/state-merge.js.map +1 -1
- package/dist/workflow/stateful-convert.d.ts +47 -0
- package/dist/workflow/stateful-convert.d.ts.map +1 -0
- package/dist/workflow/stateful-convert.js +151 -0
- package/dist/workflow/stateful-convert.js.map +1 -0
- package/dist/workflow/stateful-validate.d.ts +67 -0
- package/dist/workflow/stateful-validate.d.ts.map +1 -0
- package/dist/workflow/stateful-validate.js +123 -0
- package/dist/workflow/stateful-validate.js.map +1 -0
- package/dist/workflow/strict-checks.d.ts +22 -0
- package/dist/workflow/strict-checks.d.ts.map +1 -0
- package/dist/workflow/strict-checks.js +95 -0
- package/dist/workflow/strict-checks.js.map +1 -0
- package/dist/workflow/tool-state-io.d.ts +14 -0
- package/dist/workflow/tool-state-io.d.ts.map +1 -0
- package/dist/workflow/tool-state-io.js +33 -0
- package/dist/workflow/tool-state-io.js.map +1 -0
- package/dist/workflow/validators.d.ts +34 -0
- package/dist/workflow/validators.d.ts.map +1 -0
- package/dist/workflow/validators.js +83 -0
- package/dist/workflow/validators.js.map +1 -0
- package/dist/workflow/walk-helpers.d.ts +29 -0
- package/dist/workflow/walk-helpers.d.ts.map +1 -0
- package/dist/workflow/walk-helpers.js +89 -0
- package/dist/workflow/walk-helpers.js.map +1 -0
- package/dist/workflow/walker.d.ts +55 -0
- package/dist/workflow/walker.d.ts.map +1 -0
- package/dist/workflow/walker.js +199 -0
- package/dist/workflow/walker.js.map +1 -0
- package/package.json +21 -16
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema validation wrappers for stateful conversion.
|
|
3
|
+
*
|
|
4
|
+
* Runs the generated Effect Schema (`createFieldModel`) against native
|
|
5
|
+
* tool_state (pre-conversion) and format2 state (post-conversion), throwing
|
|
6
|
+
* a tagged `ConversionValidationFailure` on mismatch. The stateful wrappers
|
|
7
|
+
* catch this and push a structured fallback entry so callers can
|
|
8
|
+
* distinguish validation failures from walker errors.
|
|
9
|
+
*
|
|
10
|
+
* Deferred from Step 2 of TS_STATEFUL_CONVERSION_PLAN — integration point
|
|
11
|
+
* is the stateful runner, which calls these pre/post `convert`.
|
|
12
|
+
*/
|
|
13
|
+
import * as S from "effect/Schema";
|
|
14
|
+
import * as ParseResult from "effect/ParseResult";
|
|
15
|
+
// Side-effect import: registers all parameter generators so createFieldModel
|
|
16
|
+
// can look them up. Without this, a direct import of model-factory returns
|
|
17
|
+
// undefined for every call (the parameters/index.js side-effects never run).
|
|
18
|
+
import "../schema/parameters/index.js";
|
|
19
|
+
import { createFieldModel } from "../schema/model-factory.js";
|
|
20
|
+
import { injectConnectionsIntoState, stripConnectedValues } from "./state-merge.js";
|
|
21
|
+
/**
|
|
22
|
+
* Thrown when tool_state fails Effect Schema validation before or after
|
|
23
|
+
* stateful conversion. Carries the phase and formatted issue list so the
|
|
24
|
+
* runner can emit a structured fallback status.
|
|
25
|
+
*/
|
|
26
|
+
export class ConversionValidationFailure extends Error {
|
|
27
|
+
phase;
|
|
28
|
+
issues;
|
|
29
|
+
_tag = "ConversionValidationFailure";
|
|
30
|
+
constructor(phase, issues) {
|
|
31
|
+
super(`state failed ${phase}-conversion validation: ${issues.join("; ")}`);
|
|
32
|
+
this.phase = phase;
|
|
33
|
+
this.issues = issues;
|
|
34
|
+
this.name = "ConversionValidationFailure";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function formatIssues(error) {
|
|
38
|
+
const issues = ParseResult.ArrayFormatter.formatErrorSync(error);
|
|
39
|
+
return issues.map((i) => (i.path.length ? `${i.path.join(".")}: ${i.message}` : i.message));
|
|
40
|
+
}
|
|
41
|
+
function buildBundle(inputs) {
|
|
42
|
+
return { parameters: inputs };
|
|
43
|
+
}
|
|
44
|
+
/** JSON-safe deep clone — tool_state is plain data. Avoids `structuredClone`
|
|
45
|
+
* which isn't in the schema package's TS lib (no `@types/node`). */
|
|
46
|
+
function deepClone(value) {
|
|
47
|
+
return JSON.parse(JSON.stringify(value));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate native tool_state against `workflow_step_native`. Connection
|
|
51
|
+
* paths are merged as `ConnectedValue` markers before validation so linked
|
|
52
|
+
* fields don't trip the schema.
|
|
53
|
+
*
|
|
54
|
+
* Returns silently if the schema cannot be built (unsupported parameter
|
|
55
|
+
* types) or if validation passes. Throws `ConversionValidationFailure`
|
|
56
|
+
* with phase="pre" on validation failure.
|
|
57
|
+
*/
|
|
58
|
+
export function validateNativeStepState(inputs, toolState, inputConnections = {}) {
|
|
59
|
+
const bundle = buildBundle(inputs);
|
|
60
|
+
const model = createFieldModel(bundle, "workflow_step_native");
|
|
61
|
+
if (!model)
|
|
62
|
+
return; // unsupported parameter types — skip validation, conversion may still work
|
|
63
|
+
// Deep copy + inject connections so ConnectedValue markers appear where the
|
|
64
|
+
// schema expects them (matches validate-workflow's native path).
|
|
65
|
+
const state = deepClone(toolState);
|
|
66
|
+
if (Object.keys(inputConnections).length > 0) {
|
|
67
|
+
injectConnectionsIntoState(inputs, state, inputConnections);
|
|
68
|
+
}
|
|
69
|
+
const decode = S.decodeUnknownEither(model, { onExcessProperty: "ignore" });
|
|
70
|
+
const result = decode(state);
|
|
71
|
+
if (result._tag === "Left") {
|
|
72
|
+
throw new ConversionValidationFailure("pre", formatIssues(result.left));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validate format2 tool_state against `workflow_step`. Any stray
|
|
77
|
+
* `ConnectedValue` markers left over from normalization are stripped
|
|
78
|
+
* before validation (they belong in the `in` block, not the state).
|
|
79
|
+
*
|
|
80
|
+
* Returns silently on success or if the schema cannot be built. Throws
|
|
81
|
+
* `ConversionValidationFailure` with phase="post" on validation failure.
|
|
82
|
+
*/
|
|
83
|
+
export function validateFormat2StepState(inputs, format2State) {
|
|
84
|
+
const bundle = buildBundle(inputs);
|
|
85
|
+
const model = createFieldModel(bundle, "workflow_step");
|
|
86
|
+
if (!model)
|
|
87
|
+
return;
|
|
88
|
+
const state = deepClone(format2State);
|
|
89
|
+
stripConnectedValues(inputs, state);
|
|
90
|
+
const decode = S.decodeUnknownEither(model, { onExcessProperty: "ignore" });
|
|
91
|
+
const result = decode(state);
|
|
92
|
+
if (result._tag === "Left") {
|
|
93
|
+
throw new ConversionValidationFailure("post", formatIssues(result.left));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Strict variant of {@link validateFormat2StepState}: reports unknown keys as
|
|
98
|
+
* diagnostics rather than silently ignoring them.
|
|
99
|
+
*
|
|
100
|
+
* Uses `onExcessProperty: "error"` so Effect Schema flags any key that has no
|
|
101
|
+
* corresponding parameter definition. Returns an empty array if the schema
|
|
102
|
+
* cannot be built or validation passes.
|
|
103
|
+
*/
|
|
104
|
+
export function validateFormat2StepStateStrict(inputs, format2State) {
|
|
105
|
+
const bundle = buildBundle(inputs);
|
|
106
|
+
const model = createFieldModel(bundle, "workflow_step");
|
|
107
|
+
if (!model)
|
|
108
|
+
return [];
|
|
109
|
+
const state = deepClone(format2State);
|
|
110
|
+
stripConnectedValues(inputs, state);
|
|
111
|
+
const decode = S.decodeUnknownEither(model, { onExcessProperty: "error" });
|
|
112
|
+
const result = decode(state);
|
|
113
|
+
if (result._tag === "Left") {
|
|
114
|
+
const issues = ParseResult.ArrayFormatter.formatErrorSync(result.left);
|
|
115
|
+
return issues.map((i) => ({
|
|
116
|
+
path: i.path.map(String).join("."),
|
|
117
|
+
message: i.message,
|
|
118
|
+
severity: "error",
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=stateful-validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateful-validate.js","sourceRoot":"","sources":["../../src/workflow/stateful-validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,6EAA6E;AAC7E,2EAA2E;AAC3E,6EAA6E;AAC7E,OAAO,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAg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
+
* Walks top-level steps only (matching Python `validate_encoding_native`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateEncodingNative(workflowDict: Record<string, unknown>): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Format2: reject steps using `tool_state` field instead of `state`.
|
|
9
|
+
*
|
|
10
|
+
* No string-state check — format2 state comes from YAML parsing so
|
|
11
|
+
* it's always a dict. The Python side checks this defensively but
|
|
12
|
+
* it's not a real-world scenario.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateEncodingFormat2(workflowDict: Record<string, unknown>): string[];
|
|
15
|
+
/** Dispatch encoding check based on format auto-detection. */
|
|
16
|
+
export declare function checkStrictEncoding(workflowDict: Record<string, unknown>, format?: WorkflowFormat): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Strict structure check — decode with onExcessProperty: "error" to
|
|
19
|
+
* catch unknown keys at envelope and step level.
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkStrictStructure(workflowDict: Record<string, unknown>, format?: WorkflowFormat): string[];
|
|
22
|
+
//# sourceMappingURL=strict-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict-checks.d.ts","sourceRoot":"","sources":["../../src/workflow/strict-checks.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQzD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAqBtF;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAiBvF;AAED,8DAA8D;AAC9D,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,MAAM,CAAC,EAAE,cAAc,GACtB,MAAM,EAAE,CAKV;AASD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,MAAM,CAAC,EAAE,cAAc,GACtB,MAAM,EAAE,CAcV"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-normalization strict validation checks for workflows.
|
|
3
|
+
*
|
|
4
|
+
* These run on raw workflow dicts before any schema normalization,
|
|
5
|
+
* matching the Python pattern of failing fast before decoding.
|
|
6
|
+
*/
|
|
7
|
+
import { NativeGalaxyWorkflowSchema, GalaxyWorkflowSchema } from "./raw/index.js";
|
|
8
|
+
import { detectFormat } from "./detect-format.js";
|
|
9
|
+
import { withClass } from "./validators.js";
|
|
10
|
+
import * as ParseResult from "effect/ParseResult";
|
|
11
|
+
import * as S from "effect/Schema";
|
|
12
|
+
// ── Encoding checks ──────────────────────────────────────────────────
|
|
13
|
+
/**
|
|
14
|
+
* Native: reject tool_state that is a JSON string instead of a parsed dict.
|
|
15
|
+
* Walks top-level steps only (matching Python `validate_encoding_native`).
|
|
16
|
+
*/
|
|
17
|
+
export function validateEncodingNative(workflowDict) {
|
|
18
|
+
const errors = [];
|
|
19
|
+
const steps = workflowDict.steps;
|
|
20
|
+
if (!steps || typeof steps !== "object")
|
|
21
|
+
return errors;
|
|
22
|
+
const entries = Array.isArray(steps)
|
|
23
|
+
? steps.map((s, i) => [String(i), s])
|
|
24
|
+
: Object.entries(steps);
|
|
25
|
+
for (const [key, step] of entries) {
|
|
26
|
+
if (!step || typeof step !== "object")
|
|
27
|
+
continue;
|
|
28
|
+
const s = step;
|
|
29
|
+
if (s.type === "subworkflow")
|
|
30
|
+
continue;
|
|
31
|
+
if (!s.tool_id)
|
|
32
|
+
continue;
|
|
33
|
+
const toolState = s.tool_state;
|
|
34
|
+
if (typeof toolState === "string") {
|
|
35
|
+
errors.push(`step ${key}: tool_state is a JSON string (legacy encoding), expected a dict`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return errors;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Format2: reject steps using `tool_state` field instead of `state`.
|
|
42
|
+
*
|
|
43
|
+
* No string-state check — format2 state comes from YAML parsing so
|
|
44
|
+
* it's always a dict. The Python side checks this defensively but
|
|
45
|
+
* it's not a real-world scenario.
|
|
46
|
+
*/
|
|
47
|
+
export function validateEncodingFormat2(workflowDict) {
|
|
48
|
+
const errors = [];
|
|
49
|
+
const steps = workflowDict.steps;
|
|
50
|
+
if (!steps || !Array.isArray(steps))
|
|
51
|
+
return errors;
|
|
52
|
+
for (let i = 0; i < steps.length; i++) {
|
|
53
|
+
const step = steps[i];
|
|
54
|
+
if (!step || typeof step !== "object")
|
|
55
|
+
continue;
|
|
56
|
+
const s = step;
|
|
57
|
+
if (s.run && typeof s.run === "object")
|
|
58
|
+
continue; // subworkflow
|
|
59
|
+
if (!s.tool_id)
|
|
60
|
+
continue;
|
|
61
|
+
if ("tool_state" in s && !("state" in s)) {
|
|
62
|
+
errors.push(`step ${i}: uses "tool_state" instead of "state" (format2 should use "state")`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return errors;
|
|
66
|
+
}
|
|
67
|
+
/** Dispatch encoding check based on format auto-detection. */
|
|
68
|
+
export function checkStrictEncoding(workflowDict, format) {
|
|
69
|
+
const fmt = format ?? detectFormat(workflowDict);
|
|
70
|
+
return fmt === "native"
|
|
71
|
+
? validateEncodingNative(workflowDict)
|
|
72
|
+
: validateEncodingFormat2(workflowDict);
|
|
73
|
+
}
|
|
74
|
+
// ── Structure checks ─────────────────────────────────────────────────
|
|
75
|
+
function formatIssues(error) {
|
|
76
|
+
const issues = ParseResult.ArrayFormatter.formatErrorSync(error);
|
|
77
|
+
return issues.map((i) => `${i.path.join(".")}: ${i.message}`);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Strict structure check — decode with onExcessProperty: "error" to
|
|
81
|
+
* catch unknown keys at envelope and step level.
|
|
82
|
+
*/
|
|
83
|
+
export function checkStrictStructure(workflowDict, format) {
|
|
84
|
+
const fmt = format ?? detectFormat(workflowDict);
|
|
85
|
+
const cls = fmt === "native" ? "NativeGalaxyWorkflow" : "GalaxyWorkflow";
|
|
86
|
+
const data = withClass(workflowDict, cls);
|
|
87
|
+
const schema = fmt === "native" ? NativeGalaxyWorkflowSchema : GalaxyWorkflowSchema;
|
|
88
|
+
const decode = S.decodeUnknownEither(schema, { onExcessProperty: "error" });
|
|
89
|
+
const result = decode(data);
|
|
90
|
+
if (result._tag === "Left") {
|
|
91
|
+
return formatIssues(result.left);
|
|
92
|
+
}
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=strict-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict-checks.js","sourceRoot":"","sources":["../../src/workflow/strict-checks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAEnC,wEAAwE;AAExE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAqC;IAC1E,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;IACjC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAEvD,MAAM,OAAO,GAAwB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACvD,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,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AmB,CAAC,MAAM,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5E,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE5B,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helper for reading a native step's `tool_state`.
|
|
3
|
+
*
|
|
4
|
+
* Native workflows store parameter state as either:
|
|
5
|
+
* - a JSON-encoded string (`.ga` on disk), or
|
|
6
|
+
* - a parsed dict (after normalization / in-memory manipulation).
|
|
7
|
+
*
|
|
8
|
+
* Consumers elsewhere in the package duplicated this logic (cross-check
|
|
9
|
+
* extractor, normalized native builder, clean). Kept here as the shared
|
|
10
|
+
* root. `clean.ts` wraps this with legacy-dict decoding; it's a superset, not
|
|
11
|
+
* a replacement.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseToolState(raw: unknown): Record<string, unknown>;
|
|
14
|
+
//# sourceMappingURL=tool-state-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-state-io.d.ts","sourceRoot":"","sources":["../../src/workflow/tool-state-io.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBpE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helper for reading a native step's `tool_state`.
|
|
3
|
+
*
|
|
4
|
+
* Native workflows store parameter state as either:
|
|
5
|
+
* - a JSON-encoded string (`.ga` on disk), or
|
|
6
|
+
* - a parsed dict (after normalization / in-memory manipulation).
|
|
7
|
+
*
|
|
8
|
+
* Consumers elsewhere in the package duplicated this logic (cross-check
|
|
9
|
+
* extractor, normalized native builder, clean). Kept here as the shared
|
|
10
|
+
* root. `clean.ts` wraps this with legacy-dict decoding; it's a superset, not
|
|
11
|
+
* a replacement.
|
|
12
|
+
*/
|
|
13
|
+
export function parseToolState(raw) {
|
|
14
|
+
if (typeof raw === "string") {
|
|
15
|
+
if (raw === "")
|
|
16
|
+
return {};
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
20
|
+
return parsed;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
/* fall through to empty */
|
|
25
|
+
}
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
29
|
+
return raw;
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=tool-state-io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-state-io.js","sourceRoot":"","sources":["../../src/workflow/tool-state-io.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,GAAG,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnE,OAAO,MAAiC,CAAC;YAC3C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,2BAA2B;QAC7B,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,GAA8B,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Effect-schema validator dispatch for workflow dict inputs.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors gxformat2/validators.py. Callers pass a parsed workflow dict and get
|
|
5
|
+
* back the decoded value or throw on validation failure. Used by the schema-rule
|
|
6
|
+
* catalog runner and declarative-operation tests.
|
|
7
|
+
*
|
|
8
|
+
* The generated Effect schemas make `class` a required literal; Python's
|
|
9
|
+
* pydantic models default it. `withClass` injects the discriminator when
|
|
10
|
+
* missing so pass/fail semantics match Python byte-for-byte — see the plan
|
|
11
|
+
* note about `Format2MissingClass` being unenforceable today.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Return `raw` with `class: cls` injected if missing, and the same injection
|
|
15
|
+
* applied recursively to step subworkflows. Native steps embed subworkflows
|
|
16
|
+
* under `.subworkflow`; format2 steps embed them under `.run` (when `run` is
|
|
17
|
+
* an inline dict, not a URL).
|
|
18
|
+
*
|
|
19
|
+
* The cls string must match the parent document's class: nested format2
|
|
20
|
+
* subworkflows inherit `"GalaxyWorkflow"`, native inherit `"NativeGalaxyWorkflow"`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function withClass(raw: unknown, cls: string): unknown;
|
|
23
|
+
export declare function validateFormat2(wf: unknown): unknown;
|
|
24
|
+
export declare function validateFormat2Strict(wf: unknown): unknown;
|
|
25
|
+
export declare function validateNative(wf: unknown): unknown;
|
|
26
|
+
export declare function validateNativeStrict(wf: unknown): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Pick the validator matching a fixture filename's format.
|
|
29
|
+
*
|
|
30
|
+
* `.ga` → native; anything else → format2. `strict` picks the closed-schema
|
|
31
|
+
* flavor that rejects unknown fields.
|
|
32
|
+
*/
|
|
33
|
+
export declare function validatorForFixture(fixtureName: string, strict: boolean): (wf: unknown) => unknown;
|
|
34
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/workflow/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAkB5D;AAgBD,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAIpD;AAED,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAI1D;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAInD;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAIzD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,OAAO,GACd,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAK1B"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Effect-schema validator dispatch for workflow dict inputs.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors gxformat2/validators.py. Callers pass a parsed workflow dict and get
|
|
5
|
+
* back the decoded value or throw on validation failure. Used by the schema-rule
|
|
6
|
+
* catalog runner and declarative-operation tests.
|
|
7
|
+
*
|
|
8
|
+
* The generated Effect schemas make `class` a required literal; Python's
|
|
9
|
+
* pydantic models default it. `withClass` injects the discriminator when
|
|
10
|
+
* missing so pass/fail semantics match Python byte-for-byte — see the plan
|
|
11
|
+
* note about `Format2MissingClass` being unenforceable today.
|
|
12
|
+
*/
|
|
13
|
+
import { Schema } from "effect";
|
|
14
|
+
import { GalaxyWorkflowSchema } from "./raw/gxformat2.effect.js";
|
|
15
|
+
import { NativeGalaxyWorkflowSchema } from "./raw/native.effect.js";
|
|
16
|
+
/**
|
|
17
|
+
* Return `raw` with `class: cls` injected if missing, and the same injection
|
|
18
|
+
* applied recursively to step subworkflows. Native steps embed subworkflows
|
|
19
|
+
* under `.subworkflow`; format2 steps embed them under `.run` (when `run` is
|
|
20
|
+
* an inline dict, not a URL).
|
|
21
|
+
*
|
|
22
|
+
* The cls string must match the parent document's class: nested format2
|
|
23
|
+
* subworkflows inherit `"GalaxyWorkflow"`, native inherit `"NativeGalaxyWorkflow"`.
|
|
24
|
+
*/
|
|
25
|
+
export function withClass(raw, cls) {
|
|
26
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
27
|
+
return raw;
|
|
28
|
+
const obj = raw;
|
|
29
|
+
const result = "class" in obj ? { ...obj } : { ...obj, class: cls };
|
|
30
|
+
const steps = result.steps;
|
|
31
|
+
if (!steps || typeof steps !== "object")
|
|
32
|
+
return result;
|
|
33
|
+
if (Array.isArray(steps)) {
|
|
34
|
+
result.steps = steps.map((step) => injectStepSubworkflow(step, cls));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const next = {};
|
|
38
|
+
for (const [key, step] of Object.entries(steps)) {
|
|
39
|
+
next[key] = injectStepSubworkflow(step, cls);
|
|
40
|
+
}
|
|
41
|
+
result.steps = next;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function injectStepSubworkflow(step, cls) {
|
|
46
|
+
if (!step || typeof step !== "object")
|
|
47
|
+
return step;
|
|
48
|
+
const s = step;
|
|
49
|
+
if (s.subworkflow && typeof s.subworkflow === "object") {
|
|
50
|
+
return { ...s, subworkflow: withClass(s.subworkflow, cls) };
|
|
51
|
+
}
|
|
52
|
+
// format2 steps embed subworkflows under `run` when it's an inline dict.
|
|
53
|
+
// Skip string runs (URLs) and missing runs.
|
|
54
|
+
if (s.run && typeof s.run === "object" && !Array.isArray(s.run)) {
|
|
55
|
+
return { ...s, run: withClass(s.run, cls) };
|
|
56
|
+
}
|
|
57
|
+
return s;
|
|
58
|
+
}
|
|
59
|
+
export function validateFormat2(wf) {
|
|
60
|
+
return Schema.decodeUnknownSync(GalaxyWorkflowSchema, { onExcessProperty: "ignore" })(withClass(wf, "GalaxyWorkflow"));
|
|
61
|
+
}
|
|
62
|
+
export function validateFormat2Strict(wf) {
|
|
63
|
+
return Schema.decodeUnknownSync(GalaxyWorkflowSchema, { onExcessProperty: "error" })(withClass(wf, "GalaxyWorkflow"));
|
|
64
|
+
}
|
|
65
|
+
export function validateNative(wf) {
|
|
66
|
+
return Schema.decodeUnknownSync(NativeGalaxyWorkflowSchema, { onExcessProperty: "ignore" })(withClass(wf, "NativeGalaxyWorkflow"));
|
|
67
|
+
}
|
|
68
|
+
export function validateNativeStrict(wf) {
|
|
69
|
+
return Schema.decodeUnknownSync(NativeGalaxyWorkflowSchema, { onExcessProperty: "error" })(withClass(wf, "NativeGalaxyWorkflow"));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Pick the validator matching a fixture filename's format.
|
|
73
|
+
*
|
|
74
|
+
* `.ga` → native; anything else → format2. `strict` picks the closed-schema
|
|
75
|
+
* flavor that rejects unknown fields.
|
|
76
|
+
*/
|
|
77
|
+
export function validatorForFixture(fixtureName, strict) {
|
|
78
|
+
if (fixtureName.endsWith(".ga")) {
|
|
79
|
+
return strict ? validateNativeStrict : validateNative;
|
|
80
|
+
}
|
|
81
|
+
return strict ? validateFormat2Strict : validateFormat2;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/workflow/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAA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AAC,EAAW;IAC9C,OAAO,MAAM,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CACxF,SAAS,CAAC,EAAE,EAAE,sBAAsB,CAAC,CACtC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAAmB,EACnB,MAAe;IAEf,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,cAAc,CAAC;IACxD,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,eAAe,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helper functions for walking Galaxy parameter trees.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from state-merge.ts to break a circular dependency:
|
|
5
|
+
* walker.ts needs these helpers, and state-merge.ts needs walkNativeState.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Python galaxy.tool_util.parameters.visitor.
|
|
8
|
+
*/
|
|
9
|
+
import type { ConditionalParameterModel, ConditionalWhen } from "../schema/bundle-types.js";
|
|
10
|
+
/** Build flat pipe-separated state path: `name` or `prefix|name`. */
|
|
11
|
+
export declare function flatStatePath(name: string, prefix?: string): string;
|
|
12
|
+
/** Filter a flat key-value map to keys starting with a given prefix. */
|
|
13
|
+
export declare function keysStartingWith<T>(map: Record<string, T>, prefix: string): Record<string, T>;
|
|
14
|
+
/**
|
|
15
|
+
* Split flat connection keys for a repeat into per-instance arrays.
|
|
16
|
+
*
|
|
17
|
+
* Connection keys use the pattern `repeatName_N|paramName`.
|
|
18
|
+
* Returns an array of per-instance connection dicts.
|
|
19
|
+
*/
|
|
20
|
+
export declare function repeatInputsToArray<T>(statePath: string, inputs: Record<string, T>): Record<string, T>[];
|
|
21
|
+
/**
|
|
22
|
+
* Select the matching ConditionalWhen for a conditional state dict.
|
|
23
|
+
*
|
|
24
|
+
* Matches the test parameter's value in state against each when's
|
|
25
|
+
* discriminator. Falls back to the default when if no match found.
|
|
26
|
+
* Returns null if no match at all (graceful degradation).
|
|
27
|
+
*/
|
|
28
|
+
export declare function selectWhichWhen(conditional: ConditionalParameterModel, state: Record<string, unknown>): ConditionalWhen | null;
|
|
29
|
+
//# sourceMappingURL=walk-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk-helpers.d.ts","sourceRoot":"","sources":["../../src/workflow/walk-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AAKnC,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQ7F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GACxB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAuBrB;AAID;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,yBAAyB,EACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,eAAe,GAAG,IAAI,CAmBxB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helper functions for walking Galaxy parameter trees.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from state-merge.ts to break a circular dependency:
|
|
5
|
+
* walker.ts needs these helpers, and state-merge.ts needs walkNativeState.
|
|
6
|
+
*
|
|
7
|
+
* Ported from Python galaxy.tool_util.parameters.visitor.
|
|
8
|
+
*/
|
|
9
|
+
import { parseBool } from "./coercions.js";
|
|
10
|
+
// --- Path helpers ---
|
|
11
|
+
/** Build flat pipe-separated state path: `name` or `prefix|name`. */
|
|
12
|
+
export function flatStatePath(name, prefix) {
|
|
13
|
+
return prefix != null ? `${prefix}|${name}` : name;
|
|
14
|
+
}
|
|
15
|
+
/** Filter a flat key-value map to keys starting with a given prefix. */
|
|
16
|
+
export function keysStartingWith(map, prefix) {
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const [key, value] of Object.entries(map)) {
|
|
19
|
+
if (key.startsWith(prefix)) {
|
|
20
|
+
result[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Split flat connection keys for a repeat into per-instance arrays.
|
|
27
|
+
*
|
|
28
|
+
* Connection keys use the pattern `repeatName_N|paramName`.
|
|
29
|
+
* Returns an array of per-instance connection dicts.
|
|
30
|
+
*/
|
|
31
|
+
export function repeatInputsToArray(statePath, inputs) {
|
|
32
|
+
const repeatInputs = keysStartingWith(inputs, statePath + "_");
|
|
33
|
+
let highestCount = -1;
|
|
34
|
+
for (const key of Object.keys(repeatInputs)) {
|
|
35
|
+
const numStr = key.slice(statePath.length + 1).split("|")[0];
|
|
36
|
+
const num = parseInt(numStr, 10);
|
|
37
|
+
if (!isNaN(num) && num > highestCount) {
|
|
38
|
+
highestCount = num;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const params = [];
|
|
42
|
+
for (let i = 0; i <= highestCount; i++) {
|
|
43
|
+
params.push({});
|
|
44
|
+
}
|
|
45
|
+
for (const [key, value] of Object.entries(repeatInputs)) {
|
|
46
|
+
const numStr = key.slice(statePath.length + 1).split("|")[0];
|
|
47
|
+
const num = parseInt(numStr, 10);
|
|
48
|
+
if (!isNaN(num)) {
|
|
49
|
+
params[num][key] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return params;
|
|
53
|
+
}
|
|
54
|
+
// --- Conditional branch selection ---
|
|
55
|
+
/**
|
|
56
|
+
* Select the matching ConditionalWhen for a conditional state dict.
|
|
57
|
+
*
|
|
58
|
+
* Matches the test parameter's value in state against each when's
|
|
59
|
+
* discriminator. Falls back to the default when if no match found.
|
|
60
|
+
* Returns null if no match at all (graceful degradation).
|
|
61
|
+
*/
|
|
62
|
+
export function selectWhichWhen(conditional, state) {
|
|
63
|
+
const testParam = conditional.test_parameter;
|
|
64
|
+
const testValue = state[testParam.name];
|
|
65
|
+
// Try exact match first
|
|
66
|
+
for (const when of conditional.whens) {
|
|
67
|
+
if (_testValueMatchesDiscriminator(testParam, testValue, when.discriminator)) {
|
|
68
|
+
return when;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Fall back to default when
|
|
72
|
+
for (const when of conditional.whens) {
|
|
73
|
+
if (when.is_default_when) {
|
|
74
|
+
return when;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function _testValueMatchesDiscriminator(testParam, testValue, discriminator) {
|
|
80
|
+
if (testParam.parameter_type === "gx_boolean") {
|
|
81
|
+
// Boolean coercion: handle string "true"/"false"/"True"/"False" and actual booleans
|
|
82
|
+
const boolValue = parseBool(testValue);
|
|
83
|
+
const discBool = typeof discriminator === "boolean" ? discriminator : parseBool(discriminator);
|
|
84
|
+
return boolValue === discBool;
|
|
85
|
+
}
|
|
86
|
+
// Select: string comparison
|
|
87
|
+
return String(testValue) === String(discriminator);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=walk-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk-helpers.js","sourceRoot":"","sources":["../../src/workflow/walk-helpers.ts"],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YACzB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,8BAA8B,CACrC,SAAuD,EACvD,SAAkB,EAClB,aAA+B;IAE/B,IAAI,SAAS,CAAC,cAAc,KAAK,YAAY,EAAE,CAAC;QAC9C,oFAAoF;QACpF,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,OAAO,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAC/F,OAAO,SAAS,KAAK,QAAQ,CAAC;IAChC,CAAC;IACD,4BAA4B;IAC5B,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,aAAa,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-aware state walkers for native and format2 workflow tool state.
|
|
3
|
+
*
|
|
4
|
+
* Port of Python galaxy.tool_util.workflow_state._walker.
|
|
5
|
+
*
|
|
6
|
+
* Walks the parameter tree using tool definitions, calling a leaf callback
|
|
7
|
+
* for each scalar parameter. Handles conditionals (branch selection),
|
|
8
|
+
* repeats (instance expansion), and sections (recursion). Builds a new
|
|
9
|
+
* state dict from callback return values.
|
|
10
|
+
*
|
|
11
|
+
* Design principles:
|
|
12
|
+
* - No double encoding: containers must be proper dicts/lists, never JSON strings
|
|
13
|
+
* - No legacy decode: string containers are errors, not silently accommodated
|
|
14
|
+
* - SKIP_VALUE sentinel omits a value from the output
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolParameterModel } from "../schema/bundle-types.js";
|
|
17
|
+
/** Sentinel: return from leaf callback to omit a value from output. */
|
|
18
|
+
export declare const SKIP_VALUE: unique symbol;
|
|
19
|
+
export type LeafCallback = (toolInput: ToolParameterModel, value: unknown, statePath: string) => unknown | typeof SKIP_VALUE;
|
|
20
|
+
export interface WalkNativeOptions {
|
|
21
|
+
prefix?: string;
|
|
22
|
+
checkUnknownKeys?: boolean;
|
|
23
|
+
/** Copy undeclared keys from input state to output (default: false). */
|
|
24
|
+
preserveUnknownKeys?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Walk native workflow tool_state using the parameter tree.
|
|
28
|
+
*
|
|
29
|
+
* For each leaf parameter, calls `leafCallback(toolInput, value, statePath)`.
|
|
30
|
+
* Return values build the output dict; return SKIP_VALUE to omit.
|
|
31
|
+
*
|
|
32
|
+
* Containers (conditionals, repeats, sections) are recursed into.
|
|
33
|
+
* Bookkeeping keys (__current_case__, etc.) are stripped.
|
|
34
|
+
* Input connections are used to determine repeat instance counts.
|
|
35
|
+
*
|
|
36
|
+
* @throws Error if a container parameter value is a string (legacy encoding)
|
|
37
|
+
*/
|
|
38
|
+
export declare function walkNativeState(inputConnections: Record<string, unknown>, toolInputs: ToolParameterModel[], state: Record<string, unknown>, leafCallback: LeafCallback, options?: WalkNativeOptions): Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Walk format2 workflow tool state using the parameter tree.
|
|
41
|
+
*
|
|
42
|
+
* Simpler than native walking — no bookkeeping keys, no input connections,
|
|
43
|
+
* no double-encoding concerns. Clean dict walking with conditional branch
|
|
44
|
+
* selection, repeat iteration, section recursion.
|
|
45
|
+
*
|
|
46
|
+
* @throws Error if a container parameter value is a string
|
|
47
|
+
*/
|
|
48
|
+
export declare function walkFormat2State(toolInputs: ToolParameterModel[], state: Record<string, unknown>, leafCallback: LeafCallback, prefix?: string): Record<string, unknown>;
|
|
49
|
+
/** Error thrown when unknown keys are detected in native state. */
|
|
50
|
+
export declare class UnknownKeyError extends Error {
|
|
51
|
+
readonly key: string;
|
|
52
|
+
readonly prefix?: string | undefined;
|
|
53
|
+
constructor(key: string, prefix?: string | undefined);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=walker.d.ts.map
|
|
@@ -0,0 +1 @@
|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