mendixplatformsdk
Advanced tools
Comparing version 5.1.2 to 5.1.3
{ | ||
"name": "mendixplatformsdk", | ||
"description": "Mendix Platform SDK", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"author": "Mendix", | ||
@@ -21,14 +21,10 @@ "license": "MIT", | ||
"devDependencies": { | ||
"mendixmodelsdk": "^4.56.0" | ||
"mendixmodelsdk": "^4.86.0" | ||
}, | ||
"peerDependencies": { | ||
"mendixmodelsdk": "^4.56.0" | ||
"mendixmodelsdk": "^4.86.0" | ||
}, | ||
"resolutions": { | ||
"mendixmodelsdk/**/@types/eventsource": "1.1.8" | ||
}, | ||
"main": "./src/index.js", | ||
"typings": "./src/index.d.ts", | ||
"dependencies": { | ||
"@types/eventsource": "1.1.8", | ||
"mobx": "^5.0.0", | ||
@@ -35,0 +31,0 @@ "wolfy87-eventemitter": "^5.2.1", |
@@ -24,7 +24,15 @@ "use strict"; | ||
const { summary, image, repositoryType, templateId, templateDownloadURL } = options ?? {}; | ||
const createAppBody = { name: appName, summary, image, repository_type: repositoryType, use_app_template: true }; | ||
if (templateId || templateDownloadURL) { | ||
if (templateDownloadURL) { | ||
logger_1.logger.warn("The parameter 'templateDownloadURL' is deprecated and the server currently ignores this field"); | ||
} | ||
const createAppBody = { | ||
name: appName, | ||
summary, | ||
image, | ||
repository_type: repositoryType || "git", | ||
use_app_template: true | ||
}; | ||
if (templateId) { | ||
createAppBody.app_template = { | ||
template_id: templateId, | ||
template_download_url: templateDownloadURL | ||
template_id: templateId | ||
}; | ||
@@ -31,0 +39,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
commitId: options?.commitId | ||
}); | ||
}, "POST", (0, config_1.getPlatformConfig)().taskPollingTimeoutInMs); | ||
return response.result?.workingCopyId; | ||
@@ -72,3 +72,3 @@ }, { | ||
}; | ||
await this.restConnector.awaitTask(`/v1/temporary-working-copies/${workingCopyId}/commit`, body); | ||
await this.restConnector.awaitTask(`/v1/temporary-working-copies/${workingCopyId}/commit`, body, "POST", (0, config_1.getPlatformConfig)().taskPollingTimeoutInMs); | ||
}, { | ||
@@ -75,0 +75,0 @@ maxAttempts: 3, |
@@ -18,6 +18,7 @@ /** Type of the model repository. Possible values: `"svn"` and `"git"`. */ | ||
/** | ||
* Note: This parameter is deprecated and the server currently ignores this field | ||
* | ||
* URL of the download location of the app template package file (mpk). | ||
* If the template package is private, this URL must be authenticated with a signature. | ||
* | ||
* When neither `templateDownloadURL` or `templateId` are set, the default Blank App is used for app initialization. | ||
*/ | ||
@@ -28,3 +29,3 @@ templateDownloadURL?: string; | ||
* | ||
* When neither `templateDownloadURL` or `templateId` are set, the default Blank App is used for app initialization. | ||
* When `templateId` is not set, the default Blank App is used for app initialization. | ||
*/ | ||
@@ -31,0 +32,0 @@ templateId?: string; |
@@ -13,2 +13,4 @@ /** | ||
mendixToken: string; | ||
/** Task polling timeout. Default is 15 minutes */ | ||
taskPollingTimeoutInMs: number; | ||
} | ||
@@ -15,0 +17,0 @@ /** |
@@ -8,3 +8,4 @@ "use strict"; | ||
projectServiceEndpoint: "https://projectservice.mendix.com", | ||
mendixToken: process.env.MENDIX_TOKEN || "" | ||
mendixToken: process.env.MENDIX_TOKEN || "", | ||
taskPollingTimeoutInMs: 900000 | ||
}; | ||
@@ -11,0 +12,0 @@ let platformConfig = { ...defaultConfig }; |
@@ -8,2 +8,3 @@ "use strict"; | ||
constructor(baseURL, credentials, validateStatus = true, headers = {}) { | ||
this.AWAIT_TASK_TIMEOUT_IN_MS = 900000; // 15m | ||
this.defaultOptions = { | ||
@@ -85,3 +86,3 @@ url: baseURL, | ||
} | ||
async awaitTask(url, body, method = "POST") { | ||
async awaitTask(url, body, method = "POST", timeoutInMs = this.AWAIT_TASK_TIMEOUT_IN_MS) { | ||
const result = await doRequest({ ...this.defaultOptions, method, pathname: url, json: body }); | ||
@@ -92,2 +93,9 @@ if (result.status !== 202) { | ||
const { taskId } = result.data; | ||
const lastTaskData = await withTimeout(this.waitRunningTask(taskId), timeoutInMs); | ||
if (lastTaskData.status !== "finished") { | ||
throw lastTaskData.result; | ||
} | ||
return lastTaskData; | ||
} | ||
async waitRunningTask(taskId) { | ||
let lastTaskData = { status: "running" }; | ||
@@ -102,5 +110,2 @@ while (lastTaskData.status === "running") { | ||
} | ||
if (lastTaskData.status !== "finished") { | ||
throw lastTaskData.result; | ||
} | ||
return lastTaskData; | ||
@@ -169,2 +174,8 @@ } | ||
} | ||
async function withTimeout(promise, timeoutInMs) { | ||
let timeoutHandle; | ||
const timeoutPromise = new Promise((_, reject) => (timeoutHandle = setTimeout(() => reject(new Error("Timeout exceeded")), timeoutInMs))); | ||
const result = await Promise.race([promise.finally(() => clearTimeout(timeoutHandle)), timeoutPromise]); | ||
return result; | ||
} | ||
//# sourceMappingURL=RestConnector.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80298
8
1177
- Removed@types/eventsource@1.1.8
- Removed@types/eventsource@1.1.8(transitive)