Interface JourneyResult
interface JourneyResult {
abort:
| NotAValue
| UnexpectedResult
| RequiredDataMissing
| WrongType
| InvalidLifecycle
| RescueSkipped
| ReservedMetadataKey
| (
StepCouldNotBeBuilt & ({ readonly errorMessage: string; readonly error: unknown; } | { readonly errorMessage?: never; readonly error?: never; })
)
| PolicyCouldNotBeBuilt & { error: unknown }
| HookFailed & { error: unknown }
| ReporterFailed & { error: unknown }
| undefined;
failure: Failure | undefined;
journeyId: JourneyId;
status: JourneyStatus;
isAborted(): this is { status: Aborted };
isFailed(): this is { status: Failed };
isSucceeded(): this is { status: Succeeded };
output<S extends Readonly<Record<string, RequestType>>>(
shape: S,
): Output<S>;
}
abort:
| NotAValue
| UnexpectedResult
| RequiredDataMissing
| WrongType
| InvalidLifecycle
| RescueSkipped
| ReservedMetadataKey
| (
StepCouldNotBeBuilt & ({ readonly errorMessage: string; readonly error: unknown; } | { readonly errorMessage?: never; readonly error?: never; })
)
| PolicyCouldNotBeBuilt & { error: unknown }
| HookFailed & { error: unknown }
| ReporterFailed & { error: unknown }
| undefined;
failure: Failure | undefined;
journeyId: JourneyId;
status: JourneyStatus;
isAborted(): this is { status: Aborted };
isFailed(): this is { status: Failed };
isSucceeded(): this is { status: Succeeded };
output<S extends Readonly<Record<string, RequestType>>>(
shape: S,
): Output<S>;
}
Properties
Readonlyabort
abort:
| NotAValue
| UnexpectedResult
| RequiredDataMissing
| WrongType
| InvalidLifecycle
| RescueSkipped
| ReservedMetadataKey
| (
StepCouldNotBeBuilt & ({ readonly errorMessage: string; readonly error: unknown; } | { readonly errorMessage?: never; readonly error?: never; })
)
| PolicyCouldNotBeBuilt & { error: unknown }
| HookFailed & { error: unknown }
| ReporterFailed & { error: unknown }
| undefined
| NotAValue
| UnexpectedResult
| RequiredDataMissing
| WrongType
| InvalidLifecycle
| RescueSkipped
| ReservedMetadataKey
| (
StepCouldNotBeBuilt & ({ readonly errorMessage: string; readonly error: unknown; } | { readonly errorMessage?: never; readonly error?: never; })
)
| PolicyCouldNotBeBuilt & { error: unknown }
| HookFailed & { error: unknown }
| ReporterFailed & { error: unknown }
| undefined
Why the journey was aborted, when it was.
Type Declaration
- NotAValue
- UnexpectedResult
- RequiredDataMissing
- WrongType
- InvalidLifecycle
- RescueSkipped
- ReservedMetadataKey
- StepCouldNotBeBuilt & ({ readonly errorMessage: string; readonly error: unknown; } | { readonly errorMessage?: never; readonly error?: never; })
- PolicyCouldNotBeBuilt & { error: unknown }
-
Readonlyerror: unknownWhat the custom code that caused the abort threw, as it was thrown.
-
- HookFailed & { error: unknown }
-
Readonlyerror: unknownWhat the custom code that caused the abort threw, as it was thrown.
-
- ReporterFailed & { error: unknown }
-
Readonlyerror: unknownWhat the custom code that caused the abort threw, as it was thrown.
-
- undefined
Readonlyfailure
Why the journey failed, when it failed.
Readonlyjourney Id
The journey's ID.
Readonlystatus
How the journey ended.
Methods
is Aborted
-
Whether the journey was aborted.
Returns this is { status: Aborted }
is Failed
-
Whether the journey failed.
Returns this is { status: Failed }
is Succeeded
-
Whether the journey succeeded.
Returns this is { status: Succeeded }
output
-
Reads the journey's output from its data bag: under each key of
shape, the value its type reads, as DataBag.read reads it, so anOptionfor a type wrapped inoptional, and an instance made byfromValuefor a class named withclassOf.import assert from "node:assert/strict";
import { LocalExecutor } from "itinera/executor";
import { OutputError } from "itinera/journey";
import { None, type Option } from "itinera/option";
import { Step } from "itinera/step";
import { Workflow } from "itinera/workflow";
import { integer, optional, string } from "itinera/value";
class Charge extends Step {
override run() {
return this.succeed();
}
}
class Orders extends Workflow {}
export default (async () => {
const orders = Orders.builder()
.name("orders")
.step(Charge.builder("charge"))
.build();
const instance = orders.instance({ order: "A-1", amount: 1250 });
const result = await new LocalExecutor().run(instance);
const receipt: { readonly amount: number; readonly note: Option<string> } =
result.output({ amount: integer, note: optional(string) });
assert.equal(receipt.amount, 1250);
assert.equal(receipt.note, None);
assert.throws(
() => result.output({ order: integer }),
(thrown: unknown) =>
thrown instanceof OutputError &&
thrown.problem.kind === "other type" &&
thrown.problem.key === "order",
);
})();Type Parameters
- S extends Readonly<Record<string, RequestType>>
Parameters
- shape: S
Returns Output<S>
What running a journey gives: its journey ID and how it ended, its business outcome. Each step's status and the name of the step that failed are not in it, but in the journey's events.