ballerina-core 1.0.192 → 1.0.193
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
|
@@ -1324,30 +1324,15 @@ export const dispatchFromAPIRawValue =
|
|
|
1324
1324
|
)}`,
|
|
1325
1325
|
);
|
|
1326
1326
|
|
|
1327
|
-
if (caseType.kind != "record" && caseType.kind != "lookup")
|
|
1328
|
-
return ValueOrErrors.Default.throwOne(
|
|
1329
|
-
`union case ${
|
|
1330
|
-
result.caseName
|
|
1331
|
-
} expected record or lookup type, got ${JSON.stringify(caseType)}`,
|
|
1332
|
-
);
|
|
1333
|
-
|
|
1334
1327
|
return dispatchFromAPIRawValue(
|
|
1335
1328
|
caseType,
|
|
1336
1329
|
types,
|
|
1337
1330
|
converters,
|
|
1338
1331
|
injectedPrimitives,
|
|
1339
1332
|
)(result.fields).Then((value) =>
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
)
|
|
1344
|
-
: ValueOrErrors.Default.throwOne(
|
|
1345
|
-
`union case ${
|
|
1346
|
-
result.caseName
|
|
1347
|
-
} expected record, got ${PredicateValue.Operations.GetKind(
|
|
1348
|
-
value,
|
|
1349
|
-
)}`,
|
|
1350
|
-
),
|
|
1333
|
+
ValueOrErrors.Default.return(
|
|
1334
|
+
PredicateValue.Default.unionCase(result.caseName, value),
|
|
1335
|
+
),
|
|
1351
1336
|
);
|
|
1352
1337
|
}
|
|
1353
1338
|
|
package/src/forms/domains/dispatched-forms/deserializer/domains/specification/domains/types/state.ts
CHANGED
|
@@ -191,6 +191,8 @@ export const SerializedType = {
|
|
|
191
191
|
SerializedType.isApplication(_) &&
|
|
192
192
|
_.fun == "ReadOnly" &&
|
|
193
193
|
_.args.length == 1,
|
|
194
|
+
isRecordFields: (_: unknown) =>
|
|
195
|
+
typeof _ == "object" && _ != null && !("fun" in _) && !("args" in _),
|
|
194
196
|
};
|
|
195
197
|
|
|
196
198
|
export type StringSerializedType = string;
|
|
@@ -1042,41 +1044,25 @@ export const DispatchParsedType = {
|
|
|
1042
1044
|
return ValueOrErrors.Operations.All(
|
|
1043
1045
|
List<ValueOrErrors<[string, DispatchParsedType<T>], string>>(
|
|
1044
1046
|
rawType.args.map((unionCase) =>
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
)
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
)
|
|
1065
|
-
: DispatchParsedType.Operations.ParseRawType(
|
|
1066
|
-
`Union:Case ${unionCase.caseName}`,
|
|
1067
|
-
unionCase.fields == undefined
|
|
1068
|
-
? { fields: {} }
|
|
1069
|
-
: unionCase,
|
|
1070
|
-
typeNames,
|
|
1071
|
-
serializedTypes,
|
|
1072
|
-
alreadyParsedTypes,
|
|
1073
|
-
injectedPrimitives,
|
|
1074
|
-
).Then((parsedType) =>
|
|
1075
|
-
ValueOrErrors.Default.return([
|
|
1076
|
-
unionCase.caseName,
|
|
1077
|
-
parsedType[0],
|
|
1078
|
-
]),
|
|
1079
|
-
),
|
|
1047
|
+
DispatchParsedType.Operations.ParseRawType(
|
|
1048
|
+
`Union:Case ${unionCase.caseName}`,
|
|
1049
|
+
unionCase.fields == undefined
|
|
1050
|
+
? { fields: {} }
|
|
1051
|
+
: // we allow the record fields to be defined directly in the spec instead of
|
|
1052
|
+
// inside a fields key
|
|
1053
|
+
SerializedType.isRecordFields(unionCase.fields)
|
|
1054
|
+
? { fields: unionCase.fields }
|
|
1055
|
+
: unionCase.fields,
|
|
1056
|
+
typeNames,
|
|
1057
|
+
serializedTypes,
|
|
1058
|
+
alreadyParsedTypes,
|
|
1059
|
+
injectedPrimitives,
|
|
1060
|
+
).Then((parsedType) =>
|
|
1061
|
+
ValueOrErrors.Default.return([
|
|
1062
|
+
unionCase.caseName,
|
|
1063
|
+
parsedType[0],
|
|
1064
|
+
]),
|
|
1065
|
+
),
|
|
1080
1066
|
),
|
|
1081
1067
|
),
|
|
1082
1068
|
).Then((parsedUnionCases) =>
|
|
@@ -425,7 +425,7 @@ export const PredicateValue = {
|
|
|
425
425
|
kind: "record",
|
|
426
426
|
fields,
|
|
427
427
|
}),
|
|
428
|
-
unionCase: (caseName: string, fields:
|
|
428
|
+
unionCase: (caseName: string, fields: PredicateValue): ValueUnionCase => ({
|
|
429
429
|
kind: "unionCase",
|
|
430
430
|
caseName,
|
|
431
431
|
fields,
|