durable-functions
Version:
Durable Functions library for Node.js Azure Functions
53 lines • 2.2 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrchestratorState = void 0;
const WhenAllAction_1 = require("../actions/WhenAllAction");
const WhenAnyAction_1 = require("../actions/WhenAnyAction");
const ReplaySchema_1 = require("./ReplaySchema");
class OrchestratorState {
constructor(options, _literalActions = false) {
this.isDone = options.isDone;
this.actions = options.actions;
this.output = options.output;
this.schemaVersion = options.schemaVersion;
if (options.error) {
this.error = options.error;
}
if (options.customStatus) {
this.customStatus = options.customStatus;
}
if (options.schemaVersion === ReplaySchema_1.ReplaySchema.V1 && !_literalActions) {
const actions = this.actions[0];
const newActions = [];
if (actions !== undefined) {
for (const action of actions) {
const newEntry = [];
if (action instanceof WhenAllAction_1.WhenAllAction || action instanceof WhenAnyAction_1.WhenAnyAction) {
const innerActionArr = this.flattenCompoundActions(action.compoundActions);
newEntry.push(...innerActionArr);
}
else {
newEntry.push(action);
}
newActions.push(newEntry);
}
this.actions = newActions;
}
}
}
flattenCompoundActions(actions) {
const flatActions = [];
for (const action of actions) {
if (action instanceof WhenAllAction_1.WhenAllAction || action instanceof WhenAnyAction_1.WhenAnyAction) {
const innerActionArr = this.flattenCompoundActions(action.compoundActions);
flatActions.push(...innerActionArr);
}
else {
flatActions.push(action);
}
}
return flatActions;
}
}
exports.OrchestratorState = OrchestratorState;
//# sourceMappingURL=OrchestratorState.js.map
;