diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/_index.md b/content/en/docs/apidocs-mxsdk/mxsdk/_index.md index 35a075cb16b..42552e69acb 100644 --- a/content/en/docs/apidocs-mxsdk/mxsdk/_index.md +++ b/content/en/docs/apidocs-mxsdk/mxsdk/_index.md @@ -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 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/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 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..684731c2050 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 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: 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/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 deleted file mode 100644 index ba96c7fb90a..00000000000 --- a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-howtos/manipulating-existing-models/closing-the-server-connection.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: "Close the Server Connection" -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: - -```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(); - } - ); - }); -} -``` - -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/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..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 @@ -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 = await workingCopy.openModel(); model.allModules() .filter(module => module.fromAppStore === true) .forEach(module => 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]; 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..5d08b8cf8ad 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 @@ -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: 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..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 @@ -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. @@ -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. 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..c13e64a2273 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`: @@ -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: @@ -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} @@ -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 | diff --git a/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md b/content/en/docs/apidocs-mxsdk/mxsdk/sdk-intro.md index 87eddb5f550..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 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