Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const updateOptions: portal.IUpdateItemOptions = {
item: itemInfo,
params: {
text: data
},
authentication: authentication
};
portal.updateItem(updateOptions).then(
() => {
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))
);
return new Promise((resolve, reject) => {
const addMetadataOptions: portal.IUpdateItemOptions = {
item: {
id: itemId
},
params: {
// Pass metadata in via params because item property is serialized, which discards a blob
metadata: metadataFile
},
authentication: authentication
};
portal.updateItem(addMetadataOptions).then(resolve, reject);
});
}
isGroup: boolean = false
): Promise {
const updateOptions: any = {
params: {
// Pass image in directly because item object is serialized, which discards a blob
thumbnail: blob
},
authentication: authentication
};
updateOptions[isGroup ? "group" : "item"] = {
id: itemId
};
return isGroup
? portal.updateGroup(updateOptions)
: portal.updateItem(updateOptions);
}
export function addMetadataFromBlob(
blob: Blob,
itemId: string,
authentication: UserSession
): Promise {
const updateOptions: any = {
item: {
id: itemId
},
params: {
// Pass metadata in via params because item property is serialized, which discards a blob
metadata: blob
},
authentication: authentication
};
return portal.updateItem(updateOptions);
}
return new Promise((resolve, reject) => {
// Update its URL
const options = {
item: {
id,
url
},
authentication: authentication
};
portal.updateItem(options).then(
() => {
resolve(id);
},
e => reject(generalHelpers.fail(e))
);
});
}
export function addThumbnailFromUrl(
url: string,
itemId: string,
authentication: UserSession,
isGroup: boolean = false
): Promise {
const updateOptions: any = {
authentication: authentication
};
updateOptions[isGroup ? "group" : "item"] = {
id: itemId,
thumbnailurl: url
};
return isGroup
? portal.updateGroup(updateOptions)
: portal.updateItem(updateOptions);
}
return new Promise((resolve, reject) => {
const updateOptions: portal.IUpdateItemOptions = {
item: itemInfo,
folderId: folderId,
authentication: authentication
};
portal.updateItem(updateOptions).then(
response => (response.success ? resolve(response) : reject(response)),
err => reject(err)
);
});
}
public async updateItem(item: IItem, data : any){
return updateItem({
item: {
id: item.id,
text: this.getSafeData(data),
},
portal: this.restURL,
authentication: this.authentication,
});
}