import { request , IRequestOptions } from "@esri/arcgis-rest-request" ; import { IPagingParams , IItem , IFolder , IPagedResponse , } from "@esri/arcgis-rest-types" ; import { getPortalUrl } from "../util/get-portal-url" ; import { determineOwner } from "./helpers" ; export type UnixTime = number ; export interface IUserContentRequestOptions extends IPagingParams , IRequestOptions { owner ? : string ; folderId ? : string ; } export interface IUserContentResponse extends IPagedResponse { username : string ; currentFolder ? : IFolder ; items : IItem [ ] ; folders : IFolder [ ] ; } param requestOptions returns export const getUserContent = ( requestOptions ) : Promise < IUserContentResponse > => { const { folderId : folder , start = 1 , num = 10 , authentication , } = requestOptions ; const suffix = folder ? `/${ folder }` : "" ; return determineOwner ( requestOptions ) . then ( ( owner ) => `${ getPortalUrl ( requestOptions ) }/content/users/${ owner }${ suffix }` ) . then ( ( url ) => request ( url , { httpMethod : "GET" , authentication , params : { start , num , } , } ) ) ; } ;