diff --git a/.nvmrc b/.nvmrc index 2831228..31102b2 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14.17.1 +14.18.1 diff --git a/dist/iTunesSearch/index.d.ts b/dist/iTunesSearch/index.d.ts index 81ba62f..3636628 100644 --- a/dist/iTunesSearch/index.d.ts +++ b/dist/iTunesSearch/index.d.ts @@ -3,7 +3,6 @@ import { IiTunesSearch, ISearchAllOptions } from "./interfaces"; export declare class iTunesSearch implements IiTunesSearch { options: ISearchAllOptions; defaultOptions: ISearchAllOptions; - private iTunesFetch; searchAlbum: (term: string, options?: ISearchAllOptions | undefined) => Promise; searchSong: (term: string, options?: ISearchAllOptions | undefined) => Promise; searchArtist: (term: string, options?: ISearchAllOptions | undefined) => Promise; diff --git a/dist/iTunesSearch/index.d.ts.map b/dist/iTunesSearch/index.d.ts.map index 4534732..c7b47f3 100644 --- a/dist/iTunesSearch/index.d.ts.map +++ b/dist/iTunesSearch/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/iTunesSearch/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,aAAa,EACb,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,oBAA2B;IAClC,cAAc,oBAMS;IAEvB,OAAO,CAAC,WAAW,CAGjB;IAEF,WAAW,SAAgB,MAAM,8CAAgC,QAAQ,UAAU,CAAC,CACG;IAEvF,UAAU,SAAgB,MAAM,8CAAgC,QAAQ,UAAU,CAAC,CACE;IAErF,YAAY,SAAgB,MAAM,8CAAgC,QAAQ,UAAU,CAAC,CACmC;IAExH,SAAS,SAAgB,MAAM,8CAAgC,QAAQ,UAAU,CAAC,CACK;IAEvF,WAAW,SAAgB,MAAM,8CAAgC,QAAQ,UAAU,CAAC,CACE;IAEtF,gBAAgB,SAAgB,MAAM,8CAAgC,QA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QAAQ;CA0GjB"} \ No newline at end of file diff --git a/dist/iTunesSearch/index.js b/dist/iTunesSearch/index.js index d04163f..d46177a 100644 --- a/dist/iTunesSearch/index.js +++ b/dist/iTunesSearch/index.js @@ -10,15 +10,12 @@ class iTunesSearch { this.options = {}; this.defaultOptions = { limit: 1, - country: "US", - language: "en", + country: null, + language: null, attribute: null, - entity: null - }; - this.iTunesFetch = axios_1.default.create({ - baseURL: 'https://itunes.apple.com', + entity: null, timeout: 2000 - }); + }; this.searchAlbum = async (term, options) => await this.performSearch(term, { ...options, ...{ entity: "album" } }, "searchAlbum"); this.searchSong = async (term, options) => await this.performSearch(term, { ...options, ...{ media: "music" } }, "searchSong"); this.searchArtist = async (term, options) => await this.performSearch(term, { ...options, ...{ entity: "allArtist", attribute: "allArtistTerm" } }, "searchArtist"); @@ -30,11 +27,17 @@ class iTunesSearch { this.searchPodcast = async (term, options) => await this.performSearch(term, { ...options, ...{ entity: "podcast" } }, "searchPodcast"); this.searchAll = async (term, options) => await this.performSearch(term, { ...options }, "searchAll"); this.performSearch = async (term, options, validate) => { + const searchObject = this.validate(term, options, validate); try { - const searchObject = this.validate(term, options, validate); + const iTunesFetch = axios_1.default.create({ + baseURL: 'https://itunes.apple.com', + timeout: options?.timeout || 2000 + }); + if (options.timeout) + delete options.timeout; const querystring = new URLSearchParams(searchObject); const searchQueryStr = `/search?term=${encodeURI(term)}&${querystring.toString()}`; - const { data } = await this.iTunesFetch.get(searchQueryStr); + const { data } = await iTunesFetch.get(searchQueryStr); return data; } catch (e) { diff --git a/dist/iTunesSearch/interfaces.d.ts b/dist/iTunesSearch/interfaces.d.ts index 9ddcf06..99204b5 100644 --- a/dist/iTunesSearch/interfaces.d.ts +++ b/dist/iTunesSearch/interfaces.d.ts @@ -6,6 +6,7 @@ export interface ISearchAllOptions { attribute?: AttributeType | string | null | undefined; language?: string | null | undefined; country?: string | null | undefined; + timeout?: number | null | undefined; } export interface ISearchMandatoryAllOptions { limit?: number; @@ -13,6 +14,7 @@ export interface ISearchMandatoryAllOptions { attribute: AttributeType; language?: string; country?: string; + timeout?: number; } export interface IiTunesSearch { defaultOptions: ISearchAllOptions; diff --git a/dist/iTunesSearch/interfaces.d.ts.map b/dist/iTunesSearch/interfaces.d.ts.map index 0b31098..dd195ad 100644 --- a/dist/iTunesSearch/interfaces.d.ts.map +++ b/dist/iTunesSearch/interfaces.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/iTunesSearch/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,iBAAiB;IAChC,CAAC,GAAG,EAAE,MAAM,GAAE,GAAG,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChD,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACrC;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAE;IACpB,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,iBAAiB,CAAC;IAClC,WAAW,EAAE,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/E,UAAU,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,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CAAC,UAAU,CAAC,CAAC;IAC9E,gBAAgB,EAAE,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACnF,UAAU,EAAE,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7E,eAAe,EAAE,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAClF,aAAa,EAAE,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAChF,SAAS,EAAE,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAE,0BAA0B,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACtF;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,IAAI,EAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC/D"} \ No newline at end of file diff --git a/dist/web.minified/itunesSearch.min.js b/dist/web.minified/itunesSearch.min.js index f7325cb..7b6b52d 100644 --- a/dist/web.minified/itunesSearch.min.js +++ b/dist/web.minified/itunesSearch.min.js @@ -1 +1 @@ -(()=>{var e={156:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.iTunesSearch=void 0;const o=n(r(669));t.iTunesSearch=class{constructor(){this.options={},this.defaultOptions={limit:1,country:"US",language:"en",attribute:null,entity:null},this.iTunesFetch=o.default.create({baseURL:"https://itunes.apple.com",timeout:2e3}),this.searchAlbum=async(e,t)=>await this.performSearch(e,{...t,entity:"album"},"searchAlbum"),this.searchSong=async(e,t)=>await this.performSearch(e,{...t,media:"music"},"searchSong"),this.searchArtist=async(e,t)=>await this.performSearch(e,{...t,entity:"allArtist",attribute:"allArtistTerm"},"searchArtist"),this.searchApp=async(e,t)=>await this.performSearch(e,{...t,entity:"software"},"searchApp"),this.searchMovie=async(e,t)=>await this.performSearch(e,{...t,entity:"movie"},"searchMovie"),this.searchMusicVideo=async(e,t)=>await this.performSearch(e,{...t,media:"musicVideo"},"searchMusicVideo"),this.searchBook=async(e,t)=>await this.performSearch(e,{...t,entity:"ebook"},"searchBook"),this.searchAudiobook=async(e,t)=>await this.performSearch(e,{...t,entity:"audiobook"},"searchAudiobook"),this.searchPodcast=async(e,t)=>await this.performSearch(e,{...t,entity:"podcast"},"searchPodcast"),this.searchAll=async(e,t)=>await this.performSearch(e,{...t},"searchAll"),this.performSearch=async(e,t,r)=>{try{const n=this.validate(e,t,r),o=new URLSearchParams(n),s=`/search?term=${encodeURI(e)}&${o.toString()}`,{data:i}=await this.iTunesFetch.get(s);return i}catch(e){throw e}}}validate(e,t,r){const n=Object.fromEntries(Object.entries({...this.defaultOptions,...t}).filter((([e,t])=>null!==t))),o=new RegExp(/^(AD|AE|AF|AG|AI|AL|AM|AO|AQ|AR|AS|AT|AU|AW|AX|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BJ|BL|BM|BN|BO|BQ|BR|BS|BT|BV|BW|BY|BZ|CA|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|CR|CU|CV|CW|CX|CY|CZ|DE|DJ|DK|DM|DO|DZ|EC|EE|EG|EH|ER|ES|ET|FI|FJ|FK|FM|FO|FR|GA|GB|GD|GE|GF|GG|GH|GI|GL|GM|GN|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|HU|ID|IE|IL|IM|IN|IO|IQ|IR|IS|IT|JE|JM|JO|JP|KE|KG|KH|KI|KM|KN|KP|KR|KW|KY|KZ|LA|LB|LC|LI|LK|LR|LS|LT|LU|LV|LY|MA|MC|MD|ME|MF|MG|MH|MK|ML|MM|MN|MO|MP|MQ|MR|MS|MT|MU|MV|MW|MX|MY|MZ|NA|NC|NE|NF|NG|NI|NL|NO|NP|NR|NU|NZ|OM|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PS|PT|PW|PY|QA|RE|RO|RS|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|SS|ST|SV|SX|SY|SZ|TC|TD|TF|TG|TH|TJ|TK|TL|TM|TN|TO|TR|TT|TV|TW|TZ|UA|UG|UM|US|UY|UZ|VA|VC|VE|VG|VI|VN|VU|WF|WS|YE|YT|ZA|ZM|ZW)$/,"g"),s=new RegExp(/^(ab|aa|af|ak|sq|am|ar|an|hy|as|av|ae|ay|az|bm|ba|eu|be|bn|bi|bs|br|bg|my|ca|ch|ce|ny|zh|cv|kw|co|cr|hr|cs|da|dv|nl|dz|en|eo|et|ee|fo|fj|fi|fr|ff|gl|ka|de|el|gn|gu|ht|ha|he|hz|hi|ho|hu|ia|id|ie|ga|ig|ik|io|is|it|iu|ja|jv|kl|kn|kr|ks|kk|km|ki|rw|ky|kv|kg|ko|ku|kj|la|lb|lg|li|ln|lo|lt|lu|lv|gv|mk|mg|ms|ml|mt|mi|mr|mh|mn|na|nv|nd|ne|ng|nb|nn|no|ii|nr|oc|oj|cu|om|or|os|pa|pi|fa|pl|ps|pt|qu|rm|rn|ro|ru|sa|sc|sd|se|sm|sg|sr|gd|sn|si|sk|sl|so|st|es|su|sw|ss|sv|ta|te|tg|th|ti|bo|tk|tl|tn|to|tr|ts|tt|tw|ty|ug|uk|ur|uz|ve|vi|vo|wa|cy|wo|fy|xh|yi|yo|za|zu)$/,"g"),i=["album","allArtist","allTrack","audiobook","audiobookAuthor","ebook","iPadSoftware","macSoftware","mix","movie","movieArtist","musicArtist","musicTrack","musicVideo","podcast","podcastAuthor","shortFilm","shortFilmArtist","software","song","tvEpisode","tvSeason"],a=["actorTerm","albumTerm","allArtistTerm","allTrackTerm","artistTerm","authorTerm","composerTerm","descriptionTerm","directorTerm","featureFilmTerm","genreIndex","keywordsTerm","languageTerm","mixTerm","movieArtistTerm","movieTerm","producerTerm","ratingIndex","ratingTerm","releaseYearTerm","shortFilmTerm","showTerm","softwareDeveloper","songTerm","titleTerm","tvEpisodeTerm","tvSeasonTerm"];if("searchAll"===r){if(n.entity&&!i.includes(n.entity))throw new TypeError(`The entity with value ${JSON.stringify(n.entity)} is not valid. Expected one of the following list ${JSON.stringify(i)}`);if(n.attribute&&!a.includes(n.attribute))throw new TypeError(`The attribute with value ${JSON.stringify(n.attribute)} is not valid. Expected one of the following list ${JSON.stringify(a)}`);if(!n.entity||!n.attribute)throw new TypeError('searchAll expects to have both "entity" and "attribute" values in the options object')}if("string"!=typeof e||!e.trim().length)throw new TypeError('A "term" is a string required on any search. "term" cannot have empty spaces as well.');if(!Number.isInteger(n.limit))throw new TypeError(`Optional argument "limit" must be a number. Passed ${typeof n.limit}(${n.limit})`);if(!o.test(n.country))throw new TypeError(`Optional argument "country" must be a string and should be a valid ISO 3166-1 Alpha 2 country code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Passed ${typeof n.country}( ${JSON.stringify(n.country)} )`);if(!s.test(n.language))throw new TypeError(`Optional argument "language" must be a string and should be a valid ISO 639-1 language code (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). Passed ${typeof n.language}( ${JSON.stringify(n.language)} )`);return n}}},669:(e,t,r)=>{e.exports=r(609)},448:(e,t,r)=>{"use strict";var n=r(867),o=r(26),s=r(372),i=r(327),a=r(97),c=r(109),u=r(985),f=r(61);e.exports=function(e){return new Promise((function(t,r){var h=e.data,l=e.headers;n.isFormData(h)&&delete l["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";l.Authorization="Basic "+btoa(d+":"+m)}var g=a(e.baseURL,e.url);if(p.open(e.method.toUpperCase(),i(g,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,p.onreadystatechange=function(){if(p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in p?c(p.getAllResponseHeaders()):null,s={data:e.responseType&&"text"!==e.responseType?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:n,config:e,request:p};o(t,r,s),p=null}},p.onabort=function(){p&&(r(f("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(f("Network Error",e,null,p)),p=null},p.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(f(t,e,"ECONNABORTED",p)),p=null},n.isStandardBrowserEnv()){var y=(e.withCredentials||u(g))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;y&&(l[e.xsrfHeaderName]=y)}if("setRequestHeader"in p&&n.forEach(l,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete l[t]:p.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),e.responseType)try{p.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){p&&(p.abort(),r(e),p=null)})),h||(h=null),p.send(h)}))}},609:(e,t,r)=>{"use strict";var n=r(867),o=r(849),s=r(321),i=r(185);function a(e){var t=new s(e),r=o(s.prototype.request,t);return n.extend(r,s.prototype,t),n.extend(r,t),r}var c=a(r(655));c.Axios=s,c.create=function(e){return a(i(c.defaults,e))},c.Cancel=r(263),c.CancelToken=r(972),c.isCancel=r(502),c.all=function(e){return Promise.all(e)},c.spread=r(713),c.isAxiosError=r(268),e.exports=c,e.exports.default=c},263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:(e,t,r)=>{"use strict";var n=r(263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,r)=>{"use strict";var n=r(867),o=r(327),s=r(782),i=r(572),a=r(185);function c(e){this.defaults=e,this.interceptors={request:new s,response:new s}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[i,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},c.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,r,n){return this.request(a(n||{},{method:e,url:t,data:r}))}})),e.exports=c},782:(e,t,r)=>{"use strict";var n=r(867);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},97:(e,t,r)=>{"use strict";var n=r(793),o=r(303);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},61:(e,t,r)=>{"use strict";var n=r(481);e.exports=function(e,t,r,o,s){var i=new Error(e);return n(i,t,r,o,s)}},572:(e,t,r)=>{"use strict";var n=r(867),o=r(527),s=r(502),i=r(655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function(t){return a(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function(t){return s(t)||(a(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],s=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function u(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=c(void 0,t[e]))})),n.forEach(s,u),n.forEach(i,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(void 0,t[o])})),n.forEach(a,(function(n){n in t?r[n]=c(e[n],t[n]):n in e&&(r[n]=c(void 0,e[n]))}));var f=o.concat(s).concat(i).concat(a),h=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===f.indexOf(e)}));return n.forEach(h,u),r}},26:(e,t,r)=>{"use strict";var n=r(61);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},655:(e,t,r)=>{"use strict";var n=r(867),o=r(16),s={"Content-Type":"application/x-www-form-urlencoded"};function i(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var a,c={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(a=r(448)),a),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(i(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(i(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(s)})),e.exports=c},849:e=>{"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n{"use strict";var n=r(867);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var s;if(r)s=r(t);else if(n.isURLSearchParams(t))s=t.toString();else{var i=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),i.push(o(t)+"="+o(e))})))})),s=i.join("&")}if(s){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}},303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},372:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(s)&&a.push("domain="+s),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},793:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},268:e=>{"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},985:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},16:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},109:(e,t,r)=>{"use strict";var n=r(867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,s,i={};return e?(n.forEach(e.split("\n"),(function(e){if(s=e.indexOf(":"),t=n.trim(e.substr(0,s)).toLowerCase(),r=n.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i}},713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},867:(e,t,r)=>{"use strict";var n=r(849),o=Object.prototype.toString;function s(e){return"[object Array]"===o.call(e)}function i(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),s(e))for(var r=0,n=e.length;r{"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.searchSong=e.searchPodcast=e.searchMusicVideo=e.searchMovie=e.searchBook=e.searchAudiobook=e.searchApp=e.searchAll=e.searchArtist=e.searchAlbum=void 0;const t=new(r(156).iTunesSearch);e.searchAlbum=t.searchAlbum,e.searchArtist=t.searchArtist,e.searchAll=t.searchAll,e.searchApp=t.searchApp,e.searchAudiobook=t.searchAudiobook,e.searchBook=t.searchBook,e.searchMovie=t.searchMovie,e.searchMusicVideo=t.searchMusicVideo,e.searchPodcast=t.searchPodcast,e.searchSong=t.searchSong})(),window.iTunesSearch=n})(); \ No newline at end of file +(()=>{var e={156:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.iTunesSearch=void 0;const o=n(r(669));t.iTunesSearch=class{constructor(){this.options={},this.defaultOptions={limit:1,country:null,language:null,attribute:null,entity:null,timeout:2e3},this.searchAlbum=async(e,t)=>await this.performSearch(e,{...t,entity:"album"},"searchAlbum"),this.searchSong=async(e,t)=>await this.performSearch(e,{...t,media:"music"},"searchSong"),this.searchArtist=async(e,t)=>await this.performSearch(e,{...t,entity:"allArtist",attribute:"allArtistTerm"},"searchArtist"),this.searchApp=async(e,t)=>await this.performSearch(e,{...t,entity:"software"},"searchApp"),this.searchMovie=async(e,t)=>await this.performSearch(e,{...t,entity:"movie"},"searchMovie"),this.searchMusicVideo=async(e,t)=>await this.performSearch(e,{...t,media:"musicVideo"},"searchMusicVideo"),this.searchBook=async(e,t)=>await this.performSearch(e,{...t,entity:"ebook"},"searchBook"),this.searchAudiobook=async(e,t)=>await this.performSearch(e,{...t,entity:"audiobook"},"searchAudiobook"),this.searchPodcast=async(e,t)=>await this.performSearch(e,{...t,entity:"podcast"},"searchPodcast"),this.searchAll=async(e,t)=>await this.performSearch(e,{...t},"searchAll"),this.performSearch=async(e,t,r)=>{const n=this.validate(e,t,r);try{const r=o.default.create({baseURL:"https://itunes.apple.com",timeout:t?.timeout||2e3});t.timeout&&delete t.timeout;const s=new URLSearchParams(n),i=`/search?term=${encodeURI(e)}&${s.toString()}`,{data:a}=await r.get(i);return a}catch(e){throw e}}}validate(e,t,r){const n=Object.fromEntries(Object.entries({...this.defaultOptions,...t}).filter((([e,t])=>null!==t))),o=new RegExp(/^(AD|AE|AF|AG|AI|AL|AM|AO|AQ|AR|AS|AT|AU|AW|AX|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BJ|BL|BM|BN|BO|BQ|BR|BS|BT|BV|BW|BY|BZ|CA|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|CR|CU|CV|CW|CX|CY|CZ|D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|sw|ss|sv|ta|te|tg|th|ti|bo|tk|tl|tn|to|tr|ts|tt|tw|ty|ug|uk|ur|uz|ve|vi|vo|wa|cy|wo|fy|xh|yi|yo|za|zu)$/,"g"),i=["album","allArtist","allTrack","audiobook","audiobookAuthor","ebook","iPadSoftware","macSoftware","mix","movie","movieArtist","musicArtist","musicTrack","musicVideo","podcast","podcastAuthor","shortFilm","shortFilmArtist","software","song","tvEpisode","tvSeason"],a=["actorTerm","albumTerm","allArtistTerm","allTrackTerm","artistTerm","authorTerm","composerTerm","descriptionTerm","directorTerm","featureFilmTerm","genreIndex","keywordsTerm","languageTerm","mixTerm","movieArtistTerm","movieTerm","producerTerm","ratingIndex","ratingTerm","releaseYearTerm","shortFilmTerm","showTerm","softwareDeveloper","songTerm","titleTerm","tvEpisodeTerm","tvSeasonTerm"];if("searchAll"===r){if(n.entity&&!i.includes(n.entity))throw new TypeError(`The entity with value ${JSON.stringify(n.entity)} is not valid. Expected one of the following list ${JSON.stringify(i)}`);if(n.attribute&&!a.includes(n.attribute))throw new TypeError(`The attribute with value ${JSON.stringify(n.attribute)} is not valid. Expected one of the following list ${JSON.stringify(a)}`);if(!n.entity||!n.attribute)throw new TypeError('searchAll expects to have both "entity" and "attribute" values in the options object')}if("string"!=typeof e||!e.trim().length)throw new TypeError('A "term" is a string required on any search. "term" cannot have empty spaces as well.');if(!Number.isInteger(n.limit))throw new TypeError(`Optional argument "limit" must be a number. Passed ${typeof n.limit}(${n.limit})`);if(!o.test(n.country))throw new TypeError(`Optional argument "country" must be a string and should be a valid ISO 3166-1 Alpha 2 country code (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Passed ${typeof n.country}( ${JSON.stringify(n.country)} )`);if(!s.test(n.language))throw new TypeError(`Optional argument "language" must be a string and should be a valid ISO 639-1 language code (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). Passed ${typeof n.language}( ${JSON.stringify(n.language)} )`);return n}}},669:(e,t,r)=>{e.exports=r(609)},448:(e,t,r)=>{"use strict";var n=r(867),o=r(26),s=r(372),i=r(327),a=r(97),c=r(109),u=r(985),l=r(61);e.exports=function(e){return new Promise((function(t,r){var f=e.data,h=e.headers,p=e.responseType;n.isFormData(f)&&delete h["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",g=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";h.Authorization="Basic "+btoa(m+":"+g)}var v=a(e.baseURL,e.url);function y(){if(d){var n="getAllResponseHeaders"in d?c(d.getAllResponseHeaders()):null,s={data:p&&"text"!==p&&"json"!==p?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:n,config:e,request:d};o(t,r,s),d=null}}if(d.open(e.method.toUpperCase(),i(v,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,"onloadend"in d?d.onloadend=y:d.onreadystatechange=function(){d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))&&setTimeout(y)},d.onabort=function(){d&&(r(l("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function(){r(l("Network Error",e,null,d)),d=null},d.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(l(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",d)),d=null},n.isStandardBrowserEnv()){var b=(e.withCredentials||u(v))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;b&&(h[e.xsrfHeaderName]=b)}"setRequestHeader"in d&&n.forEach(h,(function(e,t){void 0===f&&"content-type"===t.toLowerCase()?delete h[t]:d.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(d.withCredentials=!!e.withCredentials),p&&"json"!==p&&(d.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){d&&(d.abort(),r(e),d=null)})),f||(f=null),d.send(f)}))}},609:(e,t,r)=>{"use strict";var n=r(867),o=r(849),s=r(321),i=r(185);function a(e){var t=new s(e),r=o(s.prototype.request,t);return n.extend(r,s.prototype,t),n.extend(r,t),r}var c=a(r(655));c.Axios=s,c.create=function(e){return a(i(c.defaults,e))},c.Cancel=r(263),c.CancelToken=r(972),c.isCancel=r(502),c.all=function(e){return Promise.all(e)},c.spread=r(713),c.isAxiosError=r(268),e.exports=c,e.exports.default=c},263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:(e,t,r)=>{"use strict";var n=r(263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,r)=>{"use strict";var n=r(867),o=r(327),s=r(782),i=r(572),a=r(185),c=r(875),u=c.validators;function l(e){this.defaults=e,this.interceptors={request:new s,response:new s}}l.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var l=[i,void 0];for(Array.prototype.unshift.apply(l,r),l.concat(s),o=Promise.resolve(e);l.length;)o=o.then(l.shift(),l.shift());return o}for(var f=e;r.length;){var h=r.shift(),p=r.shift();try{f=h(f)}catch(e){p(e);break}}try{o=i(f)}catch(e){return Promise.reject(e)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},l.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){l.prototype[e]=function(t,r,n){return this.request(a(n||{},{method:e,url:t,data:r}))}})),e.exports=l},782:(e,t,r)=>{"use strict";var n=r(867);function o(){this.handlers=[]}o.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},97:(e,t,r)=>{"use strict";var n=r(793),o=r(303);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},61:(e,t,r)=>{"use strict";var n=r(481);e.exports=function(e,t,r,o,s){var i=new Error(e);return n(i,t,r,o,s)}},572:(e,t,r)=>{"use strict";var n=r(867),o=r(527),s=r(502),i=r(655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function(t){return a(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return s(t)||(a(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],s=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function u(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=c(void 0,t[e]))})),n.forEach(s,u),n.forEach(i,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=c(void 0,e[o])):r[o]=c(void 0,t[o])})),n.forEach(a,(function(n){n in t?r[n]=c(e[n],t[n]):n in e&&(r[n]=c(void 0,e[n]))}));var l=o.concat(s).concat(i).concat(a),f=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return n.forEach(f,u),r}},26:(e,t,r)=>{"use strict";var n=r(61);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:(e,t,r)=>{"use strict";var n=r(867),o=r(655);e.exports=function(e,t,r){var s=this||o;return n.forEach(r,(function(r){e=r.call(s,e,t)})),e}},655:(e,t,r)=>{"use strict";var n=r(867),o=r(16),s=r(481),i={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=r(448)),c),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),JSON.stringify(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||o&&n.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw s(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){u.headers[e]=n.merge(i)})),e.exports=u},849:e=>{"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n{"use strict";var n=r(867);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var s;if(r)s=r(t);else if(n.isURLSearchParams(t))s=t.toString();else{var i=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),i.push(o(t)+"="+o(e))})))})),s=i.join("&")}if(s){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}},303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},372:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(s)&&a.push("domain="+s),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},793:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},268:e=>{"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},985:(e,t,r)=>{"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},16:(e,t,r)=>{"use strict";var n=r(867);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},109:(e,t,r)=>{"use strict";var n=r(867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,s,i={};return e?(n.forEach(e.split("\n"),(function(e){if(s=e.indexOf(":"),t=n.trim(e.substr(0,s)).toLowerCase(),r=n.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i}},713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},875:(e,t,r)=>{"use strict";var n=r(593),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var s={},i=n.version.split(".");function a(e,t){for(var r=t?t.split("."):i,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]0;){var s=n[o],i=t[s];if(i){var a=e[s],c=void 0===a||i(a,s,e);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:o}},867:(e,t,r)=>{"use strict";var n=r(849),o=Object.prototype.toString;function s(e){return"[object Array]"===o.call(e)}function i(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===o.call(e)}function l(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),s(e))for(var r=0,n=e.length;r{"use strict";e.exports=JSON.parse('{"_args":[["axios@0.21.2","C:\\\\Git-Projects\\\\itunes-search"]],"_from":"axios@0.21.2","_id":"axios@0.21.2","_inBundle":false,"_integrity":"sha512-87otirqUw3e8CzHTMO+/9kh/FSgXt/eVDvipijwDtEuwbkySWZ9SBm6VEubmJ/kLKEoLQV/POhxXFb66bfekfg==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"axios@0.21.2","name":"axios","escapedName":"axios","rawSpec":"0.21.2","saveSpec":null,"fetchSpec":"0.21.2"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.2.tgz","_spec":"0.21.2","_where":"C:\\\\Git-Projects\\\\itunes-search","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.14.0"},"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"homepage":"https://axios-http.com","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.21.2"}')}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}var n={};(()=>{"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.searchSong=e.searchPodcast=e.searchMusicVideo=e.searchMovie=e.searchBook=e.searchAudiobook=e.searchApp=e.searchAll=e.searchArtist=e.searchAlbum=void 0;const t=new(r(156).iTunesSearch);e.searchAlbum=t.searchAlbum,e.searchArtist=t.searchArtist,e.searchAll=t.searchAll,e.searchApp=t.searchApp,e.searchAudiobook=t.searchAudiobook,e.searchBook=t.searchBook,e.searchMovie=t.searchMovie,e.searchMusicVideo=t.searchMusicVideo,e.searchPodcast=t.searchPodcast,e.searchSong=t.searchSong})(),window.iTunesSearch=n})(); \ No newline at end of file diff --git a/docs/searchAlbum.md b/docs/searchAlbum.md index 3cfba7c..88d6e3d 100644 --- a/docs/searchAlbum.md +++ b/docs/searchAlbum.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchAll.md b/docs/searchAll.md index 1542a57..7e2d8ea 100644 --- a/docs/searchAll.md +++ b/docs/searchAll.md @@ -21,6 +21,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | attribute | string | 🟡 if you need more precision | The attribute you want to search for in the stores, relative to the specified media type. For example, if you want to search for an artist by name specify `entity=allArtist&attribute=allArtistTerm.` Check the list of Attributes. | | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ##### Entities for each media type diff --git a/docs/searchApp.md b/docs/searchApp.md index c9e53ae..454fc7f 100644 --- a/docs/searchApp.md +++ b/docs/searchApp.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchArtist.md b/docs/searchArtist.md index 62d58c4..485ad54 100644 --- a/docs/searchArtist.md +++ b/docs/searchArtist.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchAudiobook.md b/docs/searchAudiobook.md index c4cc5da..b3ecc8d 100644 --- a/docs/searchAudiobook.md +++ b/docs/searchAudiobook.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchBook.md b/docs/searchBook.md index 32bae1a..c8b024a 100644 --- a/docs/searchBook.md +++ b/docs/searchBook.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchMovie.md b/docs/searchMovie.md index c7ff30f..62947d7 100644 --- a/docs/searchMovie.md +++ b/docs/searchMovie.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchMusicVideo.md b/docs/searchMusicVideo.md index d247b2b..c5998c7 100644 --- a/docs/searchMusicVideo.md +++ b/docs/searchMusicVideo.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchPodcast.md b/docs/searchPodcast.md index b7e4968..b3e113b 100644 --- a/docs/searchPodcast.md +++ b/docs/searchPodcast.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/docs/searchSong.md b/docs/searchSong.md index 1ae7f60..7ab1906 100644 --- a/docs/searchSong.md +++ b/docs/searchSong.md @@ -19,6 +19,7 @@ Please Check [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) For La | limit | number | ✅ | Required if options is defined. A Numeric value that sets the limit of results by the search term | 1 | | language | string | 🔴 | a language code based on [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | "en" | | country | string | 🔴 | a country code based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) | "US" | +| timeout | number | 🔴 | The amout of milliseconds that will be allowed the search to take before timeout. | 2000 | ## Example of use: diff --git a/examples/html/index.html b/examples/html/index.html index 30384d0..e24bcdd 100644 --- a/examples/html/index.html +++ b/examples/html/index.html @@ -1,24 +1,27 @@ + @tbogard/itunes-search example +
 
   
+ diff --git a/examples/node/index.js b/examples/node/index.js index 4eb50c9..30077e7 100644 --- a/examples/node/index.js +++ b/examples/node/index.js @@ -1,5 +1,5 @@ const { searchApp, searchAudiobook, searchBook, searchArtist } = require('../../dist/index'); -searchArtist('Hikaru Utada').then(data => { +searchArtist('Hikaru Utada',{limit: 1,timeout:5000}).then(data => { console.log(JSON.stringify(data,null,2)) }) diff --git a/src/iTunesSearch/index.ts b/src/iTunesSearch/index.ts index 303e76a..b092b70 100644 --- a/src/iTunesSearch/index.ts +++ b/src/iTunesSearch/index.ts @@ -10,16 +10,12 @@ export class iTunesSearch implements IiTunesSearch { options = {} as ISearchAllOptions; defaultOptions = { limit: 1, - country: "US", - language: "en", + country: 'US', + language: 'en', attribute: null, - entity: null - } as ISearchAllOptions; - - private iTunesFetch = axios.create({ - baseURL: 'https://itunes.apple.com', + entity: null, timeout: 2000 - }) + } as ISearchAllOptions; searchAlbum = async (term: string, options?: ISearchAllOptions): Promise => await this.performSearch(term, { ...options, ...{ entity: "album" } }, "searchAlbum") @@ -52,12 +48,18 @@ export class iTunesSearch implements IiTunesSearch { await this.performSearch(term, { ...options }, "searchAll") private performSearch = async (term: string, options: ISearchAllOptions, validate:string): Promise => { + const searchObject: any = this.validate(term, options, validate); // eslint-disable-next-line no-useless-catch try { - const searchObject: any = this.validate(term, options, validate); + const iTunesFetch = axios.create({ + baseURL: 'https://itunes.apple.com', + timeout: searchObject?.timeout || 2000 + }); + if (searchObject.timeout) delete searchObject.timeout; + const querystring = new URLSearchParams(searchObject); const searchQueryStr = `/search?term=${encodeURI(term)}&${querystring.toString()}`; - const { data } = await this.iTunesFetch.get(searchQueryStr); + const { data } = await iTunesFetch.get(searchQueryStr); return data; } catch (e) { throw e; diff --git a/src/iTunesSearch/interfaces.ts b/src/iTunesSearch/interfaces.ts index 5e5a479..61181c8 100644 --- a/src/iTunesSearch/interfaces.ts +++ b/src/iTunesSearch/interfaces.ts @@ -11,6 +11,7 @@ export interface ISearchAllOptions { attribute?: AttributeType | string | null | undefined; language?: string | null | undefined; country?: string | null | undefined; + timeout?: number | null | undefined; } export interface ISearchMandatoryAllOptions { @@ -19,6 +20,7 @@ export interface ISearchMandatoryAllOptions { attribute: AttributeType; language?: string; country?: string; + timeout?: number; } export interface IiTunesSearch {