Remove rawResponse support from REST JS packages#1326
Conversation
Introduce `rawRequest()` to replace `rawResponse`
dixonyant
left a comment
There was a problem hiding this comment.
@patrickarlt i tagged each of the changes with the comments on the previous pr #1317 feedback, although there were more changes here. This pr should be the one that covers or finishes everything related to rawResponse for v5. most raw response support has been dropped except for queryFeaturesRaw() and getItemDataRaw() for now. Others can be added later with better typed support. processOptions and typed methods are coming next.
| } | ||
| }; | ||
|
|
||
| if (options.file) { |
There was a problem hiding this comment.
Removing options.file here and deprecating the interface that uses it to resolve comment here: #1317 (comment)
they can use getItemDataRaw() and parse the response.blob() themselves
| } | ||
| } | ||
|
|
||
| if (typeof address !== "string" && address.rawResponse) { |
| ); | ||
| } | ||
|
|
||
| if (options.rawResponse) { |
| /** | ||
| * Response format. Defaults to "json" | ||
| * NOTE: for "pbf" you must use the method `rawRequest()` | ||
| * NOTE: for "f=pbf" you must use the method `queryFeaturesRaw()` |
| ...requestOptions.fetchOptions | ||
| } | ||
| }; | ||
| if (options.rawResponse) { |
| queryOptions.params?.f === "pbf-as-arcgis" | ||
| ) { | ||
| return queryPbfAsGeoJSONOrArcGIS(requestOptions.url, queryOptions); | ||
| } else if (queryOptions.params?.f === "pbf") { |
There was a problem hiding this comment.
removing pbf from queryFeatures() to address #1317 (comment) and users can use queryFeaturesRaw() in the case they want to use a native response or native response with pbf
| objectIds?: number[]; | ||
| } | ||
|
|
||
| export interface IQueryFeaturesRawOptions |
There was a problem hiding this comment.
pulling out this options construction code shared between queryFeatures and queryFeaturesRaw
| } | ||
| ); | ||
|
|
||
| queryOptions.fetchOptions = { |
There was a problem hiding this comment.
do we want to allow users to override or should this always be "GET" for query? @patrickarlt
| } | ||
| ); | ||
|
|
||
| options.fetchOptions = { |
There was a problem hiding this comment.
do we want to allow users to override or should this always be "GET" for queryRelated? @patrickarlt
| expect(rawBuffer.byteLength).toBe(443); | ||
| }); | ||
|
|
||
| test("queryFeatures with f=pbf should warn, but will query json and return typed json for f=pbf queries", async () => { |
There was a problem hiding this comment.
test case showing if users try and force a pbf request to request they will be warned as unsupported and will still get json
| } | ||
| }; | ||
|
|
||
| options.params.f = null; |
There was a problem hiding this comment.
leaving this here for functional equivalence. What about f=zip? https://developers.arcgis.com/rest/users-groups-and-items/item-data/
Minimum allowed line rate is |

Description
This PR propagates the recent
rawResponsedeprecation changes across the library.rawResponseis no longer supported inrequestOptionsinrequest()and users must now userawRequest()to get native responses.This PR also updates the library to use the new IRequestOptions shape
fetchOptionsobject instead of legacy properties.This change will allow for consistent and guaranteed return types across any wrapper functions that call
request. This change also guarantees that allrequestresponses return asjson. This PR drops support forrequestOptions.rawResponseacross REST JS.Users will be able to get native responses through raw versions of wrapper methods like
getItemDataRaw()orqueryFeaturesRaw()and parse the response themselves. Format params that are notjson(likef=pbfor binary return types likeblobortext) will need to use methods that wraprawRequest()and support those format types separately.Breaking Changes
Query
getFeature()no longer supports raw response.queryFeatures()can no longer be used to query features aspbfwithf=pbf.Geocode
bulkGeocode()no longer supports raw response.geocode()no longer supports raw response.Get
getItemData()no longer supports raw, file, or binary responses, usegetItemDataRaw()instead.IItemDataOptionssince we don't support thefileproperty ingetItemData()anymore. UsegetItemDataRaw()to get the native response instead.getItemInfo()no longer supportsrawResponseas an option and usesrawRequest()as default behavior.getItemResource()no longer supportsrawResponseas an option and usesrawRequest()as default behavior.Added Behavior
Query
queryFeaturesRaw()to allow users to query features as a raw response and use format params includingf=pbfor non-json types.Get
getItemDataRaw()to allow users to handle non-json data manually.