@usearazzo/runner 1.0.1-alpha.38 → 1.0.1-alpha.39
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/CHANGELOG.md +6 -0
- package/README.md +1 -0
- package/dist/arazzo-runner.browser.js +356 -147
- package/dist/arazzo-runner.browser.min.js +1 -1
- package/package.json +4 -4
- package/src/executor/WorkflowExecutor.cjs +41 -29
- package/src/executor/WorkflowExecutor.mjs +41 -29
- package/src/index.cjs +7 -0
- package/src/index.mjs +1 -0
- package/src/resolver/WorkflowInputsResolver.cjs +174 -0
- package/src/resolver/WorkflowInputsResolver.mjs +169 -0
- package/src/state/WorkflowExecutionState.cjs +8 -0
- package/src/state/WorkflowExecutionState.mjs +8 -0
- package/src/version.cjs +1 -1
- package/src/version.mjs +1 -1
- package/types/runner.d.cts +88 -1
- package/types/runner.d.ts +88 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { toValue } from '@speclynx/apidom-core';
|
|
2
|
+
import { isObjectElement } from '@speclynx/apidom-datamodel';
|
|
3
|
+
import { isJSONSchemaElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
4
|
+
import { traverse } from '@speclynx/apidom-traverse';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The inputs a workflow runs with, as {@link WorkflowInputsResolver} resolves
|
|
8
|
+
* them.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the inputs a workflow runs with: the inputs it was given, with the
|
|
14
|
+
* `default` of its `inputs` schema filled in for every input it was not given.
|
|
15
|
+
*
|
|
16
|
+
* JSON Schema makes `default` an annotation and leaves applying it to the
|
|
17
|
+
* application, so the rule is the runner's own:
|
|
18
|
+
*
|
|
19
|
+
* - an input is not given when its name is absent or its value is `undefined`;
|
|
20
|
+
* an explicit `null` is given. That holds for an input a step or an action
|
|
21
|
+
* maps too: a parameter whose expression resolves to nothing, such as an
|
|
22
|
+
* optional input passed on, leaves the default in place;
|
|
23
|
+
* - its default is the `default` of the schema its name has under
|
|
24
|
+
* `properties`, looked up through `allOf`, whose members always apply. The
|
|
25
|
+
* schema's own `default` wins over its members', an earlier member over a
|
|
26
|
+
* later one;
|
|
27
|
+
* - an object that was given has the defaults of its own missing members
|
|
28
|
+
* filled in the same way. One that was not given is not created to hold
|
|
29
|
+
* them;
|
|
30
|
+
* - a `default` under `oneOf`, `anyOf`, `if`, `then`, `else` or `not` is not
|
|
31
|
+
* applied: which branch holds depends on the value, so picking one would be
|
|
32
|
+
* a guess;
|
|
33
|
+
* - a `default` of the `inputs` schema itself is not applied: a run always has
|
|
34
|
+
* an inputs object, if an empty one.
|
|
35
|
+
*
|
|
36
|
+
* The schema is read as the workflow normalizer leaves it, dereferenced, so a
|
|
37
|
+
* `default` behind a reference is found. Two things follow from how it
|
|
38
|
+
* dereferences:
|
|
39
|
+
*
|
|
40
|
+
* - a keyword written beside a reference replaces the same keyword of the
|
|
41
|
+
* schema referenced, so `properties` beside a reference hide the
|
|
42
|
+
* `properties` behind it, and their defaults with them;
|
|
43
|
+
* - a reference back into a schema it is already inside is cut there, so in a
|
|
44
|
+
* schema that refers to itself the defaults are filled in down to where it
|
|
45
|
+
* repeats, and a `default` written beside such a reference is lost with it.
|
|
46
|
+
*
|
|
47
|
+
* Neither the schema nor the given inputs are changed. Inputs no default is
|
|
48
|
+
* filled into come back as the object that was given, and so does an object
|
|
49
|
+
* among them; one a default is filled into is copied. A given object that
|
|
50
|
+
* contains itself is not supported.
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
class WorkflowInputsResolver {
|
|
54
|
+
/**
|
|
55
|
+
* Returns `inputs` with the defaults of `schema` filled in, and those
|
|
56
|
+
* defaults on their own. A workflow without an `inputs` schema, or with one
|
|
57
|
+
* that is not an object, gets its inputs back as given.
|
|
58
|
+
*/
|
|
59
|
+
resolve(schema, inputs) {
|
|
60
|
+
const defaults = this.#defaults(this.#applicable(schema), inputs);
|
|
61
|
+
return {
|
|
62
|
+
inputs: this.#filled(inputs, defaults),
|
|
63
|
+
defaults
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The schemas that always apply to a value `schema` describes, the one
|
|
69
|
+
* whose keywords win first: `schema` itself, then the members of its
|
|
70
|
+
* `allOf` as written, each before its own.
|
|
71
|
+
*
|
|
72
|
+
* The traversal goes into `allOf` only: every other keyword either
|
|
73
|
+
* describes a different value (`properties`, `items`) or applies only to
|
|
74
|
+
* some values (`oneOf`, `anyOf`, `if`). It takes each schema once
|
|
75
|
+
* (`skipVisited`), where it is first met: a dereferenced schema shares
|
|
76
|
+
* structure, and a schema referenced in two places would otherwise be walked
|
|
77
|
+
* again at each of them.
|
|
78
|
+
*/
|
|
79
|
+
#applicable(schema) {
|
|
80
|
+
if (!isJSONSchemaElement(schema)) return [];
|
|
81
|
+
const applicable = [];
|
|
82
|
+
const collect = path => {
|
|
83
|
+
applicable.push(path.node);
|
|
84
|
+
};
|
|
85
|
+
traverse(schema, {
|
|
86
|
+
// a schema written in the Arazzo document, or referenced from an
|
|
87
|
+
// OpenAPI 2.0 or 3.0 one
|
|
88
|
+
JSONSchemaElement: collect,
|
|
89
|
+
// a schema referenced from an OpenAPI 3.1 document
|
|
90
|
+
SchemaElement: collect,
|
|
91
|
+
MemberElement(path) {
|
|
92
|
+
if (toValue(path.node.key) !== 'allOf') path.skip();
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
skipVisited: 'skip'
|
|
96
|
+
});
|
|
97
|
+
return applicable;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The defaults `schemas` declare for what `value` was not given, in the
|
|
102
|
+
* shape of `value`: the default of an input that is missing, and, for an
|
|
103
|
+
* object that was given, the defaults of its own missing members under its
|
|
104
|
+
* name. `schemas` come as {@link WorkflowInputsResolver.#applicable} orders
|
|
105
|
+
* them, so the first one that declares a default for a name wins.
|
|
106
|
+
*/
|
|
107
|
+
#defaults(schemas, value) {
|
|
108
|
+
const names = new Set(schemas.flatMap(schema => this.#properties(schema)?.keys() ?? []));
|
|
109
|
+
const defaults = [];
|
|
110
|
+
for (const name of names) {
|
|
111
|
+
// each once: schemas dereferenced from one reference share their
|
|
112
|
+
// `properties`, and would bring the same property schema once each.
|
|
113
|
+
const propertySchemas = [...new Set(schemas.flatMap(schema => this.#applicable(this.#properties(schema)?.get(name))))];
|
|
114
|
+
if (!this.#isGiven(value, name)) {
|
|
115
|
+
const declaring = propertySchemas.find(schema => schema.default !== undefined);
|
|
116
|
+
if (declaring !== undefined) defaults.push([name, toValue(declaring.default)]);
|
|
117
|
+
} else if (this.#isPlainObject(value[name])) {
|
|
118
|
+
const members = this.#defaults(propertySchemas, value[name]);
|
|
119
|
+
if (Object.keys(members).length > 0) defaults.push([name, members]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// an entry list, so a name like `__proto__` becomes an own property.
|
|
123
|
+
return Object.fromEntries(defaults);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* `value` with `defaults` filled in: `value` itself when there are none,
|
|
128
|
+
* otherwise a copy of it that has them. A default is copied too, so the
|
|
129
|
+
* result shares nothing with `defaults`, and an object that was given is
|
|
130
|
+
* replaced by one that has its members' defaults.
|
|
131
|
+
*/
|
|
132
|
+
#filled(value, defaults) {
|
|
133
|
+
if (Object.keys(defaults).length === 0) return value;
|
|
134
|
+
const filled = Object.entries(defaults).map(([name, found]) => [name, this.#isGiven(value, name) ? this.#filled(value[name], found) : structuredClone(found)]);
|
|
135
|
+
// spread, so a name like `__proto__` stays an own property; the copy
|
|
136
|
+
// keeps the prototype of what was given, which may be none.
|
|
137
|
+
return Object.setPrototypeOf({
|
|
138
|
+
...value,
|
|
139
|
+
...Object.fromEntries(filled)
|
|
140
|
+
}, Object.getPrototypeOf(value));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The `properties` of `schema`, when it declares them as a map.
|
|
145
|
+
*/
|
|
146
|
+
#properties(schema) {
|
|
147
|
+
return isObjectElement(schema.properties) ? schema.properties : undefined;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Whether `value` was given an input of that name: present, and not
|
|
152
|
+
* `undefined`.
|
|
153
|
+
*/
|
|
154
|
+
#isGiven(value, name) {
|
|
155
|
+
return Object.hasOwn(value, name) && value[name] !== undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Whether `value` is an object written as a literal or parsed from JSON or
|
|
160
|
+
* YAML. Anything else an input can hold (an array, a `Date`, a `Blob`) is
|
|
161
|
+
* left as given: it has no members a schema's `properties` describes.
|
|
162
|
+
*/
|
|
163
|
+
#isPlainObject(value) {
|
|
164
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
165
|
+
const prototype = Object.getPrototypeOf(value);
|
|
166
|
+
return prototype === Object.prototype || prototype === null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export default WorkflowInputsResolver;
|
|
@@ -60,6 +60,14 @@ class WorkflowExecutionState {
|
|
|
60
60
|
this.#workflows.set(workflowId, workflow);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The inputs the workflow runs with, read via `$inputs.{name}`. Treat the
|
|
65
|
+
* returned object as immutable.
|
|
66
|
+
*/
|
|
67
|
+
get inputs() {
|
|
68
|
+
return this.#inputs;
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
/**
|
|
64
72
|
* The workflow's own accumulated outputs. Read-only by contract, like the
|
|
65
73
|
* context produced by `toContext`; treat the returned object as immutable.
|
|
@@ -54,6 +54,14 @@ class WorkflowExecutionState {
|
|
|
54
54
|
this.#workflows.set(workflowId, workflow);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The inputs the workflow runs with, read via `$inputs.{name}`. Treat the
|
|
59
|
+
* returned object as immutable.
|
|
60
|
+
*/
|
|
61
|
+
get inputs() {
|
|
62
|
+
return this.#inputs;
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
/**
|
|
58
66
|
* The workflow's own accumulated outputs. Read-only by contract, like the
|
|
59
67
|
* context produced by `toContext`; treat the returned object as immutable.
|
package/src/version.cjs
CHANGED
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
// generated by scripts/version-update.mjs from package.json; do not edit
|
|
8
|
-
const version = '1.0.1-alpha.
|
|
8
|
+
const version = '1.0.1-alpha.38';
|
|
9
9
|
var _default = exports.default = version;
|
package/src/version.mjs
CHANGED
package/types/runner.d.cts
CHANGED
|
@@ -2405,6 +2405,24 @@ export declare interface ResolvedRequestBody {
|
|
|
2405
2405
|
readonly contentType?: string;
|
|
2406
2406
|
}
|
|
2407
2407
|
|
|
2408
|
+
/**
|
|
2409
|
+
* The inputs a workflow runs with, as {@link WorkflowInputsResolver} resolves
|
|
2410
|
+
* them.
|
|
2411
|
+
* @public
|
|
2412
|
+
*/
|
|
2413
|
+
export declare interface ResolvedWorkflowInputs {
|
|
2414
|
+
/**
|
|
2415
|
+
* The inputs that were given, with the defaults filled in.
|
|
2416
|
+
*/
|
|
2417
|
+
readonly inputs: Record<string, unknown>;
|
|
2418
|
+
/**
|
|
2419
|
+
* The members of `inputs` that came from a default and were not given, in
|
|
2420
|
+
* the shape of `inputs`: a default filled into an object that was given
|
|
2421
|
+
* sits under that object's name. Empty when no default was filled in.
|
|
2422
|
+
*/
|
|
2423
|
+
readonly defaults: Record<string, unknown>;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2408
2426
|
/**
|
|
2409
2427
|
* Carries a `reason`, one of the class's static reason fields.
|
|
2410
2428
|
*
|
|
@@ -3335,7 +3353,9 @@ export declare interface WorkflowDescriptor {
|
|
|
3335
3353
|
*/
|
|
3336
3354
|
export declare interface WorkflowExecuteOptions {
|
|
3337
3355
|
/**
|
|
3338
|
-
* The workflow's inputs, read via `$inputs`.
|
|
3356
|
+
* The workflow's inputs, read via `$inputs`. An input that is not given
|
|
3357
|
+
* takes the `default` its name has in the workflow's `inputs` schema, see
|
|
3358
|
+
* {@link WorkflowInputsResolver}.
|
|
3339
3359
|
*/
|
|
3340
3360
|
readonly inputs?: Record<string, unknown>;
|
|
3341
3361
|
/**
|
|
@@ -3487,6 +3507,16 @@ export declare interface WorkflowExecutionEventBase extends ArazzoRunnerEventBas
|
|
|
3487
3507
|
*/
|
|
3488
3508
|
export declare interface WorkflowExecutionResult {
|
|
3489
3509
|
readonly workflowId: string;
|
|
3510
|
+
/**
|
|
3511
|
+
* The inputs the workflow was not given and took from the `default` of its
|
|
3512
|
+
* `inputs` schema, in the shape of the inputs: a default filled into an
|
|
3513
|
+
* object that was given sits under that object's name. Present only when
|
|
3514
|
+
* at least one default was filled in.
|
|
3515
|
+
*
|
|
3516
|
+
* The inputs the workflow was given are not reported: they are the
|
|
3517
|
+
* caller's, and may hold credentials. A default is part of the document.
|
|
3518
|
+
*/
|
|
3519
|
+
readonly inputDefaults?: Record<string, unknown>;
|
|
3490
3520
|
readonly outputs: Record<string, unknown>;
|
|
3491
3521
|
readonly steps: readonly StepRunRecord[];
|
|
3492
3522
|
readonly status: 'completed' | 'ended' | 'failed' | 'transferred';
|
|
@@ -3577,6 +3607,11 @@ export declare class WorkflowExecutionState {
|
|
|
3577
3607
|
inputs?: Record<string, unknown>;
|
|
3578
3608
|
outputs?: Record<string, unknown>;
|
|
3579
3609
|
}): void;
|
|
3610
|
+
/**
|
|
3611
|
+
* The inputs the workflow runs with, read via `$inputs.{name}`. Treat the
|
|
3612
|
+
* returned object as immutable.
|
|
3613
|
+
*/
|
|
3614
|
+
get inputs(): Readonly<Record<string, unknown>>;
|
|
3580
3615
|
/**
|
|
3581
3616
|
* The workflow's own accumulated outputs. Read-only by contract, like the
|
|
3582
3617
|
* context produced by `toContext`; treat the returned object as immutable.
|
|
@@ -3766,6 +3801,57 @@ export declare interface WorkflowExecutorOptions {
|
|
|
3766
3801
|
*/
|
|
3767
3802
|
export declare type WorkflowId = string;
|
|
3768
3803
|
|
|
3804
|
+
/**
|
|
3805
|
+
* Resolves the inputs a workflow runs with: the inputs it was given, with the
|
|
3806
|
+
* `default` of its `inputs` schema filled in for every input it was not given.
|
|
3807
|
+
*
|
|
3808
|
+
* JSON Schema makes `default` an annotation and leaves applying it to the
|
|
3809
|
+
* application, so the rule is the runner's own:
|
|
3810
|
+
*
|
|
3811
|
+
* - an input is not given when its name is absent or its value is `undefined`;
|
|
3812
|
+
* an explicit `null` is given. That holds for an input a step or an action
|
|
3813
|
+
* maps too: a parameter whose expression resolves to nothing, such as an
|
|
3814
|
+
* optional input passed on, leaves the default in place;
|
|
3815
|
+
* - its default is the `default` of the schema its name has under
|
|
3816
|
+
* `properties`, looked up through `allOf`, whose members always apply. The
|
|
3817
|
+
* schema's own `default` wins over its members', an earlier member over a
|
|
3818
|
+
* later one;
|
|
3819
|
+
* - an object that was given has the defaults of its own missing members
|
|
3820
|
+
* filled in the same way. One that was not given is not created to hold
|
|
3821
|
+
* them;
|
|
3822
|
+
* - a `default` under `oneOf`, `anyOf`, `if`, `then`, `else` or `not` is not
|
|
3823
|
+
* applied: which branch holds depends on the value, so picking one would be
|
|
3824
|
+
* a guess;
|
|
3825
|
+
* - a `default` of the `inputs` schema itself is not applied: a run always has
|
|
3826
|
+
* an inputs object, if an empty one.
|
|
3827
|
+
*
|
|
3828
|
+
* The schema is read as the workflow normalizer leaves it, dereferenced, so a
|
|
3829
|
+
* `default` behind a reference is found. Two things follow from how it
|
|
3830
|
+
* dereferences:
|
|
3831
|
+
*
|
|
3832
|
+
* - a keyword written beside a reference replaces the same keyword of the
|
|
3833
|
+
* schema referenced, so `properties` beside a reference hide the
|
|
3834
|
+
* `properties` behind it, and their defaults with them;
|
|
3835
|
+
* - a reference back into a schema it is already inside is cut there, so in a
|
|
3836
|
+
* schema that refers to itself the defaults are filled in down to where it
|
|
3837
|
+
* repeats, and a `default` written beside such a reference is lost with it.
|
|
3838
|
+
*
|
|
3839
|
+
* Neither the schema nor the given inputs are changed. Inputs no default is
|
|
3840
|
+
* filled into come back as the object that was given, and so does an object
|
|
3841
|
+
* among them; one a default is filled into is copied. A given object that
|
|
3842
|
+
* contains itself is not supported.
|
|
3843
|
+
* @public
|
|
3844
|
+
*/
|
|
3845
|
+
export declare class WorkflowInputsResolver {
|
|
3846
|
+
#private;
|
|
3847
|
+
/**
|
|
3848
|
+
* Returns `inputs` with the defaults of `schema` filled in, and those
|
|
3849
|
+
* defaults on their own. A workflow without an `inputs` schema, or with one
|
|
3850
|
+
* that is not an object, gets its inputs back as given.
|
|
3851
|
+
*/
|
|
3852
|
+
resolve(schema: unknown, inputs: Record<string, unknown>): ResolvedWorkflowInputs;
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3769
3855
|
/**
|
|
3770
3856
|
* The workflow was normalized.
|
|
3771
3857
|
* @public
|
|
@@ -3850,6 +3936,7 @@ export declare interface WorkflowSettledEvent extends WorkflowExecutionEventBase
|
|
|
3850
3936
|
readonly type: 'workflow:settled';
|
|
3851
3937
|
readonly status: WorkflowExecutionResult['status'];
|
|
3852
3938
|
readonly settledStatus: WorkflowExecutionResult['settledStatus'];
|
|
3939
|
+
readonly inputDefaults?: WorkflowExecutionResult['inputDefaults'];
|
|
3853
3940
|
readonly outputs: WorkflowExecutionResult['outputs'];
|
|
3854
3941
|
/**
|
|
3855
3942
|
* What the invocation threw, as `execute` rejects with it: an
|
package/types/runner.d.ts
CHANGED
|
@@ -2405,6 +2405,24 @@ export declare interface ResolvedRequestBody {
|
|
|
2405
2405
|
readonly contentType?: string;
|
|
2406
2406
|
}
|
|
2407
2407
|
|
|
2408
|
+
/**
|
|
2409
|
+
* The inputs a workflow runs with, as {@link WorkflowInputsResolver} resolves
|
|
2410
|
+
* them.
|
|
2411
|
+
* @public
|
|
2412
|
+
*/
|
|
2413
|
+
export declare interface ResolvedWorkflowInputs {
|
|
2414
|
+
/**
|
|
2415
|
+
* The inputs that were given, with the defaults filled in.
|
|
2416
|
+
*/
|
|
2417
|
+
readonly inputs: Record<string, unknown>;
|
|
2418
|
+
/**
|
|
2419
|
+
* The members of `inputs` that came from a default and were not given, in
|
|
2420
|
+
* the shape of `inputs`: a default filled into an object that was given
|
|
2421
|
+
* sits under that object's name. Empty when no default was filled in.
|
|
2422
|
+
*/
|
|
2423
|
+
readonly defaults: Record<string, unknown>;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2408
2426
|
/**
|
|
2409
2427
|
* Carries a `reason`, one of the class's static reason fields.
|
|
2410
2428
|
*
|
|
@@ -3335,7 +3353,9 @@ export declare interface WorkflowDescriptor {
|
|
|
3335
3353
|
*/
|
|
3336
3354
|
export declare interface WorkflowExecuteOptions {
|
|
3337
3355
|
/**
|
|
3338
|
-
* The workflow's inputs, read via `$inputs`.
|
|
3356
|
+
* The workflow's inputs, read via `$inputs`. An input that is not given
|
|
3357
|
+
* takes the `default` its name has in the workflow's `inputs` schema, see
|
|
3358
|
+
* {@link WorkflowInputsResolver}.
|
|
3339
3359
|
*/
|
|
3340
3360
|
readonly inputs?: Record<string, unknown>;
|
|
3341
3361
|
/**
|
|
@@ -3487,6 +3507,16 @@ export declare interface WorkflowExecutionEventBase extends ArazzoRunnerEventBas
|
|
|
3487
3507
|
*/
|
|
3488
3508
|
export declare interface WorkflowExecutionResult {
|
|
3489
3509
|
readonly workflowId: string;
|
|
3510
|
+
/**
|
|
3511
|
+
* The inputs the workflow was not given and took from the `default` of its
|
|
3512
|
+
* `inputs` schema, in the shape of the inputs: a default filled into an
|
|
3513
|
+
* object that was given sits under that object's name. Present only when
|
|
3514
|
+
* at least one default was filled in.
|
|
3515
|
+
*
|
|
3516
|
+
* The inputs the workflow was given are not reported: they are the
|
|
3517
|
+
* caller's, and may hold credentials. A default is part of the document.
|
|
3518
|
+
*/
|
|
3519
|
+
readonly inputDefaults?: Record<string, unknown>;
|
|
3490
3520
|
readonly outputs: Record<string, unknown>;
|
|
3491
3521
|
readonly steps: readonly StepRunRecord[];
|
|
3492
3522
|
readonly status: 'completed' | 'ended' | 'failed' | 'transferred';
|
|
@@ -3577,6 +3607,11 @@ export declare class WorkflowExecutionState {
|
|
|
3577
3607
|
inputs?: Record<string, unknown>;
|
|
3578
3608
|
outputs?: Record<string, unknown>;
|
|
3579
3609
|
}): void;
|
|
3610
|
+
/**
|
|
3611
|
+
* The inputs the workflow runs with, read via `$inputs.{name}`. Treat the
|
|
3612
|
+
* returned object as immutable.
|
|
3613
|
+
*/
|
|
3614
|
+
get inputs(): Readonly<Record<string, unknown>>;
|
|
3580
3615
|
/**
|
|
3581
3616
|
* The workflow's own accumulated outputs. Read-only by contract, like the
|
|
3582
3617
|
* context produced by `toContext`; treat the returned object as immutable.
|
|
@@ -3766,6 +3801,57 @@ export declare interface WorkflowExecutorOptions {
|
|
|
3766
3801
|
*/
|
|
3767
3802
|
export declare type WorkflowId = string;
|
|
3768
3803
|
|
|
3804
|
+
/**
|
|
3805
|
+
* Resolves the inputs a workflow runs with: the inputs it was given, with the
|
|
3806
|
+
* `default` of its `inputs` schema filled in for every input it was not given.
|
|
3807
|
+
*
|
|
3808
|
+
* JSON Schema makes `default` an annotation and leaves applying it to the
|
|
3809
|
+
* application, so the rule is the runner's own:
|
|
3810
|
+
*
|
|
3811
|
+
* - an input is not given when its name is absent or its value is `undefined`;
|
|
3812
|
+
* an explicit `null` is given. That holds for an input a step or an action
|
|
3813
|
+
* maps too: a parameter whose expression resolves to nothing, such as an
|
|
3814
|
+
* optional input passed on, leaves the default in place;
|
|
3815
|
+
* - its default is the `default` of the schema its name has under
|
|
3816
|
+
* `properties`, looked up through `allOf`, whose members always apply. The
|
|
3817
|
+
* schema's own `default` wins over its members', an earlier member over a
|
|
3818
|
+
* later one;
|
|
3819
|
+
* - an object that was given has the defaults of its own missing members
|
|
3820
|
+
* filled in the same way. One that was not given is not created to hold
|
|
3821
|
+
* them;
|
|
3822
|
+
* - a `default` under `oneOf`, `anyOf`, `if`, `then`, `else` or `not` is not
|
|
3823
|
+
* applied: which branch holds depends on the value, so picking one would be
|
|
3824
|
+
* a guess;
|
|
3825
|
+
* - a `default` of the `inputs` schema itself is not applied: a run always has
|
|
3826
|
+
* an inputs object, if an empty one.
|
|
3827
|
+
*
|
|
3828
|
+
* The schema is read as the workflow normalizer leaves it, dereferenced, so a
|
|
3829
|
+
* `default` behind a reference is found. Two things follow from how it
|
|
3830
|
+
* dereferences:
|
|
3831
|
+
*
|
|
3832
|
+
* - a keyword written beside a reference replaces the same keyword of the
|
|
3833
|
+
* schema referenced, so `properties` beside a reference hide the
|
|
3834
|
+
* `properties` behind it, and their defaults with them;
|
|
3835
|
+
* - a reference back into a schema it is already inside is cut there, so in a
|
|
3836
|
+
* schema that refers to itself the defaults are filled in down to where it
|
|
3837
|
+
* repeats, and a `default` written beside such a reference is lost with it.
|
|
3838
|
+
*
|
|
3839
|
+
* Neither the schema nor the given inputs are changed. Inputs no default is
|
|
3840
|
+
* filled into come back as the object that was given, and so does an object
|
|
3841
|
+
* among them; one a default is filled into is copied. A given object that
|
|
3842
|
+
* contains itself is not supported.
|
|
3843
|
+
* @public
|
|
3844
|
+
*/
|
|
3845
|
+
export declare class WorkflowInputsResolver {
|
|
3846
|
+
#private;
|
|
3847
|
+
/**
|
|
3848
|
+
* Returns `inputs` with the defaults of `schema` filled in, and those
|
|
3849
|
+
* defaults on their own. A workflow without an `inputs` schema, or with one
|
|
3850
|
+
* that is not an object, gets its inputs back as given.
|
|
3851
|
+
*/
|
|
3852
|
+
resolve(schema: unknown, inputs: Record<string, unknown>): ResolvedWorkflowInputs;
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3769
3855
|
/**
|
|
3770
3856
|
* The workflow was normalized.
|
|
3771
3857
|
* @public
|
|
@@ -3850,6 +3936,7 @@ export declare interface WorkflowSettledEvent extends WorkflowExecutionEventBase
|
|
|
3850
3936
|
readonly type: 'workflow:settled';
|
|
3851
3937
|
readonly status: WorkflowExecutionResult['status'];
|
|
3852
3938
|
readonly settledStatus: WorkflowExecutionResult['settledStatus'];
|
|
3939
|
+
readonly inputDefaults?: WorkflowExecutionResult['inputDefaults'];
|
|
3853
3940
|
readonly outputs: WorkflowExecutionResult['outputs'];
|
|
3854
3941
|
/**
|
|
3855
3942
|
* What the invocation threw, as `execute` rejects with it: an
|