unsplash-js
Advanced tools
Comparing version 7.0.13 to 7.0.14
@@ -7,2 +7,7 @@ import { PaginationParams } from '../types/request'; | ||
}; | ||
export declare const getTopics: (topicIds?: string[] | undefined) => { | ||
topics: string; | ||
} | { | ||
topics?: undefined; | ||
}; | ||
export declare const getFeedParams: ({ page, perPage, orderBy }: PaginationParams) => Record<string, number | import("../types/request").OrderBy>; |
@@ -27,13 +27,15 @@ import { OrientationParam, PaginationParams } from '../../types/request'; | ||
}; | ||
export declare type RandomParams = { | ||
collectionIds?: string[]; | ||
topicIds?: string[]; | ||
featured?: boolean; | ||
username?: string; | ||
query?: string; | ||
contentFilter?: 'low' | 'high'; | ||
count?: number; | ||
} & OrientationParam; | ||
export declare const getRandom: { | ||
getPathname: (params: unknown) => string; | ||
} & { | ||
handleRequest: (a: ({ | ||
collectionIds?: string[] | undefined; | ||
featured?: boolean | undefined; | ||
username?: string | undefined; | ||
query?: string | undefined; | ||
contentFilter?: "low" | "high" | undefined; | ||
count?: number | undefined; | ||
} & OrientationParam) | undefined, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams; | ||
handleRequest: (a: RandomParams | undefined, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams; | ||
handleResponse: import("../../helpers/response").HandleResponse<Photo.Random | Photo.Random[]>; | ||
@@ -40,0 +42,0 @@ }; |
@@ -24,3 +24,3 @@ import { OrientationParam, PaginationParams } from '../../types/request'; | ||
export declare const getPhotos: { | ||
getPathname: (params: unknown) => string; | ||
getPathname: (params: void | undefined) => string; | ||
} & { | ||
@@ -31,3 +31,3 @@ handleRequest: (a: SearchPhotosParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams; | ||
export declare const getCollections: { | ||
getPathname: (params: unknown) => string; | ||
getPathname: (params: void | undefined) => string; | ||
} & { | ||
@@ -38,3 +38,3 @@ handleRequest: (a: SearchParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams; | ||
export declare const getUsers: { | ||
getPathname: (params: unknown) => string; | ||
getPathname: (params: void | undefined) => string; | ||
} & { | ||
@@ -41,0 +41,0 @@ handleRequest: (a: SearchParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams; |
@@ -342,2 +342,7 @@ 'use strict'; | ||
}; | ||
var getTopics = function getTopics(topicIds) { | ||
return isDefined(topicIds) ? { | ||
topics: topicIds.join() | ||
} : {}; | ||
}; | ||
var getFeedParams = function getFeedParams(_ref) { | ||
@@ -524,3 +529,4 @@ var page = _ref.page, | ||
contentFilter = _ref5.contentFilter, | ||
queryParams = _objectWithoutPropertiesLoose(_ref5, ["collectionIds", "contentFilter"]); | ||
topicIds = _ref5.topicIds, | ||
queryParams = _objectWithoutPropertiesLoose(_ref5, ["collectionIds", "contentFilter", "topicIds"]); | ||
@@ -531,3 +537,3 @@ return { | ||
content_filter: contentFilter | ||
}, getCollections(collectionIds))), | ||
}, getCollections(collectionIds), getTopics(topicIds))), | ||
headers: { | ||
@@ -575,3 +581,3 @@ /** | ||
var getPhotos$1 = /*#__PURE__*/function () { | ||
var getPathname = function getPathname() { | ||
var _getPathname = function getPathname() { | ||
return SEARCH_PATH_PREFIX + "/photos"; | ||
@@ -581,3 +587,6 @@ }; | ||
return makeEndpoint({ | ||
getPathname: getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: function getPathname(_params) { | ||
return _getPathname(); | ||
}, | ||
handleRequest: createRequestHandler(function (_ref) { | ||
@@ -594,3 +603,3 @@ var query = _ref.query, | ||
return { | ||
pathname: getPathname(), | ||
pathname: _getPathname(), | ||
query: compactDefined(_extends({ | ||
@@ -611,3 +620,3 @@ query: query, | ||
var getCollections$1 = /*#__PURE__*/function () { | ||
var getPathname = function getPathname() { | ||
var _getPathname2 = function getPathname() { | ||
return SEARCH_PATH_PREFIX + "/collections"; | ||
@@ -617,3 +626,6 @@ }; | ||
return makeEndpoint({ | ||
getPathname: getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: function getPathname(_params) { | ||
return _getPathname2(); | ||
}, | ||
handleRequest: createRequestHandler(function (_ref2) { | ||
@@ -624,3 +636,3 @@ var query = _ref2.query, | ||
return { | ||
pathname: getPathname(), | ||
pathname: _getPathname2(), | ||
query: _extends({ | ||
@@ -635,3 +647,3 @@ query: query | ||
var getUsers = /*#__PURE__*/function () { | ||
var getPathname = function getPathname() { | ||
var _getPathname3 = function getPathname() { | ||
return SEARCH_PATH_PREFIX + "/users"; | ||
@@ -641,3 +653,6 @@ }; | ||
return makeEndpoint({ | ||
getPathname: getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: function getPathname(_params) { | ||
return _getPathname3(); | ||
}, | ||
handleRequest: createRequestHandler(function (_ref3) { | ||
@@ -648,3 +663,3 @@ var query = _ref3.query, | ||
return { | ||
pathname: getPathname(), | ||
pathname: _getPathname3(), | ||
query: _extends({ | ||
@@ -651,0 +666,0 @@ query: query |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("content-type");function n(){return(n=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function t(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(a[t]=e[t]);return a}var r=o((function(e){return"string"==typeof e?e:null})),a=function(e){return null!=e};function o(e){return function(n){return a(e(n))}}var u=function(e){return Object.keys(e).reduce((function(t,r){var o,u=e[r];return n({},t,a(u)?((o={})[r]=u,o):{})}),{})};function i(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n.length-1;return function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];for(var o=n[0].apply(this,t),u=1;u<=r;u++)o=n[u].call(this,o);return o}}var s,c,l=o((function(e){return a(e)&&"object"==typeof e&&!Array.isArray(e)?e:null})),h=o((function(e){return Array.isArray(e)&&e.every(r)&&e.length>0?e:null})),p=o((function(e){return l(e)&&"errors"in e&&h(e.errors)?{errors:e.errors}:null})),d=function(e){this.message=e},f=function(n){if(function(n){var t=n.headers.get("content-type");return a(t)&&"application/json"===e.parse(t).type}(n))return n.json().catch((function(e){throw new d("unable to parse JSON response.")}));throw new d("expected JSON response from server.")},g=function(){return function(e){return f(e.response)}},m=function(e){return function(r,a){void 0===a&&(a={});var o=e(r),u=o.headers,i=o.query;return n({},t(o,["headers","query"]),a,{query:i,headers:n({},u,a.headers)})}},y=function(e){return e},v=function(e){var r=e.accessKey,o=e.apiVersion,u=void 0===o?"v1":o,s=e.apiUrl,c=void 0===s?"https://api.unsplash.com":s,l=e.headers,h=e.fetch,g=t(e,["accessKey","apiVersion","apiUrl","headers","fetch"]);return function(e){var t=e.handleResponse;return i(e.handleRequest,(function(e){var o=e.method,i=void 0===o?"GET":o,s=e.headers,m=e.body,y=e.signal,v=function(e){var n=e.pathname,t=e.query;return function(e){var r=new URL(e);return function(e){return function(n){"/"===n.pathname?n.pathname=e:n.pathname+=e}}(n)(r),function(e){return function(n){Object.keys(e).forEach((function(t){return n.searchParams.set(t,e[t].toString())}))}}(t)(r),r.toString()}}({pathname:e.pathname,query:e.query})(c),q=n({method:i,headers:n({},l,s,{"Accept-Version":u},a(r)?{Authorization:"Client-ID "+r}:{}),body:m,signal:y},g);return(null!=h?h:fetch)(v,q).then(function(e){return function(t){return(t.ok?e({response:t}).then((function(e){return{type:"success",status:t.status,response:e,originalResponse:t}})):f(t).then((function(e){return n({type:"error",status:t.status},function(e){return p(e)?{errors:e.errors,source:"api"}:{errors:["Responded with a status code outside the 2xx range, and the response body is not recognisable."],source:"decoding"}}(e),{originalResponse:t})}))).catch((function(e){if(e instanceof d)return{type:"error",source:"decoding",status:t.status,originalResponse:t,errors:[e.message]};throw e}))}}(t))}))}},q=function(e){var n=e.headers.get("x-total");if(a(n)){var t=parseInt(n);if(Number.isInteger(t))return t;throw new d("expected x-total header to be valid integer.")}throw new d("expected x-total header to exist.")},R=function(){return function(e){var n=e.response;return g()({response:n}).then((function(e){return{results:e,total:q(n)}}))}},P=function(e){return a(e)?{collections:e.join()}:{}},w=function(e){return u({per_page:e.perPage,order_by:e.orderBy,page:e.page})},I=function(){var e=function(e){return"/collections/"+e.collectionId+"/photos"};return{getPathname:e,handleRequest:m((function(r){var a=r.collectionId,o=r.orientation,i=t(r,["collectionId","orientation"]);return{pathname:e({collectionId:a}),query:u(n({},w(i),{orientation:o}))}})),handleResponse:R()}}(),_=function(){var e=function(e){return"/collections/"+e.collectionId};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({collectionId:n.collectionId}),query:{}}})),handleResponse:g()}}(),b=function(){return{getPathname:function(){return"/collections"},handleRequest:m((function(e){return void 0===e&&(e={}),{pathname:"/collections",query:w(e)}})),handleResponse:R()}}(),k=function(){var e=function(e){return"/collections/"+e.collectionId+"/related"};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({collectionId:n.collectionId}),query:{}}})),handleResponse:g()}}(),S={__proto__:null,getPhotos:I,get:_,list:b,getRelated:k},O=function(){return{getPathname:function(e){return"/photos"},handleRequest:m((function(e){return void 0===e&&(e={}),{pathname:"/photos",query:u(w(e))}})),handleResponse:R()}}(),A=function(){var e=function(e){return"/photos/"+e.photoId};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({photoId:n.photoId}),query:{}}})),handleResponse:g()}}(),j=function(){var e=function(e){return"/photos/"+e.photoId+"/statistics"};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({photoId:n.photoId}),query:{}}})),handleResponse:g()}}(),x=function(){return{getPathname:function(){return"/photos/random"},handleRequest:m((function(e){var r=void 0===e?{}:e,a=r.collectionIds,o=r.contentFilter,i=t(r,["collectionIds","contentFilter"]);return{pathname:"/photos/random",query:u(n({},i,{content_filter:o},P(a))),headers:{"cache-control":"no-cache"}}})),handleResponse:g()}}(),L={handleRequest:m((function(e){var n=function(e){var n=new URL(e),t=n.pathname;return{query:function(e){var n={};return e.forEach((function(e,t){n[t]=e})),n}(n.searchParams),pathname:"/"===t?void 0:t}}(e.downloadLocation),t=n.pathname,r=n.query;if(!a(t))throw new Error("Could not parse pathname from url.");return{pathname:t,query:u(r)}})),handleResponse:g()},C={__proto__:null,list:O,get:A,getStats:j,getRandom:x,trackDownload:L},T=function(){return{getPathname:function(){return"/search/photos"},handleRequest:m((function(e){var r=e.query,a=e.page,o=e.perPage,i=e.orderBy,s=e.collectionIds,c=e.lang,l=e.contentFilter,h=t(e,["query","page","perPage","orderBy","collectionIds","lang","contentFilter"]);return{pathname:"/search/photos",query:u(n({query:r,content_filter:l,lang:c,order_by:i},w({page:a,perPage:o}),P(s),h))}})),handleResponse:g()}}(),z=function(){return{getPathname:function(){return"/search/collections"},handleRequest:m((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/collections",query:n({query:r},w(a))}})),handleResponse:g()}}(),B=function(){return{getPathname:function(){return"/search/users"},handleRequest:m((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/users",query:n({query:r},w(a))}})),handleResponse:g()}}(),E={__proto__:null,getPhotos:T,getCollections:z,getUsers:B},U=function(){var e=function(e){return"/users/"+e.username};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({username:n.username}),query:{}}})),handleResponse:g()}}(),M=function(){var e=function(e){return"/users/"+e.username+"/photos"};return{getPathname:e,handleRequest:m((function(r){var a=r.username,o=r.stats,i=r.orientation,s=t(r,["username","stats","orientation"]);return{pathname:e({username:a}),query:u(n({},w(s),{orientation:i,stats:o}))}})),handleResponse:R()}}(),K=function(){var e=function(e){return"/users/"+e.username+"/likes"};return{getPathname:e,handleRequest:m((function(r){var a=r.username,o=r.orientation,i=t(r,["username","orientation"]);return{pathname:e({username:a}),query:u(n({},w(i),{orientation:o}))}})),handleResponse:R()}}(),D=function(){var e=function(e){return"/users/"+e.username+"/collections"};return{getPathname:e,handleRequest:m((function(n){var r=n.username,a=t(n,["username"]);return{pathname:e({username:r}),query:w(a)}})),handleResponse:R()}}(),F={__proto__:null,get:U,getPhotos:M,getLikes:K,getCollections:D},H=function(e){return"/topics/"+e.topicIdOrSlug},N=y({getPathname:H,handleRequest:function(e){var t=e.orderBy,r=e.topicIdsOrSlugs;return{pathname:"/topics",query:u(n({},w({page:e.page,perPage:e.perPage}),{ids:null==r?void 0:r.join(","),order_by:t}))}},handleResponse:R()}),G=y({getPathname:H,handleRequest:function(e){return{pathname:H({topicIdOrSlug:e.topicIdOrSlug}),query:{}}},handleResponse:g()}),V=function(){var e=i(H,(function(e){return e+"/photos"}));return{getPathname:e,handleRequest:function(r){var a=r.topicIdOrSlug,o=r.orientation,i=t(r,["topicIdOrSlug","orientation"]);return{pathname:e({topicIdOrSlug:a}),query:u(n({},w(i),{orientation:o}))}},handleResponse:R()}}(),J={__proto__:null,collections:S,photos:C,search:E,users:F,topics:{__proto__:null,list:N,get:G,getPhotos:V},trackNonHotLinkedPhotoView:function(e){var n=e.appId;return function(e){var t=e.photoId,r=Array.isArray(t)?t:[t];if(r.length>20)throw new Error("You cannot track more than 20 photos at once. Please try again with fewer photos.");return fetch("views.unsplash.com/v?photo_id="+r.join()+"&app_id="+n)}}};(s=exports.Language||(exports.Language={})).Afrikaans="af",s.Amharic="am",s.Arabic="ar",s.Azerbaijani="az",s.Belarusian="be",s.Bulgarian="bg",s.Bengali="bn",s.Bosnian="bs",s.Catalan="ca",s.Cebuano="ceb",s.Corsican="co",s.Czech="cs",s.Welsh="cy",s.Danish="da",s.German="de",s.Greek="el",s.English="en",s.Esperanto="eo",s.Spanish="es",s.Estonian="et",s.Basque="eu",s.Persian="fa",s.Finnish="fi",s.French="fr",s.Frisian="fy",s.Irish="ga",s.ScotsGaelic="gd",s.Galician="gl",s.Gujarati="gu",s.Hausa="ha",s.Hawaiian="haw",s.Hindi="hi",s.Hmong="hmn",s.Croatian="hr",s.HaitianCreole="ht",s.Hungarian="hu",s.Armenian="hy",s.Indonesian="id",s.Igbo="ig",s.Icelandic="is",s.Italian="it",s.Hebrew="iw",s.Japanese="ja",s.Javanese="jw",s.Georgian="ka",s.Kazakh="kk",s.Khmer="km",s.Kannada="kn",s.Korean="ko",s.Kurdish="ku",s.Kyrgyz="ky",s.Latin="la",s.Luxembourgish="lb",s.Lao="lo",s.Lithuanian="lt",s.Latvian="lv",s.Malagasy="mg",s.Maori="mi",s.Macedonian="mk",s.Malayalam="ml",s.Mongolian="mn",s.Marathi="mr",s.Malay="ms",s.Maltese="mt",s.Myanmar="my",s.Nepali="ne",s.Dutch="nl",s.Norwegian="no",s.Nyanja="ny",s.Oriya="or",s.Punjabi="pa",s.Polish="pl",s.Pashto="ps",s.Portuguese="pt",s.Romanian="ro",s.Russian="ru",s.Kinyarwanda="rw",s.Sindhi="sd",s.Sinhala="si",s.Slovak="sk",s.Slovenian="sl",s.Samoan="sm",s.Shona="sn",s.Somali="so",s.Albanian="sq",s.Serbian="sr",s.Sesotho="st",s.Sundanese="su",s.Swedish="sv",s.Swahili="sw",s.Tamil="ta",s.Telugu="te",s.Tajik="tg",s.Thai="th",s.Turkmen="tk",s.Filipino="tl",s.Turkish="tr",s.Tatar="tt",s.Uighur="ug",s.Ukrainian="uk",s.Urdu="ur",s.Uzbek="uz",s.Vietnamese="vi",s.Xhosa="xh",s.Yiddish="yi",s.Yoruba="yo",s.ChineseSimplified="zh",s.ChineseTraditional="zh-TW",s.Zulu="zu",(c=exports.OrderBy||(exports.OrderBy={})).LATEST="latest",c.POPULAR="popular",c.VIEWS="views",c.DOWNLOADS="downloads",c.OLDEST="oldest";var W=i(v,(function(e){return{photos:{get:e(A),list:e(O),getStats:e(j),getRandom:e(x),trackDownload:e(L)},users:{getPhotos:e(M),getCollections:e(D),getLikes:e(K),get:e(U)},search:{getCollections:e(z),getPhotos:e(T),getUsers:e(B)},collections:{getPhotos:e(I),get:e(_),list:e(b),getRelated:e(k)},topics:{list:e(N),get:e(G),getPhotos:e(V)}}}));exports._internals=J,exports.createApi=W; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("content-type");function n(){return(n=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function t(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(a[t]=e[t]);return a}var r=o((function(e){return"string"==typeof e?e:null})),a=function(e){return null!=e};function o(e){return function(n){return a(e(n))}}var u=function(e){return Object.keys(e).reduce((function(t,r){var o,u=e[r];return n({},t,a(u)?((o={})[r]=u,o):{})}),{})};function i(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n.length-1;return function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];for(var o=n[0].apply(this,t),u=1;u<=r;u++)o=n[u].call(this,o);return o}}var s,c,l=o((function(e){return a(e)&&"object"==typeof e&&!Array.isArray(e)?e:null})),h=o((function(e){return Array.isArray(e)&&e.every(r)&&e.length>0?e:null})),p=o((function(e){return l(e)&&"errors"in e&&h(e.errors)?{errors:e.errors}:null})),d=function(e){this.message=e},f=function(n){if(function(n){var t=n.headers.get("content-type");return a(t)&&"application/json"===e.parse(t).type}(n))return n.json().catch((function(e){throw new d("unable to parse JSON response.")}));throw new d("expected JSON response from server.")},g=function(){return function(e){return f(e.response)}},m=function(e){return function(r,a){void 0===a&&(a={});var o=e(r),u=o.headers,i=o.query;return n({},t(o,["headers","query"]),a,{query:i,headers:n({},u,a.headers)})}},y=function(e){return e},v=function(e){var r=e.accessKey,o=e.apiVersion,u=void 0===o?"v1":o,s=e.apiUrl,c=void 0===s?"https://api.unsplash.com":s,l=e.headers,h=e.fetch,g=t(e,["accessKey","apiVersion","apiUrl","headers","fetch"]);return function(e){var t=e.handleResponse;return i(e.handleRequest,(function(e){var o=e.method,i=void 0===o?"GET":o,s=e.headers,m=e.body,y=e.signal,v=function(e){var n=e.pathname,t=e.query;return function(e){var r=new URL(e);return function(e){return function(n){"/"===n.pathname?n.pathname=e:n.pathname+=e}}(n)(r),function(e){return function(n){Object.keys(e).forEach((function(t){return n.searchParams.set(t,e[t].toString())}))}}(t)(r),r.toString()}}({pathname:e.pathname,query:e.query})(c),q=n({method:i,headers:n({},l,s,{"Accept-Version":u},a(r)?{Authorization:"Client-ID "+r}:{}),body:m,signal:y},g);return(null!=h?h:fetch)(v,q).then(function(e){return function(t){return(t.ok?e({response:t}).then((function(e){return{type:"success",status:t.status,response:e,originalResponse:t}})):f(t).then((function(e){return n({type:"error",status:t.status},function(e){return p(e)?{errors:e.errors,source:"api"}:{errors:["Responded with a status code outside the 2xx range, and the response body is not recognisable."],source:"decoding"}}(e),{originalResponse:t})}))).catch((function(e){if(e instanceof d)return{type:"error",source:"decoding",status:t.status,originalResponse:t,errors:[e.message]};throw e}))}}(t))}))}},q=function(e){var n=e.headers.get("x-total");if(a(n)){var t=parseInt(n);if(Number.isInteger(t))return t;throw new d("expected x-total header to be valid integer.")}throw new d("expected x-total header to exist.")},R=function(){return function(e){var n=e.response;return g()({response:n}).then((function(e){return{results:e,total:q(n)}}))}},P=function(e){return a(e)?{collections:e.join()}:{}},I=function(e){return a(e)?{topics:e.join()}:{}},w=function(e){return u({per_page:e.perPage,order_by:e.orderBy,page:e.page})},_=function(){var e=function(e){return"/collections/"+e.collectionId+"/photos"};return{getPathname:e,handleRequest:m((function(r){var a=r.collectionId,o=r.orientation,i=t(r,["collectionId","orientation"]);return{pathname:e({collectionId:a}),query:u(n({},w(i),{orientation:o}))}})),handleResponse:R()}}(),b=function(){var e=function(e){return"/collections/"+e.collectionId};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({collectionId:n.collectionId}),query:{}}})),handleResponse:g()}}(),k=function(){return{getPathname:function(){return"/collections"},handleRequest:m((function(e){return void 0===e&&(e={}),{pathname:"/collections",query:w(e)}})),handleResponse:R()}}(),S=function(){var e=function(e){return"/collections/"+e.collectionId+"/related"};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({collectionId:n.collectionId}),query:{}}})),handleResponse:g()}}(),O={__proto__:null,getPhotos:_,get:b,list:k,getRelated:S},j=function(){return{getPathname:function(e){return"/photos"},handleRequest:m((function(e){return void 0===e&&(e={}),{pathname:"/photos",query:u(w(e))}})),handleResponse:R()}}(),A=function(){var e=function(e){return"/photos/"+e.photoId};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({photoId:n.photoId}),query:{}}})),handleResponse:g()}}(),x=function(){var e=function(e){return"/photos/"+e.photoId+"/statistics"};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({photoId:n.photoId}),query:{}}})),handleResponse:g()}}(),L=function(){return{getPathname:function(){return"/photos/random"},handleRequest:m((function(e){var r=void 0===e?{}:e,a=r.collectionIds,o=r.contentFilter,i=r.topicIds,s=t(r,["collectionIds","contentFilter","topicIds"]);return{pathname:"/photos/random",query:u(n({},s,{content_filter:o},P(a),I(i))),headers:{"cache-control":"no-cache"}}})),handleResponse:g()}}(),C={handleRequest:m((function(e){var n=function(e){var n=new URL(e),t=n.pathname;return{query:function(e){var n={};return e.forEach((function(e,t){n[t]=e})),n}(n.searchParams),pathname:"/"===t?void 0:t}}(e.downloadLocation),t=n.pathname,r=n.query;if(!a(t))throw new Error("Could not parse pathname from url.");return{pathname:t,query:u(r)}})),handleResponse:g()},T={__proto__:null,list:j,get:A,getStats:x,getRandom:L,trackDownload:C},z=function(){return{getPathname:function(e){return"/search/photos"},handleRequest:m((function(e){var r=e.query,a=e.page,o=e.perPage,i=e.orderBy,s=e.collectionIds,c=e.lang,l=e.contentFilter,h=t(e,["query","page","perPage","orderBy","collectionIds","lang","contentFilter"]);return{pathname:"/search/photos",query:u(n({query:r,content_filter:l,lang:c,order_by:i},w({page:a,perPage:o}),P(s),h))}})),handleResponse:g()}}(),B=function(){return{getPathname:function(e){return"/search/collections"},handleRequest:m((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/collections",query:n({query:r},w(a))}})),handleResponse:g()}}(),E=function(){return{getPathname:function(e){return"/search/users"},handleRequest:m((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/users",query:n({query:r},w(a))}})),handleResponse:g()}}(),U={__proto__:null,getPhotos:z,getCollections:B,getUsers:E},M=function(){var e=function(e){return"/users/"+e.username};return{getPathname:e,handleRequest:m((function(n){return{pathname:e({username:n.username}),query:{}}})),handleResponse:g()}}(),K=function(){var e=function(e){return"/users/"+e.username+"/photos"};return{getPathname:e,handleRequest:m((function(r){var a=r.username,o=r.stats,i=r.orientation,s=t(r,["username","stats","orientation"]);return{pathname:e({username:a}),query:u(n({},w(s),{orientation:i,stats:o}))}})),handleResponse:R()}}(),D=function(){var e=function(e){return"/users/"+e.username+"/likes"};return{getPathname:e,handleRequest:m((function(r){var a=r.username,o=r.orientation,i=t(r,["username","orientation"]);return{pathname:e({username:a}),query:u(n({},w(i),{orientation:o}))}})),handleResponse:R()}}(),F=function(){var e=function(e){return"/users/"+e.username+"/collections"};return{getPathname:e,handleRequest:m((function(n){var r=n.username,a=t(n,["username"]);return{pathname:e({username:r}),query:w(a)}})),handleResponse:R()}}(),H={__proto__:null,get:M,getPhotos:K,getLikes:D,getCollections:F},N=function(e){return"/topics/"+e.topicIdOrSlug},G=y({getPathname:N,handleRequest:function(e){var t=e.orderBy,r=e.topicIdsOrSlugs;return{pathname:"/topics",query:u(n({},w({page:e.page,perPage:e.perPage}),{ids:null==r?void 0:r.join(","),order_by:t}))}},handleResponse:R()}),V=y({getPathname:N,handleRequest:function(e){return{pathname:N({topicIdOrSlug:e.topicIdOrSlug}),query:{}}},handleResponse:g()}),J=function(){var e=i(N,(function(e){return e+"/photos"}));return{getPathname:e,handleRequest:function(r){var a=r.topicIdOrSlug,o=r.orientation,i=t(r,["topicIdOrSlug","orientation"]);return{pathname:e({topicIdOrSlug:a}),query:u(n({},w(i),{orientation:o}))}},handleResponse:R()}}(),W={__proto__:null,collections:O,photos:T,search:U,users:H,topics:{__proto__:null,list:G,get:V,getPhotos:J},trackNonHotLinkedPhotoView:function(e){var n=e.appId;return function(e){var t=e.photoId,r=Array.isArray(t)?t:[t];if(r.length>20)throw new Error("You cannot track more than 20 photos at once. Please try again with fewer photos.");return fetch("views.unsplash.com/v?photo_id="+r.join()+"&app_id="+n)}}};(s=exports.Language||(exports.Language={})).Afrikaans="af",s.Amharic="am",s.Arabic="ar",s.Azerbaijani="az",s.Belarusian="be",s.Bulgarian="bg",s.Bengali="bn",s.Bosnian="bs",s.Catalan="ca",s.Cebuano="ceb",s.Corsican="co",s.Czech="cs",s.Welsh="cy",s.Danish="da",s.German="de",s.Greek="el",s.English="en",s.Esperanto="eo",s.Spanish="es",s.Estonian="et",s.Basque="eu",s.Persian="fa",s.Finnish="fi",s.French="fr",s.Frisian="fy",s.Irish="ga",s.ScotsGaelic="gd",s.Galician="gl",s.Gujarati="gu",s.Hausa="ha",s.Hawaiian="haw",s.Hindi="hi",s.Hmong="hmn",s.Croatian="hr",s.HaitianCreole="ht",s.Hungarian="hu",s.Armenian="hy",s.Indonesian="id",s.Igbo="ig",s.Icelandic="is",s.Italian="it",s.Hebrew="iw",s.Japanese="ja",s.Javanese="jw",s.Georgian="ka",s.Kazakh="kk",s.Khmer="km",s.Kannada="kn",s.Korean="ko",s.Kurdish="ku",s.Kyrgyz="ky",s.Latin="la",s.Luxembourgish="lb",s.Lao="lo",s.Lithuanian="lt",s.Latvian="lv",s.Malagasy="mg",s.Maori="mi",s.Macedonian="mk",s.Malayalam="ml",s.Mongolian="mn",s.Marathi="mr",s.Malay="ms",s.Maltese="mt",s.Myanmar="my",s.Nepali="ne",s.Dutch="nl",s.Norwegian="no",s.Nyanja="ny",s.Oriya="or",s.Punjabi="pa",s.Polish="pl",s.Pashto="ps",s.Portuguese="pt",s.Romanian="ro",s.Russian="ru",s.Kinyarwanda="rw",s.Sindhi="sd",s.Sinhala="si",s.Slovak="sk",s.Slovenian="sl",s.Samoan="sm",s.Shona="sn",s.Somali="so",s.Albanian="sq",s.Serbian="sr",s.Sesotho="st",s.Sundanese="su",s.Swedish="sv",s.Swahili="sw",s.Tamil="ta",s.Telugu="te",s.Tajik="tg",s.Thai="th",s.Turkmen="tk",s.Filipino="tl",s.Turkish="tr",s.Tatar="tt",s.Uighur="ug",s.Ukrainian="uk",s.Urdu="ur",s.Uzbek="uz",s.Vietnamese="vi",s.Xhosa="xh",s.Yiddish="yi",s.Yoruba="yo",s.ChineseSimplified="zh",s.ChineseTraditional="zh-TW",s.Zulu="zu",(c=exports.OrderBy||(exports.OrderBy={})).LATEST="latest",c.POPULAR="popular",c.VIEWS="views",c.DOWNLOADS="downloads",c.OLDEST="oldest";var Y=i(v,(function(e){return{photos:{get:e(A),list:e(j),getStats:e(x),getRandom:e(L),trackDownload:e(C)},users:{getPhotos:e(K),getCollections:e(F),getLikes:e(D),get:e(M)},search:{getCollections:e(B),getPhotos:e(z),getUsers:e(E)},collections:{getPhotos:e(_),get:e(b),list:e(k),getRelated:e(S)},topics:{list:e(G),get:e(V),getPhotos:e(J)}}}));exports._internals=W,exports.createApi=Y; | ||
//# sourceMappingURL=unsplash-js.cjs.production.min.js.map |
@@ -338,2 +338,7 @@ import { parse } from 'content-type'; | ||
}; | ||
var getTopics = function getTopics(topicIds) { | ||
return isDefined(topicIds) ? { | ||
topics: topicIds.join() | ||
} : {}; | ||
}; | ||
var getFeedParams = function getFeedParams(_ref) { | ||
@@ -520,3 +525,4 @@ var page = _ref.page, | ||
contentFilter = _ref5.contentFilter, | ||
queryParams = _objectWithoutPropertiesLoose(_ref5, ["collectionIds", "contentFilter"]); | ||
topicIds = _ref5.topicIds, | ||
queryParams = _objectWithoutPropertiesLoose(_ref5, ["collectionIds", "contentFilter", "topicIds"]); | ||
@@ -527,3 +533,3 @@ return { | ||
content_filter: contentFilter | ||
}, getCollections(collectionIds))), | ||
}, getCollections(collectionIds), getTopics(topicIds))), | ||
headers: { | ||
@@ -571,3 +577,3 @@ /** | ||
var getPhotos$1 = /*#__PURE__*/function () { | ||
var getPathname = function getPathname() { | ||
var _getPathname = function getPathname() { | ||
return SEARCH_PATH_PREFIX + "/photos"; | ||
@@ -577,3 +583,6 @@ }; | ||
return makeEndpoint({ | ||
getPathname: getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: function getPathname(_params) { | ||
return _getPathname(); | ||
}, | ||
handleRequest: createRequestHandler(function (_ref) { | ||
@@ -590,3 +599,3 @@ var query = _ref.query, | ||
return { | ||
pathname: getPathname(), | ||
pathname: _getPathname(), | ||
query: compactDefined(_extends({ | ||
@@ -607,3 +616,3 @@ query: query, | ||
var getCollections$1 = /*#__PURE__*/function () { | ||
var getPathname = function getPathname() { | ||
var _getPathname2 = function getPathname() { | ||
return SEARCH_PATH_PREFIX + "/collections"; | ||
@@ -613,3 +622,6 @@ }; | ||
return makeEndpoint({ | ||
getPathname: getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: function getPathname(_params) { | ||
return _getPathname2(); | ||
}, | ||
handleRequest: createRequestHandler(function (_ref2) { | ||
@@ -620,3 +632,3 @@ var query = _ref2.query, | ||
return { | ||
pathname: getPathname(), | ||
pathname: _getPathname2(), | ||
query: _extends({ | ||
@@ -631,3 +643,3 @@ query: query | ||
var getUsers = /*#__PURE__*/function () { | ||
var getPathname = function getPathname() { | ||
var _getPathname3 = function getPathname() { | ||
return SEARCH_PATH_PREFIX + "/users"; | ||
@@ -637,3 +649,6 @@ }; | ||
return makeEndpoint({ | ||
getPathname: getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: function getPathname(_params) { | ||
return _getPathname3(); | ||
}, | ||
handleRequest: createRequestHandler(function (_ref3) { | ||
@@ -644,3 +659,3 @@ var query = _ref3.query, | ||
return { | ||
pathname: getPathname(), | ||
pathname: _getPathname3(), | ||
query: _extends({ | ||
@@ -647,0 +662,0 @@ query: query |
{ | ||
"name": "unsplash-js", | ||
"version": "7.0.13", | ||
"version": "7.0.14", | ||
"description": "Official JavaScript wrapper for the Unsplash API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -390,3 +390,4 @@ # Unsplash | ||
| **`featured`** | _boolean_ | Optional | | ||
| **`collectionIds`** | _Array<number>_ | Optional | | ||
| **`collectionIds`** | _Array<string>_ | Optional | | ||
| **`topicIds`** | _Array<string>_ | Optional | | ||
| **`count`** | _string_ | Optional | | ||
@@ -403,2 +404,3 @@ | ||
collectionIds: ['abc123'], | ||
topicIds: ['def456'], | ||
featured: true, | ||
@@ -405,0 +407,0 @@ username: 'naoufal', |
@@ -8,2 +8,5 @@ import { PaginationParams } from '../types/request'; | ||
export const getTopics = (topicIds?: string[]) => | ||
isDefined(topicIds) ? { topics: topicIds.join() } : {}; | ||
export const getFeedParams = ({ page, perPage, orderBy }: PaginationParams) => | ||
@@ -10,0 +13,0 @@ compactDefined({ |
@@ -54,2 +54,12 @@ import { handleFeedResponse } from '../../helpers/feed'; | ||
export type RandomParams = { | ||
collectionIds?: string[]; | ||
topicIds?: string[]; | ||
featured?: boolean; | ||
username?: string; | ||
query?: string; | ||
contentFilter?: 'low' | 'high'; | ||
count?: number; | ||
} & OrientationParam; | ||
export const getRandom = (() => { | ||
@@ -60,14 +70,3 @@ const getPathname = () => `${PHOTOS_PATH_PREFIX}/random`; | ||
handleRequest: createRequestHandler( | ||
({ | ||
collectionIds, | ||
contentFilter, | ||
...queryParams | ||
}: { | ||
collectionIds?: string[]; | ||
featured?: boolean; | ||
username?: string; | ||
query?: string; | ||
contentFilter?: 'low' | 'high'; | ||
count?: number; | ||
} & OrientationParam = {}) => ({ | ||
({ collectionIds, contentFilter, topicIds, ...queryParams }: RandomParams = {}) => ({ | ||
pathname: getPathname(), | ||
@@ -78,2 +77,3 @@ query: compactDefined({ | ||
...Query.getCollections(collectionIds), | ||
...Query.getTopics(topicIds), | ||
}), | ||
@@ -80,0 +80,0 @@ headers: { |
@@ -36,3 +36,4 @@ import { compactDefined } from '../../helpers/fp'; | ||
return makeEndpoint({ | ||
getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: (_params?: void) => getPathname(), | ||
handleRequest: createRequestHandler( | ||
@@ -68,3 +69,4 @@ ({ | ||
return makeEndpoint({ | ||
getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: (_params?: void) => getPathname(), | ||
handleRequest: createRequestHandler(({ query, ...paginationParams }: SearchParams) => ({ | ||
@@ -81,3 +83,4 @@ pathname: getPathname(), | ||
return makeEndpoint({ | ||
getPathname, | ||
// Wrapper uses type trick to allow 0 args | ||
getPathname: (_params?: void) => getPathname(), | ||
handleRequest: createRequestHandler(({ query, ...paginationParams }: SearchParams) => ({ | ||
@@ -84,0 +87,0 @@ pathname: getPathname(), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
329235
3871
692