@usearazzo/runner 1.0.1-alpha.37 → 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.
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _apidomCore = require("@speclynx/apidom-core");
8
+ var _apidomDatamodel = require("@speclynx/apidom-datamodel");
9
+ var _apidomNsArazzo = require("@speclynx/apidom-ns-arazzo-1");
10
+ var _apidomTraverse = require("@speclynx/apidom-traverse");
11
+ /**
12
+ * The inputs a workflow runs with, as {@link WorkflowInputsResolver} resolves
13
+ * them.
14
+ * @public
15
+ */
16
+
17
+ /**
18
+ * Resolves the inputs a workflow runs with: the inputs it was given, with the
19
+ * `default` of its `inputs` schema filled in for every input it was not given.
20
+ *
21
+ * JSON Schema makes `default` an annotation and leaves applying it to the
22
+ * application, so the rule is the runner's own:
23
+ *
24
+ * - an input is not given when its name is absent or its value is `undefined`;
25
+ * an explicit `null` is given. That holds for an input a step or an action
26
+ * maps too: a parameter whose expression resolves to nothing, such as an
27
+ * optional input passed on, leaves the default in place;
28
+ * - its default is the `default` of the schema its name has under
29
+ * `properties`, looked up through `allOf`, whose members always apply. The
30
+ * schema's own `default` wins over its members', an earlier member over a
31
+ * later one;
32
+ * - an object that was given has the defaults of its own missing members
33
+ * filled in the same way. One that was not given is not created to hold
34
+ * them;
35
+ * - a `default` under `oneOf`, `anyOf`, `if`, `then`, `else` or `not` is not
36
+ * applied: which branch holds depends on the value, so picking one would be
37
+ * a guess;
38
+ * - a `default` of the `inputs` schema itself is not applied: a run always has
39
+ * an inputs object, if an empty one.
40
+ *
41
+ * The schema is read as the workflow normalizer leaves it, dereferenced, so a
42
+ * `default` behind a reference is found. Two things follow from how it
43
+ * dereferences:
44
+ *
45
+ * - a keyword written beside a reference replaces the same keyword of the
46
+ * schema referenced, so `properties` beside a reference hide the
47
+ * `properties` behind it, and their defaults with them;
48
+ * - a reference back into a schema it is already inside is cut there, so in a
49
+ * schema that refers to itself the defaults are filled in down to where it
50
+ * repeats, and a `default` written beside such a reference is lost with it.
51
+ *
52
+ * Neither the schema nor the given inputs are changed. Inputs no default is
53
+ * filled into come back as the object that was given, and so does an object
54
+ * among them; one a default is filled into is copied. A given object that
55
+ * contains itself is not supported.
56
+ * @public
57
+ */
58
+ class WorkflowInputsResolver {
59
+ /**
60
+ * Returns `inputs` with the defaults of `schema` filled in, and those
61
+ * defaults on their own. A workflow without an `inputs` schema, or with one
62
+ * that is not an object, gets its inputs back as given.
63
+ */
64
+ resolve(schema, inputs) {
65
+ const defaults = this.#defaults(this.#applicable(schema), inputs);
66
+ return {
67
+ inputs: this.#filled(inputs, defaults),
68
+ defaults
69
+ };
70
+ }
71
+
72
+ /**
73
+ * The schemas that always apply to a value `schema` describes, the one
74
+ * whose keywords win first: `schema` itself, then the members of its
75
+ * `allOf` as written, each before its own.
76
+ *
77
+ * The traversal goes into `allOf` only: every other keyword either
78
+ * describes a different value (`properties`, `items`) or applies only to
79
+ * some values (`oneOf`, `anyOf`, `if`). It takes each schema once
80
+ * (`skipVisited`), where it is first met: a dereferenced schema shares
81
+ * structure, and a schema referenced in two places would otherwise be walked
82
+ * again at each of them.
83
+ */
84
+ #applicable(schema) {
85
+ if (!(0, _apidomNsArazzo.isJSONSchemaElement)(schema)) return [];
86
+ const applicable = [];
87
+ const collect = path => {
88
+ applicable.push(path.node);
89
+ };
90
+ (0, _apidomTraverse.traverse)(schema, {
91
+ // a schema written in the Arazzo document, or referenced from an
92
+ // OpenAPI 2.0 or 3.0 one
93
+ JSONSchemaElement: collect,
94
+ // a schema referenced from an OpenAPI 3.1 document
95
+ SchemaElement: collect,
96
+ MemberElement(path) {
97
+ if ((0, _apidomCore.toValue)(path.node.key) !== 'allOf') path.skip();
98
+ }
99
+ }, {
100
+ skipVisited: 'skip'
101
+ });
102
+ return applicable;
103
+ }
104
+
105
+ /**
106
+ * The defaults `schemas` declare for what `value` was not given, in the
107
+ * shape of `value`: the default of an input that is missing, and, for an
108
+ * object that was given, the defaults of its own missing members under its
109
+ * name. `schemas` come as {@link WorkflowInputsResolver.#applicable} orders
110
+ * them, so the first one that declares a default for a name wins.
111
+ */
112
+ #defaults(schemas, value) {
113
+ const names = new Set(schemas.flatMap(schema => this.#properties(schema)?.keys() ?? []));
114
+ const defaults = [];
115
+ for (const name of names) {
116
+ // each once: schemas dereferenced from one reference share their
117
+ // `properties`, and would bring the same property schema once each.
118
+ const propertySchemas = [...new Set(schemas.flatMap(schema => this.#applicable(this.#properties(schema)?.get(name))))];
119
+ if (!this.#isGiven(value, name)) {
120
+ const declaring = propertySchemas.find(schema => schema.default !== undefined);
121
+ if (declaring !== undefined) defaults.push([name, (0, _apidomCore.toValue)(declaring.default)]);
122
+ } else if (this.#isPlainObject(value[name])) {
123
+ const members = this.#defaults(propertySchemas, value[name]);
124
+ if (Object.keys(members).length > 0) defaults.push([name, members]);
125
+ }
126
+ }
127
+ // an entry list, so a name like `__proto__` becomes an own property.
128
+ return Object.fromEntries(defaults);
129
+ }
130
+
131
+ /**
132
+ * `value` with `defaults` filled in: `value` itself when there are none,
133
+ * otherwise a copy of it that has them. A default is copied too, so the
134
+ * result shares nothing with `defaults`, and an object that was given is
135
+ * replaced by one that has its members' defaults.
136
+ */
137
+ #filled(value, defaults) {
138
+ if (Object.keys(defaults).length === 0) return value;
139
+ const filled = Object.entries(defaults).map(([name, found]) => [name, this.#isGiven(value, name) ? this.#filled(value[name], found) : structuredClone(found)]);
140
+ // spread, so a name like `__proto__` stays an own property; the copy
141
+ // keeps the prototype of what was given, which may be none.
142
+ return Object.setPrototypeOf({
143
+ ...value,
144
+ ...Object.fromEntries(filled)
145
+ }, Object.getPrototypeOf(value));
146
+ }
147
+
148
+ /**
149
+ * The `properties` of `schema`, when it declares them as a map.
150
+ */
151
+ #properties(schema) {
152
+ return (0, _apidomDatamodel.isObjectElement)(schema.properties) ? schema.properties : undefined;
153
+ }
154
+
155
+ /**
156
+ * Whether `value` was given an input of that name: present, and not
157
+ * `undefined`.
158
+ */
159
+ #isGiven(value, name) {
160
+ return Object.hasOwn(value, name) && value[name] !== undefined;
161
+ }
162
+
163
+ /**
164
+ * Whether `value` is an object written as a literal or parsed from JSON or
165
+ * YAML. Anything else an input can hold (an array, a `Date`, a `Blob`) is
166
+ * left as given: it has no members a schema's `properties` describes.
167
+ */
168
+ #isPlainObject(value) {
169
+ if (typeof value !== 'object' || value === null) return false;
170
+ const prototype = Object.getPrototypeOf(value);
171
+ return prototype === Object.prototype || prototype === null;
172
+ }
173
+ }
174
+ var _default = exports.default = WorkflowInputsResolver;
@@ -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.36';
8
+ const version = '1.0.1-alpha.38';
9
9
  var _default = exports.default = version;
package/src/version.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  // generated by scripts/version-update.mjs from package.json; do not edit
2
- const version = '1.0.1-alpha.36';
2
+ const version = '1.0.1-alpha.38';
3
3
  export default version;
@@ -1136,7 +1136,7 @@ export declare class ExecutionError extends ArazzoRunnerError {
1136
1136
  static readonly InvalidWorkflowReference: "invalid-workflow-reference";
1137
1137
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
1138
1138
  static readonly MalformedDependsOn: "malformed-dependsOn";
1139
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
1139
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
1140
1140
  static readonly MalformedSteps: "malformed-steps";
1141
1141
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
1142
1142
  static readonly MissingOperation: "missing-operation";
@@ -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
@@ -1136,7 +1136,7 @@ export declare class ExecutionError extends ArazzoRunnerError {
1136
1136
  static readonly InvalidWorkflowReference: "invalid-workflow-reference";
1137
1137
  /** A workflow's `dependsOn` is not a list or holds a non-string entry. */
1138
1138
  static readonly MalformedDependsOn: "malformed-dependsOn";
1139
- /** A workflow's `steps` is not a list or holds an entry that is not a Step Object. */
1139
+ /** A workflow's `steps` is absent, empty, not a list, or holds an entry that is not a Step Object. */
1140
1140
  static readonly MalformedSteps: "malformed-steps";
1141
1141
  /** A step run as an operation declares neither an `operationId` nor an `operationPath`. */
1142
1142
  static readonly MissingOperation: "missing-operation";
@@ -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