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 getItemResources(
requestOptions: IItemIdRequestOptions
): Promise {
const url = `${getPortalUrl(requestOptions)}/content/items/${
requestOptions.id
}/resources`;
// mix in user supplied params
requestOptions.params = {
...requestOptions.params,
num: 1000
};
return request(url, requestOptions);
}
export function addItemData(
requestOptions: IItemDataAddRequestOptions
): Promise {
const owner = determineOwner(requestOptions);
const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
requestOptions.id
}/update`;
// Portal API requires that the 'data' be POSTed in a `file` form field.
requestOptions.params = {
file: requestOptions.data,
...requestOptions.params
};
return request(url, requestOptions);
}
/**
export function updateItemResource(
requestOptions: IItemResourceRequestOptions
): Promise {
const owner = determineOwner(requestOptions);
const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
requestOptions.id
}/updateResources`;
// mix in user supplied params
requestOptions.params = {
file: requestOptions.resource,
fileName: requestOptions.name,
text: requestOptions.content,
...requestOptions.params
};
// only override whatever access was specified previously if 'private' was passed explicitly
if (typeof requestOptions.private !== "undefined") {
requestOptions.params.access = requestOptions.private
? "private"
: "inherit";
export function removeItemResource(
requestOptions: IItemResourceRequestOptions
): Promise {
const owner = determineOwner(requestOptions);
const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
requestOptions.id
}/removeResources`;
// mix in user supplied params
requestOptions.params = {
...requestOptions.params,
resource: requestOptions.resource
};
return request(url, requestOptions);
}
export function addItemJsonData(
requestOptions: IItemDataAddRequestOptions
): Promise {
const owner = determineOwner(requestOptions);
const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
requestOptions.id
}/update`;
// Portal API requires that the 'data' be stringified and POSTed in
// a `text` form field. It can also be sent with the `.create` call by sending
// a `.data` property.
requestOptions.params = {
text: JSON.stringify(requestOptions.data),
...requestOptions.params
};
return request(url, requestOptions);
}
/**
params: {}
};
if (typeof search === "string") {
options.params.q = search;
} else {
options.params = search.searchForm;
// mixin, giving user supplied requestOptions precedence
options = {
...options,
...search
};
}
// construct the search url
const url = `${getPortalUrl(options)}/search`;
// send the request
return request(url, options);
}
export function getItem(
id: string,
requestOptions?: IRequestOptions
): Promise {
const url = `${getPortalUrl(requestOptions)}/content/items/${id}`;
// default to a GET request
const options: IRequestOptions = {
...{ httpMethod: "GET" },
...requestOptions
};
return request(url, options);
}
export function removeFolder(
requestOptions: IFolderIdRequestOptions
): Promise<{
success: boolean;
folder: {
username: string;
id: string;
title: string;
};
}> {
const owner = determineOwner(requestOptions);
const url = `${getPortalUrl(
requestOptions
)}/content/users/${encodeURIComponent(owner)}/${
requestOptions.folderId
}/delete`;
return request(url, requestOptions);
}
export function unprotectItem(
requestOptions: IItemIdRequestOptions
): Promise {
const owner = determineOwner(requestOptions);
const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
requestOptions.id
}/unprotect`;
return request(url, requestOptions);
}
export function protectItem(
requestOptions: IItemIdRequestOptions
): Promise {
const owner = determineOwner(requestOptions);
const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${
requestOptions.id
}/protect`;
return request(url, requestOptions);
}