The Mendix SDK: Platform and Model
The Mendix SDK's consist of two powerful components: the Mendix Platform SDK and the Mendix Model SDK. With the Platform SDK lets you create new apps, manage repositories and automatically commit changes to Team Server. The Model SDK then provides full access to the internal model of your Mendix app. This allows you to read, analyze and modify every detail of your domain model, microflows, widgets and more.
By combining these two SDKs, you have a single solution for both setting up and managing Mendix applications (Platform SDK) and deeply automating and editing their content (Model SDK). This takes much of the repetitive and error-prone work out of your hands, allowing you to develop more efficiently and with more control.
Why the Mendix Model SDK is indispensable.
The Mendix Model SDK is a powerful and versatile toolkit that enables developers to read, analyze and even modify every detail of their Mendix apps. With this SDK, a lot of manual, repetitive work disappears into the background, allowing you to develop faster and more error-free. Below you will discover why the Mendix Model SDK is so interesting, plus a short demo of how to get started with it.
What makes the Mendix Model SDK so strong?
- Full Read and Write Access. The Mendix Model SDK gives you access to all layers of your app - from domain models and microflows to web services and widgets. This opens the door to advanced analysis (for quality reports, for example) and automatic model creation.
- Automation & Efficiency With the SDK, you can fully automate tasks that are normally manual and error-prone (such as adding entities, updating microflows or generating documentation) via TypeScript or JavaScript scripts.
- Power in Combination with the Mendix Platform SDK. The Mendix Platform SDK allows you to create new apps, manage repositories and automatically commit changes back into Team Server, while the Mendix Model SDK makes the inside of your model accessible. Together, they form a complete ecosystem for DevOps in Mendix.
Technical highlights of the Mendix Model SDK ⚙️
- Read and Analyze Having access to every detail of your app model allows you to build sophisticated analysis tools that assess the architecture and quality of your Mendix app. Think about scanning inconsistencies or generating visual overviews.
- Automated Changes. Want to automatically add new entities or update existing microflows? With the Mendix Model SDK, you can easily create scripts that update the model in a consistent manner.
- Support for TypeScript & JavaScript Do you like to work in TypeScript for strict type checking, or just in JavaScript for rapid prototyping? The Mendix Model SDK supports both, so you can flexibly choose what works best for your project.
Short demo: getting started with the Mendix Model SDK
The steps below illustrate how to set up a small scripting environment so you can discover the power of the Mendix Model SDK.
- Your personal access token (PAT).
Before running your first script, it is essential to set up a Personal Access Token (PAT). You must create this token in your Mendix profile and have the appropriate permissions. Then you can save this token as an environment variable on your computer or include it in your script.
Within Mendix, you can press your profile icon -> then on User Settings -> and finally on the left side of the navbar on Developer Settings.
Here you can press New Token and create a token with minimum:
Model Repository - mx:modelrepository:repo:write
Sprintr Project API -. mx:app:create and mx:app:delete
- Install required packages
npm init --yes
npm install -g typescript
npm install mendixmodelsdk@latest mendixplatformsdk@latest when @types/when --save
tsc --init
This sets up a basic project and installs the SDKs in your development environment.
- Create a TypeScript file
Add a file demo.ts Add:
import { domainmodels } from "mendixmodelsdk";
import { MendixPlatformClient, setPlatformConfig } from "mendixplatformsdk";
async function main() {
const client = new MendixPlatformClient();
// 1. Configureer de Mendix Platform SDK met je Mendix token
setPlatformConfig({
mendixToken: "JouwMendixTokenHier"
})
// 2. Maak een nieuwe Mendix-app aan met Git als repository
const app = await client.createNewApp(`NewApp-${Date.now()}`, {
repositoryType: "git",
});
// 3. Maak een tijdelijke working copy aan van de hoofd-branch ('main')
const workingCopy = await app.createTemporaryWorkingCopy("main");
const model = await workingCopy.openModel();
// 4. Pak het domeinmodel van 'MyFirstModule' en laad deze volledig in
const domainModelInterface = model.allDomainModels().filter(dm => dm.containerAsModule.name === "MyFirstModule")[0];
const domainModel = await domainModelInterface.load();
// 5. Maak een nieuwe entiteit aan en geef deze een unieke naam
const entity = domainmodels.Entity.createIn(domainModel);
entity.name = `NewEntity_${Date.now()}`;
// 6. Sla alle wijzigingen op en commit alles terug naar de Team Server
await model.flushChanges();
await workingCopy.commitToRepository("main");
}
main().catch(console.error);
What happens here:
- createNewApp() - You bootstrap a completely new Mendix app and immediately set up a repository in Team Server.
- createTemporaryWorkingCopy() - From this new app, you create a "working version" that you can edit locally.
- Edit the model - Load your domain model and add a new entity to it.
- Commit - Save your changes and send them back to the Team Server for your colleagues to use right away.
Compile & Run
tsc demo.ts
node demo.js
The next step in your Mendix journey
With the Mendix Model SDK and Mendix Platform SDK, you can take your app development to the next level. Whether you want to automate quality checks, write scripts to systematically extend your model, or generate dynamic documentation - the possibilities are virtually endless.
Are you ready to take the next step in low-code automation? Then the Mendix Model SDK is the toolkit to start with.
I invite you to explore the SDK for yourself and set up your own experiments. Do you have questions or want to share your experiences? Let me know in the comments!
Did you like this article? Then check out our other articles on: The New Wave IT
Within The New Wave IT we are intensively engaged in researching the latest developments. Wondering how The New Wave IT can help you? Feel free to contact us via The New Wave IT | LinkedIn or visit our website at The New Wave IT. We would love to help you out!