Skip to content

MS-3808 review sdk docs #9312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/en/docs/apidocs-mxsdk/mxsdk/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: "Presents documentation for Mendix SDKs, including Mendix Platform
---

{{% alert color="warning" %}}
Mendix Platform SDK versions below 5.0 are deprecated. They depend on the [Projects API](/apidocs-mxsdk/apidocs/projects-api/) which will be removed early in 2024. A firm date will be communicated once a decision has been made.
Mendix Platform SDK versions below 5.0 are deprecated.
{{% /alert %}}

## Introduction
Expand Down
1 change: 0 additions & 1 deletion content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ For an explanation on this topic, see [How to Manipulate Existing Models](/apido
Some more explanation on manipulating existing models can be found in these documents:

* [How to Change Things in the Model](/apidocs-mxsdk/mxsdk/changing-things-in-the-model/)
* [How to Close the Server Connection](/apidocs-mxsdk/mxsdk/closing-the-server-connection/)
* [How to Find Things in the Model](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/)
* [How to Load Units and Elements](/apidocs-mxsdk/mxsdk/loading-units-and-elements/)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ customer.location = { x: 100, y: 100 };
With these ingredients, you can create the two entities. Replace the snippet that creates a single entity in the script that you created in the [previous how-to steps](/apidocs-mxsdk/mxsdk/creating-your-first-script/) with the following snippet to create the two new entities:

```ts
const domainModel = await loadDomainModel(workingCopy);
const domainModel = await domainModelInterface.load();
const customer = domainmodels.Entity.createIn(domainModel);
customer.name = `Customer`;
customer.location = { x: 100, y: 100 };
Expand Down Expand Up @@ -148,14 +148,16 @@ In the Model SDK, the [`Entity.generalization`](https://apidocs.rnd.mendix.com/m
So, to set up entity `Customer` as a specialization of entity `Administration.Account`, you first need to look up the `Account` entity which [can be done in several ways](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/). The following snippet looks up the `Account` entity in the `Administration` domain model, using the `findEntityByQualifiedName` function:

```ts
const systemUser = workingCopy.model().findEntityByQualifiedName(`Administration.Account`);
const systemUser = model.findEntityByQualifiedName(`Administration.Account`);
```

The `domainmodels.Generalization` instance that will be used to configure the `Account` instance can now be created. The `generalization` property is set to the `System.User` entity instance that was looked up:

```ts
const generalization = domainmodels.Generalization.createIn(customer);
generalization.generalization = systemUser;
if(systemUser){
const generalization = domainmodels.Generalization.createIn(customer);
generalization.generalization = systemUser;
}
```

Together, the creation of the `Customer` entity will look like the following code snippet. Replace the creation of the `customer` entity instance in the script with the following snippet:
Expand All @@ -166,8 +168,10 @@ customer.name = `Customer`;
customer.location = { x: 100, y: 100 };

const generalization = domainmodels.Generalization.createIn(customer);
const systemUser = workingCopy.model().findEntityByQualifiedName(`Administration.Account`);
generalization.generalization = systemUser;
const systemUser = model.findEntityByQualifiedName(`Administration.Account`);
if (systemUser) {
generalization.generalization = systemUser;
}
```

### Resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ After setting up all the prerequisites, you can start writing a first script tha

Don't forget to [set up your personal access token](/apidocs-mxsdk/mxsdk/set-up-your-pat/) before executing the script.

{{% alert color="warning" %}}
Working copy creation is a resource-intensive process. Consider reusing previously-created ones by invoking `app.getOnlineWorkingCopy(workingCopyId)`. All working copies are automatically deleted after 24 hours.
{{% /alert %}}

### Code Explanation

Here are some explanations about the script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ All the parts of a *deleted* element are also *deleted* and cannot be accessed.

## Next Step

Continue with [How to Close the Server Connection](/apidocs-mxsdk/mxsdk/closing-the-server-connection/).
Continue with [How to Find Things in the Model](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/).

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ url: /apidocs-mxsdk/mxsdk/finding-things-in-the-model/

## Introduction

The `model` object you get back from `workingCopy.model()` can be used to find and even manipulate units and elements. It provides three different means with which you can find units and elements.
The `model` object you get back from `workingCopy.openModel()` can be used to find and even manipulate units and elements. It provides three different means with which you can find units and elements.

## The model.root Property

Expand All @@ -14,7 +14,8 @@ The `root` object refers to the `root` app node in the **App Explorer** in Studi
For example, this snippet finds the name of the first attribute of the `Customer` entity in the first module of your app:

```js
const model = workingCopy.model();
const model = await workingCopy.openModel();

const domainModel = model.root.modules[0].domainModel;
const customerEntity = domainModel.entities.filter(entity => entity.name === "Customer")[0]

Expand All @@ -40,7 +41,9 @@ For all the referable concepts in a model (both units, such as a page, as well a

```js
const customerEntity = model.findEntityByQualifiedName("Customers.Customer");
const attributeName = customerEntity.attributes[0].name;
if (customerEntity) {
const attributeName = customerEntity.attributes[0].name;
}
```

For more information, see [How to Load Units and Elements](/apidocs-mxsdk/mxsdk/loading-units-and-elements/).
Expand All @@ -50,7 +53,7 @@ For more information, see [How to Load Units and Elements](/apidocs-mxsdk/mxsdk/
Implement this snippet to fetch information on all the Marketplace modules used in your app:

```js
const model = workingCopy.model();
const model = await workingCopy.openModel();
model.allModules()
.filter(module => module.fromAppStore === true)
.forEach(module =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ Since a unit might already have been loaded before, you are also allowed to use
The following (slightly) contrived example demonstrates the behavior of `load`. The type information is made explicit in this example for demonstration purposes, but you can just omit this code since the TypeScript compiler will infer it. Note that this example is contrived: a normal flow would be to call `load` on the `domainModel` and work with the fully-loaded domain model inside its callback.

```ts
import {domainmodels} from "mendixmodelsdk";

const model = workingCopy.model();
const model = await workingCopy.openModel();

// at first, only interfaces are available:
const domainModel = model.allDomainModels()[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ deprecated: true
---

{{% alert color="warning" %}}
Mendix Platform SDK versions below 5.0 are deprecated. They depend on the [Projects API](/apidocs-mxsdk/apidocs/projects-api/) which will be removed early in 2024. A firm date will be communicated once a decision has been made.
Mendix Platform SDK versions below 5.0 are deprecated.
{{% /alert %}}

The following how-tos present details for Mendix Platform SDK versions below 5.0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ To set up your development tools, follow these steps:

```bash
$ node --version
v14.15.0
v18.20.8
```

For Debian-based Linux distributions such as Ubuntu, please refer to [NodeSource Node.js Binary Distributions](https://github.com/nodesource/distributions#user-content-installation-instructions) to properly set up your apt-get sources.

In the rest of the how-tos, in blocks such as the above, lines starting with a `$` represent commands to type into a terminal. Sometimes a line follows without a $, represents output of the command.

3. Install [Visual Studio Code](https://code.visualstudio.com/) (not to be confused with Visual Studio), a text editor/IDE with good support for [TypeScript](https://www.typescriptlang.org/). Make sure you have a recent version (v1.11.0+); check the version you are using through Help > About when you have Code opened.
4. Install TypeScript 4.4.3 or higher with [`npm`](https://www.npmjs.com/) (or [`yarn`](https://yarnpkg.com/)), Node.js's package manager:
4. Install TypeScript 4.6.2 or higher with [`npm`](https://www.npmjs.com/) (or [`yarn`](https://yarnpkg.com/)), Node.js's package manager:

```bash
$ npm install -g typescript
Expand All @@ -52,7 +52,7 @@ To set up your development tools, follow these steps:

```bash
$ tsc --version
Version 4.4.3 (or higher)
Version 4.6.2 (or higher)
```

If the version number is much lower, it could be that you also have an outdated TypeScript SDK on your system, left over from a previous installation. You can either uninstall the old TypeScript SDK, or bypass it by removing the old TypeScript SDK from your system's PATH environment variable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ This how-to provides guidance on using the Platform SDK to do the following:
The entry point for the Mendix Platform SDK is `MendixPlatformClient`. In most cases, you will need to instantiate a new object from this class:

```ts
import { MendixPlatformClient } from "mendixplatformsdk";

const client = new MendixPlatformClient();
```

Expand All @@ -31,6 +33,8 @@ The platform client allows you to create a new Mendix app by simply passing the

```ts
const app = await client.createNewApp("My new App");

console.log(`App created with ID: ${app.appId}`);
```

You can pass the following options to `createNewApp`:
Expand All @@ -45,16 +49,14 @@ You can pass the following options to `createNewApp`:

If both `templateDownloadURL` and `templateId` are left blank, the app will be created using the standard blank app template in the latest Mendix version.

Here is an example for creating a Mendix app based on the [Asset Manager App](https://marketplace.mendix.com/link/component/69674) template:
Here is an example for creating a Mendix app based on version 2.1.0 of the [Blank GenAI App](https://marketplace.mendix.com/link/component/227934) template:

```ts
const app = await client.createNewApp("My Asset Management", {
templateId: "6e66fe4d-6e96-4eb8-a2b6-a61dec37a799"
const app = await client.createNewApp("My GenAI App", {
templateId: "ba6ca01b-e2a4-45fa-870d-9e28b6acb845"
});
```

{{% alert color="warning" %}}The [Asset Manager App](https://marketplace.mendix.com/link/component/69674) template is deprecated and was created using Studio Pro 8.14.0. You cannot open it directly in Studio Pro 10 versions. To be able to use it in Studio Pro 10, you need to first upgrade it to a Studio Pro 9 app and then upgrade it to a Studio Pro 10 app. For more instructions, see the [Prerequisites](/refguide/extending-your-application-with-custom-java/#prerequisites) section in *Extending Your Application with Custom Java*.{{% /alert %}}

## Opening an Existing App {#opening-existing-app}

The platform client allows you to open an existing app using the app ID:
Expand All @@ -72,7 +74,13 @@ You can get the **App ID** (represented as **Project ID**) in the app's [Setting
From the app object, you can get some information about its repository (such as the repository type, URL, and default branch name):

```ts
const repositoryInfo = app.getRepositoryInfo();
const repository = app.getRepository();

const repositoryInfo = await repository.getInfo();
console.log("Repository Info: ", repositoryInfo);

const commitMessages = (await repository.getBranchCommits("main")).items.map(commit => commit.message);
console.log("Commit messages: ", commitMessages);
```

## Deleting an App {#deleting}
Expand All @@ -93,8 +101,14 @@ To change your app, you need to create a temporary working copy of a particular

```ts
const workingCopy = await app.createTemporaryWorkingCopy("main");

console.log(`Working ID: ${workingCopy.workingCopyId}`);
```

{{% alert color="warning" %}}
Working copy creation a resource intensive process, consider reusing previously created ones by invoking `app.getOnlineWorkingCopy(workingCopyId)`. All working copies are automatically deleted after 24 hours.
{{% /alert %}}

You can pass the following options to `createTemporaryWorkingCopy`:

| Name | Description |
Expand Down
7 changes: 1 addition & 6 deletions content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ When changing these components, make sure to use the [reverse engineering tool](

### Quick Setup

To set up the Mendix Platform and Model SDKs, perform the following steps using a command line console.

1. `npm init --yes`
2. `npm install -g typescript`
3. `npm install mendixmodelsdk mendixplatformsdk when @types/when --save`
4. `tsc --init`
To set up the Mendix Platform and Model SDKs, follow the [Quick Installation](/apidocs-mxsdk/mxsdk/setting-up-your-development-environment/#quick-installation) guide.

### Detailed Resources

Expand Down