Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
folderResponse.folder.id +
")"
);
console.log(
"totalEstimatedCost, progressPercentStep",
totalEstimatedCost.toString(),
progressPercentStep.toFixed(2).toString()
);
progressCallback((percentDone += 2 * progressPercentStep)); // for data fetch and folder creation
const updateItemInfo = {
...item,
type: "Solution",
typeKeywords: ["Solution"]
};
common
.createItemWithData(
updateItemInfo,
{},
destinationAuthentication,
templateDictionary.folderId
)
.then(
updateResponse => {
const oldID: string = sourceId;
const newID: string = updateResponse.id;
console.log("Solution " + newID + " created");
templateDictionary.solutionItemId = newID;
item.id = newID;
item.thumbnailUrl = _checkedReplaceAll(
item.thumbnailUrl,
oldID,
// Create the item, then update its URL with its new id
// some fieldnames are used as keys for objects
// when we templatize field references for web applications we first stringify the components of the
// web application that could contain field references and then serach for them with a regular expression.
// We also need to stringify the web application when de-templatizing so it will find all of these occurrences as well.
if (template.type === "Web Mapping Application" && template.data) {
newItemTemplate = JSON.parse(
common.replaceInTemplate(
JSON.stringify(newItemTemplate),
templateDictionary
)
);
}
common
.createItemWithData(
newItemTemplate.item,
newItemTemplate.data,
destinationAuthentication,
templateDictionary.folderId
)
.then(
createResponse => {
progressTickCallback();
// Add the new item to the settings
newItemTemplate.itemId = createResponse.id;
templateDictionary[template.itemId] = {
itemId: createResponse.id
};
// Set the appItemId manually to get around cases where the path was incorrectly set
return new Promise(resolve => {
// If this is a Web AppBuilder application, we will create a Code Attachment for downloading
if (
common.hasAnyKeyword(originalTemplate, [
"WAB2D",
"WAB3D",
"Web AppBuilder"
])
) {
common
.createItemWithData(
{
tags: originalTemplate.item.tags,
title: originalTemplate.item.title,
type: "Code Attachment",
typeKeywords: ["Code", "Javascript", "Web Mapping Application"],
relationshipType: "WMA2Code",
originItemId: newlyCreatedItem.itemId,
url:
common.replaceInTemplate(
common.PLACEHOLDER_SERVER_NAME,
templateDictionary
) +
"/sharing/rest/content/items/" +
newlyCreatedItem.itemId +
"/package"
tags: options?.tags ?? [],
typeKeywords: ["Solution", "Template"]
};
if (Array.isArray(options?.additionalTypeKeywords)) {
solutionItem.typeKeywords = solutionItem.typeKeywords.concat(
options!.additionalTypeKeywords
);
}
const solutionData: common.ISolutionItemData = {
metadata: {},
templates: []
};
// Create new solution item
common
.createItemWithData(
solutionItem,
solutionData,
authentication,
undefined // use top-level folder
)
.then(
updateResponse => {
// Thumbnail must be added manually
if (solutionItem.thumbnailUrl) {
// thumbnailUrl += "?token=" + authentication.token();
common
.addThumbnailFromUrl(
solutionItem.thumbnailUrl,
updateResponse.id,
authentication