From 3959256d1077345f8a98a26826ed6fe7d8ff1994 Mon Sep 17 00:00:00 2001 From: "Ali.Haydar.Sumer" Date: Wed, 21 Jan 2026 13:53:13 +0100 Subject: [PATCH 1/3] Generate types for editable files and images --- .../src/typings-generator/WidgetXml.ts | 1 + .../src/typings-generator/generate.ts | 2 ++ .../src/typings-generator/generateClientTypes.ts | 11 +++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/pluggable-widgets-tools/src/typings-generator/WidgetXml.ts b/packages/pluggable-widgets-tools/src/typings-generator/WidgetXml.ts index 99656baa..f6220ef6 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/WidgetXml.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/WidgetXml.ts @@ -51,6 +51,7 @@ export interface Property { isDefault?: string; dataSource?: string; onChange?: string; + allowUpload?: string; }; caption?: string[]; category?: string[]; diff --git a/packages/pluggable-widgets-tools/src/typings-generator/generate.ts b/packages/pluggable-widgets-tools/src/typings-generator/generate.ts index 4db45602..c4bc4f48 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/generate.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/generate.ts @@ -10,6 +10,8 @@ const mxExports = [ "DynamicValue", "EditableValue", "EditableListValue", + "EditableFileValue", + "EditableImageValue", "FileValue", "ListValue", "NativeIcon", diff --git a/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts b/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts index 704d6bd7..4c4a01ec 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts @@ -128,12 +128,15 @@ function toClientPropType( return "number"; case "decimal": return "Big"; - case "icon": + case "icon": return isNative ? "DynamicValue" : "DynamicValue"; - case "image": - return isNative ? "DynamicValue" : "DynamicValue"; + case "image": { + const allowUpload = prop.$.allowUpload === "true"; + const imageType = isNative ? "NativeImage" : "WebImage"; + return allowUpload ? `EditableImageValue<${imageType}>` : `DynamicValue<${imageType}>`; + } case "file": - return "DynamicValue"; + return prop.$.allowUpload ? "EditableFileValue" : "DynamicValue"; case "datasource": return "ListValue"; case "attribute": { From 52b27e6fc8489812ed06eb08c0c7094e693ef08f Mon Sep 17 00:00:00 2001 From: "Ali.Haydar.Sumer" Date: Wed, 21 Jan 2026 13:53:28 +0100 Subject: [PATCH 2/3] Add unit tests --- .../typings-generator/__tests__/index.spec.ts | 12 +++ .../__tests__/inputs/file.ts | 8 ++ .../__tests__/inputs/image.ts | 81 +++++++++++++++++++ .../__tests__/outputs/file.ts | 5 +- .../__tests__/outputs/image.ts | 38 +++++++++ 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/image.ts create mode 100644 packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/image.ts diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts index b628948c..50c894d8 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/index.spec.ts @@ -45,6 +45,8 @@ import { associationMetaDataNativeInput, associationMetaDataWebInput } from "./i import { associationMetaDataNativeOutput, associationMetaDataWebOutput } from "./outputs/metadata-association"; import {listActionWithVariablesInput, listActionWithVariablesInputNative} from "./inputs/list-action-with-variables"; import {listActionWithVariablesOutput, listActionWithVariablesOutputNative} from "./outputs/list-action-with-variables"; +import {imageWebInput, imageNativeInput} from "./inputs/image"; +import {imageWebOutput, imageNativeOutput} from "./outputs/image"; describe("Generating tests", () => { it("Generates a parsed typing from XML for native", () => { @@ -236,6 +238,16 @@ describe("Generating tests", () => { const newContent = generateNativeTypesFor(associationMetaDataNativeInput); expect(newContent).toBe(associationMetaDataNativeOutput); }); + + it("Generates a parsed typing from XML for web using images", () => { + const newContent = generateFullTypesFor(imageWebInput); + expect(newContent).toBe(imageWebOutput); + }); + + it("Generates a parsed typing from XML for native using images", () => { + const newContent = generateNativeTypesFor(imageNativeInput); + expect(newContent).toBe(imageNativeOutput); + }); }); function generateFullTypesFor(xml: string) { diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/file.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/file.ts index cb04709c..2cd55cc7 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/file.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/file.ts @@ -12,6 +12,10 @@ export const fileInput = ` File 2 + + File 3 + + @@ -49,6 +53,10 @@ export const fileInputNative = ` File 2 + + File 3 + + diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/image.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/image.ts new file mode 100644 index 00000000..d649f924 --- /dev/null +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/image.ts @@ -0,0 +1,81 @@ +export const imageWebInput = ` + + + + + Image + + + + Image 2 + + + + Image 3 + + + + + + Action + + + + + + + Action + + + + + + + + + + +`; + +export const imageNativeInput = ` + + + + + Image + + + + Image 2 + + + + Image 3 + + + + + + Action + + + + + + + Action + + + + + + + + + + +`; diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/file.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/file.ts index 8be35660..9f1ec7b9 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/file.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/outputs/file.ts @@ -3,7 +3,7 @@ export const fileWebOutput = `/** * WARNING: All changes made to this file will be overwritten * @author Mendix Widgets Framework Team */ -import { ActionValue, DynamicValue, EditableValue, FileValue } from "mendix"; +import { ActionValue, DynamicValue, EditableValue, EditableFileValue, FileValue } from "mendix"; export interface MyWidgetContainerProps { name: string; @@ -11,6 +11,7 @@ export interface MyWidgetContainerProps { id: string; file: DynamicValue; file2?: DynamicValue; + file3: EditableFileValue; description: EditableValue; action?: ActionValue; } @@ -21,6 +22,7 @@ export interface MyWidgetPreviewProps { translate: (text: string) => string; file: string; file2: string; + file3: string; description: string; action: {} | null; } @@ -30,6 +32,7 @@ export const fileNativeOutput = `export interface MyWidgetProps