diff --git a/packages/pluggable-widgets-tools/CHANGELOG.md b/packages/pluggable-widgets-tools/CHANGELOG.md index 19187a7c..c6c39135 100644 --- a/packages/pluggable-widgets-tools/CHANGELOG.md +++ b/packages/pluggable-widgets-tools/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Added + +- We added the property type AssociationMetaData which exposes useful metadata for filtering and sorting datasources. + +### Changed + +- We updated the Mendix package to 10.16.49747. + ## [10.15.0] - 2024-09-24 ### Added diff --git a/packages/pluggable-widgets-tools/package-lock.json b/packages/pluggable-widgets-tools/package-lock.json index 07ddd30f..ace819b4 100644 --- a/packages/pluggable-widgets-tools/package-lock.json +++ b/packages/pluggable-widgets-tools/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mendix/pluggable-widgets-tools", - "version": "10.15.0", + "version": "10.16.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mendix/pluggable-widgets-tools", - "version": "10.15.0", + "version": "10.16.0", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.12.3", @@ -64,7 +64,7 @@ "jest-junit": "^13.0.0", "jest-react-hooks-shallow": "^1.5.1", "make-dir": "^3.1.0", - "mendix": "^10.15.46408", + "mendix": "^10.16.49747", "metro-react-native-babel-preset": "^0.74.1", "mime": "^3.0.0", "node-fetch": "^2.6.1", @@ -13829,9 +13829,9 @@ "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==" }, "node_modules/mendix": { - "version": "10.15.46408", - "resolved": "https://registry.npmjs.org/mendix/-/mendix-10.15.46408.tgz", - "integrity": "sha512-9bsFR4kYoKKWlu9P4tuIEpaWuZmU1imcqwDpWXxHNaIurL5Ovi+UiQ6szqQeS+8th8TKNPXgiETmN8+7XPhAtw==", + "version": "10.16.49747", + "resolved": "https://registry.npmjs.org/mendix/-/mendix-10.16.49747.tgz", + "integrity": "sha512-soc4deezipGgzWVWrfsg1e73w8xXE3ydlW0PyRsV8IHq4BCliloWag1Vh5kYEpYqt+4naBKuLASMHLhSlKKQIw==", "license": "MIT", "dependencies": { "@types/big.js": "^6.0.0", @@ -30755,9 +30755,9 @@ "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q==" }, "mendix": { - "version": "10.15.46408", - "resolved": "https://registry.npmjs.org/mendix/-/mendix-10.15.46408.tgz", - "integrity": "sha512-9bsFR4kYoKKWlu9P4tuIEpaWuZmU1imcqwDpWXxHNaIurL5Ovi+UiQ6szqQeS+8th8TKNPXgiETmN8+7XPhAtw==", + "version": "10.16.49747", + "resolved": "https://registry.npmjs.org/mendix/-/mendix-10.16.49747.tgz", + "integrity": "sha512-soc4deezipGgzWVWrfsg1e73w8xXE3ydlW0PyRsV8IHq4BCliloWag1Vh5kYEpYqt+4naBKuLASMHLhSlKKQIw==", "requires": { "@types/big.js": "^6.0.0", "@types/react": "~18.0.0", diff --git a/packages/pluggable-widgets-tools/package.json b/packages/pluggable-widgets-tools/package.json index eb2365f7..ad657177 100644 --- a/packages/pluggable-widgets-tools/package.json +++ b/packages/pluggable-widgets-tools/package.json @@ -1,6 +1,6 @@ { "name": "@mendix/pluggable-widgets-tools", - "version": "10.15.0", + "version": "10.16.0", "description": "Mendix Pluggable Widgets Tools", "engines": { "node": ">=16" @@ -80,7 +80,7 @@ "jest-junit": "^13.0.0", "jest-react-hooks-shallow": "^1.5.1", "make-dir": "^3.1.0", - "mendix": "^10.15.46408", + "mendix": "^10.16.49747", "metro-react-native-babel-preset": "^0.74.1", "mime": "^3.0.0", "node-fetch": "^2.6.1", 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 ee493c7e..c9e63fef 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 @@ -41,6 +41,8 @@ import { } from "./outputs/non-linked-list-attribute-refset"; import { attributeMetaDataNativeInput, attributeMetaDataWebInput } from "./inputs/metadata-attribute"; import { attributeMetaDataNativeOutput, attributeMetaDataWebOutput } from "./outputs/metadata-attribute"; +import { associationMetaDataNativeInput, associationMetaDataWebInput } from "./inputs/metadata-association"; +import { associationMetaDataNativeOutput, associationMetaDataWebOutput } from "./outputs/metadata-association"; describe("Generating tests", () => { it("Generates a parsed typing from XML for native", () => { @@ -212,6 +214,16 @@ describe("Generating tests", () => { const newContent = generateNativeTypesFor(attributeMetaDataNativeInput); expect(newContent).toBe(attributeMetaDataNativeOutput); }); + + it("Generates a parsed typing from XML for web using metadata association", () => { + const newContent = generateFullTypesFor(associationMetaDataWebInput); + expect(newContent).toBe(associationMetaDataWebOutput); + }); + + it("Generates a parsed typing from XML for native using metadata association", () => { + const newContent = generateNativeTypesFor(associationMetaDataNativeInput); + expect(newContent).toBe(associationMetaDataNativeOutput); + }); }); function generateFullTypesFor(xml: string) { diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/metadata-association.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/metadata-association.ts new file mode 100644 index 00000000..874e66ed --- /dev/null +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/metadata-association.ts @@ -0,0 +1,56 @@ +export const associationMetaDataWebInput = ` + + + + + Reference + + + + Reference + + + + + + + Reference + + + + + + + +`; +export const associationMetaDataNativeInput = ` + + + + + Reference + + + + Reference + + + + + + + Reference + + + + + + + +`; diff --git a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/metadata-attribute.ts b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/metadata-attribute.ts index 4d79de82..5a194ee3 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/metadata-attribute.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/__tests__/inputs/metadata-attribute.ts @@ -27,6 +27,7 @@ export const attributeMetaDataWebInput = ` `; + export const attributeMetaDataNativeInput = ` { + name: string; + style: Style[]; + data: ListValue; + metaReference: AssociationMetaData; + metaReferenceSet: AssociationMetaData; +}`; diff --git a/packages/pluggable-widgets-tools/src/typings-generator/generate.ts b/packages/pluggable-widgets-tools/src/typings-generator/generate.ts index d17c8381..d26e1e30 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/generate.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/generate.ts @@ -5,6 +5,7 @@ import { WidgetXml } from "./WidgetXml"; const mxExports = [ "ActionValue", + "AssociationMetaData", "AttributeMetaData", "DynamicValue", "EditableValue", diff --git a/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts b/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts index 1e00cf9f..c4d6bd2d 100644 --- a/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts +++ b/packages/pluggable-widgets-tools/src/typings-generator/generateClientTypes.ts @@ -141,7 +141,7 @@ function toClientPropType( if (!linkedToDataSource) { throw new Error(`[XML] Attribute property can only have isMetaData="true" when linked to a datasource`); } - return `AttributeMetaData<${unionType}>` + return `AttributeMetaData<${unionType}>`; } if (!prop.associationTypes?.length) { @@ -158,9 +158,18 @@ function toClientPropType( if (!prop.associationTypes?.length) { throw new Error("[XML] Association property requires associationTypes element"); } + + const linkedToDataSource = !!prop.$.dataSource; + if (prop.$.isMetaData === "true") { + if (!linkedToDataSource) { + throw new Error(`[XML] Association property can only have isMetaData="true" when linked to a datasource`); + } + return "AssociationMetaData"; + } + const types = prop.associationTypes .flatMap(ats => ats.associationType) - .map(at => toAssociationOutputType(at.$.name, !!prop.$.dataSource)); + .map(at => toAssociationOutputType(at.$.name, linkedToDataSource)); return toUniqueUnionType(types); } case "expression":