ballerina-core 1.0.57 → 1.0.58
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
|
@@ -32,7 +32,7 @@ export type BuiltInApiConverters = {
|
|
|
32
32
|
"boolean": ApiConverter<boolean>
|
|
33
33
|
"maybeBoolean": ApiConverter<boolean | undefined>
|
|
34
34
|
"base64File": ApiConverter<string>
|
|
35
|
-
"secret": ApiConverter<string
|
|
35
|
+
"secret": ApiConverter<string>
|
|
36
36
|
"Date": ApiConverter<Maybe<Date>>
|
|
37
37
|
"CollectionReference": ApiConverter<CollectionReference>
|
|
38
38
|
"SingleSelection": ApiConverter<CollectionSelection<any>>
|
|
@@ -294,15 +294,25 @@ export const toAPIRawValue = <T>(t: Type, types: Map<TypeName, TypeDefinition>,
|
|
|
294
294
|
return ValueOrErrors.Operations.All(parsedMap.concat(nonUniqueKeyErrors))
|
|
295
295
|
}
|
|
296
296
|
} else { // t.kind == lookup: we are dealing with a record/object or extended type
|
|
297
|
-
const
|
|
298
|
-
if("extends" in tDef && tDef.extends.length == 1) {
|
|
299
|
-
return ValueOrErrors.Operations.Return(converters[(tDef.extends[0] as keyof BuiltInApiConverters)].toAPIRawValue([raw, formState.modifiedByUser] as never))
|
|
300
|
-
}
|
|
301
|
-
const convertedMap = tDef.fields.mapEntries(([fieldName, fieldType] ) => {
|
|
297
|
+
const convertMap = (typeDefinition: TypeDefinition, isExtended: boolean) => (typeDefinition).fields.mapEntries(([fieldName, fieldType] ) => {
|
|
302
298
|
const fieldValue = raw[fieldName]
|
|
303
|
-
const
|
|
299
|
+
const fieldFormState = isExtended ? formState : formState.formFieldStates[fieldName]
|
|
300
|
+
const converted = toAPIRawValue(fieldType, types, builtIns, converters, injectedPrimitives)(fieldValue, fieldFormState)
|
|
304
301
|
return [fieldName, converted]
|
|
305
302
|
})
|
|
303
|
+
|
|
304
|
+
const tDef = types.get(t.name)!
|
|
305
|
+
const isExtended = "extends" in tDef && tDef.extends.length == 1
|
|
306
|
+
// Check for deprecated primitive CollectionReference - later should return error in this case
|
|
307
|
+
if(isExtended && !types.has(tDef.extends[0])) {
|
|
308
|
+
console.warn(`Deprecated: Primitive Collection Reference. Please use a CollectionReference in the form config instead. Cannot find type ${tDef.extends[0]} when resolving toAPIRawValue, assuming the deprecated primitive CollectionReference is being used.`)
|
|
309
|
+
return ValueOrErrors.Operations.Return(converters["CollectionReference"].toAPIRawValue([raw, formState.modifiedByUser] as never))
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const extendedTDef = isExtended ? types.get(tDef.extends[0])! : undefined;
|
|
313
|
+
|
|
314
|
+
const convertedMap = extendedTDef ? convertMap(extendedTDef, true) : convertMap(tDef, false)
|
|
315
|
+
|
|
306
316
|
if(convertedMap.some((valueOrError) => valueOrError.kind == "errors")) {
|
|
307
317
|
const propertiesWithErrors = convertedMap.filter((valueOrError) => valueOrError.kind == "errors")
|
|
308
318
|
const namedErrors = propertiesWithErrors.map((value, key) => value.MapErrors(_ => _.map((_: string) => `${key}: ${_}`)))
|
|
@@ -160,8 +160,8 @@ export const FormsConfig = {
|
|
|
160
160
|
errors = errors.push(`arg ${fieldDef.args[0]} in type ${typeName} references non existent type`);
|
|
161
161
|
return
|
|
162
162
|
}
|
|
163
|
-
if (argType.extends.length != 1 || argType.extends[0] != "CollectionReference")
|
|
164
|
-
errors = errors.push(`field ${fieldName} in type ${typeName}: SingleSelection requires ${argType.name} to
|
|
163
|
+
if (argType.extends.length != 1 || (argType.extends[0] != "CollectionReference" && !types.has(argType.extends[0])))
|
|
164
|
+
errors = errors.push(`field ${fieldName} in type ${typeName}: SingleSelection requires ${argType.name} to extend ${argType.extends[0]}`);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
if (fieldDef.kind == "application" && fieldDef.value == "Multiselection") {
|
|
@@ -173,8 +173,8 @@ export const FormsConfig = {
|
|
|
173
173
|
errors = errors.push(`arg ${fieldDef.args[0]} in type ${typeName} references non existent type`);
|
|
174
174
|
return errors
|
|
175
175
|
}
|
|
176
|
-
if (argType.extends.length != 1 || argType.extends[0] != "CollectionReference")
|
|
177
|
-
errors = errors.push(`field ${fieldName} in type ${typeName}: Multiselection requires ${argType.name} to
|
|
176
|
+
if (argType.extends.length != 1 || (argType.extends[0] != "CollectionReference" && !types.has(argType.extends[0])))
|
|
177
|
+
errors = errors.push(`field ${fieldName} in type ${typeName}: Multiselection requires ${argType.name} to extend ${argType.extends[0]}`);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
if (fieldDef.kind == "application" && fieldDef.value == "List") {
|