import { request , cleanUrl , appendCustomParams } from "@esri/arcgis-rest-request" ; import { ISpatialReference , IFeature , IHasZM , GeometryType , IField } from "@esri/arcgis-rest-types" ; import { IGetLayerOptions } from "./helpers" ; /**
 * Related record query request options. Additional arguments can be passed via the [params](/arcgis-rest-js/api/feature-service/IQueryRelatedOptions/#params) property. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/query-related-feature-service-.htm) for more information and a full list of parameters.
 */ export interface IQueryRelatedOptions extends IGetLayerOptions { relationshipId ? : number ; objectIds ? : number [ ] ; outFields ? : "*" | string [ ] ; definitionExpression ? : string ; } /**
 * Related record data structure
 */ export interface IRelatedRecordGroup { objectId : number ; relatedRecords ? : IFeature [ ] ; count ? : number ; } /**
 * Related record response structure
 */ export interface IQueryRelatedResponse extends IHasZM { geometryType ? : GeometryType ; spatialReference ? : ISpatialReference ; fields ? : IField [ ] ; relatedRecordGroups : IRelatedRecordGroup [ ] ; } param requestOptions returns export function queryRelated ( requestOptions ) { const options = appendCustomParams < IQueryRelatedOptions > ( requestOptions , [ "objectIds" , "relationshipId" , "definitionExpression" , "outFields" ] , { httpMethod : "GET" , params : { definitionExpression : "1=1" , outFields : "*" , relationshipId : 0 , ... requestOptions . params } } ) ; return request ( `${ cleanUrl ( requestOptions . url ) }/queryRelatedRecords` , options ) ; }