Skip to content

Introduce rawRequest() to replace rawResponse#1317

Merged
dixonyant merged 46 commits into
v5.0.0from
rawrequest-replace-rawresponse
Jun 18, 2026
Merged

Introduce rawRequest() to replace rawResponse#1317
dixonyant merged 46 commits into
v5.0.0from
rawrequest-replace-rawresponse

Conversation

@dixonyant

@dixonyant dixonyant commented May 15, 2026

Copy link
Copy Markdown
Contributor

This PR introduces rawRequest() to replace rawResponse: true in rest-request. It also implements the new IRequestOptions interface across request and request tests.
It outright removes support for rawResponse and maxUrlLength while retaining backwards-compatibility for legacy IRequestOptions.

Users will have to update their code to use requestFlags.ignoreMaxUrlLength and manually request a raw response using rawRequest() and handle the response on their own.

Raw Request:
- to be used to request a response as html, text, pbf, or BLOB.

IRequestOptions:
- moved http related options to requestOption.fetchOptions
- moved boolean flags to requestOptions.requestFlags
- refactored maxUrlLength case to a new workflow that uses requestFlags.ignoreMaxUrlLength when users want to force a GET request with a very long url length (due to long query params or other large stringified properties appended to url)
- removed requestfrom IRequestOptions as it was an artifact from jasmine era testing days

Added normalizeDeprecatedRequestOptions() as a way to support backwards compatibility for ILegacyRequestOptions (except for rawResponse and maxUrlLength which we are fully removing from request in this pr).

@dixonyant dixonyant marked this pull request as draft May 15, 2026 18:18
@dixonyant dixonyant changed the title Rawrequest replace rawresponse RawRequest() to replace rawResponse May 15, 2026
@dixonyant dixonyant changed the title RawRequest() to replace rawResponse Introduce rawRequest() to replace rawResponse May 15, 2026
@dixonyant dixonyant changed the base branch from main to v5.0.0 May 15, 2026 18:20
@dixonyant dixonyant marked this pull request as ready for review June 5, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new rawRequest() API in @esri/arcgis-rest-request to replace the legacy rawResponse behavior, while also migrating legacy top-level request options (e.g. httpMethod, headers, credentials, signal, hideToken, suppressWarnings) into the newer fetchOptions and requestFlags shapes.

