@esri/arcgis-rest-request
Advanced tools
Comparing version 1.19.0 to 1.19.1
@@ -89,4 +89,8 @@ /* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc. | ||
} | ||
/* updateResources currently requires FormData even when the input parameters dont warrant it. | ||
https://developers.arcgis.com/rest/users-groups-and-items/update-resources.htm | ||
see https://github.com/Esri/arcgis-rest-js/pull/500 for more info. */ | ||
var forceFormData = new RegExp("/items/.+/updateResources").test(url); | ||
if (fetchOptions.method === "POST") { | ||
fetchOptions.body = encodeFormData(params); | ||
fetchOptions.body = encodeFormData(params, forceFormData); | ||
} | ||
@@ -100,3 +104,3 @@ // Mixin headers from request options | ||
/* istanbul ignore else blob responses are difficult to make cross platform we will just have to trust the isomorphic fetch will do its job */ | ||
if (!requiresFormData(params)) { | ||
if (!requiresFormData(params) && !forceFormData) { | ||
fetchOptions.headers["Content-Type"] = | ||
@@ -103,0 +107,0 @@ "application/x-www-form-urlencoded"; |
@@ -7,2 +7,2 @@ /** | ||
*/ | ||
export declare function encodeFormData(params: any): FormData | string; | ||
export declare function encodeFormData(params: any, forceFormData?: boolean): FormData | string; |
@@ -11,4 +11,5 @@ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
*/ | ||
export function encodeFormData(params) { | ||
var useFormData = requiresFormData(params); | ||
export function encodeFormData(params, forceFormData) { | ||
// see https://github.com/Esri/arcgis-rest-js/issues/499 for more info. | ||
var useFormData = requiresFormData(params) || forceFormData; | ||
var newParams = processParams(params); | ||
@@ -15,0 +16,0 @@ if (useFormData) { |
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
* Apache-2.0 */ | ||
/** | ||
@@ -4,0 +4,0 @@ * Checks parameters to see if we should use FormData to send the request |
@@ -91,4 +91,8 @@ "use strict"; | ||
} | ||
/* updateResources currently requires FormData even when the input parameters dont warrant it. | ||
https://developers.arcgis.com/rest/users-groups-and-items/update-resources.htm | ||
see https://github.com/Esri/arcgis-rest-js/pull/500 for more info. */ | ||
var forceFormData = new RegExp("/items/.+/updateResources").test(url); | ||
if (fetchOptions.method === "POST") { | ||
fetchOptions.body = encode_form_data_1.encodeFormData(params); | ||
fetchOptions.body = encode_form_data_1.encodeFormData(params, forceFormData); | ||
} | ||
@@ -102,3 +106,3 @@ // Mixin headers from request options | ||
/* istanbul ignore else blob responses are difficult to make cross platform we will just have to trust the isomorphic fetch will do its job */ | ||
if (!process_params_1.requiresFormData(params)) { | ||
if (!process_params_1.requiresFormData(params) && !forceFormData) { | ||
fetchOptions.headers["Content-Type"] = | ||
@@ -105,0 +109,0 @@ "application/x-www-form-urlencoded"; |
@@ -13,4 +13,5 @@ "use strict"; | ||
*/ | ||
function encodeFormData(params) { | ||
var useFormData = process_params_1.requiresFormData(params); | ||
function encodeFormData(params, forceFormData) { | ||
// see https://github.com/Esri/arcgis-rest-js/issues/499 for more info. | ||
var useFormData = process_params_1.requiresFormData(params) || forceFormData; | ||
var newParams = process_params_1.processParams(params); | ||
@@ -17,0 +18,0 @@ if (useFormData) { |
"use strict"; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
* Apache-2.0 */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -5,0 +5,0 @@ /** |
/* @preserve | ||
* @esri/arcgis-rest-request - v1.19.0 - Apache-2.0 | ||
* @esri/arcgis-rest-request - v1.19.1 - Apache-2.0 | ||
* Copyright (c) 2017-2019 Esri, Inc. | ||
* Thu Mar 28 2019 12:28:57 GMT-0700 (Pacific Daylight Time) | ||
* Tue Apr 02 2019 09:57:43 GMT-0700 (Pacific Daylight Time) | ||
*/ | ||
@@ -53,3 +53,3 @@ (function (global, factory) { | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
* Apache-2.0 */ | ||
/** | ||
@@ -170,4 +170,5 @@ * Checks parameters to see if we should use FormData to send the request | ||
*/ | ||
function encodeFormData(params) { | ||
var useFormData = requiresFormData(params); | ||
function encodeFormData(params, forceFormData) { | ||
// see https://github.com/Esri/arcgis-rest-js/issues/499 for more info. | ||
var useFormData = requiresFormData(params) || forceFormData; | ||
var newParams = processParams(params); | ||
@@ -313,4 +314,8 @@ if (useFormData) { | ||
} | ||
/* updateResources currently requires FormData even when the input parameters dont warrant it. | ||
https://developers.arcgis.com/rest/users-groups-and-items/update-resources.htm | ||
see https://github.com/Esri/arcgis-rest-js/pull/500 for more info. */ | ||
var forceFormData = new RegExp("/items/.+/updateResources").test(url); | ||
if (fetchOptions.method === "POST") { | ||
fetchOptions.body = encodeFormData(params); | ||
fetchOptions.body = encodeFormData(params, forceFormData); | ||
} | ||
@@ -324,3 +329,3 @@ // Mixin headers from request options | ||
/* istanbul ignore else blob responses are difficult to make cross platform we will just have to trust the isomorphic fetch will do its job */ | ||
if (!requiresFormData(params)) { | ||
if (!requiresFormData(params) && !forceFormData) { | ||
fetchOptions.headers["Content-Type"] = | ||
@@ -327,0 +332,0 @@ "application/x-www-form-urlencoded"; |
/* @preserve | ||
* @esri/arcgis-rest-request - v1.19.0 - Apache-2.0 | ||
* @esri/arcgis-rest-request - v1.19.1 - Apache-2.0 | ||
* Copyright (c) 2017-2019 Esri, Inc. | ||
* Thu Mar 28 2019 12:29:00 GMT-0700 (Pacific Daylight Time) | ||
* Tue Apr 02 2019 09:57:46 GMT-0700 (Pacific Daylight Time) | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var t=function(e,r){return(t=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,r)};var r=function(){return(r=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function o(e){return Object.keys(e).some(function(t){var r=e[t];if(!r)return!1;switch(r.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function n(e){var t={};return Object.keys(e).forEach(function(r){var o=e[r];if(o||0===o||"boolean"==typeof o||"string"==typeof o){var n;switch(o.constructor.name){case"Array":n=o[0]&&o[0].constructor&&"Object"===o[0].constructor.name?JSON.stringify(o):o.join(",");break;case"Object":n=JSON.stringify(o);break;case"Date":n=o.valueOf();break;case"Function":n=null;break;case"Boolean":n=o+"";break;default:n=o}(n||0===n||"string"==typeof n)&&(t[r]=n)}}),t}function a(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function s(e){var t=n(e);return Object.keys(t).map(function(e){return a(e,t[e])}).join("&")}function i(e){var t=o(e),r=n(e);if(t){var a=new FormData;return Object.keys(r).forEach(function(e){if("undefined"!=typeof Blob&&r[e]instanceof Blob){var t=r.fileName||r[e].name||e;a.append(e,r[e],t)}else a.append(e,r[e])}),a}return s(e)}var c=function(){return function(e,t,r,o,n){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=o,this.options=n}}();c.prototype=Object.create(Error.prototype),c.prototype.constructor=c;var u="@esri/arcgis-rest-js";function f(e,t){void 0===t&&(t={params:{f:"json"}});var n=r({httpMethod:"POST"},t),a=[],f=[];if(n.fetch||"undefined"==typeof fetch?(a.push("`fetch`"),f.push("`isomorphic-fetch`")):n.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(a.push("`Promise`"),f.push("`es6-promise`")),"undefined"==typeof FormData&&(a.push("`FormData`"),f.push("`isomorphic-form-data`")),!n.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires global variables for `fetch`, `Promise` and `FormData` to be present in the global scope. You are missing "+a.join(", ")+". We recommend installing the "+f.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var h=n.httpMethod,p=n.authentication,d=n.rawResponse,m=r({f:"json"},t.params),O={method:h,credentials:"same-origin"};return(p?p.getToken(e,{fetch:n.fetch}):Promise.resolve("")).then(function(a){if(a.length&&(m.token=a),"GET"===O.method){var c=""===s(m)?e:e+"?"+s(m);n.maxUrlLength&&c.length>n.maxUrlLength?O.method="POST":e=c}return"POST"===O.method&&(O.body=i(m)),O.headers=r({},t.headers),"undefined"!=typeof window||O.headers.referer||(O.headers.referer=u),o(m)||(O.headers["Content-Type"]="application/x-www-form-urlencoded"),n.fetch(e,O)}).then(function(t){if(!t.ok){var r=t.status,o=t.statusText;throw new c(o,"HTTP "+r,t,e,n)}if(d)return t;switch(m.f){case"json":case"geojson":return t.json();case"html":case"text":return t.text();default:return t.blob()}}).then(function(t){return"json"!==m.f&&"geojson"!==m.f||d?t:l(t,e,m,n)})}var h,p=function(e){function o(t,r,o,n,a){void 0===t&&(t="AUTHENTICATION_ERROR"),void 0===r&&(r="AUTHENTICATION_ERROR_CODE");var s=e.call(this,t,r,o,n,a)||this;return s.name="ArcGISAuthError",s.message="AUTHENTICATION_ERROR_CODE"===r?t:r+": "+t,s}return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}(o,e),o.prototype.retry=function(e,t){var o=this;void 0===t&&(t=3);var n=0,a=function(s,i){e(o.url,o.options).then(function(e){var t=r({},o.options,{authentication:e});return n+=1,f(o.url,t)}).then(function(e){s(e)}).catch(function(e){"ArcGISAuthError"===e.name&&n<t?a(s,i):"ArcGISAuthError"===e.name&&n>=t?i(o):i(e)})};return new Promise(function(e,t){a(e,t)})},o}(c);function l(e,t,r,o){if(e.code>=400){var n=e.message,a=e.code;throw new c(n,a,e,t,o)}if(e.error){var s=e.error,i=(n=s.message,a=s.code,s.messageCode),u=i||a||"UNKNOWN_ERROR_CODE";if(498===a||499===a||"GWM_0003"===i||400===a&&"Unable to generate token."===n)throw new p(n,u,e,t,o);throw new c(n,u,e,t,o)}if("failed"===e.status||"failure"===e.status){n=void 0,a="UNKNOWN_ERROR_CODE";try{n=JSON.parse(e.statusMessage).message,a=JSON.parse(e.statusMessage).code}catch(t){n=e.statusMessage||e.message}throw new c(n,a,e,t,o)}return e}function d(e){return"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e}function m(e){return void 0===e&&(e={}),e.portal?d(e.portal):e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function O(e,t){var o=e||"self";return f(m(t)+"/portals/"+o,r({httpMethod:"GET"},t))}(h=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",h.ArcGISAuthError="ArcGISAuthError",e.NODEJS_DEFAULT_REFERER_HEADER=u,e.request=f,e.ArcGISAuthError=p,e.checkForErrors=l,e.encodeFormData=i,e.encodeParam=a,e.encodeQueryString=s,e.warn=function(e){console&&console.warn&&console.warn.apply(console,[e])},e.ArcGISRequestError=c,e.requiresFormData=o,e.processParams=n,e.getSelf=function(e){return O(null,e)},e.getPortal=O,e.getPortalUrl=m,e.appendCustomParams=function(e,t){Object.keys(e).forEach(function(r){"url"!==r&&"params"!==r&&"authentication"!==r&&"httpMethod"!==r&&"fetch"!==r&&"portal"!==r&&"maxUrlLength"!==r&&"headers"!==r&&"endpoint"!==r&&"decodeValues"!==r&&(t.params[r]=e[r])})},e.cleanUrl=d,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.arcgisRest=e.arcgisRest||{})}(this,function(e){"use strict";var t=function(e,r){return(t=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,r)};var r=function(){return(r=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function o(e){return Object.keys(e).some(function(t){var r=e[t];if(!r)return!1;switch(r.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function n(e){var t={};return Object.keys(e).forEach(function(r){var o=e[r];if(o||0===o||"boolean"==typeof o||"string"==typeof o){var n;switch(o.constructor.name){case"Array":n=o[0]&&o[0].constructor&&"Object"===o[0].constructor.name?JSON.stringify(o):o.join(",");break;case"Object":n=JSON.stringify(o);break;case"Date":n=o.valueOf();break;case"Function":n=null;break;case"Boolean":n=o+"";break;default:n=o}(n||0===n||"string"==typeof n)&&(t[r]=n)}}),t}function a(e,t){return encodeURIComponent(e)+"="+encodeURIComponent(t)}function s(e){var t=n(e);return Object.keys(t).map(function(e){return a(e,t[e])}).join("&")}function i(e,t){var r=o(e)||t,a=n(e);if(r){var i=new FormData;return Object.keys(a).forEach(function(e){if("undefined"!=typeof Blob&&a[e]instanceof Blob){var t=a.fileName||a[e].name||e;i.append(e,a[e],t)}else i.append(e,a[e])}),i}return s(e)}var c=function(){return function(e,t,r,o,n){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=o,this.options=n}}();c.prototype=Object.create(Error.prototype),c.prototype.constructor=c;var u="@esri/arcgis-rest-js";function f(e,t){void 0===t&&(t={params:{f:"json"}});var n=r({httpMethod:"POST"},t),a=[],f=[];if(n.fetch||"undefined"==typeof fetch?(a.push("`fetch`"),f.push("`isomorphic-fetch`")):n.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(a.push("`Promise`"),f.push("`es6-promise`")),"undefined"==typeof FormData&&(a.push("`FormData`"),f.push("`isomorphic-form-data`")),!n.fetch||"undefined"==typeof Promise||"undefined"==typeof FormData)throw new Error("`arcgis-rest-request` requires global variables for `fetch`, `Promise` and `FormData` to be present in the global scope. You are missing "+a.join(", ")+". We recommend installing the "+f.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var h=n.httpMethod,p=n.authentication,l=n.rawResponse,m=r({f:"json"},t.params),O={method:h,credentials:"same-origin"};return(p?p.getToken(e,{fetch:n.fetch}):Promise.resolve("")).then(function(a){if(a.length&&(m.token=a),"GET"===O.method){var c=""===s(m)?e:e+"?"+s(m);n.maxUrlLength&&c.length>n.maxUrlLength?O.method="POST":e=c}var f=new RegExp("/items/.+/updateResources").test(e);return"POST"===O.method&&(O.body=i(m,f)),O.headers=r({},t.headers),"undefined"!=typeof window||O.headers.referer||(O.headers.referer=u),o(m)||f||(O.headers["Content-Type"]="application/x-www-form-urlencoded"),n.fetch(e,O)}).then(function(t){if(!t.ok){var r=t.status,o=t.statusText;throw new c(o,"HTTP "+r,t,e,n)}if(l)return t;switch(m.f){case"json":case"geojson":return t.json();case"html":case"text":return t.text();default:return t.blob()}}).then(function(t){return"json"!==m.f&&"geojson"!==m.f||l?t:d(t,e,m,n)})}var h,p=function(e){function o(t,r,o,n,a){void 0===t&&(t="AUTHENTICATION_ERROR"),void 0===r&&(r="AUTHENTICATION_ERROR_CODE");var s=e.call(this,t,r,o,n,a)||this;return s.name="ArcGISAuthError",s.message="AUTHENTICATION_ERROR_CODE"===r?t:r+": "+t,s}return function(e,r){function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}(o,e),o.prototype.retry=function(e,t){var o=this;void 0===t&&(t=3);var n=0,a=function(s,i){e(o.url,o.options).then(function(e){var t=r({},o.options,{authentication:e});return n+=1,f(o.url,t)}).then(function(e){s(e)}).catch(function(e){"ArcGISAuthError"===e.name&&n<t?a(s,i):"ArcGISAuthError"===e.name&&n>=t?i(o):i(e)})};return new Promise(function(e,t){a(e,t)})},o}(c);function d(e,t,r,o){if(e.code>=400){var n=e.message,a=e.code;throw new c(n,a,e,t,o)}if(e.error){var s=e.error,i=(n=s.message,a=s.code,s.messageCode),u=i||a||"UNKNOWN_ERROR_CODE";if(498===a||499===a||"GWM_0003"===i||400===a&&"Unable to generate token."===n)throw new p(n,u,e,t,o);throw new c(n,u,e,t,o)}if("failed"===e.status||"failure"===e.status){n=void 0,a="UNKNOWN_ERROR_CODE";try{n=JSON.parse(e.statusMessage).message,a=JSON.parse(e.statusMessage).code}catch(t){n=e.statusMessage||e.message}throw new c(n,a,e,t,o)}return e}function l(e){return"/"===(e=e.trim())[e.length-1]&&(e=e.slice(0,-1)),e}function m(e){return void 0===e&&(e={}),e.portal?l(e.portal):e.authentication?e.authentication.portal:"https://www.arcgis.com/sharing/rest"}function O(e,t){var o=e||"self";return f(m(t)+"/portals/"+o,r({httpMethod:"GET"},t))}(h=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",h.ArcGISAuthError="ArcGISAuthError",e.NODEJS_DEFAULT_REFERER_HEADER=u,e.request=f,e.ArcGISAuthError=p,e.checkForErrors=d,e.encodeFormData=i,e.encodeParam=a,e.encodeQueryString=s,e.warn=function(e){console&&console.warn&&console.warn.apply(console,[e])},e.ArcGISRequestError=c,e.requiresFormData=o,e.processParams=n,e.getSelf=function(e){return O(null,e)},e.getPortal=O,e.getPortalUrl=m,e.appendCustomParams=function(e,t){Object.keys(e).forEach(function(r){"url"!==r&&"params"!==r&&"authentication"!==r&&"httpMethod"!==r&&"fetch"!==r&&"portal"!==r&&"maxUrlLength"!==r&&"headers"!==r&&"endpoint"!==r&&"decodeValues"!==r&&(t.params[r]=e[r])})},e.cleanUrl=l,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=request.umd.min.js.map |
{ | ||
"name": "@esri/arcgis-rest-request", | ||
"version": "1.19.0", | ||
"version": "1.19.1", | ||
"description": "Common methods and utilities for @esri/arcgis-rest-js packages.", | ||
@@ -5,0 +5,0 @@ "main": "dist/node/index.js", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191709
2067