@esri/arcgis-rest-request
Advanced tools
Comparing version 3.0.0-beta.0 to 3.0.0
/* @preserve | ||
* @esri/arcgis-rest-request - v3.0.0-beta.0 - Apache-2.0 | ||
* @esri/arcgis-rest-request - v3.0.0 - Apache-2.0 | ||
* Copyright (c) 2017-2021 Esri, Inc. | ||
* Fri Jan 15 2021 13:14:31 GMT-0800 (Pacific Standard Time) | ||
* Mon Jan 25 2021 15:21:44 GMT-0700 (Mountain Standard Time) | ||
*/ | ||
@@ -6,0 +6,0 @@ (function (global, factory) { |
/* @preserve | ||
* @esri/arcgis-rest-request - v3.0.0-beta.0 - Apache-2.0 | ||
* @esri/arcgis-rest-request - v3.0.0 - Apache-2.0 | ||
* Copyright (c) 2017-2021 Esri, Inc. | ||
* Fri Jan 15 2021 13:14:32 GMT-0800 (Pacific Standard Time) | ||
* Mon Jan 25 2021 15:21:47 GMT-0700 (Mountain Standard Time) | ||
*/ | ||
!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 c=function(){return(c=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 u(t){return Object.keys(t).some(function(e){e=t[e];if(!e)return!1;switch(e&&e.toParam&&(e=e.toParam()),e.constructor.name){case"Array":case"Object":case"Date":case"Function":case"Boolean":case"String":case"Number":return!1;default:return!0}})}function o(o){var a={};return Object.keys(o).forEach(function(e){var t=o[e];if(t&&t.toParam&&(t=t.toParam()),t||0===t||"boolean"==typeof t||"string"==typeof t){switch(t.constructor.name){case"Array":var r=null===(r=null===(r=t[0])||void 0===r?void 0:r.constructor)||void 0===r?void 0:r.name,n="Array"===r?t:"Object"===r?JSON.stringify(t):t.join(",");break;case"Object":n=JSON.stringify(t);break;case"Date":n=t.valueOf();break;case"Function":n=null;break;case"Boolean":n=t+"";break;default:n=t}(n||0===n||"string"==typeof n||Array.isArray(n))&&(a[e]=n)}}),a}function n(t,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(function(e){return n(t,e)}).join("&"):encodeURIComponent(t)+"="+encodeURIComponent(e)}function f(e){var t=o(e);return Object.keys(t).map(function(e){return n(e,t[e])}).join("&")}function h(e,t){var t=u(e)||t,r=o(e);if(t){var n=new FormData;return Object.keys(r).forEach(function(e){var t;"undefined"!=typeof Blob&&r[e]instanceof Blob?(t=r.fileName||r[e].name||e,n.append(e,r[e],t)):n.append(e,r[e])}),n}return f(e)}var p=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 a(e){console&&console.warn&&console.warn.apply(console,[e])}p.prototype=Object.create(Error.prototype),p.prototype.constructor=p;var d="@esri/arcgis-rest-js",l={httpMethod:"POST",params:{f:"json"}};var s,t,i,m,y=(r(t=g,i=s=p),t.prototype=null===i?Object.create(i):(O.prototype=i.prototype,new O),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){e=c(c({},o.options),{authentication:e});return a+=1,E(o.url,e)}).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 O(){this.constructor=t}function g(e,t,r,n,o){void 0===e&&(e="AUTHENTICATION_ERROR"),void 0===t&&(t="AUTHENTICATION_ERROR_CODE");o=s.call(this,e,t,r,n,o)||this;return o.name="ArcGISAuthError",o.message="AUTHENTICATION_ERROR_CODE"===t?e:t+": "+e,o}function v(t,e,r,n,o){if(400<=t.code){var a=t.message,s=t.code;throw new p(a,s,t,e,n)}if(t.error){var i=t.error,a=i.message,s=i.code,c=i.messageCode,i=c||s||"UNKNOWN_ERROR_CODE";if(498===s||499===s||"GWM_0003"===c||400===s&&"Unable to generate token."===a)throw o||new y(a,i,t,e,n);throw new p(a,i,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 p(a,s,t,e,n)}function E(n,e){void 0===e&&(e={params:{f:"json"}});var o=c(c(c({httpMethod:"POST"},l),e),{params:c(c({},l.params),e.params),headers:c(c({},l.headers),e.headers)}),t=[],e=[];if(o.fetch||"undefined"==typeof fetch?(t.push("`fetch`"),e.push("`node-fetch`")):o.fetch=fetch.bind(Function("return this")()),"undefined"==typeof Promise&&(t.push("`Promise`"),e.push("`es6-promise`")),"undefined"==typeof FormData&&(t.push("`FormData`"),e.push("`isomorphic-form-data`")),!o.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 "+e.join(", ")+" modules at the root of your application to add these to the global scope. See https://bit.ly/2KNwWaJ for more info.");var t=o.httpMethod,e=o.authentication,a=o.rawResponse,s=c({f:"json"},o.params),r=null,i={method:t,credentials:"same-origin"};return o.headers&&o.headers["X-Esri-Auth-Client-Id"]&&-1<n.indexOf("/oauth2/platformSelf")&&(i.credentials="include"),(e?e.getToken(n,{fetch:o.fetch}).catch(function(e){return e.url=n,e.options=o,r=e,Promise.resolve("")}):Promise.resolve("")).then(function(e){e.length&&(s.token=e);var t={};"GET"===i.method&&(s.token&&o.hideToken&&"undefined"==typeof window&&(t["X-Esri-Authorization"]="Bearer "+s.token,delete s.token),r=""===f(s)?n:n+"?"+f(s),o.maxUrlLength&&r.length>o.maxUrlLength||s.token&&o.hideToken?(i.method="POST",e.length&&o.hideToken&&(s.token=e,delete t["X-Esri-Authorization"])):n=r);var r=new RegExp("/items/.+/updateResources").test(n);return"POST"===i.method&&(i.body=h(s,r)),i.headers=c(c({},t),o.headers),"undefined"!=typeof window||i.headers.referer||(i.headers.referer=d),u(s)||r||(i.headers["Content-Type"]="application/x-www-form-urlencoded"),o.fetch(n,i)}).then(function(e){if(!e.ok){var t=e.status,r=e.statusText;throw new p(r,"HTTP "+t,e,n,o)}if(a)return e;switch(s.f){case"json":case"geojson":return e.json();case"html":case"text":return e.text();default:return e.blob()}}).then(function(e){if("json"!==s.f&&"geojson"!==s.f||a)return e;var t=v(e,n,0,o,r);return r&&(e=n.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0],o.authentication.trustedServers[e]={token:[],expires:new Date(Date.now()+864e5)},r=null),t})}function R(e){var t=e.split("="),e=t[0],t=t[1];return{key:decodeURIComponent(e),value:decodeURIComponent(t)}}(m=e.ErrorTypes||(e.ErrorTypes={})).ArcGISRequestError="ArcGISRequestError",m.ArcGISAuthError="ArcGISAuthError",e.ArcGISAuthError=y,e.ArcGISRequestError=p,e.NODEJS_DEFAULT_REFERER_HEADER=d,e.appendCustomParams=function(r,e,t){var n=c(c({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),t=r.key,r=r.value;return e[t]=r,e},{})},e.encodeFormData=h,e.encodeParam=n,e.encodeQueryString=f,e.processParams=o,e.request=E,e.requiresFormData=u,e.setDefaultRequestOptions=function(e,t){e.authentication&&!t&&a("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."),l=e},e.warn=a,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(s){var i={};return Object.keys(s).forEach(function(e){var t,r,n=s[e];if(n&&n.toParam&&(n=n.toParam()),n||0===n||"boolean"==typeof n||"string"==typeof n){switch(n.constructor.name){case"Array":var o=null===(r=null===(t=n[0])||void 0===t?void 0:t.constructor)||void 0===r?void 0:r.name,a="Array"===o?n:"Object"===o?JSON.stringify(n):n.join(",");break;case"Object":a=JSON.stringify(n);break;case"Date":a=n.valueOf();break;case"Function":a=null;break;case"Boolean":a=n+"";break;default:a=n}(a||0===a||"string"==typeof a||Array.isArray(a))&&(i[e]=a)}}),i}function n(t,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(function(e){return n(t,e)}).join("&"):encodeURIComponent(t)+"="+encodeURIComponent(e)}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=v,i=s=m),t.prototype=null===i?Object.create(i):(u.prototype=i.prototype,new u),v.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)})},v);function u(){this.constructor=t}function v(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 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,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 a.headers&&a.headers["X-Esri-Auth-Client-Id"]&&-1<o.indexOf("/oauth2/platformSelf")&&(f.credentials="include"),(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=g(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=g,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": "3.0.0-beta.0", | ||
"version": "3.0.0", | ||
"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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
236128
2547
0