UNPKG

@opendatasoft/api-client

Version:
3 lines (2 loc) 25.8 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).opendatasoft=t.opendatasoft||{},t.opendatasoft.apiclient={}))}(this,(function(t){"use strict";function e(t,e,r){return e=p(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return y(t)}(t,n()?Reflect.construct(e,r||[],p(t).constructor):e.apply(t,r))}function n(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(n=function(){return!!t})()}function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function o(){o=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),c=new D(r||[]);return a(i,"_invoke",{value:A(t,n,c)}),i}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",d="suspendedYield",y="executing",v="completed",g={};function m(){}function b(){}function w(){}var O={};f(O,c,(function(){return this}));var E=Object.getPrototypeOf,j=E&&E(E(k([])));j&&j!==n&&r.call(j,c)&&(O=j);var S=w.prototype=m.prototype=Object.create(O);function x(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function n(o,a,i,c){var u=p(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,r){function a(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(a,a):a()}})}function A(e,n,r){var o=h;return function(a,i){if(o===y)throw new Error("Generator is already running");if(o===v){if("throw"===a)throw i;return{value:t,done:!0}}for(r.method=a,r.arg=i;;){var c=r.delegate;if(c){var u=P(c,r);if(u){if(u===g)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=y;var s=p(e,n,r);if("normal"===s.type){if(o=r.done?v:d,s.arg===g)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=v,r.method="throw",r.arg=s.arg)}}}function P(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,P(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var a=p(o,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,g;var i=a.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,g):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function D(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function k(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(typeof e+" is not iterable")}return b.prototype=w,a(S,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:b,configurable:!0}),b.displayName=f(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},x(_.prototype),f(_.prototype,u,(function(){return this})),e.AsyncIterator=_,e.async=function(t,n,r,o,a){void 0===a&&(a=Promise);var i=new _(l(t,n,r,o),a);return e.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},x(S),f(S,s,"Generator"),f(S,c,(function(){return this})),f(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=k,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return c.type="throw",c.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:k(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),g}},e}function a(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function i(t,e,n,r,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,a(r.key),r)}}function s(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,n){return(e=a(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&h(t,e)}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(n())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var a=new(t.bind.apply(t,o));return r&&h(a,r.prototype),a}(t,arguments,p(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)},d(t)}function y(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,a,i,c=[],u=!0,s=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(c.push(r.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(t,e)||m(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,e){if(t){if("string"==typeof t)return b(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(t,e):void 0}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function w(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var O={exports:{}};!function(t,e){function n(t){return"object"!=typeof t||"toString"in t?t:Object.prototype.toString.call(t).slice(8,-1)}Object.defineProperty(e,"__esModule",{value:!0});var r="object"==typeof process&&!0;function o(t,e){if(!t){if(r)throw new Error("Invariant failed");throw new Error(e())}}e.invariant=o;var a=Object.prototype.hasOwnProperty,i=Array.prototype.splice,c=Object.prototype.toString;function u(t){return c.call(t).slice(8,-1)}var s=Object.assign||function(t,e){return f(e).forEach((function(n){a.call(e,n)&&(t[n]=e[n])})),t},f="function"==typeof Object.getOwnPropertySymbols?function(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.keys(t)};function l(t){return Array.isArray(t)?s(t.constructor(t.length),t):"Map"===u(t)?new Map(t):"Set"===u(t)?new Set(t):t&&"object"==typeof t?s(Object.create(Object.getPrototypeOf(t)),t):t}var p=function(){function t(){this.commands=s({},h),this.update=this.update.bind(this),this.update.extend=this.extend=this.extend.bind(this),this.update.isEquals=function(t,e){return t===e},this.update.newContext=function(){return(new t).update}}return Object.defineProperty(t.prototype,"isEquals",{get:function(){return this.update.isEquals},set:function(t){this.update.isEquals=t},enumerable:!0,configurable:!0}),t.prototype.extend=function(t,e){this.commands[t]=e},t.prototype.update=function(t,e){var n=this,r="function"==typeof e?{$apply:e}:e;Array.isArray(t)&&Array.isArray(r)||o(!Array.isArray(r),(function(){return"update(): You provided an invalid spec to update(). The spec may not contain an array except as the value of $set, $push, $unshift, $splice or any custom command allowing an array value."})),o("object"==typeof r&&null!==r,(function(){return"update(): You provided an invalid spec to update(). The spec and every included key path must be plain objects containing one of the following commands: "+Object.keys(n.commands).join(", ")+"."}));var i=t;return f(r).forEach((function(e){if(a.call(n.commands,e)){var o=t===i;i=n.commands[e](r[e],i,r,t),o&&n.isEquals(i,t)&&(i=t)}else{var c="Map"===u(t)?n.update(t.get(e),r[e]):n.update(t[e],r[e]),s="Map"===u(i)?i.get(e):i[e];n.isEquals(c,s)&&(void 0!==c||a.call(t,e))||(i===t&&(i=l(t)),"Map"===u(i)?i.set(e,c):i[e]=c)}})),i},t}();e.Context=p;var h={$push:function(t,e,n){return y(e,n,"$push"),t.length?e.concat(t):e},$unshift:function(t,e,n){return y(e,n,"$unshift"),t.length?t.concat(e):e},$splice:function(t,e,r,a){return function(t,e){o(Array.isArray(t),(function(){return"Expected $splice target to be an array; got "+n(t)})),g(e.$splice)}(e,r),t.forEach((function(t){g(t),e===a&&t.length&&(e=l(a)),i.apply(e,t)})),e},$set:function(t,e,n){return function(t){o(1===Object.keys(t).length,(function(){return"Cannot have more than one key in an object with $set"}))}(n),t},$toggle:function(t,e){v(t,"$toggle");var n=t.length?l(e):e;return t.forEach((function(t){n[t]=!e[t]})),n},$unset:function(t,e,n,r){return v(t,"$unset"),t.forEach((function(t){Object.hasOwnProperty.call(e,t)&&(e===r&&(e=l(r)),delete e[t])})),e},$add:function(t,e,n,r){return m(e,"$add"),v(t,"$add"),"Map"===u(e)?t.forEach((function(t){var n=t[0],o=t[1];e===r&&e.get(n)!==o&&(e=l(r)),e.set(n,o)})):t.forEach((function(t){e!==r||e.has(t)||(e=l(r)),e.add(t)})),e},$remove:function(t,e,n,r){return m(e,"$remove"),v(t,"$remove"),t.forEach((function(t){e===r&&e.has(t)&&(e=l(r)),e.delete(t)})),e},$merge:function(t,e,r,a){var i,c;return i=e,o((c=t)&&"object"==typeof c,(function(){return"update(): $merge expects a spec of type 'object'; got "+n(c)})),o(i&&"object"==typeof i,(function(){return"update(): $merge expects a target of type 'object'; got "+n(i)})),f(t).forEach((function(n){t[n]!==e[n]&&(e===a&&(e=l(a)),e[n]=t[n])})),e},$apply:function(t,e){var r;return o("function"==typeof(r=t),(function(){return"update(): expected spec of $apply to be a function; got "+n(r)+"."})),t(e)}},d=new p;function y(t,e,r){o(Array.isArray(t),(function(){return"update(): expected target of "+n(r)+" to be an array; got "+n(t)+"."})),v(e[r],r)}function v(t,e){o(Array.isArray(t),(function(){return"update(): expected spec of "+n(e)+" to be an array; got "+n(t)+". Did you forget to wrap your parameter in an array?"}))}function g(t){o(Array.isArray(t),(function(){return"update(): expected spec of $splice to be an array of arrays; got "+n(t)+". Did you forget to wrap your parameters in an array?"}))}function m(t,e){var r=u(t);o("Map"===r||"Set"===r,(function(){return"update(): "+n(e)+" expects a target of type Set or Map; got "+n(r)}))}e.isEquals=d.update.isEquals,e.extend=d.extend,e.default=d.update,e.default.default=t.exports=s(e.default,e)}(O,O.exports);var E=w(O.exports),j=function(t){function n(t,r){var o;c(this,n);var a=(this instanceof n?this.constructor:void 0).prototype;return(o=e(this,n,[JSON.stringify(r)])).details=r,o.response=t,Object.setPrototypeOf(y(o),a),o}return l(n,t),s(n)}(d(Error)),S=function(t){function n(){return c(this,n),e(this,n,arguments)}return l(n,t),s(n)}(j),x=function(t){function n(){return c(this,n),e(this,n,arguments)}return l(n,t),s(n)}(S),_=function(t){function n(){return c(this,n),e(this,n,arguments)}return l(n,t),s(n)}(S),A=function(t){function n(){return c(this,n),e(this,n,arguments)}return l(n,t),s(n)}(j),P="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function T(t){var e;return(e=t.startsWith("http://")||t.startsWith("https://")?t:"https://".concat(t,".opendatasoft.com")).endsWith("/")||(e+="/"),e+="api/explore/v2.1/"}function L(t,e){if(!t)return e;var n=t.domain,r=t.fetch,o=t.apiKey,a=t.headers,i=t.interceptRequest,c=t.interceptResponse,u=t.hideDeprecatedWarning,s={};return n&&(s.baseUrl=T(n)),o&&(s.apiKey=o),r&&(s.fetch=r),a&&(s.headers=new Headers(a)),i&&(s.interceptRequest=i),c&&(s.interceptResponse=c),s.hideDeprecatedWarning=Boolean(u),E(e,{$merge:s})}var D=function(){function t(e){var n;c(this,t),this.deprecatedWarningShown=[];var r=(null==e?void 0:e.fetch)||(null==P?void 0:P.fetch);if(!r)throw new Error("fetch() was not found, try installing a polyfill in the browser or node-fetch in nodejs. You can pass fetch as an option to the api client.");var o=(null==e?void 0:e.domain)||(null==P||null===(n=P.location)||void 0===n?void 0:n.origin);if(!o)throw new Error("Missing domain");this.defaultConfig=L(e,{baseUrl:T(o),fetch:r})}var e,n;return s(t,[{key:"get",value:(e=o().mark((function t(e,n){var r,a,i,c,u,s,f,l,p,h,d;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=L(n,this.defaultConfig),(a="string"==typeof e?e:e.toString()).startsWith("/")&&(a=a.slice(1)),(i=new URL(a,r.baseUrl)).searchParams.sort(),(c=r.headers||new Headers).append("Accept","application/json"),r.apiKey&&c.append("Authorization","".concat("ApiKey"," ").concat(r.apiKey)),u=new Request(i.toString(),{method:"GET",headers:c,credentials:"same-origin"}),!r.interceptRequest){t.next=13;break}return t.next=12,r.interceptRequest(u);case 12:u=t.sent;case 13:return s=r.fetch,t.next=16,s(u);case 16:if(f=t.sent,null!=n&&n.hideDeprecatedWarning||null===(l=f.headers.get("Ods-Explore-Api-Deprecation"))||this.deprecatedWarningShown.includes(l)||(this.deprecatedWarningShown.push(l),console.warn("@opendatasoft/api-client : ".concat(l))),!r.interceptResponse){t.next=20;break}return t.abrupt("return",r.interceptResponse(f));case 20:if(!f.ok){t.next=25;break}return t.next=23,f.json();case 23:return p=t.sent,t.abrupt("return",p);case 25:return t.next=27,f.text();case 27:if(d=t.sent)try{h=JSON.parse(d)}catch(t){}if(h||!d&&!f.statusText||(h={message:d||f.statusText}),401!==f.status){t.next=32;break}throw new x(f,h||"authentication-error");case 32:if(404!==f.status){t.next=34;break}throw new _(f,h||"not-found");case 34:if(!(f.status<500)){t.next=36;break}throw new S(f,h||"user-error");case 36:throw new A(f,h||"server-error");case 37:case"end":return t.stop()}}),t,this)})),n=function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function c(t){i(a,r,o,c,u,"next",t)}function u(t){i(a,r,o,c,u,"throw",t)}c(void 0)}))},function(t,e){return n.apply(this,arguments)})}]),t}(),k=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0;c(this,t),this.searchParams=void 0,this.params=n?function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach((function(e){f(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},n):{},this.path=e}return s(t,[{key:"getPath",value:function(){return this.path}},{key:"getSearchParams",value:function(){var t=this;return void 0===this.searchParams&&(this.searchParams=new URLSearchParams,Object.entries(this.params).forEach((function(e){var n,r=v(e,2),o=r[0],a=r[1];t.searchParams&&("string"==typeof a?null===(n=t.searchParams)||void 0===n||n.set(o,a):g(a).sort().forEach((function(e){var n;null===(n=t.searchParams)||void 0===n||n.append(o,e)})))})),this.searchParams.sort()),this.searchParams}},{key:"toString",value:function(){var t=this.getSearchParams().toString();return t&&(t="?".concat(t)),"".concat(this.getPath()).concat(t)}},{key:"set",value:function(e,n){var r=E(this.params,{$merge:f({},e,n)});return r===this.params?this:new t(this.path,r)}},{key:"unset",value:function(e){var n=E(this.params,{$unset:[e]});return n===this.params?this:new t(this.path,n)}},{key:"update",value:function(t,e){if(!e)return this;var n=this.params[t],r="";return r="string"==typeof e?e:e("string"==typeof n?n||"":(null==n?void 0:n[0])||""),this.set(t,r)}},{key:"append",value:function(t,e){var n=this.params[t],r=null;return r=void 0===n?[e]:"string"==typeof n?[n,e]:[].concat(g(n),[e]),this.set(t,r)}},{key:"select",value:function(t){return this.update("select",t)}},{key:"where",value:function(t){return this.update("where",t)}},{key:"groupBy",value:function(t){return this.update("group_by",t)}},{key:"orderBy",value:function(t){return this.update("order_by",t)}},{key:"limit",value:function(t){return"number"==typeof t?this.set("limit",t.toString()):this.update("limit",t&&function(e){return t(Number(e)).toString()})}},{key:"offset",value:function(t){return"number"==typeof t?this.set("offset",t.toString()):this.update("offset",t&&function(e){return t(Number(e)).toString()})}},{key:"facet",value:function(t){return this.append("facet",t)}},{key:"refine",value:function(t){return this.append("refine",t)}},{key:"exclude",value:function(t){return this.append("exclude",t)}},{key:"lang",value:function(t){return this.set("lang",t)}},{key:"timezone",value:function(t){return this.set("timezone",t)}}]),t}();function N(t){return function(){return{itself:function(){return new k("".concat(t,"/"))},facets:function(){return new k("".concat(t,"/facets/"))},datasets:function(){return new k("".concat(t,"/datasets/"))},assets:function(){return new k("".concat(t,"/assets/"))},export:function(e){return new k("".concat(t,"/exports/").concat(e,"/"))},dataset:function(e){return{itself:function(){return new k("".concat(t,"/datasets/").concat(e,"/"))},facets:function(){return new k("".concat(t,"/datasets/").concat(e,"/facets/"))},records:function(){return new k("".concat(t,"/datasets/").concat(e,"/records/"))},export:function(n){return new k("".concat(t,"/datasets/").concat(e,"/exports/").concat(n,"/"))},record:function(n){return new k("".concat(t,"/datasets/").concat(e,"/records/").concat(n,"/"))}}}}}}var I=N("catalog"),M=N("monitoring"),$=N("opendatasoft"),R=function(t){return"`".concat(t.replace(/`/g,"\\`"),"`")},C=function(t){return JSON.stringify(t)};function G(t){return void 0===t?"":t<10?"-0".concat(t):"-".concat(t)}var F=function(t){return t&&0!==t.length?"".concat(t.map(R).join(", "),", "):""};t.ApiClient=D,t.AuthenticationError=x,t.EXPORT_CATALOG_FORMAT={CSV:"csv",JSON:"json",XLSX:"xlsx",RDF:"rdf",TTL:"ttl",DATA_JSON:"data.json",RSS:"rss",DCAT:"dcat",DCAT_AP_CH:"dcat-ap-ch",DCAT_AP_IT:"dcat-ap-it",DCAT_AP_DE:"dcat-ap-de",DCAT_AP_SE:"dcat-ap-se",DCAT_AP_SP:"dcat-ap-sp",DCAT_AP_V1:"dcat-ap-v1",DCAT_AP_BENAP:"dcat_ap_benap"},t.EXPORT_DATASET_FORMAT={JSON:"json",GEOJSON:"geojson",SHP:"shp",CSV:"csv",XLSX:"xlsx",KML:"kml",JSONLD:"jsonld",JSONL:"jsonl",RDFXML:"rdfxml",TURTLE:"turtle",N3:"n3",MVT:"mvt",PARQUET:"parquet",FGB:"fgb",GPX:"gpx",ICAL:"ical"},t.NotFoundError=_,t.ODS_DATASET_FIELD_SEMANTIC_TYPE={IP_ADDRESS:"ip_address",MONITORING_IP_ADDRESS:"monitoring_ip_address"},t.ODS_DATASET_FIELD_TYPE={TEXT:"text",INT:"int",DOUBLE:"double",BOOLEAN:"boolean",GEO_SHAPE:"geo_shape",GEO_POINT_2D:"geo_point_2d",DATETIME:"datetime",DATE:"date",FILE:"file",JSON_BlOB:"json_blob"},t.ODS_METADATA_TEMPLATE_FIELD_TYPE={TEXT:"text",ENUM:"enum",ENUM_LIST:"enumlist",URI_ENUM:"uri_enum",URI_ENUM_LIST:"uri_enumlist",LIST:"list",DATE:"date",DATE_TIME:"datetime",BOOLEAN:"boolean",INTEGER:"int",DECIMAL:"double",HTML:"html",LONG_STRING:"longstring",GEO_SHAPE:"geo_shape",JSON:"json",IMAGE:"image"},t.Query=k,t.ServerError=A,t.UserError=S,t.all=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.filter(Boolean).map((function(t){return"(".concat(t,")")})).join(" AND ")},t.date=function(t){var e=t.year,n=t.month,r=t.day;return"date'".concat(e).concat(G(n)).concat(G(r),"'")},t.dateFromIsoString=function(t){return"date'".concat(t,"'")},t.dateTime=function(t){return"date'".concat(t.toISOString(),"'")},t.exactMatch=function(t,e){return"".concat(R(t),"=").concat(C(e))},t.field=R,t.fromCatalog=I,t.fromDataNetwork=$,t.fromMonitoring=M,t.list=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.filter(Boolean).join(",")},t.lower=function(t){return"lower(".concat(t,")")},t.not=function(t){return t?"not (".concat(t,")"):""},t.one=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.filter(Boolean).map((function(t){return"(".concat(t,")")})).join(" OR ")},t.string=C,t.textSearch=function(t){return"search(".concat(F(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])).concat(C(t),")")},t.textStartWith=function(t){return"startswith(".concat(F(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])).concat(C(t),")")},t.textSuggest=function(t){return"suggest(".concat(F(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[])).concat(C(t),")")},Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=index.umd.js.map