Changes:

  • Added rawRequest() and refactored request()/internalRequest() to centralize option normalization and deprecation warnings.
  • Added normalizeDeprecatedRequestOptions() + tests, and updated deprecated-option warning behavior (including a suppressWarnings argument).
  • Updated multiple packages/tests to use fetchOptions.method and to route raw-response use cases through rawRequest() (including Feature Service f=pbf).

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/arcgis-rest-request/test/utils/normalize-deprecated-request-options.test.ts Adds unit tests for legacy option normalization into requestFlags/fetchOptions.
packages/arcgis-rest-request/test/utils/ArcGISTokenRequestError.test.ts Updates expectations to assert fetchOptions.method rather than legacy httpMethod.
packages/arcgis-rest-request/test/utils/ArcGISRequestError.test.ts Updates expectations to assert fetchOptions.method rather than legacy httpMethod.
packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts Updates tests to pass fetchOptions.method instead of httpMethod.
packages/arcgis-rest-request/test/request.test.ts Updates request behavior tests; adds rawRequest() coverage; switches legacy options to new shapes.
packages/arcgis-rest-request/test/deprecated-request-options-warning.test.ts Updates warning assertions and adds suppressWarnings argument coverage.
packages/arcgis-rest-request/src/utils/warn-deprecated-request-options.ts Adds “unsupported” warnings for maxUrlLength/rawResponse and supports suppression.
packages/arcgis-rest-request/src/utils/normalize-deprecated-request-options.ts New helper to map legacy top-level options into requestFlags/fetchOptions.
packages/arcgis-rest-request/src/utils/IRequestOptions.ts Removes deprecated request override type and related internal type alias.
packages/arcgis-rest-request/src/utils/append-custom-params.ts Removes legacy request from the non-param key list.
packages/arcgis-rest-request/src/request.ts Core refactor: normalization, rawRequest(), revised fetch flow, and updated token handling.
packages/arcgis-rest-request/src/fetch-token.ts Removes now-unnecessary rawResponse=false forcing; renames response type.
packages/arcgis-rest-request/src/AuthenticationManagerBase.ts Removes rawResponse note/override; relies on new request behavior.
packages/arcgis-rest-request/src/ArcGISIdentityManager.ts Removes rawResponse note/override; relies on new request behavior.
packages/arcgis-rest-portal/src/sharing/is-item-shared-with-group.ts Updates docs removing the outdated rawResponse limitation note.
packages/arcgis-rest-portal/src/items/get.ts Switches file/blob paths to rawRequest() and removes rawResponse toggling via request().
packages/arcgis-rest-geocoding/src/geocode.ts Routes rawResponse behavior through rawRequest().
packages/arcgis-rest-geocoding/src/bulk.ts Routes rawResponse behavior through rawRequest().
packages/arcgis-rest-feature-service/test/query.test.ts Adds test ensuring f=pbf returns a raw Response.
packages/arcgis-rest-feature-service/test/query.test.live.ts Removes rawResponse: true from live PBF tests (now implied via behavior).
packages/arcgis-rest-feature-service/test/addToServiceDefinition.test.ts Updates expectations from httpMethod to fetchOptions.method.
packages/arcgis-rest-feature-service/src/query.ts Uses rawRequest() for PBF and updates docs about PBF usage.
packages/arcgis-rest-feature-service/src/createFeatureService.ts Removes outdated rawResponse limitation note and override.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/arcgis-rest-request/src/request.ts Outdated
Comment thread packages/arcgis-rest-request/src/request.ts Outdated
Comment thread packages/arcgis-rest-request/src/request.ts
Comment thread packages/arcgis-rest-request/src/request.ts
Comment thread packages/arcgis-rest-request/src/request.ts Outdated
Comment thread packages/arcgis-rest-request/src/request.ts Outdated
Comment thread packages/arcgis-rest-request/src/request.ts Outdated
Comment on lines +30 to +39
const fetchOptions = {
...(httpMethod !== undefined ? { method: httpMethod } : {}),
...(credentials !== undefined ? { credentials } : {}),
...(signal !== undefined ? { signal } : {}),
...requestOptions.fetchOptions,
headers: {
...(headers as any),
...(requestOptions.fetchOptions?.headers as any)
}
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created helper methods to cover this in a more comprehensive way since it is needed in multiple places. We can reevaluate once all legacy shape options and normalization functions are removed if we need to keep it around still. (there should be one or two direct calls to merge headers in request standalone)

Comment thread packages/arcgis-rest-feature-service/src/query.ts
Comment thread packages/arcgis-rest-request/src/request.ts
@dixonyant dixonyant self-assigned this Jun 5, 2026

@patrickarlt patrickarlt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dixonyant this LGTM but I would take the advice of the Copilot bot and handle the header object in other formats then just a plain object.

Comment thread packages/arcgis-rest-feature-service/src/query.ts Outdated
Comment thread packages/arcgis-rest-feature-service/src/query.ts
Comment thread packages/arcgis-rest-geocoding/src/bulk.ts
Comment thread packages/arcgis-rest-geocoding/src/geocode.ts
Comment thread packages/arcgis-rest-portal/src/items/get.ts
Comment thread packages/arcgis-rest-request/src/utils/warn-deprecated-request-options.ts Outdated
Comment thread packages/arcgis-rest-request/src/request.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 27 changed files in this pull request and generated 9 comments.

Comment thread packages/arcgis-rest-request/src/request.ts Outdated
Comment on lines 88 to 92
const options = {
httpMethod: "GET",
authentication: this,
...requestOptions,
rawResponse: false
...requestOptions
} as IRequestOptions;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These and all the below instances are all part of this larger wip change that is going into the v5.0.0 branch. The focus of this PR is to handle options at the request/rawRequest level. there is a follow up story that covers all the package-level and repo-uses of LegacyRequestOptions. These will all be done by the time v5.0.0 -> main merges into main.

Comment thread packages/arcgis-rest-request/src/ArcGISIdentityManager.ts
Comment thread packages/arcgis-rest-feature-service/src/query.ts
Comment on lines +364 to +368
} else if (queryOptions.params?.f === "pbf") {
return rawRequest(
`${cleanUrl(requestOptions.url)}/query`,
queryOptions
) as Promise<any>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dixonyant this also seems off. The goal is that all methods should return JSON by default and this breaks the pattern by returning Promise<any> if f=pbf so if someone really wants f=pbf they will neet to use a new rawQueryFeatures() that will need to be added at v5

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is off. This in-between behavior shouldn't even see the light of day since the follow-up PR is going to be all the removing of rawRequest calls from all functions that should be only returning JSON. They either get a replacement rawFunction call after v5 or with v5. Just the purpose of this PR is to replace the guts of all calls to request({rawResponse}) with rawRequest for immediate backwards compatibility internally, and then I was going to remove fully and assert types in the next follow-up PR.

Comment thread packages/arcgis-rest-geocoding/src/geocode.ts
Comment thread packages/arcgis-rest-geocoding/src/bulk.ts
Comment thread packages/arcgis-rest-feature-service/src/query.ts
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
arcgis-rest-basemap-sessions.src 100% 100% 0
arcgis-rest-basemap-sessions.src.utils 100% 100% 0
arcgis-rest-demographics.src 100% 100% 0
arcgis-rest-developer-credentials.src 100% 100% 0
arcgis-rest-developer-credentials.src.shared 100% 100% 0
arcgis-rest-elevation.src 100% 100% 0
arcgis-rest-feature-service.src 100% 100% 0
arcgis-rest-feature-service.src.pbf-parser 100% 100% 0
arcgis-rest-geocoding.src 100% 100% 0
arcgis-rest-places.src 100% 100% 0
arcgis-rest-portal.src.groups 100% 100% 0
arcgis-rest-portal.src.items 100% 100% 0
arcgis-rest-portal.src.orgs 100% 100% 0
arcgis-rest-portal.src.services 100% 100% 0
arcgis-rest-portal.src.sharing 100% 100% 0
arcgis-rest-portal.src.users 100% 100% 0
arcgis-rest-portal.src.util 100% 100% 0
arcgis-rest-request.src 100% 100% 0
arcgis-rest-request.src.types 100% 100% 0
arcgis-rest-request.src.utils 100% 100% 0
arcgis-rest-routing.src 100% 100% 0
Summary 100% (2482 / 2482) 100% (1342 / 1342) 0

Minimum allowed line rate is 100%

@patrickarlt patrickarlt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dixonyant There still seem to be a few cases where methods can return non JSON objects. These could get resolved now or in a future issue if you want to make a follow up issue.

Comment thread packages/arcgis-rest-feature-service/src/query.ts
Comment on lines +364 to +368
} else if (queryOptions.params?.f === "pbf") {
return rawRequest(
`${cleanUrl(requestOptions.url)}/query`,
queryOptions
) as Promise<any>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dixonyant this also seems off. The goal is that all methods should return JSON by default and this breaks the pattern by returning Promise<any> if f=pbf so if someone really wants f=pbf they will neet to use a new rawQueryFeatures() that will need to be added at v5

@dixonyant dixonyant merged commit 99b4b39 into v5.0.0 Jun 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants