import { request , appendCustomParams } from "@esri/arcgis-rest-request" ; import { getPortalUrl } from "../util/get-portal-url" ; import { IUserItemOptions , IItemResourceOptions , IUpdateItemResponse , IItemResourceResponse , determineOwner , IManageItemRelationshipOptions } from "./helpers" ; import { updateItem , IUpdateItemOptions } from "./update" ; export interface IAddItemDataOptions extends IUserItemOptions { /**
     * Object to store
     */ data : any ; } param requestOptions returns export function addItemData ( requestOptions ) { const options = { item : { id : requestOptions . id , data : requestOptions . data } , ... requestOptions } ; delete options . id ; delete options . data ; return updateItem ( options as IUpdateItemOptions ) ; } param requestOptions returns export function addItemRelationship ( requestOptions ) { return determineOwner ( requestOptions ) . then ( owner => { const url = `${ getPortalUrl ( requestOptions ) }/content/users/${ owner }/addRelationship` ; const options = appendCustomParams < IManageItemRelationshipOptions > ( requestOptions , [ "originItemId" , "destinationItemId" , "relationshipType" ] , { params : { ... requestOptions . params } } ) ; return request ( url , options ) ; } ) ; } param requestOptions returns export function addItemResource ( requestOptions ) { return determineOwner ( requestOptions ) . then ( owner => { const url = `${ getPortalUrl ( requestOptions ) }/content/users/${ owner }/items/${ requestOptions . id }/addResources` ; requestOptions . params = { file : requestOptions . resource , fileName : requestOptions . name , resourcesPrefix : requestOptions . prefix , text : requestOptions . content , access : requestOptions . private ? "private" : "inherit" , ... requestOptions . params } ; return request ( url , requestOptions ) ; } ) ; }