ballerina-core 1.0.210 → 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 +1 -1
- package/src/forms/domains/dispatched-forms/deserializer/domains/specification/domains/types/state.ts +7 -2
- package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/boolean/state.ts +2 -1
- package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/boolean/template.tsx +6 -3
- package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/enum/state.ts +2 -1
- package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/enum/template.tsx +6 -3
- package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/sum/state.ts +2 -1
- package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/sum/template.tsx +12 -5
- package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/table/coroutines/loadWithRetries.ts +20 -15
- package/src/forms/domains/parser/domains/predicates/state.ts +58 -5
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,
|
package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/boolean/state.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
DispatchPrimitiveType,
|
|
7
7
|
CommonAbstractRendererState,
|
|
8
8
|
CommonAbstractRendererViewOnlyReadonlyContext,
|
|
9
|
+
ValueUnit,
|
|
9
10
|
} from "../../../../../../../../main";
|
|
10
11
|
import { Unit } from "../../../../../../../fun/domains/unit/state";
|
|
11
12
|
|
|
@@ -14,7 +15,7 @@ export type BoolAbstractRendererReadonlyContext<
|
|
|
14
15
|
ExtraContext,
|
|
15
16
|
> = CommonAbstractRendererReadonlyContext<
|
|
16
17
|
DispatchPrimitiveType<any>,
|
|
17
|
-
boolean,
|
|
18
|
+
boolean | ValueUnit,
|
|
18
19
|
CustomPresentationContext,
|
|
19
20
|
ExtraContext
|
|
20
21
|
>;
|
package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/boolean/template.tsx
CHANGED
|
@@ -36,15 +36,18 @@ export const BoolAbstractRenderer = <
|
|
|
36
36
|
>((props) => {
|
|
37
37
|
const domNodeId = props.context.domNodeAncestorPath + "[boolean]";
|
|
38
38
|
|
|
39
|
-
if (
|
|
39
|
+
if (
|
|
40
|
+
!PredicateValue.Operations.IsBoolean(props.context.value) &&
|
|
41
|
+
!PredicateValue.Operations.IsUnit(props.context.value)
|
|
42
|
+
) {
|
|
40
43
|
console.error(
|
|
41
|
-
`Boolean expected but got: ${JSON.stringify(
|
|
44
|
+
`Boolean or unit value expected but got: ${JSON.stringify(
|
|
42
45
|
props.context.value,
|
|
43
46
|
)}\n...When rendering \n...${domNodeId}`,
|
|
44
47
|
);
|
|
45
48
|
return (
|
|
46
49
|
<ErrorRenderer
|
|
47
|
-
message={`${domNodeId}: Boolean expected but got ${JSON.stringify(
|
|
50
|
+
message={`${domNodeId}: Boolean or unit value expected but got ${JSON.stringify(
|
|
48
51
|
props.context.value,
|
|
49
52
|
)}`}
|
|
50
53
|
/>
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SingleSelectionType,
|
|
8
8
|
CommonAbstractRendererState,
|
|
9
9
|
CommonAbstractRendererViewOnlyReadonlyContext,
|
|
10
|
+
ValueUnit,
|
|
10
11
|
} from "../../../../../../../../main";
|
|
11
12
|
import { View } from "../../../../../../../template/state";
|
|
12
13
|
import { Synchronized } from "../../../../../../../async/domains/synchronized/state";
|
|
@@ -24,7 +25,7 @@ export type EnumAbstractRendererReadonlyContext<
|
|
|
24
25
|
ExtraContext,
|
|
25
26
|
> = CommonAbstractRendererReadonlyContext<
|
|
26
27
|
SingleSelectionType<any>,
|
|
27
|
-
ValueOption,
|
|
28
|
+
ValueOption | ValueUnit,
|
|
28
29
|
CustomPresentationContext,
|
|
29
30
|
ExtraContext
|
|
30
31
|
> &
|
package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/enum/template.tsx
CHANGED
|
@@ -50,15 +50,18 @@ export const EnumAbstractRenderer = <
|
|
|
50
50
|
>((props) => {
|
|
51
51
|
const domNodeId = props.context.domNodeAncestorPath + "[enum]";
|
|
52
52
|
|
|
53
|
-
if (
|
|
53
|
+
if (
|
|
54
|
+
!PredicateValue.Operations.IsOption(props.context.value) &&
|
|
55
|
+
!PredicateValue.Operations.IsUnit(props.context.value)
|
|
56
|
+
) {
|
|
54
57
|
console.error(
|
|
55
|
-
`Option expected but got: ${JSON.stringify(
|
|
58
|
+
`Option or unit value expected but got: ${JSON.stringify(
|
|
56
59
|
props.context.value,
|
|
57
60
|
)}\n...When rendering \n...${domNodeId}`,
|
|
58
61
|
);
|
|
59
62
|
return (
|
|
60
63
|
<ErrorRenderer
|
|
61
|
-
message={`${domNodeId}: Option value expected but got ${JSON.stringify(
|
|
64
|
+
message={`${domNodeId}: Option or unit value expected but got ${JSON.stringify(
|
|
62
65
|
props.context.value,
|
|
63
66
|
)}`}
|
|
64
67
|
/>
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
DispatchOnChange,
|
|
10
10
|
Unit,
|
|
11
11
|
CommonAbstractRendererViewOnlyReadonlyContext,
|
|
12
|
+
ValueUnit,
|
|
12
13
|
} from "../../../../../../../../main";
|
|
13
14
|
import { SumType } from "../../../../deserializer/domains/specification/domains/types/state";
|
|
14
15
|
|
|
@@ -17,7 +18,7 @@ export type SumAbstractRendererReadonlyContext<
|
|
|
17
18
|
ExtraContext = Unit,
|
|
18
19
|
> = CommonAbstractRendererReadonlyContext<
|
|
19
20
|
SumType<any>,
|
|
20
|
-
ValueSum,
|
|
21
|
+
ValueSum | ValueUnit,
|
|
21
22
|
CustomPresentationContext,
|
|
22
23
|
ExtraContext
|
|
23
24
|
>;
|
package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/sum/template.tsx
CHANGED
|
@@ -66,7 +66,9 @@ export const SumAbstractRenderer = <
|
|
|
66
66
|
..._.customFormState.left,
|
|
67
67
|
disabled: _.disabled,
|
|
68
68
|
locked: _.locked,
|
|
69
|
-
value:
|
|
69
|
+
value: PredicateValue.Operations.IsUnit(_.value)
|
|
70
|
+
? _.value
|
|
71
|
+
: _.value.value.value,
|
|
70
72
|
bindings: _.bindings,
|
|
71
73
|
extraContext: _.extraContext,
|
|
72
74
|
type: _.type.args[0],
|
|
@@ -147,7 +149,9 @@ export const SumAbstractRenderer = <
|
|
|
147
149
|
..._.customFormState.right,
|
|
148
150
|
disabled: _.disabled,
|
|
149
151
|
locked: _.locked,
|
|
150
|
-
value:
|
|
152
|
+
value: PredicateValue.Operations.IsUnit(_.value)
|
|
153
|
+
? _.value
|
|
154
|
+
: _.value.value.value,
|
|
151
155
|
bindings: _.bindings,
|
|
152
156
|
extraContext: _.extraContext,
|
|
153
157
|
type: _.type.args[1],
|
|
@@ -219,15 +223,18 @@ export const SumAbstractRenderer = <
|
|
|
219
223
|
>((props) => {
|
|
220
224
|
const domNodeId = props.context.domNodeAncestorPath + "[sum]";
|
|
221
225
|
|
|
222
|
-
if (
|
|
226
|
+
if (
|
|
227
|
+
!PredicateValue.Operations.IsSum(props.context.value) &&
|
|
228
|
+
!PredicateValue.Operations.IsUnit(props.context.value)
|
|
229
|
+
) {
|
|
223
230
|
console.error(
|
|
224
|
-
`Sum expected but got: ${JSON.stringify(
|
|
231
|
+
`Sum or unit value expected but got: ${JSON.stringify(
|
|
225
232
|
props.context.value,
|
|
226
233
|
)}\n...When rendering \n...${domNodeId}`,
|
|
227
234
|
);
|
|
228
235
|
return (
|
|
229
236
|
<ErrorRenderer
|
|
230
|
-
message={`${domNodeId}: Sum value expected but got ${JSON.stringify(
|
|
237
|
+
message={`${domNodeId}: Sum or unit value expected but got ${JSON.stringify(
|
|
231
238
|
props.context.value,
|
|
232
239
|
)}`}
|
|
233
240
|
/>
|
|
@@ -38,21 +38,26 @@ export const TableLoadWithRetries =
|
|
|
38
38
|
? Co<CustomPresentationContext, ExtraContext>()
|
|
39
39
|
.GetState()
|
|
40
40
|
.then((current) =>
|
|
41
|
-
Co<CustomPresentationContext, ExtraContext>()
|
|
42
|
-
()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
Co<CustomPresentationContext, ExtraContext>()
|
|
42
|
+
.Wait(attempt > 0 ? 1000 : 0)
|
|
43
|
+
.then(() =>
|
|
44
|
+
Co<CustomPresentationContext, ExtraContext>().Await(
|
|
45
|
+
() =>
|
|
46
|
+
tableApiSource.getMany(fromTableApiParser)({
|
|
47
|
+
chunkSize: DEFAULT_CHUNK_SIZE,
|
|
48
|
+
from:
|
|
49
|
+
current.customFormState.loadingState ==
|
|
50
|
+
"reload from 0" || current.value.to == 0
|
|
51
|
+
? 0
|
|
52
|
+
: current.value.to + 1,
|
|
53
|
+
filtersAndSorting:
|
|
54
|
+
current.customFormState.filterAndSortParam === ""
|
|
55
|
+
? undefined
|
|
56
|
+
: current.customFormState.filterAndSortParam,
|
|
57
|
+
}),
|
|
58
|
+
() => "error" as const,
|
|
59
|
+
),
|
|
60
|
+
),
|
|
56
61
|
)
|
|
57
62
|
.then((apiResult) =>
|
|
58
63
|
apiResult.kind == "l"
|
|
@@ -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(
|