Mendix SDK: importModuleMpk not updating modules inside working copy before committing

0
Hello all! In the latest version of the mendix javascript SDK a function 'importModuleMpk' was added (https://apidocs.mendix.com/modelsdk/latest/interfaces/imodelserverclient.html#importmodulempk). The function shows the newly added if a working copy is committed after being imported.  We are trying to change some things inside the newly added module before committing. The problem is: the newly added module is not showing up in the OnlineWorkingCopy before having committed the workingcopy. My question: is there a way the newly imported module is available in the current working copy before commiting? Underneath is an example function which demonstrates what our problem is. import { Branch, MendixSdkClient, OnlineWorkingCopy, Project, Revision } from 'mendixplatformsdk' import * as os from 'os' async function importModule(params) { /** setup project from parameters */ const client = new MendixSdkClient(params.username, params.apikey) const project = new Project(client, params.projectId, params.projectName) const platform = client.platform() const workingCopy = await platform.createOnlineWorkingCopy(project, new Revision(params.revisionNumber, new Branch(project, undefined))) /** check for amount of modules before importing mpk module */ const modulesBeforeImport = workingCopy.model().allModules() console.log(modulesBeforeImport.length) /** import mpk */ await new Promise((resolve, reject) => { workingCopy.model().importModuleMpk( workingCopy.id(), `${os.homedir()}/mpks/pattern-${params.moduleName}.mpk`, () => { console.log('succesfully imported mpk'); resolve() }, (error) => { console.log('failed to imported mpk'); reject(error)} ) }) /** check for amount of modules before after mpk module, where we expect to have an extra module */ const modulesAfterImport = workingCopy.model().allModules() console.log(modulesAfterImport.length) /** show amount of modules before and after */ console.log(`amount of modules before: ${modulesBeforeImport.length} and after: ${modulesAfterImport.length}`) }  
asked
1 answers
0

Currently, the `importModuleMpk` only uploads a module MPK to the Model Server but does not update the current model instance that you have in the SDK. In order to see the changes reflected back in the model, you indeed need to reload the model, and there is no workaround at moment for this.

We are aware of this issue and plan to enable updating the model automatically after importing a module MPK in the near future.

answered