ballerina-core 1.0.211 → 1.0.212
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/package.json
CHANGED
package/src/forms/domains/dispatched-forms/deserializer/domains/specification/domains/types/state.ts
CHANGED
|
@@ -49,7 +49,7 @@ export type SerializedKeyOfType<T> = {
|
|
|
49
49
|
|
|
50
50
|
export type ValidatedSerializedKeyOfType<T> = {
|
|
51
51
|
fun: "KeyOf";
|
|
52
|
-
args: Array<string
|
|
52
|
+
args: [string, Array<string>?];
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
export type SerializedLookupType = string;
|
|
@@ -183,7 +183,7 @@ export const SerializedType = {
|
|
|
183
183
|
_.fun == "KeyOf" &&
|
|
184
184
|
"args" in _ &&
|
|
185
185
|
Array.isArray(_.args) &&
|
|
186
|
-
_.args.length == 1 &&
|
|
186
|
+
(_.args.length == 1 || (_.args.length == 2 && Array.isArray(_.args[1]))) &&
|
|
187
187
|
DispatchisString(_.args[0]),
|
|
188
188
|
isOne: <T>(
|
|
189
189
|
_: SerializedType<T>,
|
|
@@ -852,6 +852,11 @@ export const DispatchParsedType = {
|
|
|
852
852
|
Map(
|
|
853
853
|
parsingResult[0].fields
|
|
854
854
|
.keySeq()
|
|
855
|
+
.filter(
|
|
856
|
+
(key) =>
|
|
857
|
+
rawType.args[1] == undefined ||
|
|
858
|
+
!rawType.args[1].includes(key),
|
|
859
|
+
)
|
|
855
860
|
.toArray()
|
|
856
861
|
.map((key) => [
|
|
857
862
|
key,
|
|
@@ -556,6 +556,7 @@ export type ExprBinaryOperator = {
|
|
|
556
556
|
kind: BinaryOperator;
|
|
557
557
|
operands: [Expr, Expr];
|
|
558
558
|
};
|
|
559
|
+
export type ExprPrepend = { kind: "prepend"; operands: [Array<string>, Expr] };
|
|
559
560
|
|
|
560
561
|
export type Expr =
|
|
561
562
|
| PredicateValue
|
|
@@ -565,7 +566,8 @@ export type Expr =
|
|
|
565
566
|
| ExprBinaryOperator
|
|
566
567
|
| ExprLambda
|
|
567
568
|
| ExprMatchCase
|
|
568
|
-
| ExprCase
|
|
569
|
+
| ExprCase
|
|
570
|
+
| ExprPrepend;
|
|
569
571
|
|
|
570
572
|
export const BinaryOperators = ["or", "equals"] as const;
|
|
571
573
|
export const BinaryOperatorsSet = Set(BinaryOperators);
|
|
@@ -1314,6 +1316,10 @@ export const PredicateValue = {
|
|
|
1314
1316
|
|
|
1315
1317
|
export const Expr = {
|
|
1316
1318
|
Default: {
|
|
1319
|
+
prepend: (prependCases: Array<string>, e: Expr): Expr => ({
|
|
1320
|
+
kind: "prepend",
|
|
1321
|
+
operands: [prependCases, e],
|
|
1322
|
+
}),
|
|
1317
1323
|
itemLookup: (e: Expr, i: number): Expr => ({
|
|
1318
1324
|
kind: "itemLookup",
|
|
1319
1325
|
operands: [e, i],
|
|
@@ -1346,6 +1352,13 @@ export const Expr = {
|
|
|
1346
1352
|
}),
|
|
1347
1353
|
},
|
|
1348
1354
|
Operations: {
|
|
1355
|
+
IsPrepend: (e: Expr): e is ExprPrepend => {
|
|
1356
|
+
return (
|
|
1357
|
+
typeof e == "object" &&
|
|
1358
|
+
!PredicateValue.Operations.IsDate(e) &&
|
|
1359
|
+
e.kind == "prepend"
|
|
1360
|
+
);
|
|
1361
|
+
},
|
|
1349
1362
|
IsItemLookup: (e: Expr): e is ExprItemLookup => {
|
|
1350
1363
|
return (
|
|
1351
1364
|
typeof e == "object" &&
|
|
@@ -1487,6 +1500,14 @@ export const Expr = {
|
|
|
1487
1500
|
),
|
|
1488
1501
|
);
|
|
1489
1502
|
}
|
|
1503
|
+
if (Expr.Operations.IsPrepend(json)) {
|
|
1504
|
+
const [casesToPrepend, expr]: [Array<string>, Expr] = json["operands"];
|
|
1505
|
+
return Expr.Operations.parse(expr).Then((expr) =>
|
|
1506
|
+
ValueOrErrors.Default.return(
|
|
1507
|
+
Expr.Default.prepend(casesToPrepend, expr),
|
|
1508
|
+
),
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1490
1511
|
return ValueOrErrors.Default.throwOne(
|
|
1491
1512
|
`cannot parse ${JSON.stringify(json)} to Expr.`,
|
|
1492
1513
|
);
|
|
@@ -1605,7 +1626,6 @@ export const Expr = {
|
|
|
1605
1626
|
PredicateValue.Operations.IsRecord(e) ||
|
|
1606
1627
|
PredicateValue.Operations.IsTuple(e) ||
|
|
1607
1628
|
PredicateValue.Operations.IsUnionCase(e) ||
|
|
1608
|
-
PredicateValue.Operations.IsUnit(e) ||
|
|
1609
1629
|
PredicateValue.Operations.IsSum(e)
|
|
1610
1630
|
? ValueOrErrors.Default.return(e)
|
|
1611
1631
|
: PredicateValue.Operations.IsVarLookup(e)
|
|
@@ -1702,9 +1722,42 @@ export const Expr = {
|
|
|
1702
1722
|
),
|
|
1703
1723
|
),
|
|
1704
1724
|
)
|
|
1705
|
-
:
|
|
1706
|
-
|
|
1707
|
-
|
|
1725
|
+
: Expr.Operations.IsPrepend(e)
|
|
1726
|
+
? Expr.Operations.Evaluate(vars)(
|
|
1727
|
+
e.operands[1],
|
|
1728
|
+
).Then((v) =>
|
|
1729
|
+
Expr.Operations.EvaluateAsRecord(vars)(
|
|
1730
|
+
v,
|
|
1731
|
+
).Then((v) => {
|
|
1732
|
+
const prependEntries: [
|
|
1733
|
+
string,
|
|
1734
|
+
PredicateValue,
|
|
1735
|
+
][] = e.operands[0].map((c: string) => [
|
|
1736
|
+
c,
|
|
1737
|
+
PredicateValue.Default.record(
|
|
1738
|
+
OrderedMap([["Value", c]]),
|
|
1739
|
+
),
|
|
1740
|
+
]);
|
|
1741
|
+
const existingEntries: [
|
|
1742
|
+
string,
|
|
1743
|
+
PredicateValue,
|
|
1744
|
+
][] = Array.from(v.fields.entries());
|
|
1745
|
+
let returnValue =
|
|
1746
|
+
PredicateValue.Default.record(
|
|
1747
|
+
OrderedMap(
|
|
1748
|
+
prependEntries.concat(
|
|
1749
|
+
existingEntries,
|
|
1750
|
+
),
|
|
1751
|
+
),
|
|
1752
|
+
);
|
|
1753
|
+
return ValueOrErrors.Default.return(
|
|
1754
|
+
returnValue,
|
|
1755
|
+
);
|
|
1756
|
+
}),
|
|
1757
|
+
)
|
|
1758
|
+
: ValueOrErrors.Default.throwOne(
|
|
1759
|
+
`Error: unsupported expression ${JSON.stringify(e)}`,
|
|
1760
|
+
);
|
|
1708
1761
|
})();
|
|
1709
1762
|
return result.MapErrors((errors) =>
|
|
1710
1763
|
errors.map(
|