@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
|
@@ -1,248 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ConnectedValue injection and stripping for workflow state dicts.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Thin wrappers around walkNativeState that inject or strip
|
|
5
|
+
* ConnectedValue markers. Mutate state in-place for caller compat.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* and format2 validation paths.
|
|
7
|
+
* Port of Python galaxy.tool_util.workflow_state._state_merge.
|
|
8
|
+
* Tree-walking helpers live in walk-helpers.ts; re-exported here
|
|
9
|
+
* for backward compatibility.
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
/** Filter a flat key→value map to keys starting with a given prefix. */
|
|
18
|
-
export function keysStartingWith(map, prefix) {
|
|
19
|
-
const result = {};
|
|
20
|
-
for (const [key, value] of Object.entries(map)) {
|
|
21
|
-
if (key.startsWith(prefix)) {
|
|
22
|
-
result[key] = value;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Split flat connection keys for a repeat into per-instance arrays.
|
|
29
|
-
*
|
|
30
|
-
* Connection keys use the pattern `repeatName_N|paramName`.
|
|
31
|
-
* Returns an array of per-instance connection dicts.
|
|
32
|
-
*/
|
|
33
|
-
export function repeatInputsToArray(statePath, inputs) {
|
|
34
|
-
const repeatInputs = keysStartingWith(inputs, statePath + "_");
|
|
35
|
-
let highestCount = -1;
|
|
36
|
-
for (const key of Object.keys(repeatInputs)) {
|
|
37
|
-
const numStr = key.slice(statePath.length + 1).split("|")[0];
|
|
38
|
-
const num = parseInt(numStr, 10);
|
|
39
|
-
if (!isNaN(num) && num > highestCount) {
|
|
40
|
-
highestCount = num;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const params = [];
|
|
44
|
-
for (let i = 0; i <= highestCount; i++) {
|
|
45
|
-
params.push({});
|
|
46
|
-
}
|
|
47
|
-
for (const [key, value] of Object.entries(repeatInputs)) {
|
|
48
|
-
const numStr = key.slice(statePath.length + 1).split("|")[0];
|
|
49
|
-
const num = parseInt(numStr, 10);
|
|
50
|
-
if (!isNaN(num)) {
|
|
51
|
-
params[num][key] = value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return params;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Select the matching ConditionalWhen for a conditional state dict.
|
|
58
|
-
*
|
|
59
|
-
* Matches the test parameter's value in state against each when's
|
|
60
|
-
* discriminator. Falls back to the default when if no match found.
|
|
61
|
-
* Returns null if no match at all (graceful degradation).
|
|
62
|
-
*/
|
|
63
|
-
export function selectWhichWhen(conditional, state) {
|
|
64
|
-
const testParam = conditional.test_parameter;
|
|
65
|
-
const testValue = state[testParam.name];
|
|
66
|
-
// Try exact match first
|
|
67
|
-
for (const when of conditional.whens) {
|
|
68
|
-
if (_testValueMatchesDiscriminator(testParam, testValue, when.discriminator)) {
|
|
69
|
-
return when;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Fall back to default when
|
|
73
|
-
for (const when of conditional.whens) {
|
|
74
|
-
if (when.is_default_when) {
|
|
75
|
-
return when;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
function _testValueMatchesDiscriminator(testParam, testValue, discriminator) {
|
|
81
|
-
if (testParam.parameter_type === "gx_boolean") {
|
|
82
|
-
// Boolean coercion: handle string "true"/"false"/"True"/"False" and actual booleans
|
|
83
|
-
const boolValue = _coerceToBool(testValue);
|
|
84
|
-
const discBool = typeof discriminator === "boolean" ? discriminator : _coerceToBool(discriminator);
|
|
85
|
-
return boolValue === discBool;
|
|
86
|
-
}
|
|
87
|
-
// Select: string comparison
|
|
88
|
-
return String(testValue) === String(discriminator);
|
|
89
|
-
}
|
|
90
|
-
function _coerceToBool(value) {
|
|
91
|
-
if (typeof value === "boolean")
|
|
92
|
-
return value;
|
|
93
|
-
if (typeof value === "string") {
|
|
94
|
-
const lower = value.toLowerCase();
|
|
95
|
-
if (lower === "true")
|
|
96
|
-
return true;
|
|
97
|
-
if (lower === "false")
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
11
|
+
import { CONNECTED_VALUE, isConnectedValue } from "./runtime-markers.js";
|
|
12
|
+
import { walkNativeState, SKIP_VALUE } from "./walker.js";
|
|
13
|
+
import { flatStatePath, keysStartingWith, repeatInputsToArray, selectWhichWhen, } from "./walk-helpers.js";
|
|
14
|
+
// Re-export helpers so existing importers don't break
|
|
15
|
+
export { flatStatePath, keysStartingWith, repeatInputsToArray, selectWhichWhen };
|
|
102
16
|
// --- Main injection function ---
|
|
103
|
-
const CONNECTED_VALUE = { __class__: "ConnectedValue" };
|
|
104
17
|
/**
|
|
105
18
|
* Inject ConnectedValue markers into a state dict for all connections.
|
|
106
19
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
20
|
+
* Uses walkNativeState with a leaf callback that replaces connected
|
|
21
|
+
* leaves with ConnectedValue markers, then reassigns the input state
|
|
22
|
+
* in-place to preserve the mutation contract callers expect.
|
|
110
23
|
*
|
|
111
24
|
* @returns remaining unmatched connection paths (empty if all consumed)
|
|
112
25
|
*/
|
|
113
26
|
export function injectConnectionsIntoState(toolInputs, state, connections) {
|
|
114
27
|
const remaining = { ...connections };
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
28
|
+
const result = walkNativeState(connections, toolInputs, state, (_input, value, statePath) => {
|
|
29
|
+
if (statePath in remaining) {
|
|
30
|
+
delete remaining[statePath];
|
|
31
|
+
return { ...CONNECTED_VALUE };
|
|
32
|
+
}
|
|
33
|
+
return value === undefined ? SKIP_VALUE : value;
|
|
34
|
+
}, { preserveUnknownKeys: true });
|
|
35
|
+
for (const key of Object.keys(state))
|
|
36
|
+
delete state[key];
|
|
37
|
+
Object.assign(state, result);
|
|
118
38
|
return remaining;
|
|
119
39
|
}
|
|
120
|
-
function _mergeParam(connections, toolInput, state, prefix, branchConnections) {
|
|
121
|
-
if (branchConnections == null) {
|
|
122
|
-
branchConnections = connections;
|
|
123
|
-
}
|
|
124
|
-
const name = toolInput.name;
|
|
125
|
-
const parameterType = toolInput.parameter_type;
|
|
126
|
-
const statePath = flatStatePath(name, prefix);
|
|
127
|
-
if (parameterType === "gx_conditional") {
|
|
128
|
-
const conditional = toolInput;
|
|
129
|
-
let conditionalState = state[name];
|
|
130
|
-
if (conditionalState == null) {
|
|
131
|
-
conditionalState = {};
|
|
132
|
-
state[name] = conditionalState;
|
|
133
|
-
}
|
|
134
|
-
const when = selectWhichWhen(conditional, conditionalState);
|
|
135
|
-
const conditionalConnections = keysStartingWith(branchConnections, statePath);
|
|
136
|
-
_mergeParam(connections, conditional.test_parameter, conditionalState, statePath, conditionalConnections);
|
|
137
|
-
if (when != null) {
|
|
138
|
-
for (const whenParameter of when.parameters) {
|
|
139
|
-
_mergeParam(connections, whenParameter, conditionalState, statePath, conditionalConnections);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
else if (parameterType === "gx_repeat") {
|
|
144
|
-
const repeat = toolInput;
|
|
145
|
-
let repeatStateArray = state[name];
|
|
146
|
-
if (repeatStateArray == null) {
|
|
147
|
-
repeatStateArray = [];
|
|
148
|
-
}
|
|
149
|
-
const repeatInstanceConnects = repeatInputsToArray(statePath, connections);
|
|
150
|
-
for (let i = 0; i < repeatInstanceConnects.length; i++) {
|
|
151
|
-
while (repeatStateArray.length <= i) {
|
|
152
|
-
repeatStateArray.push({});
|
|
153
|
-
}
|
|
154
|
-
const instancePrefix = `${statePath}_${i}`;
|
|
155
|
-
for (const repeatParameter of repeat.parameters) {
|
|
156
|
-
_mergeParam(connections, repeatParameter, repeatStateArray[i], instancePrefix, repeatInstanceConnects[i]);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (repeatStateArray.length > 0 && !(name in state)) {
|
|
160
|
-
state[name] = repeatStateArray;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else if (parameterType === "gx_section") {
|
|
164
|
-
const section = toolInput;
|
|
165
|
-
let sectionState = state[name];
|
|
166
|
-
if (sectionState == null) {
|
|
167
|
-
sectionState = {};
|
|
168
|
-
state[name] = sectionState;
|
|
169
|
-
}
|
|
170
|
-
const sectionConnections = keysStartingWith(branchConnections, statePath);
|
|
171
|
-
for (const sectionParameter of section.parameters) {
|
|
172
|
-
_mergeParam(connections, sectionParameter, sectionState, statePath, sectionConnections);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
// Leaf parameter
|
|
177
|
-
if (statePath in branchConnections) {
|
|
178
|
-
state[name] = { ...CONNECTED_VALUE };
|
|
179
|
-
delete connections[statePath];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
40
|
// --- ConnectedValue stripping ---
|
|
184
|
-
function _isConnectedValue(value) {
|
|
185
|
-
return (value != null &&
|
|
186
|
-
typeof value === "object" &&
|
|
187
|
-
!Array.isArray(value) &&
|
|
188
|
-
value.__class__ === "ConnectedValue");
|
|
189
|
-
}
|
|
190
41
|
/**
|
|
191
42
|
* Strip ConnectedValue markers from a state dict using the parameter tree.
|
|
192
43
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
44
|
+
* Uses walkNativeState with a leaf callback that omits ConnectedValue
|
|
45
|
+
* entries via SKIP_VALUE, then reassigns the input state in-place to
|
|
46
|
+
* preserve the mutation contract callers expect.
|
|
195
47
|
*/
|
|
196
48
|
export function stripConnectedValues(toolInputs, state) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
function _stripParam(toolInput, state, prefix) {
|
|
202
|
-
const name = toolInput.name;
|
|
203
|
-
const parameterType = toolInput.parameter_type;
|
|
204
|
-
if (parameterType === "gx_conditional") {
|
|
205
|
-
const conditional = toolInput;
|
|
206
|
-
const conditionalState = state[name];
|
|
207
|
-
if (conditionalState == null)
|
|
208
|
-
return;
|
|
209
|
-
const statePath = flatStatePath(name, prefix);
|
|
210
|
-
_stripParam(conditional.test_parameter, conditionalState, statePath);
|
|
211
|
-
const when = selectWhichWhen(conditional, conditionalState);
|
|
212
|
-
if (when != null) {
|
|
213
|
-
for (const whenParameter of when.parameters) {
|
|
214
|
-
_stripParam(whenParameter, conditionalState, statePath);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
else if (parameterType === "gx_repeat") {
|
|
219
|
-
const repeat = toolInput;
|
|
220
|
-
const repeatStateArray = state[name];
|
|
221
|
-
if (!Array.isArray(repeatStateArray))
|
|
222
|
-
return;
|
|
223
|
-
const statePath = flatStatePath(name, prefix);
|
|
224
|
-
for (let i = 0; i < repeatStateArray.length; i++) {
|
|
225
|
-
const instancePrefix = `${statePath}_${i}`;
|
|
226
|
-
for (const repeatParameter of repeat.parameters) {
|
|
227
|
-
_stripParam(repeatParameter, repeatStateArray[i], instancePrefix);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
else if (parameterType === "gx_section") {
|
|
232
|
-
const section = toolInput;
|
|
233
|
-
const sectionState = state[name];
|
|
234
|
-
if (sectionState == null)
|
|
235
|
-
return;
|
|
236
|
-
const statePath = flatStatePath(name, prefix);
|
|
237
|
-
for (const sectionParameter of section.parameters) {
|
|
238
|
-
_stripParam(sectionParameter, sectionState, statePath);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
// Leaf parameter
|
|
243
|
-
if (_isConnectedValue(state[name])) {
|
|
244
|
-
delete state[name];
|
|
245
|
-
}
|
|
246
|
-
}
|
|
49
|
+
const cleaned = walkNativeState({}, toolInputs, state, (_input, value) => isConnectedValue(value) ? SKIP_VALUE : value === undefined ? SKIP_VALUE : value, { preserveUnknownKeys: true });
|
|
50
|
+
for (const key of Object.keys(state))
|
|
51
|
+
delete state[key];
|
|
52
|
+
Object.assign(state, cleaned);
|
|
247
53
|
}
|
|
248
54
|
//# sourceMappingURL=state-merge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-merge.js","sourceRoot":"","sources":["../../src/workflow/state-merge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"state-merge.js","sourceRoot":"","sources":["../../src/workflow/state-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,s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AC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EACjF,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAC9B,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACxD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-aware (stateful) state conversion between native and format2 formats.
|
|
3
|
+
*
|
|
4
|
+
* Uses the walker to traverse tool_state with parameter definitions,
|
|
5
|
+
* coercing scalar types and separating connections/runtime values.
|
|
6
|
+
*
|
|
7
|
+
* Design: no double encoding, no legacy decode, clean dicts throughout.
|
|
8
|
+
*/
|
|
9
|
+
import type { ToolParameterModel } from "../schema/bundle-types.js";
|
|
10
|
+
import type { NormalizedNativeStep } from "./normalized/native.js";
|
|
11
|
+
/**
|
|
12
|
+
* Coerce a native scalar value to its format2 representation.
|
|
13
|
+
*
|
|
14
|
+
* Native tool_state may have string-typed numbers, booleans, or
|
|
15
|
+
* comma-delimited multi-selects. Format2 uses proper JS types.
|
|
16
|
+
*/
|
|
17
|
+
export declare function convertScalarValue(toolInput: ToolParameterModel, value: unknown): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Reverse-coerce a format2 scalar value back to native representation.
|
|
20
|
+
*
|
|
21
|
+
* Format2 uses proper JS types; native may need string coercions for
|
|
22
|
+
* multi-select and data_column values.
|
|
23
|
+
*/
|
|
24
|
+
export declare function reverseScalarValue(toolInput: ToolParameterModel, value: unknown): unknown;
|
|
25
|
+
export interface Format2ConvertedState {
|
|
26
|
+
state: Record<string, unknown>;
|
|
27
|
+
in: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Convert a native step's tool_state to format2 state + in block.
|
|
31
|
+
*
|
|
32
|
+
* Walks the parameter tree:
|
|
33
|
+
* - Data params → `in` block (connected/runtime) or SKIP
|
|
34
|
+
* - ConnectedValue/RuntimeValue markers → `in` block
|
|
35
|
+
* - gx_rules → parse JSON string, SKIP if null/connected
|
|
36
|
+
* - Null/"null" values → SKIP
|
|
37
|
+
* - Scalars → coerce via convertScalarValue()
|
|
38
|
+
*/
|
|
39
|
+
export declare function convertStateToFormat2(nativeStep: NormalizedNativeStep, toolInputs: ToolParameterModel[]): Format2ConvertedState;
|
|
40
|
+
/**
|
|
41
|
+
* Encode format2 state back to native tool_state.
|
|
42
|
+
*
|
|
43
|
+
* Walks format2 state reversing coercions (e.g. number arrays → string arrays
|
|
44
|
+
* for multi-select/data_column). Returns a clean dict — no JSON.stringify per key.
|
|
45
|
+
*/
|
|
46
|
+
export declare function encodeStateToNative(toolInputs: ToolParameterModel[], state: Record<string, unknown>): Record<string, unknown>;
|
|
47
|
+
//# sourceMappingURL=stateful-convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateful-convert.d.ts","sourceRoot":"","sources":["../../src/workflow/stateful-convert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CA8BzF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAqBzF;AAID,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B;AAKD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,oBAAoB,EAChC,UAAU,EAAE,kBAAkB,EAAE,GAC/B,qBAAqB,CA+DvB;AAID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,kBAAkB,EAAE,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMzB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-aware (stateful) state conversion between native and format2 formats.
|
|
3
|
+
*
|
|
4
|
+
* Uses the walker to traverse tool_state with parameter definitions,
|
|
5
|
+
* coercing scalar types and separating connections/runtime values.
|
|
6
|
+
*
|
|
7
|
+
* Design: no double encoding, no legacy decode, clean dicts throughout.
|
|
8
|
+
*/
|
|
9
|
+
import { walkNativeState, walkFormat2State, SKIP_VALUE } from "./walker.js";
|
|
10
|
+
import { isConnectedValue, isRuntimeValue } from "./runtime-markers.js";
|
|
11
|
+
import { parseBool, parseNumber, parseStringArray, parseNumberArray } from "./coercions.js";
|
|
12
|
+
// --- Scalar coercions ---
|
|
13
|
+
/**
|
|
14
|
+
* Coerce a native scalar value to its format2 representation.
|
|
15
|
+
*
|
|
16
|
+
* Native tool_state may have string-typed numbers, booleans, or
|
|
17
|
+
* comma-delimited multi-selects. Format2 uses proper JS types.
|
|
18
|
+
*/
|
|
19
|
+
export function convertScalarValue(toolInput, value) {
|
|
20
|
+
const paramType = toolInput.parameter_type;
|
|
21
|
+
if (paramType === "gx_integer" || paramType === "gx_float") {
|
|
22
|
+
return parseNumber(value) ?? value;
|
|
23
|
+
}
|
|
24
|
+
if (paramType === "gx_boolean") {
|
|
25
|
+
return parseBool(value) ?? value;
|
|
26
|
+
}
|
|
27
|
+
if (paramType === "gx_select") {
|
|
28
|
+
const select = toolInput;
|
|
29
|
+
if (select.multiple) {
|
|
30
|
+
return parseStringArray(value) ?? value;
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
if (paramType === "gx_data_column") {
|
|
35
|
+
const col = toolInput;
|
|
36
|
+
if (col.multiple) {
|
|
37
|
+
return parseNumberArray(value) ?? value;
|
|
38
|
+
}
|
|
39
|
+
return parseNumber(value) ?? value;
|
|
40
|
+
}
|
|
41
|
+
// Passthrough for text, color, hidden, directory_uri, genomebuild,
|
|
42
|
+
// baseurl, drill_down, group_tag, and CWL types
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reverse-coerce a format2 scalar value back to native representation.
|
|
47
|
+
*
|
|
48
|
+
* Format2 uses proper JS types; native may need string coercions for
|
|
49
|
+
* multi-select and data_column values.
|
|
50
|
+
*/
|
|
51
|
+
export function reverseScalarValue(toolInput, value) {
|
|
52
|
+
const paramType = toolInput.parameter_type;
|
|
53
|
+
if (paramType === "gx_select") {
|
|
54
|
+
const select = toolInput;
|
|
55
|
+
if (select.multiple && Array.isArray(value)) {
|
|
56
|
+
return value.map(String);
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
if (paramType === "gx_data_column") {
|
|
61
|
+
const col = toolInput;
|
|
62
|
+
if (col.multiple && Array.isArray(value)) {
|
|
63
|
+
return value.map(String);
|
|
64
|
+
}
|
|
65
|
+
return typeof value === "number" ? String(value) : value;
|
|
66
|
+
}
|
|
67
|
+
// Most types pass through unchanged
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
/** Data parameter types — always go to `in` block, never to state. */
|
|
71
|
+
const DATA_PARAM_TYPES = new Set(["gx_data", "gx_data_collection"]);
|
|
72
|
+
/**
|
|
73
|
+
* Convert a native step's tool_state to format2 state + in block.
|
|
74
|
+
*
|
|
75
|
+
* Walks the parameter tree:
|
|
76
|
+
* - Data params → `in` block (connected/runtime) or SKIP
|
|
77
|
+
* - ConnectedValue/RuntimeValue markers → `in` block
|
|
78
|
+
* - gx_rules → parse JSON string, SKIP if null/connected
|
|
79
|
+
* - Null/"null" values → SKIP
|
|
80
|
+
* - Scalars → coerce via convertScalarValue()
|
|
81
|
+
*/
|
|
82
|
+
export function convertStateToFormat2(nativeStep, toolInputs) {
|
|
83
|
+
const toolState = nativeStep.tool_state;
|
|
84
|
+
// Widen readonly tuples to unknown for the walker's connection lookup.
|
|
85
|
+
const inputConnections = nativeStep.input_connections;
|
|
86
|
+
const connectedPaths = nativeStep.connected_paths;
|
|
87
|
+
const inBlock = {};
|
|
88
|
+
const leafCallback = (toolInput, value, statePath) => {
|
|
89
|
+
const paramType = toolInput.parameter_type;
|
|
90
|
+
// Data parameters: always to `in` block
|
|
91
|
+
if (DATA_PARAM_TYPES.has(paramType)) {
|
|
92
|
+
if (isConnectedValue(value) || connectedPaths.has(statePath)) {
|
|
93
|
+
// Connected data param — recorded via input_connections, handled by structural conversion
|
|
94
|
+
}
|
|
95
|
+
if (isRuntimeValue(value)) {
|
|
96
|
+
inBlock[statePath] = "runtime_value";
|
|
97
|
+
}
|
|
98
|
+
return SKIP_VALUE;
|
|
99
|
+
}
|
|
100
|
+
// Rules parameter: parse JSON string
|
|
101
|
+
if (paramType === "gx_rules") {
|
|
102
|
+
if (value == null || isConnectedValue(value)) {
|
|
103
|
+
if (isConnectedValue(value) || connectedPaths.has(statePath)) {
|
|
104
|
+
// Will be in `in` block via structural conversion
|
|
105
|
+
}
|
|
106
|
+
return SKIP_VALUE;
|
|
107
|
+
}
|
|
108
|
+
if (typeof value === "string") {
|
|
109
|
+
try {
|
|
110
|
+
return JSON.parse(value);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
// ConnectedValue → record in `in` block, skip from state
|
|
119
|
+
if (isConnectedValue(value)) {
|
|
120
|
+
// Connection source handled by structural conversion's input_connections
|
|
121
|
+
return SKIP_VALUE;
|
|
122
|
+
}
|
|
123
|
+
// RuntimeValue → record in `in` block, skip from state
|
|
124
|
+
if (isRuntimeValue(value)) {
|
|
125
|
+
inBlock[statePath] = "runtime_value";
|
|
126
|
+
return SKIP_VALUE;
|
|
127
|
+
}
|
|
128
|
+
// Null / "null" values → skip
|
|
129
|
+
if (value === null || value === undefined || value === "null") {
|
|
130
|
+
return SKIP_VALUE;
|
|
131
|
+
}
|
|
132
|
+
// Scalar coercion
|
|
133
|
+
return convertScalarValue(toolInput, value);
|
|
134
|
+
};
|
|
135
|
+
const state = walkNativeState(inputConnections, toolInputs, toolState, leafCallback);
|
|
136
|
+
return { state, in: inBlock };
|
|
137
|
+
}
|
|
138
|
+
// --- Format2 → Native conversion ---
|
|
139
|
+
/**
|
|
140
|
+
* Encode format2 state back to native tool_state.
|
|
141
|
+
*
|
|
142
|
+
* Walks format2 state reversing coercions (e.g. number arrays → string arrays
|
|
143
|
+
* for multi-select/data_column). Returns a clean dict — no JSON.stringify per key.
|
|
144
|
+
*/
|
|
145
|
+
export function encodeStateToNative(toolInputs, state) {
|
|
146
|
+
const leafCallback = (toolInput, value) => {
|
|
147
|
+
return reverseScalarValue(toolInput, value);
|
|
148
|
+
};
|
|
149
|
+
return walkFormat2State(toolInputs, state, leafCallback);
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=stateful-convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateful-convert.js","sourceRoot":"","sources":["../../src/workflow/stateful-convert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,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CAAC,CAAC;IAErF,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;AAChC,CAAC;AAED,sCAAsC;AAEtC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAgC,EAChC,KAA8B;IAE9B,MAAM,YAAY,GAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;QACtD,OAAO,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 "../schema/parameters/index.js";
|
|
14
|
+
import type { ToolParameterModel } from "../schema/bundle-types.js";
|
|
15
|
+
export type ValidationPhase = "pre" | "post";
|
|
16
|
+
/**
|
|
17
|
+
* Thrown when tool_state fails Effect Schema validation before or after
|
|
18
|
+
* stateful conversion. Carries the phase and formatted issue list so the
|
|
19
|
+
* runner can emit a structured fallback status.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConversionValidationFailure extends Error {
|
|
22
|
+
readonly phase: ValidationPhase;
|
|
23
|
+
readonly issues: string[];
|
|
24
|
+
readonly _tag: "ConversionValidationFailure";
|
|
25
|
+
constructor(phase: ValidationPhase, issues: string[]);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validate native tool_state against `workflow_step_native`. Connection
|
|
29
|
+
* paths are merged as `ConnectedValue` markers before validation so linked
|
|
30
|
+
* fields don't trip the schema.
|
|
31
|
+
*
|
|
32
|
+
* Returns silently if the schema cannot be built (unsupported parameter
|
|
33
|
+
* types) or if validation passes. Throws `ConversionValidationFailure`
|
|
34
|
+
* with phase="pre" on validation failure.
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateNativeStepState(inputs: ToolParameterModel[], toolState: Record<string, unknown>, inputConnections?: Record<string, unknown>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Validate format2 tool_state against `workflow_step`. Any stray
|
|
39
|
+
* `ConnectedValue` markers left over from normalization are stripped
|
|
40
|
+
* before validation (they belong in the `in` block, not the state).
|
|
41
|
+
*
|
|
42
|
+
* Returns silently on success or if the schema cannot be built. Throws
|
|
43
|
+
* `ConversionValidationFailure` with phase="post" on validation failure.
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateFormat2StepState(inputs: ToolParameterModel[], format2State: Record<string, unknown>): void;
|
|
46
|
+
/**
|
|
47
|
+
* A single diagnostic produced by tool-state validation.
|
|
48
|
+
*
|
|
49
|
+
* Defined here (lower-level module) so both {@link validateFormat2StepStateStrict}
|
|
50
|
+
* and the higher-level {@link ToolStateValidator} share one canonical type.
|
|
51
|
+
*/
|
|
52
|
+
export interface ToolStateDiagnostic {
|
|
53
|
+
/** Dot-separated parameter path, or "" for top-level / unlocated issues. */
|
|
54
|
+
path: string;
|
|
55
|
+
message: string;
|
|
56
|
+
severity: "error" | "warning";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Strict variant of {@link validateFormat2StepState}: reports unknown keys as
|
|
60
|
+
* diagnostics rather than silently ignoring them.
|
|
61
|
+
*
|
|
62
|
+
* Uses `onExcessProperty: "error"` so Effect Schema flags any key that has no
|
|
63
|
+
* corresponding parameter definition. Returns an empty array if the schema
|
|
64
|
+
* cannot be built or validation passes.
|
|
65
|
+
*/
|
|
66
|
+
export declare function validateFormat2StepStateStrict(inputs: ToolParameterModel[], format2State: Record<string, unknown>): ToolStateDiagnostic[];
|
|
67
|
+
//# sourceMappingURL=stateful-validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateful-validate.d.ts","sourceRoot":"","sources":["../../src/workflow/stateful-validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAA4B,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG9F,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7C;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;aAGlC,KAAK,EAAE,eAAe;aACtB,MAAM,EAAE,MAAM,EAAE;IAHlC,QAAQ,CAAC,IAAI,EAAG,6BAA6B,CAAU;gBAErC,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,EAAE;CAKnC;AAiBD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAC7C,IAAI,CAiBN;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,IAAI,CAaN;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,kBAAkB,EAAE,EAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,mBAAmB,EAAE,CAqBvB"}
|