import { cleanUrl , IRequestOptions } from "@esri/arcgis-rest-request" ; import { GeometryType , SpatialRelationship , IGeometry , ISpatialReference } from "@esri/arcgis-rest-types" ; /**
 * Base options for making requests against feature layers
 */ export interface IGetLayerOptions extends IRequestOptions { /**
     * Layer service url.
     */ url : string ; } export interface ISharedQueryOptions extends IGetLayerOptions { /**
     * A where clause for the query. Defaults to "1=1"
     */ where ? : string ; geometry ? : IGeometry ; geometryType ? : GeometryType ; inSR ? : string | ISpatialReference ; spatialRel ? : SpatialRelationship ; } /**
 * Add, update and delete features result Object.
 */ export interface IEditFeatureResult { objectId : number ; globalId ? : string ; success : boolean ; } /**
 * `globalId` always returned with attachments via apply edits.
 */ export interface IApplyEditsAttachmentResult extends IEditFeatureResult { globalId : string ; } /**
 * Apply edits result Object.
 */ export interface IApplyEditsResult { addResults : IEditFeatureResult [ ] ; updateResults : IEditFeatureResult [ ] ; deleteResults : IEditFeatureResult [ ] ; attachments ? : { addResults ? : IApplyEditsAttachmentResult [ ] ; updateResults ? : IApplyEditsAttachmentResult [ ] ; deleteResults ? : IApplyEditsAttachmentResult [ ] ; } ; } /**
 * Common add, update, and delete features options.
 */ export interface ISharedEditOptions extends IGetLayerOptions { /**
     * The geodatabase version to apply the edits.
     */ gdbVersion ? : string ; /**
     * Optional parameter specifying whether the response will report the time features were added.
     */ returnEditMoment ? : boolean ; /**
     * Optional parameter to specify if the edits should be applied only if all submitted edits succeed.
     */ rollbackOnFailure ? : boolean ; } const serviceRegex = new RegExp ( /.+(?:map|feature|image)server/i ) ; /**
 * Return the service url. If not matched, returns what was passed in
 */ export function parseServiceUrl ( url ) { const match = url . match ( serviceRegex ) ; if ( match ) { return match [ 0 ] ; } else { return stripQueryString ( url ) ; } } function stripQueryString ( url ) { const stripped = url . split ( '?' ) [ 0 ] ; return cleanUrl ( stripped ) ; }