@emaarco/bpmn-js-data-simulation 0.7.0 → 0.7.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathVariableDeriver.d.ts","sourceRoot":"","sources":["../../src/domain/PathVariableDeriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"PathVariableDeriver.d.ts","sourceRoot":"","sources":["../../src/domain/PathVariableDeriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAYtF,qBAAa,mBAAmB;IAC9B,MAAM,CACJ,UAAU,EAAE,SAAS,cAAc,EAAE,EACrC,MAAM,EAAE,SAAS,EACjB,cAAc,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAM,GAClE,YAAY,EAAE;IAQjB,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,cAAc;CAGvB"}
|
package/dist/index.cjs
CHANGED
|
@@ -2473,6 +2473,7 @@ const NICE_STEPS = [1, 2, 5, 10];
|
|
|
2473
2473
|
const RANGE_STEPS = 100;
|
|
2474
2474
|
const NUMBER_LITERAL = /(?<![\w.])\d+(?:\.\d+)?/g;
|
|
2475
2475
|
const COMPARISON = String.raw`(?:<=|>=|==|!=|<|>|=|\b(?:lt|gt|le|ge|eq|ne)\b)`;
|
|
2476
|
+
const RELATIONAL = String.raw`(?:<=|>=|<|>|\b(?:lt|gt|le|ge)\b)`;
|
|
2476
2477
|
const EQUALITY = String.raw`(?:==|!=|=|\b(?:eq|ne)\b)`;
|
|
2477
2478
|
const BOOLEAN_LEFT = String.raw`(?:^|(?<![\w$.])\(|\bnot\s*\(|!|&&|\|\||\b(?:and|or|not)\b)`;
|
|
2478
2479
|
const BOOLEAN_RIGHT = String.raw`(?=$|\)|&&|\|\||\b(?:and|or)\b)`;
|
|
@@ -2481,24 +2482,28 @@ class PathVariableDeriver {
|
|
|
2481
2482
|
const names = [...new Set(conditions.flatMap((condition) => condition.variableNames))];
|
|
2482
2483
|
return names.map((name) => {
|
|
2483
2484
|
const conditionsReadingName = conditions.filter((condition) => condition.variableNames.includes(name));
|
|
2484
|
-
return this.variableFor(name, values
|
|
2485
|
+
return this.variableFor(name, values, conditionsReadingName, rangeOverrides[name] ?? {});
|
|
2485
2486
|
});
|
|
2486
2487
|
}
|
|
2487
|
-
variableFor(name,
|
|
2488
|
+
variableFor(name, values, conditionsReadingName, rangeOverride) {
|
|
2489
|
+
const value = values[name];
|
|
2488
2490
|
const type = value === void 0 ? this.typeFromConditions(name, conditionsReadingName) : typeof value;
|
|
2489
2491
|
if (type === "boolean") return { name, type: "boolean" };
|
|
2490
2492
|
if (type === "number") {
|
|
2491
|
-
const comparedNumbers = conditionsReadingName.flatMap((condition) =>
|
|
2493
|
+
const comparedNumbers = conditionsReadingName.flatMap((condition) => [
|
|
2494
|
+
...this.numberLiterals(condition.expression),
|
|
2495
|
+
...this.numbersOfOtherVariables(name, condition, values)
|
|
2496
|
+
]);
|
|
2492
2497
|
return { name, type: "number", range: this.rangeAround(Number(value ?? 0), comparedNumbers, rangeOverride) };
|
|
2493
2498
|
}
|
|
2494
2499
|
if (value === void 0 || typeof value === "string") return { name, type: "text" };
|
|
2495
2500
|
return { name, type: "json" };
|
|
2496
2501
|
}
|
|
2497
|
-
// Without a value the conditions tell the type: compared with a number
|
|
2502
|
+
// Without a value the conditions tell the type: compared with a number or by <, <=, > or >=, or used as a condition of its own.
|
|
2498
2503
|
typeFromConditions(name, conditions) {
|
|
2499
2504
|
const variable = String.raw`(?<![\w.$])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\w.(])`;
|
|
2500
2505
|
const comparedWithNumber = new RegExp(
|
|
2501
|
-
String.raw`${variable}\s*${COMPARISON}\s*-?\d|\d\s*${COMPARISON}\s*${variable}`
|
|
2506
|
+
String.raw`${variable}\s*${COMPARISON}\s*-?\d|\d\s*${COMPARISON}\s*${variable}|${variable}\s*${RELATIONAL}|${RELATIONAL}\s*${variable}`
|
|
2502
2507
|
);
|
|
2503
2508
|
const usedAsBoolean = new RegExp(
|
|
2504
2509
|
String.raw`${BOOLEAN_LEFT}\s*${variable}\s*${BOOLEAN_RIGHT}|${variable}\s*${EQUALITY}\s*(?:true|false)\b|\b(?:true|false)\s*${EQUALITY}\s*${variable}`
|
|
@@ -2526,6 +2531,10 @@ class PathVariableDeriver {
|
|
|
2526
2531
|
const magnitude = 10 ** Math.floor(Math.log10(value));
|
|
2527
2532
|
return NICE_STEPS.find((step) => step * magnitude >= value) * magnitude;
|
|
2528
2533
|
}
|
|
2534
|
+
// The numbers the other variables of the condition hold, e.g. a minimum score the variable is compared with.
|
|
2535
|
+
numbersOfOtherVariables(name, condition, values) {
|
|
2536
|
+
return condition.variableNames.filter((otherName) => otherName !== name).map((otherName) => values[otherName]).filter((otherValue) => typeof otherValue === "number");
|
|
2537
|
+
}
|
|
2529
2538
|
numberLiterals(expression) {
|
|
2530
2539
|
return (expression.match(NUMBER_LITERAL) ?? []).map(Number);
|
|
2531
2540
|
}
|