@mastra/core 0.1.27-alpha.30 → 0.1.27-alpha.32
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/dist/core.cjs.development.js +506 -342
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +506 -342
- package/dist/core.esm.js.map +1 -1
- package/dist/mastra/index.d.ts +6 -0
- package/dist/workflows/types.d.ts +19 -6
- package/dist/workflows/workflow.d.ts +3 -2
- package/package.json +1 -2
|
@@ -3957,6 +3957,18 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
|
|
|
3957
3957
|
}
|
|
3958
3958
|
return agent;
|
|
3959
3959
|
};
|
|
3960
|
+
_proto.getAgents = function getAgents() {
|
|
3961
|
+
return Array.from(this.agents.entries()).map(function (_ref3) {
|
|
3962
|
+
var name = _ref3[0],
|
|
3963
|
+
agent = _ref3[1];
|
|
3964
|
+
return {
|
|
3965
|
+
name: name,
|
|
3966
|
+
instructions: agent.instructions,
|
|
3967
|
+
modelProvider: agent.model.provider,
|
|
3968
|
+
modelName: agent.model.name
|
|
3969
|
+
};
|
|
3970
|
+
});
|
|
3971
|
+
};
|
|
3960
3972
|
_proto.getWorkflow = function getWorkflow(name) {
|
|
3961
3973
|
var workflow = _classPrivateFieldLooseBase(this, _workflows)[_workflows].get(name);
|
|
3962
3974
|
if (!workflow) {
|
|
@@ -3980,7 +3992,7 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
|
|
|
3980
3992
|
throw new Error("Tool with name " + String(name) + " not found");
|
|
3981
3993
|
}
|
|
3982
3994
|
var hydratedExecutor = /*#__PURE__*/function () {
|
|
3983
|
-
var
|
|
3995
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params, runId) {
|
|
3984
3996
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3985
3997
|
while (1) switch (_context2.prev = _context2.next) {
|
|
3986
3998
|
case 0:
|
|
@@ -4006,7 +4018,7 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
|
|
|
4006
4018
|
}, _callee2);
|
|
4007
4019
|
}));
|
|
4008
4020
|
return function hydratedExecutor(_x4, _x5) {
|
|
4009
|
-
return
|
|
4021
|
+
return _ref4.apply(this, arguments);
|
|
4010
4022
|
};
|
|
4011
4023
|
}();
|
|
4012
4024
|
return _extends({}, tool, {
|
|
@@ -4019,9 +4031,9 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
|
|
|
4019
4031
|
});
|
|
4020
4032
|
};
|
|
4021
4033
|
_proto.availableIntegrations = function availableIntegrations() {
|
|
4022
|
-
return Array.from(this.integrations.entries()).map(function (
|
|
4023
|
-
var name =
|
|
4024
|
-
integration =
|
|
4034
|
+
return Array.from(this.integrations.entries()).map(function (_ref5) {
|
|
4035
|
+
var name = _ref5[0],
|
|
4036
|
+
integration = _ref5[1];
|
|
4025
4037
|
return {
|
|
4026
4038
|
name: name,
|
|
4027
4039
|
integration: integration
|
|
@@ -4031,8 +4043,8 @@ exports.Mastra = (_workflows = /*#__PURE__*/_classPrivateFieldLooseKey("workflow
|
|
|
4031
4043
|
_proto.getTools = function getTools() {
|
|
4032
4044
|
return this.tools;
|
|
4033
4045
|
};
|
|
4034
|
-
_proto.setLogger = function setLogger(
|
|
4035
|
-
var logger =
|
|
4046
|
+
_proto.setLogger = function setLogger(_ref6) {
|
|
4047
|
+
var logger = _ref6.logger;
|
|
4036
4048
|
this.logger = logger;
|
|
4037
4049
|
};
|
|
4038
4050
|
_proto.getLogger = function getLogger() {
|
|
@@ -4092,13 +4104,17 @@ var _engine = /*#__PURE__*/_classPrivateFieldLooseKey("engine");
|
|
|
4092
4104
|
var _connectionId = /*#__PURE__*/_classPrivateFieldLooseKey("connectionId");
|
|
4093
4105
|
var _entityName = /*#__PURE__*/_classPrivateFieldLooseKey("entityName");
|
|
4094
4106
|
var _telemetry = /*#__PURE__*/_classPrivateFieldLooseKey("telemetry");
|
|
4107
|
+
var _afterStepStack = /*#__PURE__*/_classPrivateFieldLooseKey("afterStepStack");
|
|
4095
4108
|
var _lastStepStack = /*#__PURE__*/_classPrivateFieldLooseKey("lastStepStack");
|
|
4096
4109
|
var _stepGraph = /*#__PURE__*/_classPrivateFieldLooseKey("stepGraph");
|
|
4110
|
+
var _stepSubscriberGraph = /*#__PURE__*/_classPrivateFieldLooseKey("stepSubscriberGraph");
|
|
4097
4111
|
var _steps = /*#__PURE__*/_classPrivateFieldLooseKey("steps");
|
|
4098
4112
|
var _recursivelyCheckForFinalState = /*#__PURE__*/_classPrivateFieldLooseKey("recursivelyCheckForFinalState");
|
|
4099
4113
|
var _buildBaseState = /*#__PURE__*/_classPrivateFieldLooseKey("buildBaseState");
|
|
4100
4114
|
var _makeStepKey = /*#__PURE__*/_classPrivateFieldLooseKey("makeStepKey");
|
|
4101
4115
|
var _buildStateHierarchy = /*#__PURE__*/_classPrivateFieldLooseKey("buildStateHierarchy");
|
|
4116
|
+
var _getDefaultActions = /*#__PURE__*/_classPrivateFieldLooseKey("getDefaultActions");
|
|
4117
|
+
var _getDefaultActors = /*#__PURE__*/_classPrivateFieldLooseKey("getDefaultActors");
|
|
4102
4118
|
var _persistWorkflowSnapshot = /*#__PURE__*/_classPrivateFieldLooseKey("persistWorkflowSnapshot");
|
|
4103
4119
|
var _loadWorkflowSnapshot = /*#__PURE__*/_classPrivateFieldLooseKey("loadWorkflowSnapshot");
|
|
4104
4120
|
var _resolveVariables = /*#__PURE__*/_classPrivateFieldLooseKey("resolveVariables");
|
|
@@ -4170,6 +4186,12 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4170
4186
|
Object.defineProperty(this, _persistWorkflowSnapshot, {
|
|
4171
4187
|
value: _persistWorkflowSnapshot2
|
|
4172
4188
|
});
|
|
4189
|
+
Object.defineProperty(this, _getDefaultActors, {
|
|
4190
|
+
value: _getDefaultActors2
|
|
4191
|
+
});
|
|
4192
|
+
Object.defineProperty(this, _getDefaultActions, {
|
|
4193
|
+
value: _getDefaultActions2
|
|
4194
|
+
});
|
|
4173
4195
|
/**
|
|
4174
4196
|
* Builds the state hierarchy for the workflow
|
|
4175
4197
|
* @returns Object representing the state hierarchy
|
|
@@ -4230,7 +4252,10 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4230
4252
|
value: void 0
|
|
4231
4253
|
});
|
|
4232
4254
|
// registers stepIds on `after` calls
|
|
4233
|
-
|
|
4255
|
+
Object.defineProperty(this, _afterStepStack, {
|
|
4256
|
+
writable: true,
|
|
4257
|
+
value: []
|
|
4258
|
+
});
|
|
4234
4259
|
Object.defineProperty(this, _lastStepStack, {
|
|
4235
4260
|
writable: true,
|
|
4236
4261
|
value: []
|
|
@@ -4241,6 +4266,10 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4241
4266
|
initial: []
|
|
4242
4267
|
}
|
|
4243
4268
|
});
|
|
4269
|
+
Object.defineProperty(this, _stepSubscriberGraph, {
|
|
4270
|
+
writable: true,
|
|
4271
|
+
value: {}
|
|
4272
|
+
});
|
|
4244
4273
|
// #delimiter = '-([-]::[-])-';
|
|
4245
4274
|
Object.defineProperty(this, _steps, {
|
|
4246
4275
|
writable: true,
|
|
@@ -4266,191 +4295,27 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4266
4295
|
*/
|
|
4267
4296
|
var _proto = Workflow.prototype;
|
|
4268
4297
|
_proto.initializeMachine = function initializeMachine() {
|
|
4269
|
-
var _this = this;
|
|
4270
4298
|
var machine = xstate.setup({
|
|
4271
4299
|
types: {},
|
|
4272
4300
|
delays: _classPrivateFieldLooseBase(this, _makeDelayMap)[_makeDelayMap](),
|
|
4273
|
-
actions:
|
|
4274
|
-
|
|
4275
|
-
stepResults: function stepResults(_ref2) {
|
|
4276
|
-
var _extends2;
|
|
4277
|
-
var context = _ref2.context,
|
|
4278
|
-
event = _ref2.event;
|
|
4279
|
-
if (!isTransitionEvent(event)) return context.stepResults;
|
|
4280
|
-
var _event$output = event.output,
|
|
4281
|
-
stepId = _event$output.stepId,
|
|
4282
|
-
result = _event$output.result;
|
|
4283
|
-
return _extends({}, context.stepResults, (_extends2 = {}, _extends2[stepId] = {
|
|
4284
|
-
status: 'success',
|
|
4285
|
-
payload: result
|
|
4286
|
-
}, _extends2));
|
|
4287
|
-
}
|
|
4288
|
-
}),
|
|
4289
|
-
setStepError: xstate.assign({
|
|
4290
|
-
stepResults: function stepResults(_ref3, params) {
|
|
4291
|
-
var _extends3;
|
|
4292
|
-
var context = _ref3.context,
|
|
4293
|
-
event = _ref3.event;
|
|
4294
|
-
if (!isErrorEvent(event)) return context.stepResults;
|
|
4295
|
-
var stepId = params.stepId;
|
|
4296
|
-
if (!stepId) return context.stepResults;
|
|
4297
|
-
return _extends({}, context.stepResults, (_extends3 = {}, _extends3[stepId] = {
|
|
4298
|
-
status: 'failed',
|
|
4299
|
-
error: event.error.message
|
|
4300
|
-
}, _extends3));
|
|
4301
|
-
}
|
|
4302
|
-
}),
|
|
4303
|
-
notifyStepCompletion: function notifyStepCompletion(_, params) {
|
|
4304
|
-
var stepId = params.stepId;
|
|
4305
|
-
_classPrivateFieldLooseBase(_this, _log)[_log](LogLevel.INFO, "Step " + stepId + " completed");
|
|
4306
|
-
},
|
|
4307
|
-
decrementAttemptCount: xstate.assign({
|
|
4308
|
-
attempts: function attempts(_ref4, params) {
|
|
4309
|
-
var _extends4;
|
|
4310
|
-
var context = _ref4.context,
|
|
4311
|
-
event = _ref4.event;
|
|
4312
|
-
if (!isTransitionEvent(event)) return context.attempts;
|
|
4313
|
-
var stepId = params.stepId;
|
|
4314
|
-
var attemptCount = context.attempts[stepId];
|
|
4315
|
-
if (attemptCount === undefined) return context.attempts;
|
|
4316
|
-
return _extends({}, context.attempts, (_extends4 = {}, _extends4[stepId] = attemptCount - 1, _extends4));
|
|
4317
|
-
}
|
|
4318
|
-
})
|
|
4319
|
-
},
|
|
4320
|
-
actors: {
|
|
4321
|
-
resolverFunction: xstate.fromPromise(/*#__PURE__*/function () {
|
|
4322
|
-
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref5) {
|
|
4323
|
-
var input, stepNode, context, resolvedData, result;
|
|
4324
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4325
|
-
while (1) switch (_context.prev = _context.next) {
|
|
4326
|
-
case 0:
|
|
4327
|
-
input = _ref5.input;
|
|
4328
|
-
stepNode = input.stepNode, context = input.context;
|
|
4329
|
-
resolvedData = _classPrivateFieldLooseBase(_this, _resolveVariables)[_resolveVariables]({
|
|
4330
|
-
stepConfig: stepNode.config,
|
|
4331
|
-
context: context
|
|
4332
|
-
});
|
|
4333
|
-
_context.next = 5;
|
|
4334
|
-
return stepNode.config.handler({
|
|
4335
|
-
context: _extends({
|
|
4336
|
-
stepResults: context.stepResults
|
|
4337
|
-
}, resolvedData),
|
|
4338
|
-
runId: _classPrivateFieldLooseBase(_this, _runId)[_runId]
|
|
4339
|
-
});
|
|
4340
|
-
case 5:
|
|
4341
|
-
result = _context.sent;
|
|
4342
|
-
return _context.abrupt("return", {
|
|
4343
|
-
stepId: stepNode.step.id,
|
|
4344
|
-
result: result
|
|
4345
|
-
});
|
|
4346
|
-
case 7:
|
|
4347
|
-
case "end":
|
|
4348
|
-
return _context.stop();
|
|
4349
|
-
}
|
|
4350
|
-
}, _callee);
|
|
4351
|
-
}));
|
|
4352
|
-
return function (_x) {
|
|
4353
|
-
return _ref6.apply(this, arguments);
|
|
4354
|
-
};
|
|
4355
|
-
}()),
|
|
4356
|
-
dependencyCheck: xstate.fromPromise(/*#__PURE__*/function () {
|
|
4357
|
-
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref7) {
|
|
4358
|
-
var input, context, stepNode, stepConfig, attemptCount, conditionMet, _conditionMet;
|
|
4359
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4360
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
4361
|
-
case 0:
|
|
4362
|
-
input = _ref7.input;
|
|
4363
|
-
context = input.context, stepNode = input.stepNode;
|
|
4364
|
-
stepConfig = stepNode.config; // TODO: Need a way to create unique ids for steps
|
|
4365
|
-
attemptCount = context.attempts[stepNode.step.id];
|
|
4366
|
-
if (!(!attemptCount || attemptCount < 0)) {
|
|
4367
|
-
_context2.next = 8;
|
|
4368
|
-
break;
|
|
4369
|
-
}
|
|
4370
|
-
if (!(stepConfig != null && stepConfig.snapshotOnTimeout)) {
|
|
4371
|
-
_context2.next = 7;
|
|
4372
|
-
break;
|
|
4373
|
-
}
|
|
4374
|
-
return _context2.abrupt("return", {
|
|
4375
|
-
type: 'SUSPENDED',
|
|
4376
|
-
stepId: stepNode.step.id
|
|
4377
|
-
});
|
|
4378
|
-
case 7:
|
|
4379
|
-
return _context2.abrupt("return", {
|
|
4380
|
-
type: 'TIMED_OUT',
|
|
4381
|
-
error: "Step:" + stepNode.step.id + " timed out"
|
|
4382
|
-
});
|
|
4383
|
-
case 8:
|
|
4384
|
-
if (stepConfig != null && stepConfig.when) {
|
|
4385
|
-
_context2.next = 10;
|
|
4386
|
-
break;
|
|
4387
|
-
}
|
|
4388
|
-
return _context2.abrupt("return", {
|
|
4389
|
-
type: 'DEPENDENCIES_MET'
|
|
4390
|
-
});
|
|
4391
|
-
case 10:
|
|
4392
|
-
if (!(typeof (stepConfig == null ? void 0 : stepConfig.when) === 'function')) {
|
|
4393
|
-
_context2.next = 18;
|
|
4394
|
-
break;
|
|
4395
|
-
}
|
|
4396
|
-
_context2.next = 13;
|
|
4397
|
-
return stepConfig.when({
|
|
4398
|
-
context: context
|
|
4399
|
-
});
|
|
4400
|
-
case 13:
|
|
4401
|
-
conditionMet = _context2.sent;
|
|
4402
|
-
if (conditionMet) {
|
|
4403
|
-
_context2.next = 16;
|
|
4404
|
-
break;
|
|
4405
|
-
}
|
|
4406
|
-
return _context2.abrupt("return", {
|
|
4407
|
-
type: 'CONDITION_FAILED',
|
|
4408
|
-
error: "Step:" + stepNode.step.id + " condition function check failed"
|
|
4409
|
-
});
|
|
4410
|
-
case 16:
|
|
4411
|
-
_context2.next = 21;
|
|
4412
|
-
break;
|
|
4413
|
-
case 18:
|
|
4414
|
-
_conditionMet = _classPrivateFieldLooseBase(_this, _evaluateCondition)[_evaluateCondition](stepConfig.when, context);
|
|
4415
|
-
if (_conditionMet) {
|
|
4416
|
-
_context2.next = 21;
|
|
4417
|
-
break;
|
|
4418
|
-
}
|
|
4419
|
-
return _context2.abrupt("return", {
|
|
4420
|
-
type: 'CONDITION_FAILED',
|
|
4421
|
-
error: "Step:" + stepNode.step.id + " condition check failed"
|
|
4422
|
-
});
|
|
4423
|
-
case 21:
|
|
4424
|
-
return _context2.abrupt("return", {
|
|
4425
|
-
type: 'DEPENDENCIES_MET'
|
|
4426
|
-
});
|
|
4427
|
-
case 22:
|
|
4428
|
-
case "end":
|
|
4429
|
-
return _context2.stop();
|
|
4430
|
-
}
|
|
4431
|
-
}, _callee2);
|
|
4432
|
-
}));
|
|
4433
|
-
return function (_x2) {
|
|
4434
|
-
return _ref8.apply(this, arguments);
|
|
4435
|
-
};
|
|
4436
|
-
}())
|
|
4437
|
-
}
|
|
4301
|
+
actions: _classPrivateFieldLooseBase(this, _getDefaultActions)[_getDefaultActions](),
|
|
4302
|
+
actors: _classPrivateFieldLooseBase(this, _getDefaultActors)[_getDefaultActors]()
|
|
4438
4303
|
}).createMachine({
|
|
4439
4304
|
id: this.name,
|
|
4440
4305
|
type: 'parallel',
|
|
4441
|
-
context: function context(
|
|
4442
|
-
var input =
|
|
4306
|
+
context: function context(_ref2) {
|
|
4307
|
+
var input = _ref2.input;
|
|
4443
4308
|
return _extends({}, input);
|
|
4444
4309
|
},
|
|
4445
|
-
states: _classPrivateFieldLooseBase(this, _buildStateHierarchy)[_buildStateHierarchy]()
|
|
4310
|
+
states: _classPrivateFieldLooseBase(this, _buildStateHierarchy)[_buildStateHierarchy](_classPrivateFieldLooseBase(this, _stepGraph)[_stepGraph])
|
|
4446
4311
|
});
|
|
4447
4312
|
_classPrivateFieldLooseBase(this, _machine)[_machine] = machine;
|
|
4448
4313
|
return machine;
|
|
4449
4314
|
};
|
|
4450
4315
|
_proto.step = function step(_step, config) {
|
|
4451
|
-
var
|
|
4452
|
-
|
|
4453
|
-
variables =
|
|
4316
|
+
var _ref3 = config || {},
|
|
4317
|
+
_ref3$variables = _ref3.variables,
|
|
4318
|
+
variables = _ref3$variables === void 0 ? {} : _ref3$variables;
|
|
4454
4319
|
var requiredData = {};
|
|
4455
4320
|
// Add valid variables to requiredData
|
|
4456
4321
|
for (var _i = 0, _Object$entries = Object.entries(variables); _i < _Object$entries.length; _i++) {
|
|
@@ -4469,15 +4334,30 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4469
4334
|
})
|
|
4470
4335
|
};
|
|
4471
4336
|
_classPrivateFieldLooseBase(this, _steps)[_steps][stepKey] = _step;
|
|
4472
|
-
|
|
4473
|
-
_classPrivateFieldLooseBase(this,
|
|
4337
|
+
var parentStepKey = _classPrivateFieldLooseBase(this, _afterStepStack)[_afterStepStack][_classPrivateFieldLooseBase(this, _afterStepStack)[_afterStepStack].length - 1];
|
|
4338
|
+
var stepGraph = _classPrivateFieldLooseBase(this, _stepSubscriberGraph)[_stepSubscriberGraph][parentStepKey || ''];
|
|
4339
|
+
// if we are in an after chain and we have a stepGraph
|
|
4340
|
+
if (parentStepKey && stepGraph) {
|
|
4341
|
+
// if the stepGraph has an initial, but it doesn't contain the current step, add it to the initial
|
|
4342
|
+
if (!stepGraph.initial.some(function (step) {
|
|
4343
|
+
return step.step.id === stepKey;
|
|
4344
|
+
})) {
|
|
4345
|
+
stepGraph.initial.push(graphEntry);
|
|
4346
|
+
}
|
|
4347
|
+
// add the current step to the stepGraph
|
|
4348
|
+
stepGraph[stepKey] = [];
|
|
4349
|
+
} else {
|
|
4350
|
+
// Normal step addition to main graph
|
|
4351
|
+
if (!_classPrivateFieldLooseBase(this, _stepGraph)[_stepGraph][stepKey]) _classPrivateFieldLooseBase(this, _stepGraph)[_stepGraph][stepKey] = [];
|
|
4352
|
+
_classPrivateFieldLooseBase(this, _stepGraph)[_stepGraph].initial.push(graphEntry);
|
|
4353
|
+
}
|
|
4474
4354
|
_classPrivateFieldLooseBase(this, _lastStepStack)[_lastStepStack].push(stepKey);
|
|
4475
4355
|
return this;
|
|
4476
4356
|
};
|
|
4477
4357
|
_proto.then = function then(step, config) {
|
|
4478
|
-
var
|
|
4479
|
-
|
|
4480
|
-
variables =
|
|
4358
|
+
var _ref4 = config || {},
|
|
4359
|
+
_ref4$variables = _ref4.variables,
|
|
4360
|
+
variables = _ref4$variables === void 0 ? {} : _ref4$variables;
|
|
4481
4361
|
var requiredData = {};
|
|
4482
4362
|
// Add valid variables to requiredData
|
|
4483
4363
|
for (var _i2 = 0, _Object$entries2 = Object.entries(variables); _i2 < _Object$entries2.length; _i2++) {
|
|
@@ -4499,10 +4379,27 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4499
4379
|
_classPrivateFieldLooseBase(this, _steps)[_steps][stepKey] = step;
|
|
4500
4380
|
// if then is called without a step, we are done
|
|
4501
4381
|
if (!lastStepKey) return this;
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4382
|
+
var parentStepKey = _classPrivateFieldLooseBase(this, _afterStepStack)[_afterStepStack][_classPrivateFieldLooseBase(this, _afterStepStack)[_afterStepStack].length - 1];
|
|
4383
|
+
var stepGraph = _classPrivateFieldLooseBase(this, _stepSubscriberGraph)[_stepSubscriberGraph][parentStepKey || ''];
|
|
4384
|
+
if (parentStepKey && stepGraph && stepGraph[lastStepKey]) {
|
|
4385
|
+
stepGraph[lastStepKey].push(graphEntry);
|
|
4386
|
+
} else {
|
|
4387
|
+
// add the step to the graph if not already there.. it should be there though, unless magic
|
|
4388
|
+
if (!_classPrivateFieldLooseBase(this, _stepGraph)[_stepGraph][lastStepKey]) _classPrivateFieldLooseBase(this, _stepGraph)[_stepGraph][lastStepKey] = [];
|
|
4389
|
+
// add the step to the graph
|
|
4390
|
+
_classPrivateFieldLooseBase(this, _stepGraph)[_stepGraph][lastStepKey].push(graphEntry);
|
|
4391
|
+
}
|
|
4392
|
+
return this;
|
|
4393
|
+
};
|
|
4394
|
+
_proto.after = function after(step) {
|
|
4395
|
+
var stepKey = _classPrivateFieldLooseBase(this, _makeStepKey)[_makeStepKey](step);
|
|
4396
|
+
_classPrivateFieldLooseBase(this, _afterStepStack)[_afterStepStack].push(stepKey);
|
|
4397
|
+
// Initialize subscriber array for this step if it doesn't exist
|
|
4398
|
+
if (!_classPrivateFieldLooseBase(this, _stepSubscriberGraph)[_stepSubscriberGraph][stepKey]) {
|
|
4399
|
+
_classPrivateFieldLooseBase(this, _stepSubscriberGraph)[_stepSubscriberGraph][stepKey] = {
|
|
4400
|
+
initial: []
|
|
4401
|
+
};
|
|
4402
|
+
}
|
|
4506
4403
|
return this;
|
|
4507
4404
|
}
|
|
4508
4405
|
/**
|
|
@@ -4514,22 +4411,22 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4514
4411
|
_proto.execute =
|
|
4515
4412
|
/*#__PURE__*/
|
|
4516
4413
|
function () {
|
|
4517
|
-
var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4518
|
-
var
|
|
4519
|
-
var
|
|
4520
|
-
return _regeneratorRuntime().wrap(function
|
|
4521
|
-
while (1) switch (
|
|
4414
|
+
var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_temp) {
|
|
4415
|
+
var _this = this;
|
|
4416
|
+
var _ref5, triggerData, loadSnapshot, snapshot;
|
|
4417
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4418
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4522
4419
|
case 0:
|
|
4523
|
-
|
|
4420
|
+
_ref5 = _temp === void 0 ? {} : _temp, triggerData = _ref5.triggerData, loadSnapshot = _ref5.loadSnapshot;
|
|
4524
4421
|
if (!(loadSnapshot && loadSnapshot.runId)) {
|
|
4525
|
-
|
|
4422
|
+
_context.next = 7;
|
|
4526
4423
|
break;
|
|
4527
4424
|
}
|
|
4528
|
-
|
|
4425
|
+
_context.next = 4;
|
|
4529
4426
|
return _classPrivateFieldLooseBase(this, _loadWorkflowSnapshot)[_loadWorkflowSnapshot](loadSnapshot.runId);
|
|
4530
4427
|
case 4:
|
|
4531
|
-
snapshot =
|
|
4532
|
-
|
|
4428
|
+
snapshot = _context.sent;
|
|
4429
|
+
_context.next = 8;
|
|
4533
4430
|
break;
|
|
4534
4431
|
case 7:
|
|
4535
4432
|
_classPrivateFieldLooseBase(this, _runId)[_runId] = crypto.randomUUID();
|
|
@@ -4537,54 +4434,56 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4537
4434
|
if (snapshot) {
|
|
4538
4435
|
snapshot = JSON.parse(snapshot);
|
|
4539
4436
|
}
|
|
4540
|
-
|
|
4437
|
+
_context.next = 11;
|
|
4541
4438
|
return _classPrivateFieldLooseBase(this, _log)[_log](LogLevel.INFO, 'Executing workflow', {
|
|
4542
4439
|
triggerData: triggerData
|
|
4543
4440
|
});
|
|
4544
4441
|
case 11:
|
|
4545
4442
|
if (!_classPrivateFieldLooseBase(this, _triggerSchema)[_triggerSchema]) {
|
|
4546
|
-
|
|
4443
|
+
_context.next = 23;
|
|
4547
4444
|
break;
|
|
4548
4445
|
}
|
|
4549
|
-
|
|
4446
|
+
_context.prev = 12;
|
|
4550
4447
|
_classPrivateFieldLooseBase(this, _triggerSchema)[_triggerSchema].parse(triggerData);
|
|
4551
|
-
|
|
4448
|
+
_context.next = 16;
|
|
4552
4449
|
return _classPrivateFieldLooseBase(this, _log)[_log](LogLevel.DEBUG, 'Trigger schema validation passed');
|
|
4553
4450
|
case 16:
|
|
4554
|
-
|
|
4451
|
+
_context.next = 23;
|
|
4555
4452
|
break;
|
|
4556
4453
|
case 18:
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4454
|
+
_context.prev = 18;
|
|
4455
|
+
_context.t0 = _context["catch"](12);
|
|
4456
|
+
_context.next = 22;
|
|
4560
4457
|
return _classPrivateFieldLooseBase(this, _log)[_log](LogLevel.ERROR, 'Trigger schema validation failed', {
|
|
4561
|
-
error:
|
|
4458
|
+
error: _context.t0
|
|
4562
4459
|
});
|
|
4563
4460
|
case 22:
|
|
4564
|
-
throw
|
|
4461
|
+
throw _context.t0;
|
|
4565
4462
|
case 23:
|
|
4566
4463
|
_classPrivateFieldLooseBase(this, _actor)[_actor] = xstate.createActor(_classPrivateFieldLooseBase(this, _machine)[_machine], {
|
|
4567
4464
|
input: {
|
|
4568
4465
|
stepResults: {},
|
|
4466
|
+
spawnedActors: [],
|
|
4467
|
+
completedActors: [],
|
|
4569
4468
|
triggerData: triggerData || {},
|
|
4570
4469
|
attempts: Object.keys(_classPrivateFieldLooseBase(this, _steps)[_steps]).reduce(function (acc, stepKey) {
|
|
4571
4470
|
var _classPrivateFieldLoo, _classPrivateFieldLoo2;
|
|
4572
|
-
acc[stepKey] = ((_classPrivateFieldLoo = _classPrivateFieldLooseBase(
|
|
4471
|
+
acc[stepKey] = ((_classPrivateFieldLoo = _classPrivateFieldLooseBase(_this, _steps)[_steps][stepKey]) == null || (_classPrivateFieldLoo = _classPrivateFieldLoo.retryConfig) == null ? void 0 : _classPrivateFieldLoo.attempts) || ((_classPrivateFieldLoo2 = _classPrivateFieldLooseBase(_this, _retryConfig)[_retryConfig]) == null ? void 0 : _classPrivateFieldLoo2.attempts) || 3;
|
|
4573
4472
|
return acc;
|
|
4574
4473
|
}, {})
|
|
4575
4474
|
},
|
|
4576
4475
|
snapshot: snapshot
|
|
4577
4476
|
});
|
|
4578
4477
|
_classPrivateFieldLooseBase(this, _actor)[_actor].start();
|
|
4579
|
-
return
|
|
4580
|
-
if (!_classPrivateFieldLooseBase(
|
|
4478
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
4479
|
+
if (!_classPrivateFieldLooseBase(_this, _actor)[_actor]) {
|
|
4581
4480
|
reject(new Error('Actor not initialized'));
|
|
4582
4481
|
return;
|
|
4583
4482
|
}
|
|
4584
|
-
_classPrivateFieldLooseBase(
|
|
4483
|
+
_classPrivateFieldLooseBase(_this, _actor)[_actor].subscribe(function (state) {
|
|
4585
4484
|
// Check if all parallel states are in a final state
|
|
4586
4485
|
var allStatesValue = state.value;
|
|
4587
|
-
var allStatesComplete = _classPrivateFieldLooseBase(
|
|
4486
|
+
var allStatesComplete = _classPrivateFieldLooseBase(_this, _recursivelyCheckForFinalState)[_recursivelyCheckForFinalState](allStatesValue);
|
|
4588
4487
|
if (allStatesComplete) {
|
|
4589
4488
|
// Check if any steps failed
|
|
4590
4489
|
var hasFailures = Object.values(state.context.stepResults).some(function (result) {
|
|
@@ -4594,27 +4493,27 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4594
4493
|
return result.status === 'suspended';
|
|
4595
4494
|
});
|
|
4596
4495
|
if (hasSuspended) {
|
|
4597
|
-
_classPrivateFieldLooseBase(
|
|
4496
|
+
_classPrivateFieldLooseBase(_this, _persistWorkflowSnapshot)[_persistWorkflowSnapshot]();
|
|
4598
4497
|
}
|
|
4599
4498
|
if (hasFailures) {
|
|
4600
|
-
_classPrivateFieldLooseBase(
|
|
4499
|
+
_classPrivateFieldLooseBase(_this, _log)[_log](LogLevel.ERROR, 'Workflow failed', {
|
|
4601
4500
|
results: state.context.stepResults
|
|
4602
4501
|
});
|
|
4603
|
-
_classPrivateFieldLooseBase(
|
|
4502
|
+
_classPrivateFieldLooseBase(_this, _cleanup)[_cleanup]();
|
|
4604
4503
|
resolve({
|
|
4605
4504
|
triggerData: triggerData,
|
|
4606
4505
|
results: state.context.stepResults,
|
|
4607
|
-
runId: _classPrivateFieldLooseBase(
|
|
4506
|
+
runId: _classPrivateFieldLooseBase(_this, _runId)[_runId]
|
|
4608
4507
|
});
|
|
4609
4508
|
} else {
|
|
4610
|
-
_classPrivateFieldLooseBase(
|
|
4509
|
+
_classPrivateFieldLooseBase(_this, _log)[_log](LogLevel.INFO, 'Workflow completed', {
|
|
4611
4510
|
results: state.context.stepResults
|
|
4612
4511
|
});
|
|
4613
|
-
_classPrivateFieldLooseBase(
|
|
4512
|
+
_classPrivateFieldLooseBase(_this, _cleanup)[_cleanup]();
|
|
4614
4513
|
resolve({
|
|
4615
4514
|
triggerData: triggerData,
|
|
4616
4515
|
results: state.context.stepResults,
|
|
4617
|
-
runId: _classPrivateFieldLooseBase(
|
|
4516
|
+
runId: _classPrivateFieldLooseBase(_this, _runId)[_runId]
|
|
4618
4517
|
});
|
|
4619
4518
|
}
|
|
4620
4519
|
}
|
|
@@ -4622,11 +4521,11 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4622
4521
|
}));
|
|
4623
4522
|
case 26:
|
|
4624
4523
|
case "end":
|
|
4625
|
-
return
|
|
4524
|
+
return _context.stop();
|
|
4626
4525
|
}
|
|
4627
|
-
},
|
|
4526
|
+
}, _callee, this, [[12, 18]]);
|
|
4628
4527
|
}));
|
|
4629
|
-
function execute(
|
|
4528
|
+
function execute(_x) {
|
|
4630
4529
|
return _execute.apply(this, arguments);
|
|
4631
4530
|
}
|
|
4632
4531
|
return execute;
|
|
@@ -4662,18 +4561,18 @@ var Workflow = /*#__PURE__*/function () {
|
|
|
4662
4561
|
}]);
|
|
4663
4562
|
}();
|
|
4664
4563
|
function _recursivelyCheckForFinalState2(value) {
|
|
4665
|
-
var
|
|
4564
|
+
var _this2 = this;
|
|
4666
4565
|
if (typeof value === 'string') {
|
|
4667
4566
|
return ['completed', 'failed', 'suspended'].includes(value);
|
|
4668
4567
|
}
|
|
4669
4568
|
return Object.values(value).every(function (val) {
|
|
4670
|
-
return _classPrivateFieldLooseBase(
|
|
4569
|
+
return _classPrivateFieldLooseBase(_this2, _recursivelyCheckForFinalState)[_recursivelyCheckForFinalState](val);
|
|
4671
4570
|
});
|
|
4672
4571
|
}
|
|
4673
4572
|
function _buildBaseState2(stepNode, nextSteps) {
|
|
4674
|
-
var
|
|
4573
|
+
var _this3 = this,
|
|
4675
4574
|
_after,
|
|
4676
|
-
|
|
4575
|
+
_ref19;
|
|
4677
4576
|
if (nextSteps === void 0) {
|
|
4678
4577
|
nextSteps = [];
|
|
4679
4578
|
}
|
|
@@ -4681,57 +4580,43 @@ function _buildBaseState2(stepNode, nextSteps) {
|
|
|
4681
4580
|
var nextStep = nextSteps.shift();
|
|
4682
4581
|
return {
|
|
4683
4582
|
initial: 'pending',
|
|
4684
|
-
entry: function entry(_ref13) {
|
|
4685
|
-
var context = _ref13.context;
|
|
4686
|
-
console.log({
|
|
4687
|
-
stepNode: stepNode,
|
|
4688
|
-
context: context
|
|
4689
|
-
}, 'entry pending =============================');
|
|
4690
|
-
},
|
|
4691
|
-
exit: function exit(_ref14) {
|
|
4692
|
-
var context = _ref14.context;
|
|
4693
|
-
console.log({
|
|
4694
|
-
stepNode: stepNode,
|
|
4695
|
-
context: context
|
|
4696
|
-
}, 'exit pending =============================');
|
|
4697
|
-
},
|
|
4698
4583
|
states: _extends({
|
|
4699
4584
|
pending: {
|
|
4700
4585
|
invoke: {
|
|
4701
4586
|
src: 'dependencyCheck',
|
|
4702
|
-
input: function input(
|
|
4703
|
-
var context =
|
|
4587
|
+
input: function input(_ref6) {
|
|
4588
|
+
var context = _ref6.context;
|
|
4704
4589
|
return {
|
|
4705
4590
|
context: context,
|
|
4706
4591
|
stepNode: stepNode
|
|
4707
4592
|
};
|
|
4708
4593
|
},
|
|
4709
4594
|
onDone: [{
|
|
4710
|
-
guard: function guard(
|
|
4711
|
-
var event =
|
|
4595
|
+
guard: function guard(_ref7) {
|
|
4596
|
+
var event = _ref7.event;
|
|
4712
4597
|
return event.output.type === 'SUSPENDED';
|
|
4713
4598
|
},
|
|
4714
4599
|
target: 'suspended',
|
|
4715
4600
|
actions: xstate.assign({
|
|
4716
|
-
stepResults: function stepResults(
|
|
4717
|
-
var
|
|
4718
|
-
var context =
|
|
4719
|
-
event =
|
|
4601
|
+
stepResults: function stepResults(_ref8) {
|
|
4602
|
+
var _extends2;
|
|
4603
|
+
var context = _ref8.context,
|
|
4604
|
+
event = _ref8.event;
|
|
4720
4605
|
if (event.output.type !== 'SUSPENDED') return context.stepResults;
|
|
4721
|
-
return _extends({}, context.stepResults, (
|
|
4606
|
+
return _extends({}, context.stepResults, (_extends2 = {}, _extends2[stepNode.step.id] = {
|
|
4722
4607
|
status: 'suspended'
|
|
4723
|
-
},
|
|
4608
|
+
}, _extends2));
|
|
4724
4609
|
}
|
|
4725
4610
|
})
|
|
4726
4611
|
}, {
|
|
4727
|
-
guard: function guard(
|
|
4728
|
-
var event =
|
|
4612
|
+
guard: function guard(_ref9) {
|
|
4613
|
+
var event = _ref9.event;
|
|
4729
4614
|
return event.output.type === 'DEPENDENCIES_MET';
|
|
4730
4615
|
},
|
|
4731
4616
|
target: 'executing'
|
|
4732
4617
|
}, {
|
|
4733
|
-
guard: function guard(
|
|
4734
|
-
var event =
|
|
4618
|
+
guard: function guard(_ref10) {
|
|
4619
|
+
var event = _ref10.event;
|
|
4735
4620
|
return event.output.type === 'DEPENDENCIES_NOT_MET';
|
|
4736
4621
|
},
|
|
4737
4622
|
target: 'waiting',
|
|
@@ -4742,46 +4627,46 @@ function _buildBaseState2(stepNode, nextSteps) {
|
|
|
4742
4627
|
}
|
|
4743
4628
|
}]
|
|
4744
4629
|
}, {
|
|
4745
|
-
guard: function guard(
|
|
4746
|
-
var event =
|
|
4630
|
+
guard: function guard(_ref11) {
|
|
4631
|
+
var event = _ref11.event;
|
|
4747
4632
|
return event.output.type === 'TIMED_OUT';
|
|
4748
4633
|
},
|
|
4749
4634
|
target: 'failed',
|
|
4750
4635
|
actions: xstate.assign({
|
|
4751
|
-
stepResults: function stepResults(
|
|
4752
|
-
var
|
|
4753
|
-
var context =
|
|
4754
|
-
event =
|
|
4636
|
+
stepResults: function stepResults(_ref12) {
|
|
4637
|
+
var _extends3;
|
|
4638
|
+
var context = _ref12.context,
|
|
4639
|
+
event = _ref12.event;
|
|
4755
4640
|
if (event.output.type !== 'TIMED_OUT') return context.stepResults;
|
|
4756
|
-
_classPrivateFieldLooseBase(
|
|
4641
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.ERROR, "Step:" + stepNode.step.id + " timed out", {
|
|
4757
4642
|
error: event.output.error
|
|
4758
4643
|
});
|
|
4759
|
-
return _extends({}, context.stepResults, (
|
|
4644
|
+
return _extends({}, context.stepResults, (_extends3 = {}, _extends3[stepNode.step.id] = {
|
|
4760
4645
|
status: 'failed',
|
|
4761
4646
|
error: event.output.error
|
|
4762
|
-
},
|
|
4647
|
+
}, _extends3));
|
|
4763
4648
|
}
|
|
4764
4649
|
})
|
|
4765
4650
|
}, {
|
|
4766
|
-
guard: function guard(
|
|
4767
|
-
var event =
|
|
4651
|
+
guard: function guard(_ref13) {
|
|
4652
|
+
var event = _ref13.event;
|
|
4768
4653
|
return event.output.type === 'CONDITION_FAILED';
|
|
4769
4654
|
},
|
|
4770
4655
|
target: 'failed',
|
|
4771
4656
|
actions: xstate.assign({
|
|
4772
|
-
stepResults: function stepResults(
|
|
4773
|
-
var
|
|
4774
|
-
var context =
|
|
4775
|
-
event =
|
|
4657
|
+
stepResults: function stepResults(_ref14) {
|
|
4658
|
+
var _extends4;
|
|
4659
|
+
var context = _ref14.context,
|
|
4660
|
+
event = _ref14.event;
|
|
4776
4661
|
if (event.output.type !== 'CONDITION_FAILED') return context.stepResults;
|
|
4777
|
-
_classPrivateFieldLooseBase(
|
|
4662
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.ERROR, "workflow condition check failed", {
|
|
4778
4663
|
error: event.output.error,
|
|
4779
4664
|
stepId: stepNode.step.id
|
|
4780
4665
|
});
|
|
4781
|
-
return _extends({}, context.stepResults, (
|
|
4666
|
+
return _extends({}, context.stepResults, (_extends4 = {}, _extends4[stepNode.step.id] = {
|
|
4782
4667
|
status: 'failed',
|
|
4783
4668
|
error: event.output.error
|
|
4784
|
-
},
|
|
4669
|
+
}, _extends4));
|
|
4785
4670
|
}
|
|
4786
4671
|
})
|
|
4787
4672
|
}]
|
|
@@ -4789,32 +4674,43 @@ function _buildBaseState2(stepNode, nextSteps) {
|
|
|
4789
4674
|
},
|
|
4790
4675
|
waiting: {
|
|
4791
4676
|
entry: function entry() {
|
|
4792
|
-
_classPrivateFieldLooseBase(
|
|
4677
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.INFO, "Step " + stepNode.step.id + " waiting " + new Date().toISOString());
|
|
4793
4678
|
},
|
|
4794
4679
|
exit: function exit() {
|
|
4795
|
-
_classPrivateFieldLooseBase(
|
|
4680
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.INFO, "Step " + stepNode.step.id + " finished waiting " + new Date().toISOString());
|
|
4796
4681
|
},
|
|
4797
4682
|
after: (_after = {}, _after[stepNode.step.id] = {
|
|
4798
4683
|
target: 'pending'
|
|
4799
4684
|
}, _after)
|
|
4800
4685
|
},
|
|
4801
4686
|
executing: {
|
|
4687
|
+
entry: function entry() {
|
|
4688
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.INFO, "Step " + stepNode.step.id + " executing");
|
|
4689
|
+
},
|
|
4690
|
+
exit: function exit() {
|
|
4691
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.INFO, "Step " + stepNode.step.id + " finished executing");
|
|
4692
|
+
},
|
|
4802
4693
|
invoke: {
|
|
4803
4694
|
src: 'resolverFunction',
|
|
4804
|
-
input: function input(
|
|
4805
|
-
var context =
|
|
4695
|
+
input: function input(_ref15) {
|
|
4696
|
+
var context = _ref15.context;
|
|
4806
4697
|
return {
|
|
4807
4698
|
context: context,
|
|
4808
4699
|
stepNode: stepNode
|
|
4809
4700
|
};
|
|
4810
4701
|
},
|
|
4811
4702
|
onDone: {
|
|
4812
|
-
target:
|
|
4703
|
+
target: 'runningSubscribers',
|
|
4813
4704
|
actions: [{
|
|
4814
4705
|
type: 'updateStepResult',
|
|
4815
4706
|
params: {
|
|
4816
4707
|
stepId: stepNode.step.id
|
|
4817
4708
|
}
|
|
4709
|
+
}, {
|
|
4710
|
+
type: 'spawnSubscribers',
|
|
4711
|
+
params: {
|
|
4712
|
+
stepId: stepNode.step.id
|
|
4713
|
+
}
|
|
4818
4714
|
}]
|
|
4819
4715
|
},
|
|
4820
4716
|
onError: {
|
|
@@ -4828,6 +4724,48 @@ function _buildBaseState2(stepNode, nextSteps) {
|
|
|
4828
4724
|
}
|
|
4829
4725
|
}
|
|
4830
4726
|
},
|
|
4727
|
+
runningSubscribers: {
|
|
4728
|
+
entry: function entry() {
|
|
4729
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.INFO, "Step " + stepNode.step.id + " running subscribers");
|
|
4730
|
+
},
|
|
4731
|
+
exit: function exit() {
|
|
4732
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.INFO, "Step " + stepNode.step.id + " finished running subscribers");
|
|
4733
|
+
},
|
|
4734
|
+
invoke: {
|
|
4735
|
+
src: 'spawnSubscriberFunction',
|
|
4736
|
+
input: function input(_ref16) {
|
|
4737
|
+
var context = _ref16.context;
|
|
4738
|
+
return {
|
|
4739
|
+
parentStepId: stepNode.step.id,
|
|
4740
|
+
context: context
|
|
4741
|
+
};
|
|
4742
|
+
},
|
|
4743
|
+
onDone: {
|
|
4744
|
+
target: nextStep ? nextStep.step.id : 'completed',
|
|
4745
|
+
actions: [xstate.assign({
|
|
4746
|
+
stepResults: function stepResults(_ref17) {
|
|
4747
|
+
var context = _ref17.context,
|
|
4748
|
+
event = _ref17.event;
|
|
4749
|
+
return _extends({}, context.stepResults, event.output.stepResults);
|
|
4750
|
+
}
|
|
4751
|
+
}), function () {
|
|
4752
|
+
return _classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.DEBUG, "Subscriber execution completed", {
|
|
4753
|
+
stepId: stepNode.step.id
|
|
4754
|
+
});
|
|
4755
|
+
}]
|
|
4756
|
+
},
|
|
4757
|
+
onError: {
|
|
4758
|
+
target: nextStep ? nextStep.step.id : 'completed',
|
|
4759
|
+
actions: function actions(_ref18) {
|
|
4760
|
+
var event = _ref18.event;
|
|
4761
|
+
_classPrivateFieldLooseBase(_this3, _log)[_log](LogLevel.ERROR, "Subscriber execution failed", {
|
|
4762
|
+
error: event.error,
|
|
4763
|
+
stepId: stepNode.step.id
|
|
4764
|
+
});
|
|
4765
|
+
}
|
|
4766
|
+
}
|
|
4767
|
+
}
|
|
4768
|
+
},
|
|
4831
4769
|
completed: {
|
|
4832
4770
|
type: 'final',
|
|
4833
4771
|
entry: [{
|
|
@@ -4854,46 +4792,272 @@ function _buildBaseState2(stepNode, nextSteps) {
|
|
|
4854
4792
|
}
|
|
4855
4793
|
}]
|
|
4856
4794
|
}
|
|
4857
|
-
}, nextStep ? (
|
|
4795
|
+
}, nextStep ? (_ref19 = {}, _ref19[nextStep.step.id] = _extends({}, _classPrivateFieldLooseBase(this, _buildBaseState)[_buildBaseState](nextStep, nextSteps)), _ref19) : {})
|
|
4858
4796
|
};
|
|
4859
4797
|
}
|
|
4860
4798
|
function _makeStepKey2(step) {
|
|
4861
4799
|
// return `${step.id}${this.#delimiter}${Object.keys(this.#steps2).length}`;
|
|
4862
4800
|
return "" + step.id;
|
|
4863
4801
|
}
|
|
4864
|
-
function _buildStateHierarchy2() {
|
|
4865
|
-
var
|
|
4802
|
+
function _buildStateHierarchy2(stepGraph) {
|
|
4803
|
+
var _this4 = this;
|
|
4866
4804
|
var states = {};
|
|
4867
|
-
|
|
4805
|
+
stepGraph.initial.forEach(function (stepNode) {
|
|
4868
4806
|
// TODO: For identical steps, use index to create unique key
|
|
4869
|
-
states[stepNode.step.id] = _extends({}, _classPrivateFieldLooseBase(
|
|
4807
|
+
states[stepNode.step.id] = _extends({}, _classPrivateFieldLooseBase(_this4, _buildBaseState)[_buildBaseState](stepNode, stepGraph[stepNode.step.id]));
|
|
4870
4808
|
});
|
|
4871
4809
|
return states;
|
|
4872
4810
|
}
|
|
4811
|
+
function _getDefaultActions2() {
|
|
4812
|
+
var _this5 = this;
|
|
4813
|
+
return {
|
|
4814
|
+
updateStepResult: xstate.assign({
|
|
4815
|
+
stepResults: function stepResults(_ref20) {
|
|
4816
|
+
var _extends5;
|
|
4817
|
+
var context = _ref20.context,
|
|
4818
|
+
event = _ref20.event;
|
|
4819
|
+
if (!isTransitionEvent(event)) return context.stepResults;
|
|
4820
|
+
var _event$output = event.output,
|
|
4821
|
+
stepId = _event$output.stepId,
|
|
4822
|
+
result = _event$output.result;
|
|
4823
|
+
return _extends({}, context.stepResults, (_extends5 = {}, _extends5[stepId] = {
|
|
4824
|
+
status: 'success',
|
|
4825
|
+
payload: result
|
|
4826
|
+
}, _extends5));
|
|
4827
|
+
}
|
|
4828
|
+
}),
|
|
4829
|
+
setStepError: xstate.assign({
|
|
4830
|
+
stepResults: function stepResults(_ref21, params) {
|
|
4831
|
+
var _extends6;
|
|
4832
|
+
var context = _ref21.context,
|
|
4833
|
+
event = _ref21.event;
|
|
4834
|
+
if (!isErrorEvent(event)) return context.stepResults;
|
|
4835
|
+
var stepId = params.stepId;
|
|
4836
|
+
if (!stepId) return context.stepResults;
|
|
4837
|
+
return _extends({}, context.stepResults, (_extends6 = {}, _extends6[stepId] = {
|
|
4838
|
+
status: 'failed',
|
|
4839
|
+
error: event.error.message
|
|
4840
|
+
}, _extends6));
|
|
4841
|
+
}
|
|
4842
|
+
}),
|
|
4843
|
+
notifyStepCompletion: function notifyStepCompletion(_, params) {
|
|
4844
|
+
var stepId = params.stepId;
|
|
4845
|
+
_classPrivateFieldLooseBase(_this5, _log)[_log](LogLevel.INFO, "Step " + stepId + " completed");
|
|
4846
|
+
},
|
|
4847
|
+
decrementAttemptCount: xstate.assign({
|
|
4848
|
+
attempts: function attempts(_ref22, params) {
|
|
4849
|
+
var _extends7;
|
|
4850
|
+
var context = _ref22.context,
|
|
4851
|
+
event = _ref22.event;
|
|
4852
|
+
if (!isTransitionEvent(event)) return context.attempts;
|
|
4853
|
+
var stepId = params.stepId;
|
|
4854
|
+
var attemptCount = context.attempts[stepId];
|
|
4855
|
+
if (attemptCount === undefined) return context.attempts;
|
|
4856
|
+
return _extends({}, context.attempts, (_extends7 = {}, _extends7[stepId] = attemptCount - 1, _extends7));
|
|
4857
|
+
}
|
|
4858
|
+
})
|
|
4859
|
+
};
|
|
4860
|
+
}
|
|
4861
|
+
function _getDefaultActors2() {
|
|
4862
|
+
var _this6 = this;
|
|
4863
|
+
return {
|
|
4864
|
+
resolverFunction: xstate.fromPromise(/*#__PURE__*/function () {
|
|
4865
|
+
var _ref24 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref23) {
|
|
4866
|
+
var input, stepNode, context, resolvedData, result;
|
|
4867
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4868
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4869
|
+
case 0:
|
|
4870
|
+
input = _ref23.input;
|
|
4871
|
+
stepNode = input.stepNode, context = input.context;
|
|
4872
|
+
resolvedData = _classPrivateFieldLooseBase(_this6, _resolveVariables)[_resolveVariables]({
|
|
4873
|
+
stepConfig: stepNode.config,
|
|
4874
|
+
context: context
|
|
4875
|
+
});
|
|
4876
|
+
_context2.next = 5;
|
|
4877
|
+
return stepNode.config.handler({
|
|
4878
|
+
context: _extends({
|
|
4879
|
+
stepResults: context.stepResults
|
|
4880
|
+
}, resolvedData),
|
|
4881
|
+
runId: _classPrivateFieldLooseBase(_this6, _runId)[_runId]
|
|
4882
|
+
});
|
|
4883
|
+
case 5:
|
|
4884
|
+
result = _context2.sent;
|
|
4885
|
+
return _context2.abrupt("return", {
|
|
4886
|
+
stepId: stepNode.step.id,
|
|
4887
|
+
result: result
|
|
4888
|
+
});
|
|
4889
|
+
case 7:
|
|
4890
|
+
case "end":
|
|
4891
|
+
return _context2.stop();
|
|
4892
|
+
}
|
|
4893
|
+
}, _callee2);
|
|
4894
|
+
}));
|
|
4895
|
+
return function (_x2) {
|
|
4896
|
+
return _ref24.apply(this, arguments);
|
|
4897
|
+
};
|
|
4898
|
+
}()),
|
|
4899
|
+
dependencyCheck: xstate.fromPromise(/*#__PURE__*/function () {
|
|
4900
|
+
var _ref26 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref25) {
|
|
4901
|
+
var input, context, stepNode, stepConfig, attemptCount, conditionMet, _conditionMet;
|
|
4902
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4903
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4904
|
+
case 0:
|
|
4905
|
+
input = _ref25.input;
|
|
4906
|
+
context = input.context, stepNode = input.stepNode;
|
|
4907
|
+
stepConfig = stepNode.config; // TODO: Need a way to create unique ids for steps
|
|
4908
|
+
attemptCount = context.attempts[stepNode.step.id];
|
|
4909
|
+
if (!(!attemptCount || attemptCount < 0)) {
|
|
4910
|
+
_context3.next = 8;
|
|
4911
|
+
break;
|
|
4912
|
+
}
|
|
4913
|
+
if (!(stepConfig != null && stepConfig.snapshotOnTimeout)) {
|
|
4914
|
+
_context3.next = 7;
|
|
4915
|
+
break;
|
|
4916
|
+
}
|
|
4917
|
+
return _context3.abrupt("return", {
|
|
4918
|
+
type: 'SUSPENDED',
|
|
4919
|
+
stepId: stepNode.step.id
|
|
4920
|
+
});
|
|
4921
|
+
case 7:
|
|
4922
|
+
return _context3.abrupt("return", {
|
|
4923
|
+
type: 'TIMED_OUT',
|
|
4924
|
+
error: "Step:" + stepNode.step.id + " timed out"
|
|
4925
|
+
});
|
|
4926
|
+
case 8:
|
|
4927
|
+
if (stepConfig != null && stepConfig.when) {
|
|
4928
|
+
_context3.next = 10;
|
|
4929
|
+
break;
|
|
4930
|
+
}
|
|
4931
|
+
return _context3.abrupt("return", {
|
|
4932
|
+
type: 'DEPENDENCIES_MET'
|
|
4933
|
+
});
|
|
4934
|
+
case 10:
|
|
4935
|
+
if (!(typeof (stepConfig == null ? void 0 : stepConfig.when) === 'function')) {
|
|
4936
|
+
_context3.next = 18;
|
|
4937
|
+
break;
|
|
4938
|
+
}
|
|
4939
|
+
_context3.next = 13;
|
|
4940
|
+
return stepConfig.when({
|
|
4941
|
+
context: context
|
|
4942
|
+
});
|
|
4943
|
+
case 13:
|
|
4944
|
+
conditionMet = _context3.sent;
|
|
4945
|
+
if (conditionMet) {
|
|
4946
|
+
_context3.next = 16;
|
|
4947
|
+
break;
|
|
4948
|
+
}
|
|
4949
|
+
return _context3.abrupt("return", {
|
|
4950
|
+
type: 'CONDITION_FAILED',
|
|
4951
|
+
error: "Step:" + stepNode.step.id + " condition function check failed"
|
|
4952
|
+
});
|
|
4953
|
+
case 16:
|
|
4954
|
+
_context3.next = 21;
|
|
4955
|
+
break;
|
|
4956
|
+
case 18:
|
|
4957
|
+
_conditionMet = _classPrivateFieldLooseBase(_this6, _evaluateCondition)[_evaluateCondition](stepConfig.when, context);
|
|
4958
|
+
if (_conditionMet) {
|
|
4959
|
+
_context3.next = 21;
|
|
4960
|
+
break;
|
|
4961
|
+
}
|
|
4962
|
+
return _context3.abrupt("return", {
|
|
4963
|
+
type: 'CONDITION_FAILED',
|
|
4964
|
+
error: "Step:" + stepNode.step.id + " condition check failed"
|
|
4965
|
+
});
|
|
4966
|
+
case 21:
|
|
4967
|
+
return _context3.abrupt("return", {
|
|
4968
|
+
type: 'DEPENDENCIES_MET'
|
|
4969
|
+
});
|
|
4970
|
+
case 22:
|
|
4971
|
+
case "end":
|
|
4972
|
+
return _context3.stop();
|
|
4973
|
+
}
|
|
4974
|
+
}, _callee3);
|
|
4975
|
+
}));
|
|
4976
|
+
return function (_x3) {
|
|
4977
|
+
return _ref26.apply(this, arguments);
|
|
4978
|
+
};
|
|
4979
|
+
}()),
|
|
4980
|
+
spawnSubscriberFunction: xstate.fromPromise(/*#__PURE__*/function () {
|
|
4981
|
+
var _ref28 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref27) {
|
|
4982
|
+
var input, parentStepId, context, stepGraph, subscriberMachine, actor;
|
|
4983
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4984
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4985
|
+
case 0:
|
|
4986
|
+
input = _ref27.input;
|
|
4987
|
+
parentStepId = input.parentStepId, context = input.context;
|
|
4988
|
+
stepGraph = _classPrivateFieldLooseBase(_this6, _stepSubscriberGraph)[_stepSubscriberGraph][parentStepId];
|
|
4989
|
+
if (stepGraph) {
|
|
4990
|
+
_context4.next = 5;
|
|
4991
|
+
break;
|
|
4992
|
+
}
|
|
4993
|
+
return _context4.abrupt("return", {
|
|
4994
|
+
stepResults: {}
|
|
4995
|
+
});
|
|
4996
|
+
case 5:
|
|
4997
|
+
subscriberMachine = xstate.setup({
|
|
4998
|
+
types: {},
|
|
4999
|
+
delays: _classPrivateFieldLooseBase(_this6, _makeDelayMap)[_makeDelayMap](),
|
|
5000
|
+
actions: _classPrivateFieldLooseBase(_this6, _getDefaultActions)[_getDefaultActions](),
|
|
5001
|
+
actors: _classPrivateFieldLooseBase(_this6, _getDefaultActors)[_getDefaultActors]()
|
|
5002
|
+
}).createMachine({
|
|
5003
|
+
id: _this6.name + "-subscriber-" + parentStepId,
|
|
5004
|
+
context: context,
|
|
5005
|
+
type: 'parallel',
|
|
5006
|
+
states: _classPrivateFieldLooseBase(_this6, _buildStateHierarchy)[_buildStateHierarchy](stepGraph)
|
|
5007
|
+
});
|
|
5008
|
+
actor = xstate.createActor(subscriberMachine, {
|
|
5009
|
+
input: context
|
|
5010
|
+
});
|
|
5011
|
+
actor.start();
|
|
5012
|
+
// Create a promise that resolves when all states are final
|
|
5013
|
+
return _context4.abrupt("return", new Promise(function (resolve) {
|
|
5014
|
+
actor.subscribe(function (state) {
|
|
5015
|
+
var allStatesValue = state.value;
|
|
5016
|
+
var allStatesComplete = _classPrivateFieldLooseBase(_this6, _recursivelyCheckForFinalState)[_recursivelyCheckForFinalState](allStatesValue);
|
|
5017
|
+
if (allStatesComplete) {
|
|
5018
|
+
actor.stop();
|
|
5019
|
+
resolve({
|
|
5020
|
+
stepResults: state.context.stepResults
|
|
5021
|
+
});
|
|
5022
|
+
}
|
|
5023
|
+
});
|
|
5024
|
+
}));
|
|
5025
|
+
case 9:
|
|
5026
|
+
case "end":
|
|
5027
|
+
return _context4.stop();
|
|
5028
|
+
}
|
|
5029
|
+
}, _callee4);
|
|
5030
|
+
}));
|
|
5031
|
+
return function (_x4) {
|
|
5032
|
+
return _ref28.apply(this, arguments);
|
|
5033
|
+
};
|
|
5034
|
+
}())
|
|
5035
|
+
};
|
|
5036
|
+
}
|
|
4873
5037
|
function _persistWorkflowSnapshot2() {
|
|
4874
5038
|
return _persistWorkflowSnapshot3.apply(this, arguments);
|
|
4875
5039
|
}
|
|
4876
5040
|
function _persistWorkflowSnapshot3() {
|
|
4877
|
-
_persistWorkflowSnapshot3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5041
|
+
_persistWorkflowSnapshot3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
4878
5042
|
var _classPrivateFieldLoo5;
|
|
4879
5043
|
var snapshot;
|
|
4880
|
-
return _regeneratorRuntime().wrap(function
|
|
4881
|
-
while (1) switch (
|
|
5044
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
5045
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
4882
5046
|
case 0:
|
|
4883
5047
|
if (_classPrivateFieldLooseBase(this, _engine)[_engine]) {
|
|
4884
|
-
|
|
5048
|
+
_context6.next = 2;
|
|
4885
5049
|
break;
|
|
4886
5050
|
}
|
|
4887
|
-
return
|
|
5051
|
+
return _context6.abrupt("return");
|
|
4888
5052
|
case 2:
|
|
4889
5053
|
snapshot = (_classPrivateFieldLoo5 = _classPrivateFieldLooseBase(this, _actor)[_actor]) == null ? void 0 : _classPrivateFieldLoo5.getPersistedSnapshot();
|
|
4890
5054
|
if (snapshot) {
|
|
4891
|
-
|
|
5055
|
+
_context6.next = 5;
|
|
4892
5056
|
break;
|
|
4893
5057
|
}
|
|
4894
|
-
return
|
|
5058
|
+
return _context6.abrupt("return");
|
|
4895
5059
|
case 5:
|
|
4896
|
-
|
|
5060
|
+
_context6.next = 7;
|
|
4897
5061
|
return _classPrivateFieldLooseBase(this, _engine)[_engine].syncRecords({
|
|
4898
5062
|
name: _classPrivateFieldLooseBase(this, _entityName)[_entityName],
|
|
4899
5063
|
connectionId: _classPrivateFieldLooseBase(this, _connectionId)[_connectionId],
|
|
@@ -4905,32 +5069,32 @@ function _persistWorkflowSnapshot3() {
|
|
|
4905
5069
|
}]
|
|
4906
5070
|
});
|
|
4907
5071
|
case 7:
|
|
4908
|
-
return
|
|
5072
|
+
return _context6.abrupt("return", _classPrivateFieldLooseBase(this, _runId)[_runId]);
|
|
4909
5073
|
case 8:
|
|
4910
5074
|
case "end":
|
|
4911
|
-
return
|
|
5075
|
+
return _context6.stop();
|
|
4912
5076
|
}
|
|
4913
|
-
},
|
|
5077
|
+
}, _callee6, this);
|
|
4914
5078
|
}));
|
|
4915
5079
|
return _persistWorkflowSnapshot3.apply(this, arguments);
|
|
4916
5080
|
}
|
|
4917
|
-
function _loadWorkflowSnapshot2(
|
|
5081
|
+
function _loadWorkflowSnapshot2(_x5) {
|
|
4918
5082
|
return _loadWorkflowSnapshot3.apply(this, arguments);
|
|
4919
5083
|
}
|
|
4920
5084
|
function _loadWorkflowSnapshot3() {
|
|
4921
|
-
_loadWorkflowSnapshot3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5085
|
+
_loadWorkflowSnapshot3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(runId) {
|
|
4922
5086
|
var _state$;
|
|
4923
5087
|
var state;
|
|
4924
|
-
return _regeneratorRuntime().wrap(function
|
|
4925
|
-
while (1) switch (
|
|
5088
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
5089
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
4926
5090
|
case 0:
|
|
4927
5091
|
if (_classPrivateFieldLooseBase(this, _engine)[_engine]) {
|
|
4928
|
-
|
|
5092
|
+
_context7.next = 2;
|
|
4929
5093
|
break;
|
|
4930
5094
|
}
|
|
4931
|
-
return
|
|
5095
|
+
return _context7.abrupt("return");
|
|
4932
5096
|
case 2:
|
|
4933
|
-
|
|
5097
|
+
_context7.next = 4;
|
|
4934
5098
|
return _classPrivateFieldLooseBase(this, _engine)[_engine].getRecords({
|
|
4935
5099
|
entityName: _classPrivateFieldLooseBase(this, _entityName)[_entityName],
|
|
4936
5100
|
connectionId: _classPrivateFieldLooseBase(this, _connectionId)[_connectionId],
|
|
@@ -4943,19 +5107,19 @@ function _loadWorkflowSnapshot3() {
|
|
|
4943
5107
|
}
|
|
4944
5108
|
});
|
|
4945
5109
|
case 4:
|
|
4946
|
-
state =
|
|
4947
|
-
return
|
|
5110
|
+
state = _context7.sent;
|
|
5111
|
+
return _context7.abrupt("return", (_state$ = state[0]) == null ? void 0 : _state$.data.snapshot);
|
|
4948
5112
|
case 6:
|
|
4949
5113
|
case "end":
|
|
4950
|
-
return
|
|
5114
|
+
return _context7.stop();
|
|
4951
5115
|
}
|
|
4952
|
-
},
|
|
5116
|
+
}, _callee7, this);
|
|
4953
5117
|
}));
|
|
4954
5118
|
return _loadWorkflowSnapshot3.apply(this, arguments);
|
|
4955
5119
|
}
|
|
4956
|
-
function _resolveVariables2(
|
|
4957
|
-
var stepConfig =
|
|
4958
|
-
context =
|
|
5120
|
+
function _resolveVariables2(_ref29) {
|
|
5121
|
+
var stepConfig = _ref29.stepConfig,
|
|
5122
|
+
context = _ref29.context;
|
|
4959
5123
|
var resolvedData = {};
|
|
4960
5124
|
for (var _i3 = 0, _Object$entries3 = Object.entries(stepConfig.data); _i3 < _Object$entries3.length; _i3++) {
|
|
4961
5125
|
var _Object$entries3$_i = _Object$entries3[_i3],
|
|
@@ -4974,7 +5138,7 @@ function _resolveVariables2(_ref26) {
|
|
|
4974
5138
|
return resolvedData;
|
|
4975
5139
|
}
|
|
4976
5140
|
function _evaluateCondition2(condition, context) {
|
|
4977
|
-
var
|
|
5141
|
+
var _this7 = this;
|
|
4978
5142
|
var andBranchResult = true;
|
|
4979
5143
|
var baseResult = true;
|
|
4980
5144
|
var orBranchResult = true;
|
|
@@ -4992,33 +5156,33 @@ function _evaluateCondition2(condition, context) {
|
|
|
4992
5156
|
// AND condition
|
|
4993
5157
|
if ('and' in condition) {
|
|
4994
5158
|
andBranchResult = condition.and.every(function (cond) {
|
|
4995
|
-
return _classPrivateFieldLooseBase(
|
|
5159
|
+
return _classPrivateFieldLooseBase(_this7, _evaluateCondition)[_evaluateCondition](cond, context);
|
|
4996
5160
|
});
|
|
4997
5161
|
}
|
|
4998
5162
|
// OR condition
|
|
4999
5163
|
if ('or' in condition) {
|
|
5000
5164
|
orBranchResult = condition.or.some(function (cond) {
|
|
5001
|
-
return _classPrivateFieldLooseBase(
|
|
5165
|
+
return _classPrivateFieldLooseBase(_this7, _evaluateCondition)[_evaluateCondition](cond, context);
|
|
5002
5166
|
});
|
|
5003
5167
|
}
|
|
5004
5168
|
var finalResult = baseResult && andBranchResult && orBranchResult;
|
|
5005
5169
|
return finalResult;
|
|
5006
5170
|
}
|
|
5007
|
-
function _log2(
|
|
5171
|
+
function _log2(_x6, _x7, _x8, _x9) {
|
|
5008
5172
|
return _log3.apply(this, arguments);
|
|
5009
5173
|
}
|
|
5010
5174
|
function _log3() {
|
|
5011
|
-
_log3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5175
|
+
_log3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(level, message, data, stepId) {
|
|
5012
5176
|
var _classPrivateFieldLoo6, _classPrivateFieldLoo7;
|
|
5013
5177
|
var logMessage, logMethod;
|
|
5014
|
-
return _regeneratorRuntime().wrap(function
|
|
5015
|
-
while (1) switch (
|
|
5178
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
5179
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
5016
5180
|
case 0:
|
|
5017
5181
|
if (_classPrivateFieldLooseBase(this, _logger)[_logger]) {
|
|
5018
|
-
|
|
5182
|
+
_context8.next = 2;
|
|
5019
5183
|
break;
|
|
5020
5184
|
}
|
|
5021
|
-
return
|
|
5185
|
+
return _context8.abrupt("return");
|
|
5022
5186
|
case 2:
|
|
5023
5187
|
logMessage = {
|
|
5024
5188
|
type: RegisteredLogger.WORKFLOW,
|
|
@@ -5030,28 +5194,28 @@ function _log3() {
|
|
|
5030
5194
|
runId: _classPrivateFieldLooseBase(this, _runId)[_runId]
|
|
5031
5195
|
};
|
|
5032
5196
|
logMethod = level.toLowerCase();
|
|
5033
|
-
|
|
5197
|
+
_context8.next = 6;
|
|
5034
5198
|
return (_classPrivateFieldLoo6 = (_classPrivateFieldLoo7 = _classPrivateFieldLooseBase(this, _logger)[_logger])[logMethod]) == null ? void 0 : _classPrivateFieldLoo6.call(_classPrivateFieldLoo7, logMessage);
|
|
5035
5199
|
case 6:
|
|
5036
5200
|
case "end":
|
|
5037
|
-
return
|
|
5201
|
+
return _context8.stop();
|
|
5038
5202
|
}
|
|
5039
|
-
},
|
|
5203
|
+
}, _callee8, this);
|
|
5040
5204
|
}));
|
|
5041
5205
|
return _log3.apply(this, arguments);
|
|
5042
5206
|
}
|
|
5043
5207
|
function _makeStepDef2(stepId) {
|
|
5044
|
-
var
|
|
5208
|
+
var _this8 = this;
|
|
5045
5209
|
var handler = /*#__PURE__*/function () {
|
|
5046
|
-
var
|
|
5210
|
+
var _ref31 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref30) {
|
|
5047
5211
|
var context, runId, targetStep, payload, action, mergedData, finalAction;
|
|
5048
|
-
return _regeneratorRuntime().wrap(function
|
|
5049
|
-
while (1) switch (
|
|
5212
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5213
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
5050
5214
|
case 0:
|
|
5051
|
-
context =
|
|
5052
|
-
targetStep = _classPrivateFieldLooseBase(
|
|
5215
|
+
context = _ref30.context, runId = _ref30.runId;
|
|
5216
|
+
targetStep = _classPrivateFieldLooseBase(_this8, _steps)[_steps][stepId];
|
|
5053
5217
|
if (targetStep) {
|
|
5054
|
-
|
|
5218
|
+
_context5.next = 4;
|
|
5055
5219
|
break;
|
|
5056
5220
|
}
|
|
5057
5221
|
throw new Error("Step not found");
|
|
@@ -5059,34 +5223,34 @@ function _makeStepDef2(stepId) {
|
|
|
5059
5223
|
payload = targetStep.payload, action = targetStep.action; // Merge static payload with dynamically resolved variables
|
|
5060
5224
|
// Variables take precedence over payload values
|
|
5061
5225
|
mergedData = _extends({}, payload, context); // Only trace if telemetry is available and action exists
|
|
5062
|
-
finalAction = action && _classPrivateFieldLooseBase(
|
|
5063
|
-
spanName: "workflow." +
|
|
5226
|
+
finalAction = action && _classPrivateFieldLooseBase(_this8, _telemetry)[_telemetry] ? _classPrivateFieldLooseBase(_this8, _telemetry)[_telemetry].traceMethod(action, {
|
|
5227
|
+
spanName: "workflow." + _this8.name + ".action." + stepId
|
|
5064
5228
|
}) : action;
|
|
5065
5229
|
if (!finalAction) {
|
|
5066
|
-
|
|
5230
|
+
_context5.next = 13;
|
|
5067
5231
|
break;
|
|
5068
5232
|
}
|
|
5069
|
-
|
|
5233
|
+
_context5.next = 10;
|
|
5070
5234
|
return finalAction({
|
|
5071
5235
|
context: mergedData,
|
|
5072
5236
|
runId: runId
|
|
5073
5237
|
});
|
|
5074
5238
|
case 10:
|
|
5075
|
-
|
|
5076
|
-
|
|
5239
|
+
_context5.t0 = _context5.sent;
|
|
5240
|
+
_context5.next = 14;
|
|
5077
5241
|
break;
|
|
5078
5242
|
case 13:
|
|
5079
|
-
|
|
5243
|
+
_context5.t0 = {};
|
|
5080
5244
|
case 14:
|
|
5081
|
-
return
|
|
5245
|
+
return _context5.abrupt("return", _context5.t0);
|
|
5082
5246
|
case 15:
|
|
5083
5247
|
case "end":
|
|
5084
|
-
return
|
|
5248
|
+
return _context5.stop();
|
|
5085
5249
|
}
|
|
5086
|
-
},
|
|
5250
|
+
}, _callee5);
|
|
5087
5251
|
}));
|
|
5088
|
-
return function handler(
|
|
5089
|
-
return
|
|
5252
|
+
return function handler(_x10) {
|
|
5253
|
+
return _ref31.apply(this, arguments);
|
|
5090
5254
|
};
|
|
5091
5255
|
}();
|
|
5092
5256
|
// Only trace handler if telemetry is available
|
|
@@ -5099,11 +5263,11 @@ function _makeStepDef2(stepId) {
|
|
|
5099
5263
|
};
|
|
5100
5264
|
}
|
|
5101
5265
|
function _makeDelayMap2() {
|
|
5102
|
-
var
|
|
5266
|
+
var _this9 = this;
|
|
5103
5267
|
var delayMap = {};
|
|
5104
5268
|
Object.keys(_classPrivateFieldLooseBase(this, _steps)[_steps]).forEach(function (stepId) {
|
|
5105
5269
|
var _classPrivateFieldLoo3, _classPrivateFieldLoo4;
|
|
5106
|
-
delayMap[stepId] = ((_classPrivateFieldLoo3 = _classPrivateFieldLooseBase(
|
|
5270
|
+
delayMap[stepId] = ((_classPrivateFieldLoo3 = _classPrivateFieldLooseBase(_this9, _steps)[_steps][stepId]) == null || (_classPrivateFieldLoo3 = _classPrivateFieldLoo3.retryConfig) == null ? void 0 : _classPrivateFieldLoo3.delay) || ((_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(_this9, _retryConfig)[_retryConfig]) == null ? void 0 : _classPrivateFieldLoo4.delay) || 1000;
|
|
5107
5271
|
});
|
|
5108
5272
|
return delayMap;
|
|
5109
5273
|
}
|