@bitflow/core 0.5.0 → 0.5.4
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/{cjs/bits.d.ts → bits.d.ts} +0 -0
- package/dist/{cjs/bitsSchema.d.ts → bitsSchema.d.ts} +0 -0
- package/dist/{cjs/do.d.ts → do.d.ts} +0 -0
- package/dist/{cjs/doSchema.d.ts → doSchema.d.ts} +8 -8
- package/dist/{cjs/findLast.d.ts → findLast.d.ts} +0 -0
- package/dist/{cjs/flow.d.ts → flow.d.ts} +0 -0
- package/dist/{cjs/flowSchema.d.ts → flowSchema.d.ts} +0 -0
- package/dist/{cjs/groupBy.d.ts → groupBy.d.ts} +0 -0
- package/dist/index.cjs.js +732 -0
- package/dist/index.cjs.js.map +7 -0
- package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- package/dist/index.esm.mjs +703 -0
- package/dist/index.esm.mjs.map +7 -0
- package/dist/{cjs/lerpColor.d.ts → lerpColor.d.ts} +0 -0
- package/dist/{cjs/levenshtein.d.ts → levenshtein.d.ts} +0 -0
- package/dist/{cjs/uuid.d.ts → uuid.d.ts} +0 -0
- package/package.json +18 -22
- package/CHANGELOG.md +0 -38
- package/dist/cjs/bits.js +0 -16
- package/dist/cjs/bits.js.map +0 -1
- package/dist/cjs/bitsSchema.js +0 -77
- package/dist/cjs/bitsSchema.js.map +0 -1
- package/dist/cjs/do.js +0 -85
- package/dist/cjs/do.js.map +0 -1
- package/dist/cjs/doSchema.js +0 -38
- package/dist/cjs/doSchema.js.map +0 -1
- package/dist/cjs/findLast.js +0 -13
- package/dist/cjs/findLast.js.map +0 -1
- package/dist/cjs/flow.js +0 -131
- package/dist/cjs/flow.js.map +0 -1
- package/dist/cjs/flowSchema.js +0 -254
- package/dist/cjs/flowSchema.js.map +0 -1
- package/dist/cjs/groupBy.js +0 -27
- package/dist/cjs/groupBy.js.map +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/lerpColor.js +0 -9
- package/dist/cjs/lerpColor.js.map +0 -1
- package/dist/cjs/levenshtein.js +0 -88
- package/dist/cjs/levenshtein.js.map +0 -1
- package/dist/cjs/uuid.js +0 -16
- package/dist/cjs/uuid.js.map +0 -1
- package/dist/esm/bits.d.ts +0 -128
- package/dist/esm/bits.js +0 -9
- package/dist/esm/bits.js.map +0 -1
- package/dist/esm/bitsSchema.d.ts +0 -150
- package/dist/esm/bitsSchema.js +0 -55
- package/dist/esm/bitsSchema.js.map +0 -1
- package/dist/esm/do.d.ts +0 -37
- package/dist/esm/do.js +0 -62
- package/dist/esm/do.js.map +0 -1
- package/dist/esm/doSchema.d.ts +0 -1478
- package/dist/esm/doSchema.js +0 -23
- package/dist/esm/doSchema.js.map +0 -1
- package/dist/esm/findLast.d.ts +0 -1
- package/dist/esm/findLast.js +0 -9
- package/dist/esm/findLast.js.map +0 -1
- package/dist/esm/flow.d.ts +0 -169
- package/dist/esm/flow.js +0 -114
- package/dist/esm/flow.js.map +0 -1
- package/dist/esm/flowSchema.d.ts +0 -2520
- package/dist/esm/flowSchema.js +0 -202
- package/dist/esm/flowSchema.js.map +0 -1
- package/dist/esm/groupBy.d.ts +0 -1
- package/dist/esm/groupBy.js +0 -23
- package/dist/esm/groupBy.js.map +0 -1
- package/dist/esm/index.d.ts +0 -11
- package/dist/esm/index.js +0 -12
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lerpColor.d.ts +0 -1
- package/dist/esm/lerpColor.js +0 -5
- package/dist/esm/lerpColor.js.map +0 -1
- package/dist/esm/levenshtein.d.ts +0 -1
- package/dist/esm/levenshtein.js +0 -84
- package/dist/esm/levenshtein.js.map +0 -1
- package/dist/esm/uuid.d.ts +0 -1
- package/dist/esm/uuid.js +0 -12
- package/dist/esm/uuid.js.map +0 -1
- package/dist/types/bits.d.ts +0 -128
- package/dist/types/bitsSchema.d.ts +0 -150
- package/dist/types/do.d.ts +0 -37
- package/dist/types/doSchema.d.ts +0 -1478
- package/dist/types/findLast.d.ts +0 -1
- package/dist/types/flow.d.ts +0 -169
- package/dist/types/flowSchema.d.ts +0 -2520
- package/dist/types/groupBy.d.ts +0 -1
- package/dist/types/index.d.ts +0 -11
- package/dist/types/lerpColor.d.ts +0 -1
- package/dist/types/levenshtein.d.ts +0 -1
- package/dist/types/uuid.d.ts +0 -1
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// ../../scripts/emotion-shim.js
|
|
22
|
+
import { jsx } from "@emotion/react";
|
|
23
|
+
|
|
24
|
+
// src/bits.ts
|
|
25
|
+
var makeEvaluate = (evaluateMap) => ({ task, answer }) => {
|
|
26
|
+
const subtype = task.subtype;
|
|
27
|
+
const evaluate = evaluateMap[subtype];
|
|
28
|
+
if (!evaluate) {
|
|
29
|
+
throw new Error("subtype not supported");
|
|
30
|
+
}
|
|
31
|
+
return evaluate({ answer, task });
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/bitsSchema.ts
|
|
35
|
+
import * as z from "zod";
|
|
36
|
+
var FeedbackMessageSchema = z.object({
|
|
37
|
+
message: z.string(),
|
|
38
|
+
severity: z.enum(["error", "warning", "info", "success"])
|
|
39
|
+
});
|
|
40
|
+
var TaskSchema = z.object({
|
|
41
|
+
name: z.string(),
|
|
42
|
+
description: z.string().optional(),
|
|
43
|
+
subtype: z.string(),
|
|
44
|
+
view: z.record(z.any()),
|
|
45
|
+
evaluation: z.object({
|
|
46
|
+
mode: z.enum(["auto", "skip", "manual"]),
|
|
47
|
+
enableRetry: z.boolean(),
|
|
48
|
+
showFeedback: z.boolean()
|
|
49
|
+
}),
|
|
50
|
+
feedback: z.record(z.any()).optional()
|
|
51
|
+
});
|
|
52
|
+
var TaskStatisticSchema = z.object({
|
|
53
|
+
subtype: z.string(),
|
|
54
|
+
count: z.number()
|
|
55
|
+
});
|
|
56
|
+
var TaskAnswerSchema = z.object({
|
|
57
|
+
subtype: z.string()
|
|
58
|
+
});
|
|
59
|
+
var TaskResultSchema = z.object({
|
|
60
|
+
subtype: z.string(),
|
|
61
|
+
state: z.enum(["unknown", "manual", "correct", "wrong"]),
|
|
62
|
+
allowRetry: z.boolean().optional(),
|
|
63
|
+
feedback: z.any()
|
|
64
|
+
});
|
|
65
|
+
var InputSchema = z.object({
|
|
66
|
+
name: z.string(),
|
|
67
|
+
description: z.string(),
|
|
68
|
+
subtype: z.string(),
|
|
69
|
+
view: z.object({})
|
|
70
|
+
});
|
|
71
|
+
var TitleSchema = z.object({
|
|
72
|
+
name: z.string(),
|
|
73
|
+
description: z.string(),
|
|
74
|
+
subtype: z.string(),
|
|
75
|
+
view: z.object({})
|
|
76
|
+
});
|
|
77
|
+
var StartSchema = z.object({
|
|
78
|
+
name: z.string(),
|
|
79
|
+
description: z.string(),
|
|
80
|
+
subtype: z.string(),
|
|
81
|
+
view: z.object({})
|
|
82
|
+
});
|
|
83
|
+
var EndSchema = z.object({
|
|
84
|
+
name: z.string(),
|
|
85
|
+
description: z.string(),
|
|
86
|
+
subtype: z.string(),
|
|
87
|
+
view: z.object({})
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/do.ts
|
|
91
|
+
var isDoStartedTry = (d) => {
|
|
92
|
+
return d.status === "started";
|
|
93
|
+
};
|
|
94
|
+
var isDoFinishedTry = (d) => {
|
|
95
|
+
return d.status === "finished";
|
|
96
|
+
};
|
|
97
|
+
var isDoSkippedTry = (d) => {
|
|
98
|
+
return d.status === "skipped";
|
|
99
|
+
};
|
|
100
|
+
var skipDoTry = (doResult, evaluation = { mode: "skip" }) => {
|
|
101
|
+
const { tries } = doResult;
|
|
102
|
+
let { maxPoints } = doResult;
|
|
103
|
+
const currentTry = tries[tries.length - 1];
|
|
104
|
+
const hasTry = tries.find((doTry) => doTry.node.id === currentTry.node.id && doTry.status !== "started");
|
|
105
|
+
if (!hasTry && (evaluation == null ? void 0 : evaluation.mode) !== "skip") {
|
|
106
|
+
maxPoints += 1;
|
|
107
|
+
}
|
|
108
|
+
tries[tries.length - 1] = __spreadProps(__spreadValues({}, currentTry), {
|
|
109
|
+
evaluation,
|
|
110
|
+
status: "skipped",
|
|
111
|
+
endDate: new Date()
|
|
112
|
+
});
|
|
113
|
+
return __spreadProps(__spreadValues({}, doResult), {
|
|
114
|
+
maxPoints,
|
|
115
|
+
tries
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
var finishDoTry = (doResult, answer, result) => {
|
|
119
|
+
var _a, _b;
|
|
120
|
+
const { tries } = doResult;
|
|
121
|
+
let { points, maxPoints } = doResult;
|
|
122
|
+
const currentTry = tries[tries.length - 1];
|
|
123
|
+
const hasTry = tries.find((doTry) => doTry.node.id === currentTry.node.id && doTry.status !== "started");
|
|
124
|
+
if (!hasTry && (result == null ? void 0 : result.state) !== "unknown") {
|
|
125
|
+
maxPoints += 1;
|
|
126
|
+
}
|
|
127
|
+
tries[tries.length - 1] = __spreadProps(__spreadValues({}, currentTry), {
|
|
128
|
+
status: "finished",
|
|
129
|
+
endDate: new Date(),
|
|
130
|
+
answer,
|
|
131
|
+
result
|
|
132
|
+
});
|
|
133
|
+
const lastTry = tries.filter(isDoFinishedTry).find((doTry) => doTry.node.id === currentTry.node.id && currentTry.try - 1 === doTry.try);
|
|
134
|
+
if (!lastTry && (result == null ? void 0 : result.state) === "correct") {
|
|
135
|
+
points += 1;
|
|
136
|
+
} else if (((_a = lastTry == null ? void 0 : lastTry.result) == null ? void 0 : _a.state) === "correct" && (result == null ? void 0 : result.state) !== "correct") {
|
|
137
|
+
points -= 1;
|
|
138
|
+
} else if (((_b = lastTry == null ? void 0 : lastTry.result) == null ? void 0 : _b.state) !== "correct" && (result == null ? void 0 : result.state) === "correct") {
|
|
139
|
+
points += 1;
|
|
140
|
+
}
|
|
141
|
+
return __spreadProps(__spreadValues({}, doResult), {
|
|
142
|
+
maxPoints,
|
|
143
|
+
points,
|
|
144
|
+
tries
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
var retryDoTry = (doResult) => {
|
|
148
|
+
const { tries } = doResult;
|
|
149
|
+
const lastTry = tries[tries.length - 1];
|
|
150
|
+
tries.push({
|
|
151
|
+
status: "started",
|
|
152
|
+
try: lastTry.try + 1,
|
|
153
|
+
startDate: new Date(),
|
|
154
|
+
node: __spreadValues({}, lastTry.node)
|
|
155
|
+
});
|
|
156
|
+
return __spreadProps(__spreadValues({}, doResult), { tries });
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/doSchema.ts
|
|
160
|
+
import { z as z3 } from "zod";
|
|
161
|
+
|
|
162
|
+
// src/flowSchema.ts
|
|
163
|
+
import { z as z2 } from "zod";
|
|
164
|
+
var NodeBaseSchema = z2.object({
|
|
165
|
+
id: z2.string(),
|
|
166
|
+
position: z2.object({
|
|
167
|
+
x: z2.number(),
|
|
168
|
+
y: z2.number()
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
var FlowCheckpointNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
172
|
+
type: z2.literal("checkpoint")
|
|
173
|
+
}));
|
|
174
|
+
var FlowSynchronizeNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
175
|
+
type: z2.literal("synchronize"),
|
|
176
|
+
data: z2.object({
|
|
177
|
+
unlocked: z2.boolean()
|
|
178
|
+
})
|
|
179
|
+
}));
|
|
180
|
+
var makeFlowTaskNodeSchema = (task) => NodeBaseSchema.merge(z2.object({
|
|
181
|
+
type: z2.literal("task"),
|
|
182
|
+
data: task
|
|
183
|
+
}));
|
|
184
|
+
var makeFlowStartNodeSchema = (start) => NodeBaseSchema.merge(z2.object({
|
|
185
|
+
type: z2.literal("start"),
|
|
186
|
+
data: start
|
|
187
|
+
}));
|
|
188
|
+
var makeFlowEndNodeSchema = (end) => NodeBaseSchema.merge(z2.object({
|
|
189
|
+
type: z2.literal("end"),
|
|
190
|
+
data: end
|
|
191
|
+
}));
|
|
192
|
+
var makeFlowInputNodeSchema = (input) => NodeBaseSchema.merge(z2.object({
|
|
193
|
+
type: z2.literal("input"),
|
|
194
|
+
data: input
|
|
195
|
+
}));
|
|
196
|
+
var makeFlowTitleNodeSchema = (title) => NodeBaseSchema.merge(z2.object({
|
|
197
|
+
type: z2.literal("title"),
|
|
198
|
+
data: title
|
|
199
|
+
}));
|
|
200
|
+
var EqualConditionSchema = z2.object({
|
|
201
|
+
type: z2.literal("equal"),
|
|
202
|
+
not: z2.boolean(),
|
|
203
|
+
nodeId: z2.string(),
|
|
204
|
+
key: z2.string(),
|
|
205
|
+
value: z2.union([z2.string(), z2.number()])
|
|
206
|
+
});
|
|
207
|
+
var TrueConditionSchema = z2.object({
|
|
208
|
+
type: z2.literal("true"),
|
|
209
|
+
not: z2.boolean(),
|
|
210
|
+
nodeId: z2.string(),
|
|
211
|
+
key: z2.string()
|
|
212
|
+
});
|
|
213
|
+
var GreaterConditionSchema = z2.object({
|
|
214
|
+
type: z2.literal("greater"),
|
|
215
|
+
include: z2.boolean(),
|
|
216
|
+
not: z2.boolean(),
|
|
217
|
+
nodeId: z2.string(),
|
|
218
|
+
key: z2.string(),
|
|
219
|
+
value: z2.number()
|
|
220
|
+
});
|
|
221
|
+
var LessConditionSchema = z2.object({
|
|
222
|
+
type: z2.literal("less"),
|
|
223
|
+
include: z2.boolean(),
|
|
224
|
+
not: z2.boolean(),
|
|
225
|
+
nodeId: z2.string(),
|
|
226
|
+
key: z2.string(),
|
|
227
|
+
value: z2.number()
|
|
228
|
+
});
|
|
229
|
+
var InConditionSchema = z2.object({
|
|
230
|
+
type: z2.literal("in"),
|
|
231
|
+
not: z2.boolean(),
|
|
232
|
+
nodeId: z2.string(),
|
|
233
|
+
key: z2.string(),
|
|
234
|
+
value: z2.array(z2.union([z2.string(), z2.number()]))
|
|
235
|
+
});
|
|
236
|
+
var PrimitiveConditionSchema = z2.union([
|
|
237
|
+
EqualConditionSchema,
|
|
238
|
+
TrueConditionSchema,
|
|
239
|
+
GreaterConditionSchema,
|
|
240
|
+
LessConditionSchema,
|
|
241
|
+
InConditionSchema
|
|
242
|
+
]);
|
|
243
|
+
var AndConditionSchema = z2.object({
|
|
244
|
+
type: z2.literal("and"),
|
|
245
|
+
conditions: z2.array(PrimitiveConditionSchema)
|
|
246
|
+
});
|
|
247
|
+
var OrConditionSchema = z2.object({
|
|
248
|
+
type: z2.literal("or"),
|
|
249
|
+
conditions: z2.array(PrimitiveConditionSchema)
|
|
250
|
+
});
|
|
251
|
+
var ConditionSchema = z2.union([
|
|
252
|
+
PrimitiveConditionSchema,
|
|
253
|
+
AndConditionSchema,
|
|
254
|
+
OrConditionSchema
|
|
255
|
+
]);
|
|
256
|
+
var SplitAnswerSchema = z2.object({
|
|
257
|
+
condition: ConditionSchema
|
|
258
|
+
});
|
|
259
|
+
var FlowSplitAnswerNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
260
|
+
type: z2.literal("split-answer"),
|
|
261
|
+
data: SplitAnswerSchema
|
|
262
|
+
}));
|
|
263
|
+
var SplitResultSchema = z2.object({
|
|
264
|
+
condition: ConditionSchema
|
|
265
|
+
});
|
|
266
|
+
var FlowSplitResultNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
267
|
+
type: z2.literal("split-result"),
|
|
268
|
+
data: SplitResultSchema
|
|
269
|
+
}));
|
|
270
|
+
var SplitPointsSchema = z2.object({
|
|
271
|
+
points: z2.number()
|
|
272
|
+
});
|
|
273
|
+
var FlowSplitPointsNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
274
|
+
type: z2.literal("split-points"),
|
|
275
|
+
data: SplitPointsSchema
|
|
276
|
+
}));
|
|
277
|
+
var PortalInputSchema = z2.object({
|
|
278
|
+
portal: z2.string(),
|
|
279
|
+
description: z2.string()
|
|
280
|
+
});
|
|
281
|
+
var PortalOutputSchema = z2.object({
|
|
282
|
+
portal: z2.string(),
|
|
283
|
+
description: z2.string()
|
|
284
|
+
});
|
|
285
|
+
var FlowPortalInputNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
286
|
+
type: z2.literal("portal-input"),
|
|
287
|
+
data: PortalInputSchema
|
|
288
|
+
}));
|
|
289
|
+
var FlowPortalOutputNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
290
|
+
type: z2.literal("portal-output"),
|
|
291
|
+
data: PortalOutputSchema
|
|
292
|
+
}));
|
|
293
|
+
var FlowSplitRandomNodeSchema = NodeBaseSchema.merge(z2.object({
|
|
294
|
+
type: z2.literal("split-random")
|
|
295
|
+
}));
|
|
296
|
+
var ControlFlowNodeSchema = z2.union([
|
|
297
|
+
FlowSplitAnswerNodeSchema,
|
|
298
|
+
FlowSplitResultNodeSchema,
|
|
299
|
+
FlowSplitPointsNodeSchema,
|
|
300
|
+
FlowSplitRandomNodeSchema,
|
|
301
|
+
FlowPortalInputNodeSchema,
|
|
302
|
+
FlowPortalOutputNodeSchema
|
|
303
|
+
]);
|
|
304
|
+
var makeInteractiveFlowNodeSchema = ({
|
|
305
|
+
start,
|
|
306
|
+
end,
|
|
307
|
+
input,
|
|
308
|
+
title,
|
|
309
|
+
task
|
|
310
|
+
}) => z2.union([
|
|
311
|
+
makeFlowStartNodeSchema(start),
|
|
312
|
+
makeFlowEndNodeSchema(end),
|
|
313
|
+
makeFlowInputNodeSchema(input),
|
|
314
|
+
makeFlowTaskNodeSchema(task),
|
|
315
|
+
makeFlowTitleNodeSchema(title),
|
|
316
|
+
FlowSynchronizeNodeSchema,
|
|
317
|
+
FlowCheckpointNodeSchema
|
|
318
|
+
]);
|
|
319
|
+
var FlowEdgeSchema = z2.object({
|
|
320
|
+
id: z2.string(),
|
|
321
|
+
source: z2.string(),
|
|
322
|
+
sourceHandle: z2.union([
|
|
323
|
+
z2.literal("a"),
|
|
324
|
+
z2.literal("b"),
|
|
325
|
+
z2.literal("c"),
|
|
326
|
+
z2.literal("d"),
|
|
327
|
+
z2.literal("e"),
|
|
328
|
+
z2.literal("f")
|
|
329
|
+
]).optional(),
|
|
330
|
+
target: z2.string()
|
|
331
|
+
});
|
|
332
|
+
var makeFlowNodeSchema = ({
|
|
333
|
+
end,
|
|
334
|
+
input,
|
|
335
|
+
start,
|
|
336
|
+
task,
|
|
337
|
+
title
|
|
338
|
+
}) => z2.union([
|
|
339
|
+
FlowSplitAnswerNodeSchema,
|
|
340
|
+
FlowSplitResultNodeSchema,
|
|
341
|
+
FlowSplitPointsNodeSchema,
|
|
342
|
+
FlowSplitRandomNodeSchema,
|
|
343
|
+
FlowPortalInputNodeSchema,
|
|
344
|
+
FlowPortalOutputNodeSchema,
|
|
345
|
+
FlowSynchronizeNodeSchema,
|
|
346
|
+
FlowCheckpointNodeSchema,
|
|
347
|
+
makeFlowEndNodeSchema(end),
|
|
348
|
+
makeFlowInputNodeSchema(input),
|
|
349
|
+
makeFlowStartNodeSchema(start),
|
|
350
|
+
makeFlowTaskNodeSchema(task),
|
|
351
|
+
makeFlowTitleNodeSchema(title)
|
|
352
|
+
]);
|
|
353
|
+
var makeFlowSchema = ({
|
|
354
|
+
end,
|
|
355
|
+
input,
|
|
356
|
+
start,
|
|
357
|
+
task,
|
|
358
|
+
title
|
|
359
|
+
}) => z2.object({
|
|
360
|
+
name: z2.string(),
|
|
361
|
+
description: z2.string(),
|
|
362
|
+
language: z2.enum(["en", "de", "fr", "es", "nl", "pt", "tr", "it"]),
|
|
363
|
+
visibility: z2.enum(["public", "private", "unlisted"]),
|
|
364
|
+
draft: z2.boolean(),
|
|
365
|
+
nodes: z2.array(makeFlowNodeSchema({ start, end, input, title, task })),
|
|
366
|
+
edges: z2.array(FlowEdgeSchema),
|
|
367
|
+
zoom: z2.number().positive().default(1),
|
|
368
|
+
position: z2.tuple([z2.number(), z2.number()]).default([0, 0])
|
|
369
|
+
}).refine((data) => {
|
|
370
|
+
const ids = data.nodes.map((n) => n.id);
|
|
371
|
+
for (let edge of data.edges) {
|
|
372
|
+
if (!ids.includes(edge.source) || !ids.includes(edge.target)) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return true;
|
|
377
|
+
}, { message: "Target and source of an edge need to be valid node ids." });
|
|
378
|
+
|
|
379
|
+
// src/doSchema.ts
|
|
380
|
+
var makeDoBaseTrySchema = (flowNodeSchemas) => z3.object({
|
|
381
|
+
node: makeInteractiveFlowNodeSchema(flowNodeSchemas),
|
|
382
|
+
startDate: z3.date(),
|
|
383
|
+
try: z3.number(),
|
|
384
|
+
status: z3.string()
|
|
385
|
+
});
|
|
386
|
+
var makeDoStartedTry = (flowNodeSchemas) => makeDoBaseTrySchema(flowNodeSchemas).merge(z3.object({
|
|
387
|
+
status: z3.literal("started")
|
|
388
|
+
}));
|
|
389
|
+
var makeDoFinishedTry = (flowNodeSchemas) => makeDoBaseTrySchema(flowNodeSchemas).merge(z3.object({
|
|
390
|
+
status: z3.literal("finished"),
|
|
391
|
+
endDate: z3.date(),
|
|
392
|
+
answer: TaskAnswerSchema.optional(),
|
|
393
|
+
result: TaskResultSchema.optional()
|
|
394
|
+
}));
|
|
395
|
+
var makeDoSkippedTry = (flowNodeSchemas) => makeDoBaseTrySchema(flowNodeSchemas).merge(z3.object({
|
|
396
|
+
status: z3.literal("skipped"),
|
|
397
|
+
endDate: z3.date()
|
|
398
|
+
}));
|
|
399
|
+
|
|
400
|
+
// src/findLast.ts
|
|
401
|
+
function findLast(array, predicate) {
|
|
402
|
+
let l = array.length;
|
|
403
|
+
while (l--) {
|
|
404
|
+
if (predicate(array[l], l, array))
|
|
405
|
+
return array[l];
|
|
406
|
+
}
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// src/flow.ts
|
|
411
|
+
var isFlowTaskNode = (n) => {
|
|
412
|
+
if (n.type === "task") {
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
return false;
|
|
416
|
+
};
|
|
417
|
+
var isFlowStartNode = (n) => {
|
|
418
|
+
if (n.type === "start") {
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
return false;
|
|
422
|
+
};
|
|
423
|
+
var isFlowEndNode = (n) => {
|
|
424
|
+
if (n.type === "end") {
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
};
|
|
429
|
+
var isFlowInputNode = (n) => {
|
|
430
|
+
if (n.type === "input") {
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
};
|
|
435
|
+
var isFlowTitleNode = (n) => {
|
|
436
|
+
if (n.type === "title") {
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
return false;
|
|
440
|
+
};
|
|
441
|
+
var isFlowSplitAnswerNode = (n) => {
|
|
442
|
+
return n.type === "split-answer";
|
|
443
|
+
};
|
|
444
|
+
var isFlowSplitResultNode = (n) => {
|
|
445
|
+
return n.type === "split-result";
|
|
446
|
+
};
|
|
447
|
+
var isFlowSplitPointsNode = (n) => {
|
|
448
|
+
return n.type === "split-points";
|
|
449
|
+
};
|
|
450
|
+
var isFlowPortalInputNode = (n) => {
|
|
451
|
+
return n.type === "portal-input";
|
|
452
|
+
};
|
|
453
|
+
var isFlowPortalOutputNode = (n) => {
|
|
454
|
+
return n.type === "portal-output";
|
|
455
|
+
};
|
|
456
|
+
var isFlowSplitRandomNode = (n) => {
|
|
457
|
+
return n.type === "split-random";
|
|
458
|
+
};
|
|
459
|
+
var isControlFlowNode = (n) => {
|
|
460
|
+
return n.type === "portal-input" || n.type === "portal-output" || n.type === "split-answer" || n.type === "split-points" || n.type === "split-random" || n.type === "split-result";
|
|
461
|
+
};
|
|
462
|
+
var isInteractiveFlowNode = (n) => {
|
|
463
|
+
if (n.type === "checkpoint" || n.type === "end" || n.type === "input" || n.type === "start" || n.type === "synchronize" || n.type === "task" || n.type === "title") {
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
return false;
|
|
467
|
+
};
|
|
468
|
+
var extractInteractiveFlowPublicNode = (n) => {
|
|
469
|
+
if (n.type === "task") {
|
|
470
|
+
return {
|
|
471
|
+
id: n.id,
|
|
472
|
+
type: n.type,
|
|
473
|
+
data: {
|
|
474
|
+
name: n.data.name,
|
|
475
|
+
subtype: n.data.subtype,
|
|
476
|
+
view: n.data.view
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
} else if (n.type === "synchronize" || n.type === "checkpoint") {
|
|
480
|
+
return {
|
|
481
|
+
id: n.id,
|
|
482
|
+
type: n.type
|
|
483
|
+
};
|
|
484
|
+
} else if (n.type === "input") {
|
|
485
|
+
return {
|
|
486
|
+
id: n.id,
|
|
487
|
+
type: n.type,
|
|
488
|
+
data: n.data
|
|
489
|
+
};
|
|
490
|
+
} else if (n.type === "end") {
|
|
491
|
+
return {
|
|
492
|
+
id: n.id,
|
|
493
|
+
type: n.type,
|
|
494
|
+
data: n.data
|
|
495
|
+
};
|
|
496
|
+
} else if (n.type === "start") {
|
|
497
|
+
return {
|
|
498
|
+
id: n.id,
|
|
499
|
+
type: n.type,
|
|
500
|
+
data: n.data
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
id: n.id,
|
|
505
|
+
type: n.type,
|
|
506
|
+
data: n.data
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/groupBy.ts
|
|
511
|
+
function groupBy(array, by) {
|
|
512
|
+
const grouped = [];
|
|
513
|
+
let index = 0;
|
|
514
|
+
const indexes = {};
|
|
515
|
+
let l = 0;
|
|
516
|
+
while (l < array.length) {
|
|
517
|
+
const value = array[l];
|
|
518
|
+
const key = by(value);
|
|
519
|
+
if (indexes[key] === void 0) {
|
|
520
|
+
indexes[key] = index;
|
|
521
|
+
index++;
|
|
522
|
+
}
|
|
523
|
+
if (!grouped[indexes[key]]) {
|
|
524
|
+
grouped[indexes[key]] = [value];
|
|
525
|
+
} else {
|
|
526
|
+
grouped[indexes[key]].push(value);
|
|
527
|
+
}
|
|
528
|
+
l++;
|
|
529
|
+
}
|
|
530
|
+
return grouped;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// src/lerpColor.ts
|
|
534
|
+
function lerpColor(a, b, amount) {
|
|
535
|
+
let ah = +a.replace("#", "0x"), ar = ah >> 16, ag = ah >> 8 & 255, ab = ah & 255, bh = +b.replace("#", "0x"), br = bh >> 16, bg = bh >> 8 & 255, bb = bh & 255, rr = ar + amount * (br - ar), rg = ag + amount * (bg - ag), rb = ab + amount * (bb - ab);
|
|
536
|
+
return "#" + ((1 << 24) + (rr << 16) + (rg << 8) + rb | 0).toString(16).slice(1);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/levenshtein.ts
|
|
540
|
+
function _min(d0, d1, d2, bx, ay) {
|
|
541
|
+
return d0 < d1 || d2 < d1 ? d0 > d2 ? d2 + 1 : d0 + 1 : bx === ay ? d1 : d1 + 1;
|
|
542
|
+
}
|
|
543
|
+
var levenshtein = (a, b) => {
|
|
544
|
+
if (a === b) {
|
|
545
|
+
return 0;
|
|
546
|
+
}
|
|
547
|
+
if (a.length > b.length) {
|
|
548
|
+
var tmp = a;
|
|
549
|
+
a = b;
|
|
550
|
+
b = tmp;
|
|
551
|
+
}
|
|
552
|
+
var la = a.length;
|
|
553
|
+
var lb = b.length;
|
|
554
|
+
while (la > 0 && a.charCodeAt(la - 1) === b.charCodeAt(lb - 1)) {
|
|
555
|
+
la--;
|
|
556
|
+
lb--;
|
|
557
|
+
}
|
|
558
|
+
var offset = 0;
|
|
559
|
+
while (offset < la && a.charCodeAt(offset) === b.charCodeAt(offset)) {
|
|
560
|
+
offset++;
|
|
561
|
+
}
|
|
562
|
+
la -= offset;
|
|
563
|
+
lb -= offset;
|
|
564
|
+
if (la === 0 || lb < 3) {
|
|
565
|
+
return lb;
|
|
566
|
+
}
|
|
567
|
+
let x = 0;
|
|
568
|
+
let y;
|
|
569
|
+
let d0;
|
|
570
|
+
let d1;
|
|
571
|
+
let d2;
|
|
572
|
+
let d3;
|
|
573
|
+
let dd = 0;
|
|
574
|
+
let dy;
|
|
575
|
+
let ay;
|
|
576
|
+
let bx0;
|
|
577
|
+
let bx1;
|
|
578
|
+
let bx2;
|
|
579
|
+
let bx3;
|
|
580
|
+
let vector = [];
|
|
581
|
+
for (y = 0; y < la; y++) {
|
|
582
|
+
vector.push(y + 1);
|
|
583
|
+
vector.push(a.charCodeAt(offset + y));
|
|
584
|
+
}
|
|
585
|
+
let len = vector.length - 1;
|
|
586
|
+
for (; x < lb - 3; ) {
|
|
587
|
+
bx0 = b.charCodeAt(offset + (d0 = x));
|
|
588
|
+
bx1 = b.charCodeAt(offset + (d1 = x + 1));
|
|
589
|
+
bx2 = b.charCodeAt(offset + (d2 = x + 2));
|
|
590
|
+
bx3 = b.charCodeAt(offset + (d3 = x + 3));
|
|
591
|
+
dd = x += 4;
|
|
592
|
+
for (y = 0; y < len; y += 2) {
|
|
593
|
+
dy = vector[y];
|
|
594
|
+
ay = vector[y + 1];
|
|
595
|
+
d0 = _min(dy, d0, d1, bx0, ay);
|
|
596
|
+
d1 = _min(d0, d1, d2, bx1, ay);
|
|
597
|
+
d2 = _min(d1, d2, d3, bx2, ay);
|
|
598
|
+
dd = _min(d2, d3, dd, bx3, ay);
|
|
599
|
+
vector[y] = dd;
|
|
600
|
+
d3 = d2;
|
|
601
|
+
d2 = d1;
|
|
602
|
+
d1 = d0;
|
|
603
|
+
d0 = dy;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
for (; x < lb; ) {
|
|
607
|
+
bx0 = b.charCodeAt(offset + (d0 = x));
|
|
608
|
+
dd = ++x;
|
|
609
|
+
for (y = 0; y < len; y += 2) {
|
|
610
|
+
dy = vector[y];
|
|
611
|
+
vector[y] = dd = _min(dy, d0, dd, bx0, vector[y + 1]);
|
|
612
|
+
d0 = dy;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return dd;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// src/uuid.ts
|
|
619
|
+
function uuidv4() {
|
|
620
|
+
var uuid = "", i, random;
|
|
621
|
+
for (i = 0; i < 32; i++) {
|
|
622
|
+
random = Math.random() * 16 | 0;
|
|
623
|
+
if (i == 8 || i == 12 || i == 16 || i == 20) {
|
|
624
|
+
uuid += "-";
|
|
625
|
+
}
|
|
626
|
+
uuid += (i == 12 ? 4 : i == 16 ? random & 3 | 8 : random).toString(16);
|
|
627
|
+
}
|
|
628
|
+
return uuid;
|
|
629
|
+
}
|
|
630
|
+
export {
|
|
631
|
+
AndConditionSchema,
|
|
632
|
+
ConditionSchema,
|
|
633
|
+
ControlFlowNodeSchema,
|
|
634
|
+
EndSchema,
|
|
635
|
+
EqualConditionSchema,
|
|
636
|
+
FeedbackMessageSchema,
|
|
637
|
+
FlowCheckpointNodeSchema,
|
|
638
|
+
FlowEdgeSchema,
|
|
639
|
+
FlowPortalInputNodeSchema,
|
|
640
|
+
FlowPortalOutputNodeSchema,
|
|
641
|
+
FlowSplitAnswerNodeSchema,
|
|
642
|
+
FlowSplitPointsNodeSchema,
|
|
643
|
+
FlowSplitRandomNodeSchema,
|
|
644
|
+
FlowSplitResultNodeSchema,
|
|
645
|
+
FlowSynchronizeNodeSchema,
|
|
646
|
+
GreaterConditionSchema,
|
|
647
|
+
InConditionSchema,
|
|
648
|
+
InputSchema,
|
|
649
|
+
LessConditionSchema,
|
|
650
|
+
OrConditionSchema,
|
|
651
|
+
PortalInputSchema,
|
|
652
|
+
PortalOutputSchema,
|
|
653
|
+
PrimitiveConditionSchema,
|
|
654
|
+
SplitAnswerSchema,
|
|
655
|
+
SplitPointsSchema,
|
|
656
|
+
SplitResultSchema,
|
|
657
|
+
StartSchema,
|
|
658
|
+
TaskAnswerSchema,
|
|
659
|
+
TaskResultSchema,
|
|
660
|
+
TaskSchema,
|
|
661
|
+
TaskStatisticSchema,
|
|
662
|
+
TitleSchema,
|
|
663
|
+
TrueConditionSchema,
|
|
664
|
+
extractInteractiveFlowPublicNode,
|
|
665
|
+
findLast,
|
|
666
|
+
finishDoTry,
|
|
667
|
+
groupBy,
|
|
668
|
+
isControlFlowNode,
|
|
669
|
+
isDoFinishedTry,
|
|
670
|
+
isDoSkippedTry,
|
|
671
|
+
isDoStartedTry,
|
|
672
|
+
isFlowEndNode,
|
|
673
|
+
isFlowInputNode,
|
|
674
|
+
isFlowPortalInputNode,
|
|
675
|
+
isFlowPortalOutputNode,
|
|
676
|
+
isFlowSplitAnswerNode,
|
|
677
|
+
isFlowSplitPointsNode,
|
|
678
|
+
isFlowSplitRandomNode,
|
|
679
|
+
isFlowSplitResultNode,
|
|
680
|
+
isFlowStartNode,
|
|
681
|
+
isFlowTaskNode,
|
|
682
|
+
isFlowTitleNode,
|
|
683
|
+
isInteractiveFlowNode,
|
|
684
|
+
lerpColor,
|
|
685
|
+
levenshtein,
|
|
686
|
+
makeDoBaseTrySchema,
|
|
687
|
+
makeDoFinishedTry,
|
|
688
|
+
makeDoSkippedTry,
|
|
689
|
+
makeDoStartedTry,
|
|
690
|
+
makeEvaluate,
|
|
691
|
+
makeFlowEndNodeSchema,
|
|
692
|
+
makeFlowInputNodeSchema,
|
|
693
|
+
makeFlowNodeSchema,
|
|
694
|
+
makeFlowSchema,
|
|
695
|
+
makeFlowStartNodeSchema,
|
|
696
|
+
makeFlowTaskNodeSchema,
|
|
697
|
+
makeFlowTitleNodeSchema,
|
|
698
|
+
makeInteractiveFlowNodeSchema,
|
|
699
|
+
retryDoTry,
|
|
700
|
+
skipDoTry,
|
|
701
|
+
uuidv4
|
|
702
|
+
};
|
|
703
|
+
//# sourceMappingURL=index.esm.mjs.map
|