From c894a28c1df43b1e2bef6a286a9fbfcf51775561 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 13:19:33 +0200 Subject: [PATCH 01/13] Remove when from platformsdk dependencies. It is no longer needed in v5. --- content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md index 87eddb5f550..b811a4f1826 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md @@ -58,7 +58,7 @@ To set up the Mendix Platform and Model SDKs, perform the following steps using 1. `npm init --yes` 2. `npm install -g typescript` -3. `npm install mendixmodelsdk mendixplatformsdk when @types/when --save` +3. `npm install mendixmodelsdk mendixplatformsdk --save` 4. `tsc --init` ### Detailed Resources From 48db15fc401d77f079d958cbda9f7dd3e49fe3a5 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 13:25:12 +0200 Subject: [PATCH 02/13] Bump node version example to 18 LTS --- .../mxsdk/sdk-howtos/setting-up-your-development-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md index a134704e591..bba6a6a3698 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md @@ -34,7 +34,7 @@ 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. From 800c146b119e8ffa0b9eed8c3e22f41c04f6e7cc Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 13:29:57 +0200 Subject: [PATCH 03/13] Bump typescript version to the one used by sdks --- .../sdk-howtos/setting-up-your-development-environment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md index bba6a6a3698..bd14bffaf43 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/setting-up-your-development-environment.md @@ -42,7 +42,7 @@ To set up your development tools, follow these steps: 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 @@ -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. From 5fb90c527963a445d70fc1143c525e1d858cbc19 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 13:59:19 +0200 Subject: [PATCH 04/13] Use Blank GenAI template instead of deprecated asset manager --- .../apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md index 1ab39952a23..97dfca3aeae 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md @@ -45,16 +45,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 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: From 7e74c0dfb329febaeaaa0644a218f9401dd6a140 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 14:36:36 +0200 Subject: [PATCH 05/13] Fix and improve using platform sdk examples --- .../mxsdk/sdk-howtos/using-platform-sdk.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md index 97dfca3aeae..f396506b467 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md @@ -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(); ``` @@ -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`: @@ -70,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 commitsIDs = (await repository.getBranchCommits("main")).items.map(commit => commit.id); +console.log("Repository commits IDs: ", commitsIDs); ``` ## Deleting an App {#deleting} @@ -91,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(workingCopy.workingCopyId)`. All working copies are automatically deleted after 24 hours. +{{% /alert %}} + You can pass the following options to `createTemporaryWorkingCopy`: | Name | Description | From c8ce026d57e9f72c38c6712c23ea19d0a71dfb9b Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 14:47:54 +0200 Subject: [PATCH 06/13] Add warning about wc creation being a resource intensive process in your first script --- .../mxsdk/sdk-howtos/creating-your-first-script.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md index 9b87c7d739a..df8f75e845a 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md @@ -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 a resource intensive process, consider reusing previously created ones by invoking `app.getOnlineWorkingCopy(workingCopy.workingCopyId)`. All working copies are automatically deleted after 24 hours. +{{% /alert %}} + ### Code Explanation Here are some explanations about the script: From e7d68a420697d45f5cb82980ad3e8b51f8b20e47 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 15:09:53 +0200 Subject: [PATCH 07/13] Fix broken code in creating the domain model --- .../sdk-howtos/creating-the-domain-model.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-the-domain-model.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-the-domain-model.md index 2cebf8dee06..31f049b1e16 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-the-domain-model.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-the-domain-model.md @@ -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 }; @@ -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: @@ -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 From 327db904c185a909cc56187caf9b7e54fb911aa5 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 15:27:20 +0200 Subject: [PATCH 08/13] Fix close connection --- .../closing-the-server-connection.md | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md index ba96c7fb90a..d2a68dbdba1 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md @@ -5,23 +5,20 @@ url: /apidocs-mxsdk/mxsdk/closing-the-server-connection/ The SDK observes the complete model using the [mobx](https://github.com/mobxjs/mobx) library. This means that any change you make to the model is immediately synced with the working copy on the server. Sending changes to the server happens in the background and automatically, so there is no explicit commit. However, sending changes might take a while and your script should not end before all changes are flushed. In particular, changes are by default sent in batches of 1000 or after 200ms, whichever happens first. To wait until all changes are submitted to the server, use the [`closeConnection`](https://apidocs.rnd.mendix.com/modelsdk/latest/classes/model.html#closeconnection) function of the `model` object. -This example shows the function `closeConnection`, which you can invoke when working with a `workingCopy` instance as a last step before the final commit: +This example shows the function `closeConnection`, which you can invoke when working with a `model` instance as a last step before the final commit: ```ts -async function closeConnection(workingCopy: OnlineWorkingCopy) { - await new Promise((resolve, reject) => { - workingCopy.model().closeConnection( - () => { - console.log(`Closed connection to Model API successfully.`); - resolve(); - }, - (err) => { - console.error(`Failed to closed connection to Model API. Error: ${err}`); - reject(); - } - ); +async function closeConnection(model: IModel): Promise { + return model + .closeConnection() + .then(() => { + console.log(`Closed connection to Model API successfully.`); + }) + .catch((err) => { + console.error(`Failed to closed connection to Model API. Error: ${err}`); }); } + ``` Continue with [How to Find Things in the Model](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/). From 564a80d1d418122f4b7903d7e04a263bdb8bf504 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 15:42:36 +0200 Subject: [PATCH 09/13] Fix finding things in the model --- .../finding-things-in-the-model.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md index 69e7d6e3132..a01f0e414d8 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md @@ -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 @@ -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] @@ -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/). @@ -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 = workingCopy.openModel(); model.allModules() .filter(module => module.fromAppStore === true) .forEach(module => From a08ed57d6ea4a237ee546c678c01b3f94c7a0f03 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Fri, 4 Apr 2025 15:54:24 +0200 Subject: [PATCH 10/13] Fix loading units --- .../loading-units-and-elements.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/loading-units-and-elements.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/loading-units-and-elements.md index d8f7b8b6d18..6f500e84431 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/loading-units-and-elements.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/loading-units-and-elements.md @@ -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]; From 1d9af04d69c45fb065c280d96ff6a7a4ca28a423 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Mon, 7 Apr 2025 16:25:16 +0200 Subject: [PATCH 11/13] Link quick installation in sdk intro --- content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md index b811a4f1826..53ecc2eb4e3 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md @@ -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 --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 From 1827b3538dd2bb0ff6a19f8995616511e45a4ed6 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Mon, 7 Apr 2025 16:29:23 +0200 Subject: [PATCH 12/13] Print commit messages instead of ids in platform sdk example --- .../mxsdk/sdk-howtos/creating-your-first-script.md | 2 +- .../finding-things-in-the-model.md | 2 +- .../apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md index df8f75e845a..3096fdaf6c6 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/creating-your-first-script.md @@ -48,7 +48,7 @@ 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 a resource intensive process, consider reusing previously created ones by invoking `app.getOnlineWorkingCopy(workingCopy.workingCopyId)`. All working copies are automatically deleted after 24 hours. +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 %}} ### Code Explanation diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md index a01f0e414d8..fa4eaec2a59 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/finding-things-in-the-model.md @@ -53,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.openModel(); +const model = await workingCopy.openModel(); model.allModules() .filter(module => module.fromAppStore === true) .forEach(module => diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md index f396506b467..80d811c1e82 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/using-platform-sdk.md @@ -79,8 +79,8 @@ const repository = app.getRepository(); const repositoryInfo = await repository.getInfo(); console.log("Repository Info: ", repositoryInfo); -const commitsIDs = (await repository.getBranchCommits("main")).items.map(commit => commit.id); -console.log("Repository commits IDs: ", commitsIDs); +const commitMessages = (await repository.getBranchCommits("main")).items.map(commit => commit.message); +console.log("Commit messages: ", commitMessages); ``` ## Deleting an App {#deleting} @@ -106,7 +106,7 @@ 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(workingCopy.workingCopyId)`. All working copies are automatically deleted after 24 hours. +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`: From ad26f41b8438452b1cd3dfc42834c3f1115871a3 Mon Sep 17 00:00:00 2001 From: Pasquale Latrofa Date: Mon, 7 Apr 2025 16:45:24 +0200 Subject: [PATCH 13/13] Move how to close server connection to old sdks --- .../apidocs-mxsdk/mxsdk/sdk-howtos/_index.md | 1 - .../changing-things-in-the-model.md | 2 +- .../sdk-old-versions-howtos/_index.md | 1 + .../old-closing-the-server-connection.md} | 25 +++++++++++-------- 4 files changed, 16 insertions(+), 13 deletions(-) rename content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/{manipulating-existing-models/closing-the-server-connection.md => sdk-old-versions-howtos/old-closing-the-server-connection.md} (60%) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/_index.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/_index.md index caf186760c9..da869891acc 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/_index.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/_index.md @@ -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/) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/changing-things-in-the-model.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/changing-things-in-the-model.md index 5bb2f5e3324..1d21c69b5e7 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/changing-things-in-the-model.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/changing-things-in-the-model.md @@ -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/). diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/_index.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/_index.md index 86d19729cb6..adcb2d17a81 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/_index.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/_index.md @@ -13,3 +13,4 @@ The following how-tos present details for Mendix Platform SDK versions below 5.0 * [Set Up Your Development Environment (Old Versions)](/apidocs-mxsdk/mxsdk/old-setting-up-your-development-environment/) * [Create Your First Script (Old Versions)](/apidocs-mxsdk/mxsdk/old-creating-your-first-script/) +* [How to Close the Server Connection (Old Versions)](/apidocs-mxsdk/mxsdk/old-closing-the-server-connection/) diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/old-closing-the-server-connection.md similarity index 60% rename from content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md rename to content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/old-closing-the-server-connection.md index d2a68dbdba1..0198b49d294 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/sdk-old-versions-howtos/old-closing-the-server-connection.md @@ -1,24 +1,27 @@ --- title: "Close the Server Connection" -url: /apidocs-mxsdk/mxsdk/closing-the-server-connection/ +url: /apidocs-mxsdk/mxsdk/old-closing-the-server-connection/ --- The SDK observes the complete model using the [mobx](https://github.com/mobxjs/mobx) library. This means that any change you make to the model is immediately synced with the working copy on the server. Sending changes to the server happens in the background and automatically, so there is no explicit commit. However, sending changes might take a while and your script should not end before all changes are flushed. In particular, changes are by default sent in batches of 1000 or after 200ms, whichever happens first. To wait until all changes are submitted to the server, use the [`closeConnection`](https://apidocs.rnd.mendix.com/modelsdk/latest/classes/model.html#closeconnection) function of the `model` object. -This example shows the function `closeConnection`, which you can invoke when working with a `model` instance as a last step before the final commit: +This example shows the function `closeConnection`, which you can invoke when working with a `workingCopy` instance as a last step before the final commit: ```ts -async function closeConnection(model: IModel): Promise { - return model - .closeConnection() - .then(() => { - console.log(`Closed connection to Model API successfully.`); - }) - .catch((err) => { - console.error(`Failed to closed connection to Model API. Error: ${err}`); +async function closeConnection(workingCopy: OnlineWorkingCopy) { + await new Promise((resolve, reject) => { + workingCopy.model().closeConnection( + () => { + console.log(`Closed connection to Model API successfully.`); + resolve(); + }, + (err) => { + console.error(`Failed to closed connection to Model API. Error: ${err}`); + reject(); + } + ); }); } - ``` Continue with [How to Find Things in the Model](/apidocs-mxsdk/mxsdk/finding-things-in-the-model/).