Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function deleteFeatures(
requestOptions: IDeleteFeaturesOptions
): Promise<{ deleteResults: IEditFeatureResult[] }> {
const url = `${cleanUrl(requestOptions.url)}/deleteFeatures`;
// edit operations POST only
const options = appendCustomParams(
requestOptions,
[
"where",
"objectIds",
"gdbVersion",
"returnEditMoment",
"rollbackOnFailure"
],
{ params: { ...requestOptions.params } }
);
return request(url, options);
}
const owner = determineOwner(requestOptions);
const baseUrl = `${getPortalUrl(requestOptions)}/content/users/${owner}`;
let url = `${baseUrl}/addItem`;
if (requestOptions.folderId) {
url = `${baseUrl}/${requestOptions.folderId}/addItem`;
}
requestOptions.params = {
...requestOptions.params,
...serializeItem(requestOptions.item)
};
// serialize the item into something Portal will accept
const options = appendCustomParams(
requestOptions,
[
"owner",
"folderId",
"file",
"dataUrl",
"text",
"async",
"multipart",
"filename",
"overwrite"
],
{
params: { ...requestOptions.params }
}
);
export function addFeatures(
requestOptions: IAddFeaturesOptions
): Promise<{ addResults: IEditFeatureResult[] }> {
const url = `${cleanUrl(requestOptions.url)}/addFeatures`;
// edit operations are POST only
const options = appendCustomParams(
requestOptions,
["features", "gdbVersion", "returnEditMoment", "rollbackOnFailure"],
{ params: { ...requestOptions.params } }
);
return request(url, options);
}
export function queryRelated(
requestOptions: IQueryRelatedRequestOptions
): Promise {
const options = appendCustomParams(
requestOptions,
["objectIds", "relationshipId", "definitionExpression", "outFields"],
{
httpMethod: "GET",
params: {
// set default query parameters
definitionExpression: "1=1",
outFields: "*",
relationshipId: 0,
...requestOptions.params
}
}
);
return request(
`${cleanUrl(requestOptions.url)}/queryRelatedRecords`,
export function updateFeatures(
requestOptions: IUpdateFeaturesOptions
): Promise<{ updateResults: IEditFeatureResult[] }> {
const url = `${cleanUrl(requestOptions.url)}/updateFeatures`;
// edit operations are POST only
const options = appendCustomParams(
requestOptions,
["features", "gdbVersion", "returnEditMoment", "rollbackOnFailure"],
{ params: { ...requestOptions.params } }
);
return request(url, options);
}
export function searchGroupUsers(
id: string,
searchOptions?: ISearchGroupUsersOptions
): Promise {
const url = `${getPortalUrl(searchOptions)}/community/groups/${id}/userlist`;
const options = appendCustomParams(
searchOptions || {},
["name", "num", "start", "sortField", "sortOrder", "joined", "memberType"],
{
httpMethod: "GET"
}
);
return request(url, options);
}
export function geocode(
address: string | IGeocodeOptions
): Promise {
let options: IGeocodeOptions = {};
let endpoint: string;
if (typeof address === "string") {
options.params = { singleLine: address };
endpoint = ARCGIS_ONLINE_GEOCODING_URL;
} else {
endpoint = address.endpoint || ARCGIS_ONLINE_GEOCODING_URL;
options = appendCustomParams(
address,
[
"singleLine",
"address",
"address2",
"address3",
"neighborhood",
"city",
"subregion",
"region",
"postal",
"postalExt",
"countryCode",
"outFields",
"magicKey"
],
export function queryFeatures(
requestOptions: IQueryFeaturesOptions
): Promise {
const queryOptions = appendCustomParams(
requestOptions,
[
"where",
"objectIds",
"relationParam",
"time",
"distance",
"units",
"outFields",
"geometry",
"geometryType",
"spatialRel",
"returnGeometry",
"maxAllowableOffset",
"geometryPrecision",
"inSR",
export function genericSearch(
search: string | ISearchOptions | SearchQueryBuilder,
searchType: "item" | "group" | "user"
): Promise> {
let url: string;
let options: IRequestOptions;
if (typeof search === "string" || search instanceof SearchQueryBuilder) {
options = {
httpMethod: "GET",
params: {
q: search
}
};
} else {
options = appendCustomParams(
search,
["q", "num", "start", "sortField", "sortOrder"],
{
httpMethod: "GET"
}
);
}
let path = searchType === "item" ? "/search" : "/community/groups";
switch (searchType) {
case "item":
path = "/search";
break;
case "group":
path = "/community/groups";
break;