Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
({ searchText, itemTypes, itemTags, number }) => {
const query = new SearchQueryBuilder()
.match(session.username)
.in("owner");
// format the search query for item types
const types = itemTypes.filter(type => type.length);
// format the search query for item types
if (types.length) {
query.and().startGroup();
types.forEach((type, index, types) => {
query.match(type).in("type");
if (index !== types.length - 1) {
query.or();
}
});
query.endGroup();
const items = await element.connection.getItems();
return this.mapFolders(folders, element)
.concat(this.mapItems(items, element));
}
if(element.type === ArcGISType.GroupFolder) {
return this.getGroups(element);
}
if(element.type === ArcGISType.Group){
const query = new SearchQueryBuilder().match(element.id || '').in('group');
return this.getItems(element, query);
}
if(element.type === ArcGISType.Folder){
const q = new SearchQueryBuilder().match(element.id || '').in('ownerfolder');
return this.getItems(element, q);
}
return Promise.resolve([]);
}
///////////////////////////////////////////////////////////////////////////////////
public async getItems(params : any = {}){
await this.authenticate();
if(!params.q){
const user = await this.authentication.getUser();
params.q = new SearchQueryBuilder()
.match(user.orgId || '')
.in('orgid')
.and()
.match('root')
.in('ownerfolder')
.and()
.match(this.authentication.username)
.in('owner');
}
const query = {
num: 100,
...this.params,
...params,
authentication: this.authentication,
portal: this.restURL,
};