Comparing version 1.1.3 to 1.1.4
import { Field } from "./Field"; | ||
import { State } from "../states/State"; | ||
export declare type SupportedValueType = object | string | boolean | number | null; | ||
export declare type ResultType = { | ||
[k: string]: SupportedValueType; | ||
}; | ||
export declare class ResultField<T extends State> extends Field<T> { | ||
@@ -8,4 +11,6 @@ required: boolean; | ||
constructor(state: T); | ||
set(value: SupportedValueType): T; | ||
get(): SupportedValueType; | ||
set(name: string, value: SupportedValueType): T; | ||
setAll(value: ResultType): T; | ||
get(name: string): SupportedValueType; | ||
getAll(): ResultType; | ||
} |
@@ -19,15 +19,23 @@ "use strict"; | ||
_this.required = false; | ||
_this.result = null; | ||
_this.result = {}; | ||
return _this; | ||
} | ||
ResultField.prototype.set = function (value) { | ||
this.result = value; | ||
ResultField.prototype.set = function (name, value) { | ||
this.receiveConfiguration(); | ||
this.result[name] = value; | ||
return this.getParentState(); | ||
}; | ||
ResultField.prototype.get = function () { | ||
return this.result; | ||
ResultField.prototype.setAll = function (value) { | ||
this.receiveConfiguration(); | ||
this.result = value; | ||
return this.getParentState(); | ||
}; | ||
ResultField.prototype.get = function (name) { | ||
return this.result[name]; | ||
}; | ||
ResultField.prototype.getAll = function () { | ||
return JSON.parse(JSON.stringify(this.result)); | ||
}; | ||
return ResultField; | ||
}(Field_1.Field)); | ||
exports.ResultField = ResultField; |
@@ -86,3 +86,3 @@ "use strict"; | ||
StepFunctionsGenerator.prototype.generateResultField = function (field) { | ||
return { Result: field.get() }; | ||
return { Result: field.getAll() }; | ||
}; | ||
@@ -89,0 +89,0 @@ StepFunctionsGenerator.prototype.generateResultPathField = function (field) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("./utils"); | ||
var StateMachine = /** @class */ (function () { | ||
@@ -35,18 +36,3 @@ function StateMachine(options) { | ||
StateMachine.prototype.autoNextSetup = function () { | ||
var previousState; | ||
this.states.forEach(function (state) { | ||
if (previousState) { | ||
var next = previousState.next; | ||
if (next && !next.isConfigured()) { | ||
next.to(state); | ||
} | ||
} | ||
previousState = state; | ||
}); | ||
if (previousState) { | ||
var next = (previousState).next; | ||
if (next && !next.isConfigured()) { | ||
next.end(); | ||
} | ||
} | ||
utils_1.linkStates(this.states); | ||
}; | ||
@@ -53,0 +39,0 @@ StateMachine.prototype.validate = function () { |
import { State } from './State'; | ||
import { NextField } from '../fields/index'; | ||
import { PathField, ResultPathField, NextField } from '../fields/index'; | ||
export declare class ParallelBranch { | ||
@@ -11,2 +11,3 @@ private startAt; | ||
getStates(): State[]; | ||
autoNextSetup(): void; | ||
validate(): Error | null; | ||
@@ -17,2 +18,4 @@ } | ||
private branches; | ||
path: PathField<Parallel>; | ||
resultPath: ResultPathField<Parallel>; | ||
constructor(name: string); | ||
@@ -19,0 +22,0 @@ addBranch(branch?: ParallelBranch): ParallelBranch; |
@@ -15,2 +15,3 @@ "use strict"; | ||
var index_1 = require("../fields/index"); | ||
var utils_1 = require("../utils"); | ||
var ParallelBranch = /** @class */ (function () { | ||
@@ -34,2 +35,5 @@ function ParallelBranch(parentState) { | ||
}; | ||
ParallelBranch.prototype.autoNextSetup = function () { | ||
utils_1.linkStates(this.states); | ||
}; | ||
ParallelBranch.prototype.validate = function () { | ||
@@ -51,2 +55,4 @@ if (!this.startAt) { | ||
_this.next = new index_1.NextField(_this); | ||
_this.path = new index_1.PathField(_this); | ||
_this.resultPath = new index_1.ResultPathField(_this); | ||
return _this; | ||
@@ -53,0 +59,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { State } from "./states/State"; | ||
/** | ||
@@ -5,1 +6,2 @@ * @todo: Test this and allow more valid json-paths | ||
export declare function validateJSONPath(path: string): null | Error; | ||
export declare function linkStates(states: State[]): void; |
@@ -16,1 +16,20 @@ "use strict"; | ||
exports.validateJSONPath = validateJSONPath; | ||
function linkStates(states) { | ||
var previousState; | ||
states.forEach(function (state) { | ||
if (previousState) { | ||
var next = previousState.next; | ||
if (next && !next.isConfigured()) { | ||
next.to(state); | ||
} | ||
} | ||
previousState = state; | ||
}); | ||
if (previousState) { | ||
var next = (previousState).next; | ||
if (next && !next.isConfigured()) { | ||
next.end(); | ||
} | ||
} | ||
} | ||
exports.linkStates = linkStates; |
{ | ||
"name": "flowbject", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Flowbject is a library that allows you to describe state machines with objects.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
156955
3944