Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@esri/arcgis-rest-request

Package Overview
Dependencies
Maintainers
8
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esri/arcgis-rest-request - npm Package Compare versions

Comparing version 2.15.0 to 2.16.0

12

dist/esm/index.js

@@ -11,4 +11,16 @@ /* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.

export * from "./utils/ErrorTypes";
export * from "./utils/GrantTypes";
export * from "./utils/HTTPMethods";
export * from "./utils/IAuthenticationManager";
export * from "./utils/IFetchTokenParams";
export * from "./utils/IGenerateTokenParams";
export * from "./utils/IParams";
export * from "./utils/IParamBuilder";
export * from "./utils/IParamsBuilder";
export * from "./utils/IRequestOptions";
export * from "./utils/ITokenRequestOptions";
export * from "./utils/process-params";
export * from "./utils/ResponseFormats";
export * from "./utils/retryAuthError";
export * from "./utils/warn";
//# sourceMappingURL=index.js.map

16

dist/esm/request.js
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */
import * as tslib_1 from "tslib";
import { __assign, __extends } from "tslib";
import { encodeFormData } from "./utils/encode-form-data";

@@ -38,3 +38,3 @@ import { encodeQueryString } from "./utils/encode-query-string";

var ArcGISAuthError = /** @class */ (function (_super) {
tslib_1.__extends(ArcGISAuthError, _super);
__extends(ArcGISAuthError, _super);
/**

@@ -65,3 +65,3 @@ * Create a new `ArcGISAuthError` object.

.then(function (session) {
var newOptions = tslib_1.__assign({}, _this.options, { authentication: session });
var newOptions = __assign(__assign({}, _this.options), { authentication: session });
tries = tries + 1;

@@ -163,5 +163,5 @@ return request(_this.url, newOptions);

if (requestOptions === void 0) { requestOptions = { params: { f: "json" } }; }
var options = tslib_1.__assign({ httpMethod: "POST" }, DEFAULT_ARCGIS_REQUEST_OPTIONS, requestOptions, {
params: tslib_1.__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.params, requestOptions.params),
headers: tslib_1.__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.headers, requestOptions.headers)
var options = __assign(__assign(__assign({ httpMethod: "POST" }, DEFAULT_ARCGIS_REQUEST_OPTIONS), requestOptions), {
params: __assign(__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.params), requestOptions.params),
headers: __assign(__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.headers), requestOptions.headers)
});

@@ -192,3 +192,3 @@ var missingGlobals = [];

var httpMethod = options.httpMethod, authentication = options.authentication, rawResponse = options.rawResponse;
var params = tslib_1.__assign({ f: "json" }, options.params);
var params = __assign({ f: "json" }, options.params);
var originalAuthError = null;

@@ -267,3 +267,3 @@ var fetchOptions = {

// Mixin headers from request options
fetchOptions.headers = tslib_1.__assign({}, requestHeaders, options.headers);
fetchOptions.headers = __assign(__assign({}, requestHeaders), options.headers);
/* istanbul ignore next - karma reports coverage on browser tests only */

@@ -270,0 +270,0 @@ if (typeof window === "undefined" && !fetchOptions.headers.referer) {

/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */
import * as tslib_1 from "tslib";
import { __assign } from "tslib";
/**

@@ -18,3 +18,3 @@ * Helper for methods with lots of first order request options to pass through as request parameters.

];
var options = tslib_1.__assign({ params: {} }, baseOptions, customOptions);
var options = __assign(__assign({ params: {} }, baseOptions), customOptions);
// merge all keys in customOptions into options.params

@@ -21,0 +21,0 @@ options.params = keys.reduce(function (value, key) {

@@ -7,2 +7,6 @@ /* Copyright (c) 2018 Environmental Systems Research Institute, Inc.

export function cleanUrl(url) {
// Guard so we don't try to trim something that's not a string
if (typeof url !== "string") {
return url;
}
// trim leading and trailing spaces, but not spaces inside the url

@@ -9,0 +13,0 @@ url = url.trim();

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __assign, __spreadArrays } from "tslib";
/**

@@ -36,6 +36,6 @@ * Allows you to wrap individual methods with a default set of request options. This is useful to avoid setting the same option more then once and allows for interacting and setting defaults in a functional manner.

var options = typeof args[args.length - 1] === "object"
? tslib_1.__assign({}, defaultOptions, args.pop()) : defaultOptions;
return func.apply(void 0, args.concat([options]));
? __assign(__assign({}, defaultOptions), args.pop()) : defaultOptions;
return func.apply(void 0, __spreadArrays(args, [options]));
};
}
//# sourceMappingURL=with-options.js.map

@@ -14,4 +14,16 @@ "use strict";

tslib_1.__exportStar(require("./utils/ErrorTypes"), exports);
tslib_1.__exportStar(require("./utils/GrantTypes"), exports);
tslib_1.__exportStar(require("./utils/HTTPMethods"), exports);
tslib_1.__exportStar(require("./utils/IAuthenticationManager"), exports);
tslib_1.__exportStar(require("./utils/IFetchTokenParams"), exports);
tslib_1.__exportStar(require("./utils/IGenerateTokenParams"), exports);
tslib_1.__exportStar(require("./utils/IParams"), exports);
tslib_1.__exportStar(require("./utils/IParamBuilder"), exports);
tslib_1.__exportStar(require("./utils/IParamsBuilder"), exports);
tslib_1.__exportStar(require("./utils/IRequestOptions"), exports);
tslib_1.__exportStar(require("./utils/ITokenRequestOptions"), exports);
tslib_1.__exportStar(require("./utils/process-params"), exports);
tslib_1.__exportStar(require("./utils/ResponseFormats"), exports);
tslib_1.__exportStar(require("./utils/retryAuthError"), exports);
tslib_1.__exportStar(require("./utils/warn"), exports);
//# sourceMappingURL=index.js.map

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.request = exports.checkForErrors = exports.ArcGISAuthError = exports.setDefaultRequestOptions = exports.NODEJS_DEFAULT_REFERER_HEADER = void 0;
var tslib_1 = require("tslib");

@@ -68,3 +69,3 @@ var encode_form_data_1 = require("./utils/encode-form-data");

.then(function (session) {
var newOptions = tslib_1.__assign({}, _this.options, { authentication: session });
var newOptions = tslib_1.__assign(tslib_1.__assign({}, _this.options), { authentication: session });
tries = tries + 1;

@@ -167,5 +168,5 @@ return request(_this.url, newOptions);

if (requestOptions === void 0) { requestOptions = { params: { f: "json" } }; }
var options = tslib_1.__assign({ httpMethod: "POST" }, DEFAULT_ARCGIS_REQUEST_OPTIONS, requestOptions, {
params: tslib_1.__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.params, requestOptions.params),
headers: tslib_1.__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.headers, requestOptions.headers)
var options = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ httpMethod: "POST" }, DEFAULT_ARCGIS_REQUEST_OPTIONS), requestOptions), {
params: tslib_1.__assign(tslib_1.__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.params), requestOptions.params),
headers: tslib_1.__assign(tslib_1.__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.headers), requestOptions.headers)
});

@@ -270,3 +271,3 @@ var missingGlobals = [];

// Mixin headers from request options
fetchOptions.headers = tslib_1.__assign({}, requestHeaders, options.headers);
fetchOptions.headers = tslib_1.__assign(tslib_1.__assign({}, requestHeaders), options.headers);
/* istanbul ignore next - karma reports coverage on browser tests only */

@@ -273,0 +274,0 @@ if (typeof window === "undefined" && !fetchOptions.headers.referer) {

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.appendCustomParams = void 0;
var tslib_1 = require("tslib");

@@ -21,3 +22,3 @@ /**

];
var options = tslib_1.__assign({ params: {} }, baseOptions, customOptions);
var options = tslib_1.__assign(tslib_1.__assign({ params: {} }, baseOptions), customOptions);
// merge all keys in customOptions into options.params

@@ -24,0 +25,0 @@ options.params = keys.reduce(function (value, key) {

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ArcGISRequestError = void 0;
// TypeScript 2.1 no longer allows you to extend built in types. See https://github.com/Microsoft/TypeScript/issues/12790#issuecomment-265981442

@@ -7,0 +8,0 @@ // and https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanUrl = void 0;
/**

@@ -10,2 +11,6 @@ * Helper method to ensure that user supplied urls don't include whitespace or a trailing slash.

function cleanUrl(url) {
// Guard so we don't try to trim something that's not a string
if (typeof url !== "string") {
return url;
}
// trim leading and trailing spaces, but not spaces inside the url

@@ -12,0 +17,0 @@ url = url.trim();

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeQueryString = exports.decodeParam = void 0;
function decodeParam(param) {

@@ -7,0 +8,0 @@ var _a = param.split("="), key = _a[0], value = _a[1];

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeFormData = void 0;
var process_params_1 = require("./process-params");

@@ -7,0 +8,0 @@ var encode_query_string_1 = require("./encode-query-string");

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeQueryString = exports.encodeParam = void 0;
var process_params_1 = require("./process-params");

@@ -7,0 +8,0 @@ function encodeParam(key, value) {

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorTypes = void 0;
/**

@@ -7,0 +8,0 @@ * Enum describing the different errors that might be thrown by a request.

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.processParams = exports.requiresFormData = void 0;
/**

@@ -7,0 +8,0 @@ * Checks parameters to see if we should use FormData to send the request

@@ -5,2 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.warn = void 0;
/**

@@ -7,0 +8,0 @@ * Method used internally to surface messages to developers.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withOptions = void 0;
var tslib_1 = require("tslib");

@@ -38,4 +39,4 @@ /**

var options = typeof args[args.length - 1] === "object"
? tslib_1.__assign({}, defaultOptions, args.pop()) : defaultOptions;
return func.apply(void 0, args.concat([options]));
? tslib_1.__assign(tslib_1.__assign({}, defaultOptions), args.pop()) : defaultOptions;
return func.apply(void 0, tslib_1.__spreadArrays(args, [options]));
};

@@ -42,0 +43,0 @@ }

/* @preserve
* @esri/arcgis-rest-request - v2.15.0 - Apache-2.0
* @esri/arcgis-rest-request - v2.16.0 - Apache-2.0
* Copyright (c) 2017-2020 Esri, Inc.
* Wed Aug 19 2020 11:58:20 GMT-0600 (Mountain Daylight Time)
* Mon Aug 31 2020 16:08:50 GMT-0600 (Mountain Daylight Time)
*/

@@ -9,18 +9,18 @@ (function (global, factory) {

typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.arcgisRest = global.arcgisRest || {}));
}(this, function (exports) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisRest = global.arcgisRest || {}));
}(this, (function (exports) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -32,3 +32,3 @@ /* global Reflect, Promise */

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -305,3 +305,3 @@ };

.then(function (session) {
var newOptions = __assign({}, _this.options, { authentication: session });
var newOptions = __assign(__assign({}, _this.options), { authentication: session });
tries = tries + 1;

@@ -402,5 +402,5 @@ return request(_this.url, newOptions);

if (requestOptions === void 0) { requestOptions = { params: { f: "json" } }; }
var options = __assign({ httpMethod: "POST" }, DEFAULT_ARCGIS_REQUEST_OPTIONS, requestOptions, {
params: __assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.params, requestOptions.params),
headers: __assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.headers, requestOptions.headers)
var options = __assign(__assign(__assign({ httpMethod: "POST" }, DEFAULT_ARCGIS_REQUEST_OPTIONS), requestOptions), {
params: __assign(__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.params), requestOptions.params),
headers: __assign(__assign({}, DEFAULT_ARCGIS_REQUEST_OPTIONS.headers), requestOptions.headers)
});

@@ -505,3 +505,3 @@ var missingGlobals = [];

// Mixin headers from request options
fetchOptions.headers = __assign({}, requestHeaders, options.headers);
fetchOptions.headers = __assign(__assign({}, requestHeaders), options.headers);
/* istanbul ignore next - karma reports coverage on browser tests only */

@@ -583,3 +583,3 @@ if (typeof window === "undefined" && !fetchOptions.headers.referer) {

];
var options = __assign({ params: {} }, baseOptions, customOptions);
var options = __assign(__assign({ params: {} }, baseOptions), customOptions);
// merge all keys in customOptions into options.params

@@ -607,2 +607,6 @@ options.params = keys.reduce(function (value, key) {

function cleanUrl(url) {
// Guard so we don't try to trim something that's not a string
if (typeof url !== "string") {
return url;
}
// trim leading and trailing spaces, but not spaces inside the url

@@ -666,3 +670,3 @@ url = url.trim();

}));
})));
//# sourceMappingURL=request.umd.js.map
/* @preserve
* @esri/arcgis-rest-request - v2.15.0 - Apache-2.0
* @esri/arcgis-rest-request - v2.16.0 - Apache-2.0
* Copyright (c) 2017-2020 Esri, Inc.
* Wed Aug 19 2020 11:58:22 GMT-0600 (Mountain Daylight Time)
* Mon Aug 31 2020 16:08:53 GMT-0600 (Mountain Daylight Time)
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var h=function(){return(h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function p(r){return Object.keys(r).some(function(e){var t=r[e];if(!t)return!1;switch(t&&t.toParam&&(t=t.toParam()),t.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function a(n){var o={};return Object.keys(n).forEach(function(e){var t=n[e];if(t&&t.toParam&&(t=t.toParam()),t||0===t||"boolean"==typeof t||"string"==typeof t){var r;switch(t.constructor.name){case"Array":r=t[0]&&t[0].constructor&&"Object"===t[0].constructor.name?JSON.stringify(t):t.join(",");break;case"Object":r=JSON.stringify(t);break;case"Date":r=t.valueOf();break;case"Function":r=null;break;case"Boolean":r=t+"";break;default:r=t}!r&&0!==r&&"string"!=typeof r||(o[e]=r)}}),o}function n(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function d(e){var t=a(e);return Object.keys(t).map(function(e){return n(e,t[e])}).join("&")}function l(e,t){var r=p(e)||t,n=a(e);if(r){var o=new FormData;return Object.keys(n).forEach(function(e){if("undefined"!=typeof Blob&&n[e]instanceof Blob){var t=n.fileName||n[e].name||e;o.append(e,n[e],t)}else o.append(e,n[e])}),o}return d(e)}var m=function(e,t,r,n,o){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=n,this.options=o};function o(e){console&&console.warn&&console.warn.apply(console,[e])}m.prototype=Object.create(Error.prototype),m.prototype.constructor=m;var v="@esri/arcgis-rest-js",y={httpMethod:"POST",params:{f:"json"}};var t,s,i,c,f=(r(t=O,s=i=m),void(t.prototype=null===s?Object.create(s):(u.prototype=s.prototype,new u)),O.prototype.retry=function(e,n){var o=this;void 0===n&&(n=3);var a=0,s=function(t,r){e(o.url,o.options).then(function(e){var t=h({},o.options,{authentication:e});return a+=1,E(o.url,t)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&a<n?s(t,r):"ArcGISAuthError"===e.name&&n<=a?r(o):r(e)})};return new Promise(function(e,t){s(e,t)})},O);function u(){this.constructor=t}function O(e,t,r,n,o){void 0===e&&(e="AUTHENTICATION_ERROR"),void 0===t&&(t="AUTHENTICATION_ERROR_CODE");var a=i.call(this,e,t,r,n,o)||this;return a.name="ArcGISAuthError",a.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,a}function g(t,e,r,n,o){if(400<=t.code){var a=t.message,s=t.code;throw new m(a,s,t,e,n)}if(t.error){var i=t.error,c=(a=i.message,s=i.code,i.messageCode),u=c||s||"UNKNOWN_ERROR_CODE";if(498===s||499===s||"GWM_0003"===c||400===s&&"Unable to generate token."===a)throw o||new f(a,u,t,e,n);throw new m(a,u,t,e,n)}if("failed"!==t.status&&"failure"!==t.status)return t;a=void 0,s="UNKNOWN_ERROR_CODE";try{a=JSON.parse(t.statusMessage).message,s=JSON.parse(t.statusMessage).code}catch(e){a=t.statusMessage||t.message}throw new m(a,s,t,e,n)}function E(o,e){void 0===e&&(e={params:{f:"json"}});var a=h({httpMethod:"POST"},y,e,{params:h({},y.params,e.params),headers:h({},y.headers,e.headers)}),t=[],r=[];if(a.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),r.push("`node-fetch`")):a.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),r.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),r.push("`isomorphic-form-data`")),!a.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+r.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var n=a.httpMethod,s=a.authentication,i=a.rawResponse,c=h({f:"json"},a.params),u=null,f={method:n,credentials:"same-origin"};return(s?s.getToken(o,{fetch:a.fetch}).catch(function(e){return e.url=o,e.options=a,u=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(c.token=e);var t={};if("GET"===f.method){c.token&&a.hideToken&&"undefined"==typeof window&&(t["X-Esri-Authorization"]="Bearer "+c.token,delete c.token);var r=""===d(c)?o:o+"?"+d(c);a.maxUrlLength&&r.length>a.maxUrlLength||c.token&&a.hideToken?(f.method="POST",e.length&&a.hideToken&&(c.token=e,delete t["X-Esri-Authorization"])):o=r}var n=new RegExp("/items/.+/updateResources").test(o);return"POST"===f.method&&(f.body=l(c,n)),f.headers=h({},t,a.headers),"undefined"!=typeof window||f.headers.referer||(f.headers.referer=v),p(c)||n||(f.headers["Content-Type"]="application/x-www-form-urlencoded"),a.fetch(o,f)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new m(r,"HTTP "+t,e,o,a)}if(i)return e;switch(c.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==c.f&&"geojson"!==c.f||i)return e;var t=g(e,o,0,a,u);if(u){var r=o.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0];a.authentication.trustedServers[r]={token:[],expires:new Date(Date.now()+864e5)},u=null}return t})}function R(e){var t=e.split("="),r=t[0],n=t[1];return{key:decodeURIComponent(r),value:decodeURIComponent(n)}}(c=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",c.ArcGISAuthError="ArcGISAuthError",e.ArcGISAuthError=f,e.ArcGISRequestError=m,e.NODEJS_DEFAULT_REFERER_HEADER=v,e.appendCustomParams=function(r,e,t){var n=h({params:{}},t,r);return n.params=e.reduce(function(e,t){return!r[t]&&"boolean"!=typeof r[t]||(e[t]=r[t]),e},n.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return n[t]&&(e[t]=n[t]),e},{})},e.checkForErrors=g,e.cleanUrl=function(e){return"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e},e.decodeParam=R,e.decodeQueryString=function(e){return e.replace(/^#/,"").split("&").reduce(function(e,t){var r=R(t),n=r.key,o=r.value;return e[n]=o,e},{})},e.encodeFormData=l,e.encodeParam=n,e.encodeQueryString=d,e.processParams=a,e.request=E,e.requiresFormData=p,e.setDefaultRequestOptions=function(e,t){e.authentication&&!t&&o("You should not set `authentication` as a default in a shared environment such as a web server which will process multiple users requests. You can call `setDefaultRequestOptions` with `true` as a second argument to disable this warning."),y=e},e.warn=o,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};var h=function(){return(h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function p(r){return Object.keys(r).some(function(e){var t=r[e];if(!t)return!1;switch(t&&t.toParam&&(t=t.toParam()),t.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function a(n){var o={};return Object.keys(n).forEach(function(e){var t,r=n[e];if(r&&r.toParam&&(r=r.toParam()),r||0===r||"boolean"==typeof r||"string"==typeof r){switch(r.constructor.name){case"Array":t=r[0]&&r[0].constructor&&"Object"===r[0].constructor.name?JSON.stringify(r):r.join(",");break;case"Object":t=JSON.stringify(r);break;case"Date":t=r.valueOf();break;case"Function":t=null;break;case"Boolean":t=r+"";break;default:t=r}!t&&0!==t&&"string"!=typeof t||(o[e]=t)}}),o}function n(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function d(e){var t=a(e);return Object.keys(t).map(function(e){return n(e,t[e])}).join("&")}function l(e,t){var r=p(e)||t,n=a(e);if(r){var o=new FormData;return Object.keys(n).forEach(function(e){var t;"undefined"!=typeof Blob&&n[e]instanceof Blob?(t=n.fileName||n[e].name||e,o.append(e,n[e],t)):o.append(e,n[e])}),o}return d(e)}var m=function(e,t,r,n,o){e=e||"UNKNOWN_ERROR",t=t||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message="UNKNOWN_ERROR_CODE"===t?e:t+": "+e,this.originalMessage=e,this.code=t,this.response=r,this.url=n,this.options=o};function o(e){console&&console.warn&&console.warn.apply(console,[e])}m.prototype=Object.create(Error.prototype),m.prototype.constructor=m;var y="@esri/arcgis-rest-js",O={httpMethod:"POST",params:{f:"json"}};var s,t,i,c,f=(r(t=g,i=s=m),t.prototype=null===i?Object.create(i):(u.prototype=i.prototype,new u),g.prototype.retry=function(e,n){var o=this;void 0===n&&(n=3);var a=0,s=function(t,r){e(o.url,o.options).then(function(e){var t=h(h({},o.options),{authentication:e});return a+=1,E(o.url,t)}).then(function(e){t(e)}).catch(function(e){"ArcGISAuthError"===e.name&&a<n?s(t,r):"ArcGISAuthError"===e.name&&n<=a?r(o):r(e)})};return new Promise(function(e,t){s(e,t)})},g);function u(){this.constructor=t}function g(e,t,r,n,o){void 0===e&&(e="AUTHENTICATION_ERROR"),void 0===t&&(t="AUTHENTICATION_ERROR_CODE");var a=s.call(this,e,t,r,n,o)||this;return a.name="ArcGISAuthError",a.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,a}function v(t,e,r,n,o){if(400<=t.code){var a=t.message,s=t.code;throw new m(a,s,t,e,n)}if(t.error){var i=t.error,a=i.message,s=i.code,c=i.messageCode,u=c||s||"UNKNOWN_ERROR_CODE";if(498===s||499===s||"GWM_0003"===c||400===s&&"Unable to generate token."===a)throw o||new f(a,u,t,e,n);throw new m(a,u,t,e,n)}if("failed"!==t.status&&"failure"!==t.status)return t;a=void 0,s="UNKNOWN_ERROR_CODE";try{a=JSON.parse(t.statusMessage).message,s=JSON.parse(t.statusMessage).code}catch(e){a=t.statusMessage||t.message}throw new m(a,s,t,e,n)}function E(o,e){void 0===e&&(e={params:{f:"json"}});var a=h(h(h({httpMethod:"POST"},O),e),{params:h(h({},O.params),e.params),headers:h(h({},O.headers),e.headers)}),t=[],r=[];if(a.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),r.push("`node-fetch`")):a.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),r.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),r.push("`isomorphic-form-data`")),!a.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires a `fetch` implementation and global variables for `Promise` and `FormData` to be present in the global scope. You are missing "+t.join(", ")+". We recommend installing the "+r.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var n=a.httpMethod,s=a.authentication,i=a.rawResponse,c=h({f:"json"},a.params),u=null,f={method:n,credentials:"same-origin"};return(s?s.getToken(o,{fetch:a.fetch}).catch(function(e){return e.url=o,e.options=a,u=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(c.token=e);var t,r={};"GET"===f.method&&(c.token&&a.hideToken&&"undefined"==typeof window&&(r["X-Esri-Authorization"]="Bearer "+c.token,delete c.token),t=""===d(c)?o:o+"?"+d(c),a.maxUrlLength&&t.length>a.maxUrlLength||c.token&&a.hideToken?(f.method="POST",e.length&&a.hideToken&&(c.token=e,delete r["X-Esri-Authorization"])):o=t);var n=new RegExp("/items/.+/updateResources").test(o);return"POST"===f.method&&(f.body=l(c,n)),f.headers=h(h({},r),a.headers),"undefined"!=typeof window||f.headers.referer||(f.headers.referer=y),p(c)||n||(f.headers["Content-Type"]="application/x-www-form-urlencoded"),a.fetch(o,f)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new m(r,"HTTP "+t,e,o,a)}if(i)return e;switch(c.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==c.f&&"geojson"!==c.f||i)return e;var t,r=v(e,o,0,a,u);return u&&(t=o.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0],a.authentication.trustedServers[t]={token:[],expires:new Date(Date.now()+864e5)},u=null),r})}function R(e){var t=e.split("="),r=t[0],n=t[1];return{key:decodeURIComponent(r),value:decodeURIComponent(n)}}(c=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",c.ArcGISAuthError="ArcGISAuthError",e.ArcGISAuthError=f,e.ArcGISRequestError=m,e.NODEJS_DEFAULT_REFERER_HEADER=y,e.appendCustomParams=function(r,e,t){var n=h(h({params:{}},t),r);return n.params=e.reduce(function(e,t){return!r[t]&&"boolean"!=typeof r[t]||(e[t]=r[t]),e},n.params),["params","httpMethod","rawResponse","authentication","portal","fetch","maxUrlLength","headers"].reduce(function(e,t){return n[t]&&(e[t]=n[t]),e},{})},e.checkForErrors=v,e.cleanUrl=function(e){return"string"!=typeof e||"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e},e.decodeParam=R,e.decodeQueryString=function(e){return e.replace(/^#/,"").split("&").reduce(function(e,t){var r=R(t),n=r.key,o=r.value;return e[n]=o,e},{})},e.encodeFormData=l,e.encodeParam=n,e.encodeQueryString=d,e.processParams=a,e.request=E,e.requiresFormData=p,e.setDefaultRequestOptions=function(e,t){e.authentication&&!t&&o("You should not set `authentication` as a default in a shared environment such as a web server which will process multiple users requests. You can call `setDefaultRequestOptions` with `true` as a second argument to disable this warning."),O=e},e.warn=o,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=request.umd.min.js.map
{
"name": "@esri/arcgis-rest-request",
"version": "2.15.0",
"version": "2.16.0",
"description": "Common methods and utilities for @esri/arcgis-rest-js packages.",

@@ -13,3 +13,3 @@ "main": "dist/node/index.js",

"dependencies": {
"tslib": "^1.9.3"
"tslib": "^1.10.0"
},

@@ -16,0 +16,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc