diff --git a/packages/pluggable-widgets-tools/src/typings-generator/generate.ts b/packages/pluggable-widgets-tools/src/typings-generator/generate.ts index cab8a113..735a4945 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/generate.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/generate.ts @@ -7,12 +7,14 @@ const mxExports = [ "ActionValue", "DynamicValue", "EditableValue", + "EditableListValue", "FileValue", "ListValue", "NativeIcon", "NativeImage", "ListActionValue", "ListAttributeValue", + "ListAttributeListValue", "ListExpressionValue", "ListReferenceValue", "ListReferenceSetValue", diff --git a/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts b/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts index d02c96b6..190b39d3 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts @@ -133,7 +133,16 @@ function toClientPropType( .flatMap(ats => ats.attributeType) .map(at => toAttributeClientType(at.$.name)); const unionType = toUniqueUnionType(types); - return prop.$.dataSource ? `ListAttributeValue<${unionType}>` : `EditableValue<${unionType}>`; + + if (!prop.associationTypes?.length) { + return prop.$.dataSource ? `ListAttributeValue<${unionType}>` : `EditableValue<${unionType}>`; + } + else { + const reftypes = prop.associationTypes + .flatMap(ats => ats.associationType) + .map(at => toAttributeOutputType(at.$.name, !!prop.$.dataSource, unionType)); + return toUniqueUnionType(reftypes); + } } case "association": { if (!prop.associationTypes?.length) { @@ -278,6 +287,17 @@ export function toAssociationOutputType(xmlType: string, linkedToDataSource: boo } } +export function toAttributeOutputType(xmlType: string, linkedToDataSource: boolean, unionAttributeType: string) { + switch (xmlType) { + case "Reference": + return linkedToDataSource ? `ListAttributeValue<${unionAttributeType}>` : `EditableValue<${unionAttributeType}>`; + case "ReferenceSet": + return linkedToDataSource ? `ListAttributeListValue<${unionAttributeType}>` : `EditableListValue<${unionAttributeType}>`; + default: + return "any"; + } +} + function toSelectionClientType(xmlType: string) { switch (xmlType) { case "Single":