Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
() => {
if (access && access !== "private") {
// Set access if it is not AGOL default
// Set the access manually since the access value in createItem appears to be ignored
const accessOptions: portal.ISetAccessOptions = {
id: serviceItemId,
access: access === "public" ? "public" : "org", // need to use constants rather than string
authentication: authentication
};
portal.setItemAccess(accessOptions).then(
() => {
progressTickCallback && progressTickCallback();
resolve();
},
e => reject(generalHelpers.fail(e))
);
} else {
progressTickCallback && progressTickCallback();
resolve();
}
},
e => reject(generalHelpers.fail(e))
createResponse => {
if (createResponse.success) {
let accessDef: Promise;
// Set access if it is not AGOL default
// Set the access manually since the access value in createItem appears to be ignored
// Need to run serially; will not work reliably if done in parallel with adding the data section
if (access !== "private") {
const accessOptions: portal.ISetAccessOptions = {
id: createResponse.id,
access: access === "public" ? "public" : "org", // need to use constants rather than string
authentication: authentication
};
accessDef = portal.setItemAccess(accessOptions);
} else {
accessDef = Promise.resolve({
itemId: createResponse.id
} as portal.ISharingResponse);
}
// Now add attached items
accessDef.then(
() => {
const updateDefs: Array> = [];
// Add the data section
if (dataFile) {
updateDefs.push(
_addItemDataFile(createResponse.id, dataFile, authentication)
);
setAccess (owner, itemId, access = null, portalOpts) {
if (access === 'everyone') {
access = 'public';
}
const args = this.addOptions({
id: itemId,
owner,
access,
}, portalOpts);
return setItemAccess(args)
.catch(handleError);
},
/**