ballerina-core 1.0.84 → 1.0.85
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
|
@@ -61,7 +61,7 @@ export type ApiConverters<
|
|
|
61
61
|
> = { [key in keyof T]: ApiConverter<T[key]["type"]> } & BuiltInApiConverters;
|
|
62
62
|
|
|
63
63
|
export type VerifiedRawUnionCase = {
|
|
64
|
-
|
|
64
|
+
caseName: string;
|
|
65
65
|
fields: Record<string, any>;
|
|
66
66
|
};
|
|
67
67
|
|
|
@@ -71,7 +71,7 @@ export const VerifiedRawUnionCase = {
|
|
|
71
71
|
return (
|
|
72
72
|
typeof value == "object" &&
|
|
73
73
|
"caseName" in value &&
|
|
74
|
-
typeof value.
|
|
74
|
+
typeof value.caseName == "string" &&
|
|
75
75
|
"fields" in value &&
|
|
76
76
|
typeof value.fields == "object"
|
|
77
77
|
);
|
|
@@ -331,10 +331,10 @@ export const fromAPIRawValue =
|
|
|
331
331
|
`union expected but got ${JSON.stringify(raw)}`,
|
|
332
332
|
);
|
|
333
333
|
}
|
|
334
|
-
const caseType = t.args.get(raw.
|
|
334
|
+
const caseType = t.args.get(raw.caseName);
|
|
335
335
|
if (caseType == undefined) {
|
|
336
336
|
return ValueOrErrors.Default.throwOne(
|
|
337
|
-
`union case ${raw.
|
|
337
|
+
`union case ${raw.caseName} not found in type ${JSON.stringify(t)}`,
|
|
338
338
|
);
|
|
339
339
|
}
|
|
340
340
|
return fromAPIRawValue(
|
|
@@ -371,7 +371,7 @@ export const fromAPIRawValue =
|
|
|
371
371
|
);
|
|
372
372
|
}
|
|
373
373
|
return ValueOrErrors.Default.return(
|
|
374
|
-
PredicateValue.Default.unionCase(result.
|
|
374
|
+
PredicateValue.Default.unionCase(result.caseName, fields),
|
|
375
375
|
);
|
|
376
376
|
});
|
|
377
377
|
}
|
|
@@ -595,7 +595,7 @@ export const toAPIRawValue =
|
|
|
595
595
|
}
|
|
596
596
|
return ValueOrErrors.Operations.Return(
|
|
597
597
|
converters[t.kind].toAPIRawValue([
|
|
598
|
-
{
|
|
598
|
+
{ caseName: raw.caseName, fields: raw.fields },
|
|
599
599
|
formState.modifiedByUser,
|
|
600
600
|
]),
|
|
601
601
|
);
|
|
@@ -179,7 +179,11 @@ export type PredicateValue =
|
|
|
179
179
|
|
|
180
180
|
export type ExprLambda = { kind: "lambda"; parameter: string; body: Expr };
|
|
181
181
|
export type ExprMatchCase = { kind: "matchCase"; operands: Expr[] };
|
|
182
|
-
export type ExprCase = {
|
|
182
|
+
export type ExprCase = {
|
|
183
|
+
kind: "caseName";
|
|
184
|
+
caseName: string;
|
|
185
|
+
handler: ExprLambda;
|
|
186
|
+
};
|
|
183
187
|
export type ExprFieldLookup = { kind: "fieldLookup"; operands: [Expr, string] };
|
|
184
188
|
export type ExprIsCase = { kind: "isCase"; operands: [Expr, string] };
|
|
185
189
|
export type ExprBinaryOperator = {
|
|
@@ -41,7 +41,7 @@ export const RawType = {
|
|
|
41
41
|
_.fun == "Union" &&
|
|
42
42
|
Array.isArray(_["args"]) &&
|
|
43
43
|
_["args"].every(
|
|
44
|
-
(__) => typeof __ == "object" && "caseName"
|
|
44
|
+
(__) => typeof __ == "object" && "caseName" in __ && "fields" in __,
|
|
45
45
|
),
|
|
46
46
|
};
|
|
47
47
|
export type RawApplicationType<T> = {
|
|
@@ -113,8 +113,10 @@ export const RawFieldType = {
|
|
|
113
113
|
RawFieldType.isApplication(_) &&
|
|
114
114
|
_.fun == "MultiSelection" &&
|
|
115
115
|
_.args.length == 1,
|
|
116
|
-
isUnionCase: <T>(
|
|
117
|
-
|
|
116
|
+
isUnionCase: <T>(
|
|
117
|
+
_: RawFieldType<T>,
|
|
118
|
+
): _ is { caseName: string; fields: object } =>
|
|
119
|
+
typeof _ == "object" && "caseName" in _ && "fields" in _,
|
|
118
120
|
isUnion: <T>(
|
|
119
121
|
_: RawFieldType<T>,
|
|
120
122
|
): _ is { fun: "Union"; args: Array<{ case: string; fields: object }> } =>
|
|
@@ -124,7 +126,7 @@ export const RawFieldType = {
|
|
|
124
126
|
_.fun == "Union" &&
|
|
125
127
|
_.args.length > 0 &&
|
|
126
128
|
_.args.every(
|
|
127
|
-
(__) => typeof __ == "object" && "caseName"
|
|
129
|
+
(__) => typeof __ == "object" && "caseName" in __ && "fields" in __,
|
|
128
130
|
),
|
|
129
131
|
isForm: <T>(_: RawFieldType<T>): _ is { fields: Object } =>
|
|
130
132
|
typeof _ == "object" && "fields" in _ && isObject(_.fields),
|
|
@@ -323,13 +325,13 @@ export const ParsedType = {
|
|
|
323
325
|
}
|
|
324
326
|
if (RawFieldType.isUnionCase(rawFieldType)) {
|
|
325
327
|
return ParsedType.Operations.ParseRawFieldType(
|
|
326
|
-
rawFieldType.
|
|
328
|
+
rawFieldType.caseName,
|
|
327
329
|
rawFieldType.fields,
|
|
328
330
|
types,
|
|
329
331
|
injectedPrimitives,
|
|
330
332
|
).Then((parsedFields) =>
|
|
331
333
|
ValueOrErrors.Default.return(
|
|
332
|
-
ParsedType.Default.unionCase(rawFieldType.
|
|
334
|
+
ParsedType.Default.unionCase(rawFieldType.caseName, parsedFields),
|
|
333
335
|
),
|
|
334
336
|
);
|
|
335
337
|
}
|
|
@@ -351,7 +353,10 @@ export const ParsedType = {
|
|
|
351
353
|
injectedPrimitives,
|
|
352
354
|
).Then((parsedFields) =>
|
|
353
355
|
ValueOrErrors.Default.return(
|
|
354
|
-
ParsedType.Default.unionCase(
|
|
356
|
+
ParsedType.Default.unionCase(
|
|
357
|
+
unionCase.caseName,
|
|
358
|
+
parsedFields,
|
|
359
|
+
),
|
|
355
360
|
),
|
|
356
361
|
);
|
|
357
362
|
}),
|