piemachine 0.0.7 → 0.0.8
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/pieMachine.js +15 -15
- package/package.json +2 -1
package/dist/pieMachine.js
CHANGED
|
@@ -79,11 +79,11 @@ export class PieMachine {
|
|
|
79
79
|
for (const from in this.edges) {
|
|
80
80
|
jsonEdges[from] = edgeToJSON(this.edges[from]);
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
(_a = this.statelogClient) === null || _a === void 0 ? void 0 : _a.graph({
|
|
83
83
|
nodes: Object.keys(this.nodes),
|
|
84
84
|
edges: jsonEdges,
|
|
85
85
|
startNode: startId,
|
|
86
|
-
})
|
|
86
|
+
});
|
|
87
87
|
let currentId = startId;
|
|
88
88
|
let data = input;
|
|
89
89
|
while (currentId) {
|
|
@@ -98,15 +98,15 @@ export class PieMachine {
|
|
|
98
98
|
const startTime = performance.now();
|
|
99
99
|
data = yield this.config.hooks.beforeNode(currentId, data);
|
|
100
100
|
const endTime = performance.now();
|
|
101
|
-
|
|
101
|
+
(_c = this.statelogClient) === null || _c === void 0 ? void 0 : _c.beforeHook({
|
|
102
102
|
nodeId: currentId,
|
|
103
103
|
startData,
|
|
104
104
|
endData: data,
|
|
105
105
|
timeTaken: endTime - startTime,
|
|
106
|
-
})
|
|
106
|
+
});
|
|
107
107
|
}
|
|
108
108
|
this.debug(`Executing node: ${color.green(currentId)}`, data);
|
|
109
|
-
|
|
109
|
+
(_d = this.statelogClient) === null || _d === void 0 ? void 0 : _d.enterNode({ nodeId: currentId, data });
|
|
110
110
|
const startTime = performance.now();
|
|
111
111
|
const result = yield this.runAndValidate(nodeFunc, currentId, data);
|
|
112
112
|
const endTime = performance.now();
|
|
@@ -118,11 +118,11 @@ export class PieMachine {
|
|
|
118
118
|
else {
|
|
119
119
|
data = result;
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
(_e = this.statelogClient) === null || _e === void 0 ? void 0 : _e.exitNode({
|
|
122
122
|
nodeId: currentId,
|
|
123
123
|
data,
|
|
124
124
|
timeTaken: endTime - startTime,
|
|
125
|
-
})
|
|
125
|
+
});
|
|
126
126
|
this.debug(`Completed node: ${color.green(currentId)}`, data);
|
|
127
127
|
if ((_f = this.config.hooks) === null || _f === void 0 ? void 0 : _f.afterNode) {
|
|
128
128
|
this.debug(`After hook for node: ${color.green(currentId)}`, data);
|
|
@@ -130,12 +130,12 @@ export class PieMachine {
|
|
|
130
130
|
const startTime = performance.now();
|
|
131
131
|
data = yield this.config.hooks.afterNode(currentId, data);
|
|
132
132
|
const endTime = performance.now();
|
|
133
|
-
|
|
133
|
+
(_g = this.statelogClient) === null || _g === void 0 ? void 0 : _g.afterHook({
|
|
134
134
|
nodeId: currentId,
|
|
135
135
|
startData,
|
|
136
136
|
endData: data,
|
|
137
137
|
timeTaken: endTime - startTime,
|
|
138
|
-
})
|
|
138
|
+
});
|
|
139
139
|
}
|
|
140
140
|
const edge = this.edges[currentId];
|
|
141
141
|
if (edge === undefined) {
|
|
@@ -147,35 +147,35 @@ export class PieMachine {
|
|
|
147
147
|
if (!isValidTarget) {
|
|
148
148
|
throw new PieMachineError(`${currentId} tried to go to ${nextNode}, but did not specify a conditional edge to it. Use graph.conditionalEdge("${currentId}", ["${nextNode}"]) to define the edge.`);
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
(_h = this.statelogClient) === null || _h === void 0 ? void 0 : _h.followEdge({
|
|
151
151
|
fromNodeId: currentId,
|
|
152
152
|
toNodeId: nextNode,
|
|
153
153
|
isConditionalEdge: false,
|
|
154
154
|
data,
|
|
155
|
-
})
|
|
155
|
+
});
|
|
156
156
|
this.debug(`Following goto edge to: ${color.green(nextNode)}`, data);
|
|
157
157
|
currentId = nextNode;
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
160
160
|
if (isRegularEdge(edge)) {
|
|
161
|
-
|
|
161
|
+
(_j = this.statelogClient) === null || _j === void 0 ? void 0 : _j.followEdge({
|
|
162
162
|
fromNodeId: currentId,
|
|
163
163
|
toNodeId: edge.to,
|
|
164
164
|
isConditionalEdge: false,
|
|
165
165
|
data,
|
|
166
|
-
})
|
|
166
|
+
});
|
|
167
167
|
this.debug(`Following regular edge to: ${color.green(edge.to)}`);
|
|
168
168
|
currentId = edge.to;
|
|
169
169
|
}
|
|
170
170
|
else {
|
|
171
171
|
if (edge.condition) {
|
|
172
172
|
const nextId = yield edge.condition(data);
|
|
173
|
-
|
|
173
|
+
(_k = this.statelogClient) === null || _k === void 0 ? void 0 : _k.followEdge({
|
|
174
174
|
fromNodeId: currentId,
|
|
175
175
|
toNodeId: nextId,
|
|
176
176
|
isConditionalEdge: true,
|
|
177
177
|
data,
|
|
178
|
-
})
|
|
178
|
+
});
|
|
179
179
|
this.debug(`Following conditional edge to: ${color.green(nextId)}`, data);
|
|
180
180
|
currentId = nextId;
|
|
181
181
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piemachine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "A general-purpose library for defining and running state machines. Easy as pie.",
|
|
5
5
|
"homepage": "https://github.com/egonSchiele/piemachine",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "vitest",
|
|
8
|
+
"test:run": "vitest run",
|
|
8
9
|
"test:tsc": "tsc -p tests/tsconfig.json",
|
|
9
10
|
"coverage": "vitest --coverage",
|
|
10
11
|
"build": "rm -rf dist && tsc",
|