UNPKG

@temporalio/workflow

Version:
145 lines 7.12 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var _a, _b; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeParentClosePolicy = exports.encodeParentClosePolicy = exports.ParentClosePolicy = exports.decodeChildWorkflowCancellationType = exports.encodeChildWorkflowCancellationType = exports.ChildWorkflowCancellationType = exports.ContinueAsNew = void 0; const type_helpers_1 = require("@temporalio/common/lib/type-helpers"); const enums_helpers_1 = require("@temporalio/common/lib/internal-workflow/enums-helpers"); /** * Not an actual error, used by the Workflow runtime to abort execution when {@link continueAsNew} is called */ let ContinueAsNew = class ContinueAsNew extends Error { command; constructor(command) { super('Workflow continued as new'); this.command = command; } }; exports.ContinueAsNew = ContinueAsNew; exports.ContinueAsNew = ContinueAsNew = __decorate([ (0, type_helpers_1.SymbolBasedInstanceOfError)('ContinueAsNew') ], ContinueAsNew); /** * Determines: * - whether cancellation requests should be propagated from the Parent Workflow to the Child, and * - whether and when should the Child's cancellation be reported back to the Parent Workflow * (i.e. at which moment should the {@link executeChild}'s or {@link ChildWorkflowHandle.result}'s * promise fail with a `ChildWorkflowFailure`, with `cause` set to a `CancelledFailure`). * * Note that this setting only applies to cancellation originating from an external request for the * Parent Workflow itself, or from internal cancellation of the `CancellationScope` in which the * Child Workflow call was made. Eventual Cancellation of a Child Workflow on completion of the * Parent Workflow is controlled by the {@link ParentClosePolicy} setting. * * @default ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED */ // MAINTENANCE: Keep this typedoc in sync with the `ChildWorkflowOptions.cancellationType` field exports.ChildWorkflowCancellationType = { /** * Do not propagate cancellation requests to the Child, and immediately report cancellation * to the caller. */ ABANDON: 'ABANDON', /** * Propagate cancellation request from the Parent Workflow to the Child, yet _immediately_ report * cancellation to the caller, i.e. without waiting for the server to confirm the cancellation * request. * * Note that this cancellation type provides no guarantee, from the Parent-side, that the * cancellation request will actually be atomically added to the Child workflow's history. * In particular, the Child may complete (either successfully or uncessfully) before the * cancellation is delivered, resulting in a situation where the Parent workflow thinks its child * was cancelled, but the child actually completed successfully. * * To guarantee that the Child will eventually be notified of the cancellation request, * use {@link WAIT_CANCELLATION_REQUESTED}. */ TRY_CANCEL: 'TRY_CANCEL', /** * Propagate cancellation request from the Parent Workflow to the Child, then wait for the server * to confirm that the Child Workflow cancellation request was recorded in its history. * * This cancellation type guarantees that the Child will eventually be notified of the * cancellation request (that is, unless the Child terminates inbetween due to unexpected causes). */ WAIT_CANCELLATION_REQUESTED: 'WAIT_CANCELLATION_REQUESTED', /** * Propagate cancellation request from the Parent Workflow to the Child, then wait for completion * of the Child Workflow. * * The Child may respect cancellation, in which case the Parent's `executeChild` or * `ChildWorkflowHandle.result` promise will fail with a `ChildWorkflowFailure`, with `cause` * set to a `CancelledFailure`. On the other hand, the Child may ignore the cancellation request, * in which case the corresponding promise will either resolve with a result (if Child completed * successfully) or reject with a different cause (if Child completed uncessfully). * * @default */ WAIT_CANCELLATION_COMPLETED: 'WAIT_CANCELLATION_COMPLETED', }; // ts-prune-ignore-next _a = (0, enums_helpers_1.makeProtoEnumConverters)({ [exports.ChildWorkflowCancellationType.ABANDON]: 0, [exports.ChildWorkflowCancellationType.TRY_CANCEL]: 1, [exports.ChildWorkflowCancellationType.WAIT_CANCELLATION_COMPLETED]: 2, [exports.ChildWorkflowCancellationType.WAIT_CANCELLATION_REQUESTED]: 3, }, ''), exports.encodeChildWorkflowCancellationType = _a[0], exports.decodeChildWorkflowCancellationType = _a[1]; /** * How a Child Workflow reacts to the Parent Workflow reaching a Closed state. * * @see {@link https://docs.temporal.io/concepts/what-is-a-parent-close-policy/ | Parent Close Policy} */ exports.ParentClosePolicy = { /** * When the Parent is Closed, the Child is Terminated. * * @default */ TERMINATE: 'TERMINATE', /** * When the Parent is Closed, nothing is done to the Child. */ ABANDON: 'ABANDON', /** * When the Parent is Closed, the Child is Cancelled. */ REQUEST_CANCEL: 'REQUEST_CANCEL', /// Anything below this line has been deprecated /** * If a `ParentClosePolicy` is set to this, or is not set at all, the server default value will be used. * * @deprecated Either leave property `undefined`, or set an explicit policy instead. */ PARENT_CLOSE_POLICY_UNSPECIFIED: undefined, /** * When the Parent is Closed, the Child is Terminated. * * @deprecated Use {@link ParentClosePolicy.TERMINATE} instead. */ PARENT_CLOSE_POLICY_TERMINATE: 'TERMINATE', /** * When the Parent is Closed, nothing is done to the Child. * * @deprecated Use {@link ParentClosePolicy.ABANDON} instead. */ PARENT_CLOSE_POLICY_ABANDON: 'ABANDON', /** * When the Parent is Closed, the Child is Cancelled. * * @deprecated Use {@link ParentClosePolicy.REQUEST_CANCEL} instead. */ PARENT_CLOSE_POLICY_REQUEST_CANCEL: 'REQUEST_CANCEL', }; // ts-prune-ignore-next _b = (0, enums_helpers_1.makeProtoEnumConverters)({ [exports.ParentClosePolicy.TERMINATE]: 1, [exports.ParentClosePolicy.ABANDON]: 2, [exports.ParentClosePolicy.REQUEST_CANCEL]: 3, UNSPECIFIED: 0, }, 'PARENT_CLOSE_POLICY_'), exports.encodeParentClosePolicy = _b[0], exports.decodeParentClosePolicy = _b[1]; //# sourceMappingURL=interfaces.js.map