Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
() => {
// Prepare template
let itemTemplate = mClassifier.initItemTemplateFromJSON(findTemplateInList(itemTemplates, itemId));
// Interpolate it
itemTemplate.dependencies = itemTemplate.dependencies ?
mCommon.templatize(itemTemplate.dependencies) as string[] : [];
itemTemplate = adlib.adlib(itemTemplate, settings);
// Deploy it
itemTemplate.fcns.createItemFromTemplate(itemTemplate, settings, requestOptions, progressCallback)
.then(
itemClone => resolve(itemClone),
(e) => reject(mCommon.fail(e))
)
},
(e) => reject(mCommon.fail(e))
createResponse => {
if (createResponse.success) {
// Add the new item to the settings
settings[itemTemplate.itemId] = {
id: createResponse.id
};
itemTemplate.itemId = itemTemplate.item.id = createResponse.id;
itemTemplate = adlib.adlib(itemTemplate, settings);
// Update the app URL
progressCallback && progressCallback({
processId: itemTemplate.key,
status: "updating URL"
});
mCommon.updateItemURL(itemTemplate.itemId, itemTemplate.item.url, requestOptions)
.then(
() => {
mCommon.finalCallback(itemTemplate.key, true, progressCallback);
resolve(itemTemplate);
},
(e) => {
mCommon.finalCallback(itemTemplate.key, false, progressCallback);
reject(mCommon.fail(e));
}
createResponse => {
if (createResponse.success) {
// Add the new item to the settings
settings[itemTemplate.itemId] = {
id: createResponse.id
};
itemTemplate.itemId = itemTemplate.item.id = createResponse.id;
itemTemplate = adlib.adlib(itemTemplate, settings);
mCommon.finalCallback(itemTemplate.key, true, progressCallback);
resolve(itemTemplate);
} else {
mCommon.finalCallback(itemTemplate.key, false, progressCallback);
reject(mCommon.fail());
}
},
(e) => {
createResponse => {
if (createResponse.success) {
// Add the new item to the settings
settings[itemTemplate.itemId] = {
id: createResponse.id
};
itemTemplate.itemId = itemTemplate.item.id = createResponse.id;
itemTemplate = adlib.adlib(itemTemplate, settings);
// Update the app URL
progressCallback && progressCallback({
processId: itemTemplate.key,
status: "updating URL"
});
mCommon.updateItemURL(itemTemplate.itemId, itemTemplate.item.url, requestOptions)
.then(
() => {
mCommon.finalCallback(itemTemplate.key, true, progressCallback);
resolve(itemTemplate);
},
(e) => {
mCommon.finalCallback(itemTemplate.key, false, progressCallback);
reject(mCommon.fail(e));
}
createResponse => {
if (createResponse.success) {
// Add the new item to the settings
settings[itemTemplate.itemId] = {
id: createResponse.group.id
};
itemTemplate.itemId = createResponse.group.id;
itemTemplate = adlib.adlib(itemTemplate, settings);
// Add the group's items to it
addGroupMembers(itemTemplate, requestOptions, progressCallback)
.then(
() => {
mCommon.finalCallback(itemTemplate.key, true, progressCallback);
resolve(itemTemplate);
},
(e) => {
mCommon.finalCallback(itemTemplate.key, false, progressCallback);
reject(mCommon.fail(e));
}
);
} else {
mCommon.finalCallback(itemTemplate.key, false, progressCallback);
reject(mCommon.fail());
createResponse => {
// Add the new item to the settings list
settings[itemTemplate.itemId] = {
id: createResponse.serviceItemId,
url: createResponse.serviceurl
};
itemTemplate.itemId = itemTemplate.item.id = createResponse.serviceItemId;
itemTemplate = adlib.adlib(itemTemplate, settings);
itemTemplate.item.url = createResponse.serviceurl;
// Update item using a unique name because createFeatureService doesn't provide a way to specify
// snippet, description, etc.
const updateOptions:items.IItemUpdateRequestOptions = {
item: {
id: itemTemplate.itemId,
title: itemTemplate.item.title,
snippet: itemTemplate.item.snippet,
description: itemTemplate.item.description,
accessInfo: itemTemplate.item.accessInfo,
licenseInfo: itemTemplate.item.licenseInfo,
text: itemTemplate.data
},
...requestOptions
};
createResponse => {
if (createResponse.success) {
// Add the new item to the settings
settings[itemTemplate.itemId] = {
id: createResponse.id
};
itemTemplate.itemId = itemTemplate.item.id = createResponse.id;
itemTemplate = adlib.adlib(itemTemplate, settings);
// Update the app URL
progressCallback && progressCallback({
processId: itemTemplate.key,
status: "updating URL"
});
mCommon.updateItemURL(itemTemplate.itemId, itemTemplate.item.url, requestOptions)
.then(
() => {
mCommon.finalCallback(itemTemplate.key, true, progressCallback);
resolve(itemTemplate);
},
() => {
mCommon.finalCallback(itemTemplate.key, false, progressCallback);
reject({ success: false });
}
const transformsList: adlib.TransformsList = {
firstXform: transform1
};
const template = {
value: '{{ instance.color }}'
};
const settings = {
instance: {
color: 'red'
}
};
const interpolated = adlib.adlib(template, settings, transformsList);
const list: string[] = adlib.listDependencies(template);
firstXform: transform1
};
const template = {
value: '{{ instance.color }}'
};
const settings = {
instance: {
color: 'red'
}
};
const interpolated = adlib.adlib(template, settings, transformsList);
const list: string[] = adlib.listDependencies(template);
export function replaceInTemplate(template: any, replacements: any): any {
return adlib.adlib(template, replacements, TRANSFORMS);
}