Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createResponse => {
progressTickCallback();
if (createResponse.success) {
newItemTemplate.itemId = createResponse.group.id;
templateDictionary[template.itemId] = {
itemId: createResponse.group.id
};
// Update the template again now that we have the new item id
newItemTemplate = common.replaceInTemplate(
newItemTemplate,
templateDictionary
);
// Copy resources
common
.copyFilesFromStorageItem(
storageAuthentication,
resourceFilePaths,
createResponse.group.id,
destinationAuthentication,
true
)
.then(
() => {
// Update the template dictionary with the new id
// Replace the templatized symbols in a copy of the template
let newItemTemplate: common.IItemTemplate = common.cloneObject(template);
newItemTemplate = common.replaceInTemplate(
newItemTemplate,
templateDictionary
);
// 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
return new Promise((resolve, reject) => {
// Replace the templatized symbols in a copy of the template
let newItemTemplate: common.IItemTemplate = common.cloneObject(template);
newItemTemplate = common.replaceInTemplate(
newItemTemplate,
templateDictionary
);
// 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
)
clonedSolutionItemIds => {
progressCallback(
(percentDone += progressPercentStep)
); // for solution item creation
// Update solution item's data JSON using template dictionary, and then update the
// itemId & dependencies in each item template
itemData = common.replaceInTemplate(
itemData,
templateDictionary
);
itemData.templates = itemData.templates.map(
itemTemplate => {
// Update ids present in template dictionary
const itemId = common.getProp(
templateDictionary,
itemTemplate.itemId + ".itemId"
);
if (itemId) {
itemTemplate.itemId = itemId;
}
itemTemplate.dependencies = itemTemplate.dependencies.map(
id => {
const dependId = common.getProp(
return new Promise((resolve, reject) => {
// Replace the templatized symbols in a copy of the template
let newItemTemplate: common.IItemTemplate = common.cloneObject(template);
newItemTemplate = common.replaceInTemplate(
newItemTemplate,
templateDictionary
);
// handle group
const title: string = common.getUniqueTitle(
newItemTemplate.item.title,
templateDictionary,
"user.groups"
);
// Set the item title with a valid name for the ORG
newItemTemplate.item.title = title;
newItemTemplate.item.access = "private";
common.createGroup(newItemTemplate.item, destinationAuthentication).then(
createResponse => {
progressTickCallback();
templateDictionary
);
// Copy resources, metadata, thumbnail, form
const resourcesDef = common.copyFilesFromStorageItem(
storageAuthentication,
resourceFilePaths,
createResponse.id,
destinationAuthentication
);
// The item's URL includes its id, so it needs to be updated
const updateUrlDef = template.data
? common.updateItemURL(
createResponse.id,
common.replaceInTemplate(
newItemTemplate.item.url,
templateDictionary
),
destinationAuthentication
)
: Promise.resolve(undefined);
// Check for extra processing for web mapping application
let customProcDef: Promise;
if (template.type === "Web Mapping Application" && template.data) {
customProcDef = webmappingapplication.fineTuneCreatedItem(
template,
newItemTemplate,
templateDictionary,
destinationAuthentication
);
// Set the appItemId manually to get around cases where the path was incorrectly set
// in legacy deployments
if (
newItemTemplate.type === "Web Mapping Application" &&
template.data
) {
common.setProp(
newItemTemplate,
"data.appItemId",
createResponse.id
);
}
// Update the template again now that we have the new item id
newItemTemplate = common.replaceInTemplate(
newItemTemplate,
templateDictionary
);
// Copy resources, metadata, thumbnail, form
const resourcesDef = common.copyFilesFromStorageItem(
storageAuthentication,
resourceFilePaths,
createResponse.id,
destinationAuthentication
);
// The item's URL includes its id, so it needs to be updated
const updateUrlDef = template.data
? common.updateItemURL(
createResponse.id,
"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"
},
{},
destinationAuthentication,
templateDictionary.folderId
)
.then(
() => resolve(),
() => resolve()
);
} else {