Socket
Socket
Sign inDemoInstall

unsplash-js

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unsplash-js - npm Package Compare versions

Comparing version 7.0.11 to 7.0.12

5

dist/helpers/request.d.ts

@@ -20,3 +20,2 @@ import { ApiResponse, HandleResponse } from './response';

export declare const createRequestHandler: <Args>(fn: (a: Args) => BaseRequestParams) => HandleRequest<Args>;
export declare const createRequestGenerator: <Args, T>(handlers: RequestGenerator<Args, T>) => RequestGenerator<Args, T>;
/**

@@ -39,2 +38,6 @@ * Initial parameters that apply to all calls

};
declare type Endpoint<PathnameParams, RequestArgs, ResponseType> = {
getPathname: (params: PathnameParams) => string;
} & RequestGenerator<RequestArgs, ResponseType>;
export declare const makeEndpoint: <PathnameParams, RequestArgs, ResponseType_1>(endpoint: Endpoint<PathnameParams, RequestArgs, ResponseType_1>) => Endpoint<PathnameParams, RequestArgs, ResponseType_1>;
declare type GeneratedRequestFunction<Args, ResponseType> = (...a: Parameters<HandleRequest<Args>>) => Promise<ApiResponse<ResponseType>>;

@@ -41,0 +44,0 @@ declare type InitMakeRequest = (args: InitParams) => <Args, ResponseType>(handlers: RequestGenerator<Args, ResponseType>) => GeneratedRequestFunction<Args, ResponseType>;

@@ -6,2 +6,4 @@ import { OrientationParam, PaginationParams } from '../../types/request';

export declare const getPhotos: {
getPathname: (params: CollectionId) => string;
} & {
handleRequest: (a: CollectionId & PaginationParams & OrientationParam, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -14,2 +16,4 @@ handleResponse: import("../../helpers/response").HandleResponse<{

export declare const get: {
getPathname: (params: CollectionId) => string;
} & {
handleRequest: (a: CollectionId, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -19,2 +23,4 @@ handleResponse: import("../../helpers/response").HandleResponse<any>;

export declare const list: {
getPathname: (params: unknown) => string;
} & {
handleRequest: (a: Pick<PaginationParams, "page" | "perPage"> | undefined, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -27,2 +33,4 @@ handleResponse: import("../../helpers/response").HandleResponse<{

export declare const getRelated: {
getPathname: (params: CollectionId) => string;
} & {
handleRequest: (a: CollectionId, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -29,0 +37,0 @@ handleResponse: import("../../helpers/response").HandleResponse<any>;

@@ -7,2 +7,4 @@ import { OrientationParam, PaginationParams } from '../../types/request';

export declare const list: {
getPathname: (params: unknown) => string;
} & {
handleRequest: (a: PaginationParams | undefined, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -15,2 +17,4 @@ handleResponse: import("../../helpers/response").HandleResponse<{

export declare const get: {
getPathname: (params: PhotoId) => string;
} & {
handleRequest: (a: PhotoId, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -20,2 +24,4 @@ handleResponse: import("../../helpers/response").HandleResponse<Photo.Full>;

export declare const getStats: {
getPathname: (params: PhotoId) => string;
} & {
handleRequest: (a: PhotoId, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -25,2 +31,4 @@ handleResponse: import("../../helpers/response").HandleResponse<Photo.Stats>;

export declare const getRandom: {
getPathname: (params: unknown) => string;
} & {
handleRequest: (a: ({

@@ -27,0 +35,0 @@ collectionIds?: string[] | undefined;

@@ -24,2 +24,4 @@ import { OrientationParam, PaginationParams } from '../../types/request';

export declare const getPhotos: {
getPathname: (params: unknown) => string;
} & {
handleRequest: (a: SearchPhotosParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -29,2 +31,4 @@ handleResponse: import("../../helpers/response").HandleResponse<SearchResponse.Photos>;

export declare const getCollections: {
getPathname: (params: unknown) => string;
} & {
handleRequest: (a: SearchParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -34,2 +38,4 @@ handleResponse: import("../../helpers/response").HandleResponse<SearchResponse.Collections>;

export declare const getUsers: {
getPathname: (params: unknown) => string;
} & {
handleRequest: (a: SearchParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -36,0 +42,0 @@ handleResponse: import("../../helpers/response").HandleResponse<SearchResponse.Users>;

@@ -10,2 +10,4 @@ import { OmitStrict } from '../../helpers/typescript';

export declare const list: {
getPathname: (params: TopicIdOrSlug) => string;
} & {
handleRequest: (a: OmitStrict<PaginationParams, "orderBy"> & {

@@ -24,2 +26,4 @@ /**

export declare const get: {
getPathname: (params: TopicIdOrSlug) => string;
} & {
handleRequest: (a: TopicIdOrSlug, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -29,2 +33,4 @@ handleResponse: import("../../helpers/response").HandleResponse<Topic.Full>;

export declare const getPhotos: {
getPathname: (params: TopicIdOrSlug) => string;
} & {
handleRequest: (a: TopicIdOrSlug & PaginationParams & OrientationParam, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;

@@ -31,0 +37,0 @@ handleResponse: import("../../helpers/response").HandleResponse<{

18

dist/methods/users/index.d.ts

@@ -5,13 +5,17 @@ import { OrientationParam, PaginationParams } from '../../types/request';

import * as Collection from '../collections/types';
declare type UserName = {
declare type Username = {
username: string;
};
export declare const get: {
handleRequest: (a: UserName, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
getPathname: (params: Username) => string;
} & {
handleRequest: (a: Username, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
handleResponse: import("../../helpers/response").HandleResponse<User.Full>;
};
export declare const getPhotos: {
getPathname: (params: Username) => string;
} & {
handleRequest: (a: {
stats?: boolean | undefined;
} & OrientationParam & UserName & PaginationParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
} & OrientationParam & Username & PaginationParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
handleResponse: import("../../helpers/response").HandleResponse<{

@@ -23,3 +27,5 @@ results: Photo.Basic[];

export declare const getLikes: {
handleRequest: (a: OrientationParam & UserName & PaginationParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
getPathname: (params: Username) => string;
} & {
handleRequest: (a: OrientationParam & Username & PaginationParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
handleResponse: import("../../helpers/response").HandleResponse<{

@@ -31,3 +37,5 @@ results: Photo.Basic[];

export declare const getCollections: {
handleRequest: (a: UserName & PaginationParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
getPathname: (params: Username) => string;
} & {
handleRequest: (a: Username & PaginationParams, additionalFetchOptions?: import("../../helpers/request").AdditionalFetchOptions | undefined) => import("../../helpers/request").CompleteRequestParams;
handleResponse: import("../../helpers/response").HandleResponse<{

@@ -34,0 +42,0 @@ results: Collection.Basic[];

@@ -217,2 +217,11 @@ 'use strict';

};
var getQueryFromSearchParams = function getQueryFromSearchParams(searchParams) {
var query = {};
searchParams.forEach(function (value, key) {
query[key] = value;
});
return query;
};
var parseQueryAndPathname = function parseQueryAndPathname(url) {

@@ -223,6 +232,3 @@ var _URL = new URL(url),

var query = {};
searchParams.forEach(function (value, key) {
query[key] = value;
});
var query = getQueryFromSearchParams(searchParams);
return {

@@ -255,4 +261,4 @@ query: query,

};
var createRequestGenerator = function createRequestGenerator(handlers) {
return handlers;
var makeEndpoint = function makeEndpoint(endpoint) {
return endpoint;
};

@@ -351,51 +357,88 @@ var initMakeRequest = function initMakeRequest(_ref) {

var COLLECTIONS_PATH_PREFIX = '/collections';
var getPhotos = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
var collectionId = _ref.collectionId,
orientation = _ref.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref, ["collectionId", "orientation"]);
var getPhotos = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref) {
var collectionId = _ref.collectionId;
return COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/photos";
};
return {
pathname: COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/photos",
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var get = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var collectionId = _ref2.collectionId;
return {
pathname: COLLECTIONS_PATH_PREFIX + "/" + collectionId,
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var list = {
handleRequest: /*#__PURE__*/createRequestHandler(function (paginationParams) {
if (paginationParams === void 0) {
paginationParams = {};
}
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var collectionId = _ref2.collectionId,
orientation = _ref2.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["collectionId", "orientation"]);
return {
pathname: COLLECTIONS_PATH_PREFIX,
query: getFeedParams(paginationParams)
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var getRelated = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref3) {
return {
pathname: getPathname({
collectionId: collectionId
}),
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: handleFeedResponse()
});
}();
var get = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref3) {
var collectionId = _ref3.collectionId;
return {
pathname: COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/related",
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
return COLLECTIONS_PATH_PREFIX + "/" + collectionId;
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref4) {
var collectionId = _ref4.collectionId;
return {
pathname: getPathname({
collectionId: collectionId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var list = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return COLLECTIONS_PATH_PREFIX;
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (paginationParams) {
if (paginationParams === void 0) {
paginationParams = {};
}
return {
pathname: getPathname(),
query: getFeedParams(paginationParams)
};
}),
handleResponse: handleFeedResponse()
});
}();
var getRelated = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref5) {
var collectionId = _ref5.collectionId;
return COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/related";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref6) {
var collectionId = _ref6.collectionId;
return {
pathname: getPathname({
collectionId: collectionId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var index = {

@@ -410,60 +453,94 @@ __proto__: null,

var PHOTOS_PATH_PREFIX = '/photos';
var list$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (feedParams) {
if (feedParams === void 0) {
feedParams = {};
}
var list$1 = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return PHOTOS_PATH_PREFIX;
};
return {
pathname: PHOTOS_PATH_PREFIX,
query: compactDefined(getFeedParams(feedParams))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var get$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (feedParams) {
if (feedParams === void 0) {
feedParams = {};
}
return {
pathname: PHOTOS_PATH_PREFIX,
query: compactDefined(getFeedParams(feedParams))
};
}),
handleResponse: handleFeedResponse()
});
}();
var get$1 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref) {
var photoId = _ref.photoId;
return {
pathname: PHOTOS_PATH_PREFIX + "/" + photoId,
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getStats = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var photoId = _ref2.photoId;
return {
pathname: PHOTOS_PATH_PREFIX + "/" + photoId + "/statistics",
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getRandom = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_temp) {
var _ref3 = _temp === void 0 ? {} : _temp,
collectionIds = _ref3.collectionIds,
contentFilter = _ref3.contentFilter,
queryParams = _objectWithoutPropertiesLoose(_ref3, ["collectionIds", "contentFilter"]);
return PHOTOS_PATH_PREFIX + "/" + photoId;
};
return {
pathname: PHOTOS_PATH_PREFIX + "/random",
query: compactDefined(_extends({}, queryParams, {
content_filter: contentFilter
}, getCollections(collectionIds))),
headers: {
/**
* Avoid response caching
*/
'cache-control': 'no-cache'
}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var photoId = _ref2.photoId;
return {
pathname: getPathname({
photoId: photoId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var getStats = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref3) {
var photoId = _ref3.photoId;
return PHOTOS_PATH_PREFIX + "/" + photoId + "/statistics";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref4) {
var photoId = _ref4.photoId;
return {
pathname: getPathname({
photoId: photoId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var getRandom = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return PHOTOS_PATH_PREFIX + "/random";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_temp) {
var _ref5 = _temp === void 0 ? {} : _temp,
collectionIds = _ref5.collectionIds,
contentFilter = _ref5.contentFilter,
queryParams = _objectWithoutPropertiesLoose(_ref5, ["collectionIds", "contentFilter"]);
return {
pathname: getPathname(),
query: compactDefined(_extends({}, queryParams, {
content_filter: contentFilter
}, getCollections(collectionIds))),
headers: {
/**
* Avoid response caching
*/
'cache-control': 'no-cache'
}
};
}),
handleResponse: castResponse()
});
}();
var trackDownload = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref4) {
var downloadLocation = _ref4.downloadLocation;
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref6) {
var downloadLocation = _ref6.downloadLocation;

@@ -496,57 +573,78 @@ var _parseQueryAndPathnam = parseQueryAndPathname(downloadLocation),

var SEARCH_PATH_PREFIX = "/search";
var getPhotos$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
var query = _ref.query,
page = _ref.page,
perPage = _ref.perPage,
orderBy = _ref.orderBy,
collectionIds = _ref.collectionIds,
lang = _ref.lang,
contentFilter = _ref.contentFilter,
filters = _objectWithoutPropertiesLoose(_ref, ["query", "page", "perPage", "orderBy", "collectionIds", "lang", "contentFilter"]);
var getPhotos$1 = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return SEARCH_PATH_PREFIX + "/photos";
};
return {
pathname: SEARCH_PATH_PREFIX + "/photos",
query: compactDefined(_extends({
query: query,
content_filter: contentFilter,
lang: lang,
order_by: orderBy
}, getFeedParams({
page: page,
perPage: perPage
}), getCollections(collectionIds), filters))
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getCollections$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var query = _ref2.query,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["query"]);
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref) {
var query = _ref.query,
page = _ref.page,
perPage = _ref.perPage,
orderBy = _ref.orderBy,
collectionIds = _ref.collectionIds,
lang = _ref.lang,
contentFilter = _ref.contentFilter,
filters = _objectWithoutPropertiesLoose(_ref, ["query", "page", "perPage", "orderBy", "collectionIds", "lang", "contentFilter"]);
return {
pathname: SEARCH_PATH_PREFIX + "/collections",
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getUsers = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref3) {
var query = _ref3.query,
paginationParams = _objectWithoutPropertiesLoose(_ref3, ["query"]);
return {
pathname: getPathname(),
query: compactDefined(_extends({
query: query,
content_filter: contentFilter,
lang: lang,
order_by: orderBy
}, getFeedParams({
page: page,
perPage: perPage
}), getCollections(collectionIds), filters))
};
}),
handleResponse: castResponse()
});
}();
var getCollections$1 = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return SEARCH_PATH_PREFIX + "/collections";
};
return {
pathname: SEARCH_PATH_PREFIX + "/users",
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var query = _ref2.query,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["query"]);
return {
pathname: getPathname(),
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: castResponse()
});
}();
var getUsers = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return SEARCH_PATH_PREFIX + "/users";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref3) {
var query = _ref3.query,
paginationParams = _objectWithoutPropertiesLoose(_ref3, ["query"]);
return {
pathname: getPathname(),
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: castResponse()
});
}();
var index$2 = {

@@ -560,57 +658,97 @@ __proto__: null,

var USERS_PATH_PREFIX = '/users';
var get$2 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
var get$2 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref) {
var username = _ref.username;
return {
pathname: USERS_PATH_PREFIX + "/" + username,
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getPhotos$2 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var username = _ref2.username,
stats = _ref2.stats,
orientation = _ref2.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["username", "stats", "orientation"]);
return USERS_PATH_PREFIX + "/" + username;
};
return {
pathname: USERS_PATH_PREFIX + "/" + username + "/photos",
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation,
stats: stats
}))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var getLikes = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref3) {
var username = _ref3.username,
orientation = _ref3.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref3, ["username", "orientation"]);
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var username = _ref2.username;
return {
pathname: getPathname({
username: username
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var getPhotos$2 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref3) {
var username = _ref3.username;
return USERS_PATH_PREFIX + "/" + username + "/photos";
};
return {
pathname: USERS_PATH_PREFIX + "/" + username + "/likes",
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var getCollections$2 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref4) {
var username = _ref4.username,
paginationParams = _objectWithoutPropertiesLoose(_ref4, ["username"]);
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref4) {
var username = _ref4.username,
stats = _ref4.stats,
orientation = _ref4.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref4, ["username", "stats", "orientation"]);
return {
pathname: USERS_PATH_PREFIX + "/" + username + "/collections",
query: getFeedParams(paginationParams)
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
return {
pathname: getPathname({
username: username
}),
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation,
stats: stats
}))
};
}),
handleResponse: handleFeedResponse()
});
}();
var getLikes = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref5) {
var username = _ref5.username;
return USERS_PATH_PREFIX + "/" + username + "/likes";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref6) {
var username = _ref6.username,
orientation = _ref6.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref6, ["username", "orientation"]);
return {
pathname: getPathname({
username: username
}),
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: handleFeedResponse()
});
}();
var getCollections$2 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref7) {
var username = _ref7.username;
return USERS_PATH_PREFIX + "/" + username + "/collections";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref8) {
var username = _ref8.username,
paginationParams = _objectWithoutPropertiesLoose(_ref8, ["username"]);
return {
pathname: getPathname({
username: username
}),
query: getFeedParams(paginationParams)
};
}),
handleResponse: handleFeedResponse()
});
}();
var index$3 = {

@@ -631,6 +769,4 @@ __proto__: null,

var getTopicPhotosPath = /*#__PURE__*/flow(getTopicPath, function (topicPath) {
return topicPath + "/photos";
});
var list$2 = /*#__PURE__*/createRequestGenerator({
var list$2 = /*#__PURE__*/makeEndpoint({
getPathname: getTopicPath,
handleRequest: function handleRequest(_ref2) {

@@ -654,3 +790,4 @@ var page = _ref2.page,

});
var get$3 = /*#__PURE__*/createRequestGenerator({
var get$3 = /*#__PURE__*/makeEndpoint({
getPathname: getTopicPath,
handleRequest: function handleRequest(_ref3) {

@@ -667,19 +804,25 @@ var topicIdOrSlug = _ref3.topicIdOrSlug;

});
var getPhotos$3 = /*#__PURE__*/createRequestGenerator({
handleRequest: function handleRequest(_ref4) {
var topicIdOrSlug = _ref4.topicIdOrSlug,
orientation = _ref4.orientation,
feedParams = _objectWithoutPropertiesLoose(_ref4, ["topicIdOrSlug", "orientation"]);
var getPhotos$3 = /*#__PURE__*/function () {
var getPathname = /*#__PURE__*/flow(getTopicPath, function (topicPath) {
return topicPath + "/photos";
});
return makeEndpoint({
getPathname: getPathname,
handleRequest: function handleRequest(_ref4) {
var topicIdOrSlug = _ref4.topicIdOrSlug,
orientation = _ref4.orientation,
feedParams = _objectWithoutPropertiesLoose(_ref4, ["topicIdOrSlug", "orientation"]);
return {
pathname: getTopicPhotosPath({
topicIdOrSlug: topicIdOrSlug
}),
query: compactDefined(_extends({}, getFeedParams(feedParams), {
orientation: orientation
}))
};
},
handleResponse: /*#__PURE__*/handleFeedResponse()
});
return {
pathname: getPathname({
topicIdOrSlug: topicIdOrSlug
}),
query: compactDefined(_extends({}, getFeedParams(feedParams), {
orientation: orientation
}))
};
},
handleResponse: handleFeedResponse()
});
}();

@@ -686,0 +829,0 @@ var trackNonHotLinkedPhotoView = function trackNonHotLinkedPhotoView(_ref) {

@@ -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 s=function(e){return Object.keys(e).reduce((function(t,r){var o,s=e[r];return n({},t,a(s)?((o={})[r]=s,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),s=1;s<=r;s++)o=n[s].call(this,o);return o}}var u,l,c=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 c(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)}},y=function(e){return function(r,a){void 0===a&&(a={});var o=e(r),s=o.headers,i=o.query;return n({},t(o,["headers","query"]),a,{query:i,headers:n({},s,a.headers)})}},m=function(e){return e},v=function(e){var r=e.accessKey,o=e.apiVersion,s=void 0===o?"v1":o,u=e.apiUrl,l=void 0===u?"https://api.unsplash.com":u,c=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,u=e.headers,y=e.body,m=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})(l),q=n({method:i,headers:n({},c,u,{"Accept-Version":s},a(r)?{Authorization:"Client-ID "+r}:{}),body:y,signal:m},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)}}))}},w=function(e){return a(e)?{collections:e.join()}:{}},b=function(e){return s({per_page:e.perPage,order_by:e.orderBy,page:e.page})},k={handleRequest:y((function(e){var r=e.collectionId,a=e.orientation,o=t(e,["collectionId","orientation"]);return{pathname:"/collections/"+r+"/photos",query:s(n({},b(o),{orientation:a}))}})),handleResponse:R()},S={handleRequest:y((function(e){return{pathname:"/collections/"+e.collectionId,query:{}}})),handleResponse:g()},_={handleRequest:y((function(e){return void 0===e&&(e={}),{pathname:"/collections",query:b(e)}})),handleResponse:R()},I={handleRequest:y((function(e){return{pathname:"/collections/"+e.collectionId+"/related",query:{}}})),handleResponse:g()},P={__proto__:null,getPhotos:k,get:S,list:_,getRelated:I},O={handleRequest:y((function(e){return void 0===e&&(e={}),{pathname:"/photos",query:s(b(e))}})),handleResponse:R()},A={handleRequest:y((function(e){return{pathname:"/photos/"+e.photoId,query:{}}})),handleResponse:g()},j={handleRequest:y((function(e){return{pathname:"/photos/"+e.photoId+"/statistics",query:{}}})),handleResponse:g()},x={handleRequest:y((function(e){var r=void 0===e?{}:e,a=r.collectionIds,o=r.contentFilter,i=t(r,["collectionIds","contentFilter"]);return{pathname:"/photos/random",query:s(n({},i,{content_filter:o},w(a))),headers:{"cache-control":"no-cache"}}})),handleResponse:g()},L={handleRequest:y((function(e){var n=function(e){var n=new URL(e),t=n.pathname,r={};return n.searchParams.forEach((function(e,n){r[n]=e})),{query:r,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:s(r)}})),handleResponse:g()},C={__proto__:null,list:O,get:A,getStats:j,getRandom:x,trackDownload:L},T={handleRequest:y((function(e){var r=e.query,a=e.page,o=e.perPage,i=e.orderBy,u=e.collectionIds,l=e.lang,c=e.contentFilter,h=t(e,["query","page","perPage","orderBy","collectionIds","lang","contentFilter"]);return{pathname:"/search/photos",query:s(n({query:r,content_filter:c,lang:l,order_by:i},b({page:a,perPage:o}),w(u),h))}})),handleResponse:g()},z={handleRequest:y((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/collections",query:n({query:r},b(a))}})),handleResponse:g()},B={handleRequest:y((function(e){var r=e.query,a=t(e,["query"]);return{pathname:"/search/users",query:n({query:r},b(a))}})),handleResponse:g()},E={__proto__:null,getPhotos:T,getCollections:z,getUsers:B},U={handleRequest:y((function(e){return{pathname:"/users/"+e.username,query:{}}})),handleResponse:g()},M={handleRequest:y((function(e){var r=e.username,a=e.stats,o=e.orientation,i=t(e,["username","stats","orientation"]);return{pathname:"/users/"+r+"/photos",query:s(n({},b(i),{orientation:o,stats:a}))}})),handleResponse:R()},K={handleRequest:y((function(e){var r=e.username,a=e.orientation,o=t(e,["username","orientation"]);return{pathname:"/users/"+r+"/likes",query:s(n({},b(o),{orientation:a}))}})),handleResponse:R()},D={handleRequest:y((function(e){var n=e.username,r=t(e,["username"]);return{pathname:"/users/"+n+"/collections",query:b(r)}})),handleResponse:R()},F={__proto__:null,get:U,getPhotos:M,getLikes:K,getCollections:D},H=function(e){return"/topics/"+e.topicIdOrSlug},N=i(H,(function(e){return e+"/photos"})),G=m({handleRequest:function(e){var t=e.orderBy,r=e.topicIdsOrSlugs;return{pathname:"/topics",query:s(n({},b({page:e.page,perPage:e.perPage}),{ids:null==r?void 0:r.join(","),order_by:t}))}},handleResponse:R()}),V=m({handleRequest:function(e){return{pathname:H({topicIdOrSlug:e.topicIdOrSlug}),query:{}}},handleResponse:g()}),J=m({handleRequest:function(e){var r=e.topicIdOrSlug,a=e.orientation,o=t(e,["topicIdOrSlug","orientation"]);return{pathname:N({topicIdOrSlug:r}),query:s(n({},b(o),{orientation:a}))}},handleResponse:R()}),W={__proto__:null,collections:P,photos:C,search:E,users:F,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)}}};(u=exports.Language||(exports.Language={})).Afrikaans="af",u.Amharic="am",u.Arabic="ar",u.Azerbaijani="az",u.Belarusian="be",u.Bulgarian="bg",u.Bengali="bn",u.Bosnian="bs",u.Catalan="ca",u.Cebuano="ceb",u.Corsican="co",u.Czech="cs",u.Welsh="cy",u.Danish="da",u.German="de",u.Greek="el",u.English="en",u.Esperanto="eo",u.Spanish="es",u.Estonian="et",u.Basque="eu",u.Persian="fa",u.Finnish="fi",u.French="fr",u.Frisian="fy",u.Irish="ga",u.ScotsGaelic="gd",u.Galician="gl",u.Gujarati="gu",u.Hausa="ha",u.Hawaiian="haw",u.Hindi="hi",u.Hmong="hmn",u.Croatian="hr",u.HaitianCreole="ht",u.Hungarian="hu",u.Armenian="hy",u.Indonesian="id",u.Igbo="ig",u.Icelandic="is",u.Italian="it",u.Hebrew="iw",u.Japanese="ja",u.Javanese="jw",u.Georgian="ka",u.Kazakh="kk",u.Khmer="km",u.Kannada="kn",u.Korean="ko",u.Kurdish="ku",u.Kyrgyz="ky",u.Latin="la",u.Luxembourgish="lb",u.Lao="lo",u.Lithuanian="lt",u.Latvian="lv",u.Malagasy="mg",u.Maori="mi",u.Macedonian="mk",u.Malayalam="ml",u.Mongolian="mn",u.Marathi="mr",u.Malay="ms",u.Maltese="mt",u.Myanmar="my",u.Nepali="ne",u.Dutch="nl",u.Norwegian="no",u.Nyanja="ny",u.Oriya="or",u.Punjabi="pa",u.Polish="pl",u.Pashto="ps",u.Portuguese="pt",u.Romanian="ro",u.Russian="ru",u.Kinyarwanda="rw",u.Sindhi="sd",u.Sinhala="si",u.Slovak="sk",u.Slovenian="sl",u.Samoan="sm",u.Shona="sn",u.Somali="so",u.Albanian="sq",u.Serbian="sr",u.Sesotho="st",u.Sundanese="su",u.Swedish="sv",u.Swahili="sw",u.Tamil="ta",u.Telugu="te",u.Tajik="tg",u.Thai="th",u.Turkmen="tk",u.Filipino="tl",u.Turkish="tr",u.Tatar="tt",u.Uighur="ug",u.Ukrainian="uk",u.Urdu="ur",u.Uzbek="uz",u.Vietnamese="vi",u.Xhosa="xh",u.Yiddish="yi",u.Yoruba="yo",u.ChineseSimplified="zh",u.ChineseTraditional="zh-TW",u.Zulu="zu",(l=exports.OrderBy||(exports.OrderBy={})).LATEST="latest",l.POPULAR="popular",l.VIEWS="views",l.DOWNLOADS="downloads",l.OLDEST="oldest";var Y=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(k),get:e(S),list:e(_),getRelated:e(I)},topics:{list:e(G),get:e(V),getPhotos:e(J)}}}));exports._internals=W,exports.createApi=Y;
"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()}}(),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()}}(),_={__proto__:null,getPhotos:I,get:b,list:k,getRelated:S},O=function(){return{getPathname:function(){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:_,photos:C,search:E,users:F,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(b),list:e(k),getRelated:e(S)},topics:{list:e(N),get:e(G),getPhotos:e(V)}}}));exports._internals=J,exports.createApi=W;
//# sourceMappingURL=unsplash-js.cjs.production.min.js.map

@@ -213,2 +213,11 @@ import { parse } from 'content-type';

};
var getQueryFromSearchParams = function getQueryFromSearchParams(searchParams) {
var query = {};
searchParams.forEach(function (value, key) {
query[key] = value;
});
return query;
};
var parseQueryAndPathname = function parseQueryAndPathname(url) {

@@ -219,6 +228,3 @@ var _URL = new URL(url),

var query = {};
searchParams.forEach(function (value, key) {
query[key] = value;
});
var query = getQueryFromSearchParams(searchParams);
return {

@@ -251,4 +257,4 @@ query: query,

};
var createRequestGenerator = function createRequestGenerator(handlers) {
return handlers;
var makeEndpoint = function makeEndpoint(endpoint) {
return endpoint;
};

@@ -347,51 +353,88 @@ var initMakeRequest = function initMakeRequest(_ref) {

var COLLECTIONS_PATH_PREFIX = '/collections';
var getPhotos = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
var collectionId = _ref.collectionId,
orientation = _ref.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref, ["collectionId", "orientation"]);
var getPhotos = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref) {
var collectionId = _ref.collectionId;
return COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/photos";
};
return {
pathname: COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/photos",
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var get = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var collectionId = _ref2.collectionId;
return {
pathname: COLLECTIONS_PATH_PREFIX + "/" + collectionId,
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var list = {
handleRequest: /*#__PURE__*/createRequestHandler(function (paginationParams) {
if (paginationParams === void 0) {
paginationParams = {};
}
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var collectionId = _ref2.collectionId,
orientation = _ref2.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["collectionId", "orientation"]);
return {
pathname: COLLECTIONS_PATH_PREFIX,
query: getFeedParams(paginationParams)
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var getRelated = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref3) {
return {
pathname: getPathname({
collectionId: collectionId
}),
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: handleFeedResponse()
});
}();
var get = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref3) {
var collectionId = _ref3.collectionId;
return {
pathname: COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/related",
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
return COLLECTIONS_PATH_PREFIX + "/" + collectionId;
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref4) {
var collectionId = _ref4.collectionId;
return {
pathname: getPathname({
collectionId: collectionId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var list = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return COLLECTIONS_PATH_PREFIX;
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (paginationParams) {
if (paginationParams === void 0) {
paginationParams = {};
}
return {
pathname: getPathname(),
query: getFeedParams(paginationParams)
};
}),
handleResponse: handleFeedResponse()
});
}();
var getRelated = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref5) {
var collectionId = _ref5.collectionId;
return COLLECTIONS_PATH_PREFIX + "/" + collectionId + "/related";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref6) {
var collectionId = _ref6.collectionId;
return {
pathname: getPathname({
collectionId: collectionId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var index = {

@@ -406,60 +449,94 @@ __proto__: null,

var PHOTOS_PATH_PREFIX = '/photos';
var list$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (feedParams) {
if (feedParams === void 0) {
feedParams = {};
}
var list$1 = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return PHOTOS_PATH_PREFIX;
};
return {
pathname: PHOTOS_PATH_PREFIX,
query: compactDefined(getFeedParams(feedParams))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var get$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (feedParams) {
if (feedParams === void 0) {
feedParams = {};
}
return {
pathname: PHOTOS_PATH_PREFIX,
query: compactDefined(getFeedParams(feedParams))
};
}),
handleResponse: handleFeedResponse()
});
}();
var get$1 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref) {
var photoId = _ref.photoId;
return {
pathname: PHOTOS_PATH_PREFIX + "/" + photoId,
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getStats = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var photoId = _ref2.photoId;
return {
pathname: PHOTOS_PATH_PREFIX + "/" + photoId + "/statistics",
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getRandom = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_temp) {
var _ref3 = _temp === void 0 ? {} : _temp,
collectionIds = _ref3.collectionIds,
contentFilter = _ref3.contentFilter,
queryParams = _objectWithoutPropertiesLoose(_ref3, ["collectionIds", "contentFilter"]);
return PHOTOS_PATH_PREFIX + "/" + photoId;
};
return {
pathname: PHOTOS_PATH_PREFIX + "/random",
query: compactDefined(_extends({}, queryParams, {
content_filter: contentFilter
}, getCollections(collectionIds))),
headers: {
/**
* Avoid response caching
*/
'cache-control': 'no-cache'
}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var photoId = _ref2.photoId;
return {
pathname: getPathname({
photoId: photoId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var getStats = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref3) {
var photoId = _ref3.photoId;
return PHOTOS_PATH_PREFIX + "/" + photoId + "/statistics";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref4) {
var photoId = _ref4.photoId;
return {
pathname: getPathname({
photoId: photoId
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var getRandom = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return PHOTOS_PATH_PREFIX + "/random";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_temp) {
var _ref5 = _temp === void 0 ? {} : _temp,
collectionIds = _ref5.collectionIds,
contentFilter = _ref5.contentFilter,
queryParams = _objectWithoutPropertiesLoose(_ref5, ["collectionIds", "contentFilter"]);
return {
pathname: getPathname(),
query: compactDefined(_extends({}, queryParams, {
content_filter: contentFilter
}, getCollections(collectionIds))),
headers: {
/**
* Avoid response caching
*/
'cache-control': 'no-cache'
}
};
}),
handleResponse: castResponse()
});
}();
var trackDownload = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref4) {
var downloadLocation = _ref4.downloadLocation;
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref6) {
var downloadLocation = _ref6.downloadLocation;

@@ -492,57 +569,78 @@ var _parseQueryAndPathnam = parseQueryAndPathname(downloadLocation),

var SEARCH_PATH_PREFIX = "/search";
var getPhotos$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
var query = _ref.query,
page = _ref.page,
perPage = _ref.perPage,
orderBy = _ref.orderBy,
collectionIds = _ref.collectionIds,
lang = _ref.lang,
contentFilter = _ref.contentFilter,
filters = _objectWithoutPropertiesLoose(_ref, ["query", "page", "perPage", "orderBy", "collectionIds", "lang", "contentFilter"]);
var getPhotos$1 = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return SEARCH_PATH_PREFIX + "/photos";
};
return {
pathname: SEARCH_PATH_PREFIX + "/photos",
query: compactDefined(_extends({
query: query,
content_filter: contentFilter,
lang: lang,
order_by: orderBy
}, getFeedParams({
page: page,
perPage: perPage
}), getCollections(collectionIds), filters))
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getCollections$1 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var query = _ref2.query,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["query"]);
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref) {
var query = _ref.query,
page = _ref.page,
perPage = _ref.perPage,
orderBy = _ref.orderBy,
collectionIds = _ref.collectionIds,
lang = _ref.lang,
contentFilter = _ref.contentFilter,
filters = _objectWithoutPropertiesLoose(_ref, ["query", "page", "perPage", "orderBy", "collectionIds", "lang", "contentFilter"]);
return {
pathname: SEARCH_PATH_PREFIX + "/collections",
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getUsers = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref3) {
var query = _ref3.query,
paginationParams = _objectWithoutPropertiesLoose(_ref3, ["query"]);
return {
pathname: getPathname(),
query: compactDefined(_extends({
query: query,
content_filter: contentFilter,
lang: lang,
order_by: orderBy
}, getFeedParams({
page: page,
perPage: perPage
}), getCollections(collectionIds), filters))
};
}),
handleResponse: castResponse()
});
}();
var getCollections$1 = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return SEARCH_PATH_PREFIX + "/collections";
};
return {
pathname: SEARCH_PATH_PREFIX + "/users",
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var query = _ref2.query,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["query"]);
return {
pathname: getPathname(),
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: castResponse()
});
}();
var getUsers = /*#__PURE__*/function () {
var getPathname = function getPathname() {
return SEARCH_PATH_PREFIX + "/users";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref3) {
var query = _ref3.query,
paginationParams = _objectWithoutPropertiesLoose(_ref3, ["query"]);
return {
pathname: getPathname(),
query: _extends({
query: query
}, getFeedParams(paginationParams))
};
}),
handleResponse: castResponse()
});
}();
var index$2 = {

@@ -556,57 +654,97 @@ __proto__: null,

var USERS_PATH_PREFIX = '/users';
var get$2 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref) {
var get$2 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref) {
var username = _ref.username;
return {
pathname: USERS_PATH_PREFIX + "/" + username,
query: {}
};
}),
handleResponse: /*#__PURE__*/castResponse()
};
var getPhotos$2 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref2) {
var username = _ref2.username,
stats = _ref2.stats,
orientation = _ref2.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref2, ["username", "stats", "orientation"]);
return USERS_PATH_PREFIX + "/" + username;
};
return {
pathname: USERS_PATH_PREFIX + "/" + username + "/photos",
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation,
stats: stats
}))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var getLikes = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref3) {
var username = _ref3.username,
orientation = _ref3.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref3, ["username", "orientation"]);
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref2) {
var username = _ref2.username;
return {
pathname: getPathname({
username: username
}),
query: {}
};
}),
handleResponse: castResponse()
});
}();
var getPhotos$2 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref3) {
var username = _ref3.username;
return USERS_PATH_PREFIX + "/" + username + "/photos";
};
return {
pathname: USERS_PATH_PREFIX + "/" + username + "/likes",
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
var getCollections$2 = {
handleRequest: /*#__PURE__*/createRequestHandler(function (_ref4) {
var username = _ref4.username,
paginationParams = _objectWithoutPropertiesLoose(_ref4, ["username"]);
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref4) {
var username = _ref4.username,
stats = _ref4.stats,
orientation = _ref4.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref4, ["username", "stats", "orientation"]);
return {
pathname: USERS_PATH_PREFIX + "/" + username + "/collections",
query: getFeedParams(paginationParams)
};
}),
handleResponse: /*#__PURE__*/handleFeedResponse()
};
return {
pathname: getPathname({
username: username
}),
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation,
stats: stats
}))
};
}),
handleResponse: handleFeedResponse()
});
}();
var getLikes = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref5) {
var username = _ref5.username;
return USERS_PATH_PREFIX + "/" + username + "/likes";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref6) {
var username = _ref6.username,
orientation = _ref6.orientation,
paginationParams = _objectWithoutPropertiesLoose(_ref6, ["username", "orientation"]);
return {
pathname: getPathname({
username: username
}),
query: compactDefined(_extends({}, getFeedParams(paginationParams), {
orientation: orientation
}))
};
}),
handleResponse: handleFeedResponse()
});
}();
var getCollections$2 = /*#__PURE__*/function () {
var getPathname = function getPathname(_ref7) {
var username = _ref7.username;
return USERS_PATH_PREFIX + "/" + username + "/collections";
};
return makeEndpoint({
getPathname: getPathname,
handleRequest: createRequestHandler(function (_ref8) {
var username = _ref8.username,
paginationParams = _objectWithoutPropertiesLoose(_ref8, ["username"]);
return {
pathname: getPathname({
username: username
}),
query: getFeedParams(paginationParams)
};
}),
handleResponse: handleFeedResponse()
});
}();
var index$3 = {

@@ -627,6 +765,4 @@ __proto__: null,

var getTopicPhotosPath = /*#__PURE__*/flow(getTopicPath, function (topicPath) {
return topicPath + "/photos";
});
var list$2 = /*#__PURE__*/createRequestGenerator({
var list$2 = /*#__PURE__*/makeEndpoint({
getPathname: getTopicPath,
handleRequest: function handleRequest(_ref2) {

@@ -650,3 +786,4 @@ var page = _ref2.page,

});
var get$3 = /*#__PURE__*/createRequestGenerator({
var get$3 = /*#__PURE__*/makeEndpoint({
getPathname: getTopicPath,
handleRequest: function handleRequest(_ref3) {

@@ -663,19 +800,25 @@ var topicIdOrSlug = _ref3.topicIdOrSlug;

});
var getPhotos$3 = /*#__PURE__*/createRequestGenerator({
handleRequest: function handleRequest(_ref4) {
var topicIdOrSlug = _ref4.topicIdOrSlug,
orientation = _ref4.orientation,
feedParams = _objectWithoutPropertiesLoose(_ref4, ["topicIdOrSlug", "orientation"]);
var getPhotos$3 = /*#__PURE__*/function () {
var getPathname = /*#__PURE__*/flow(getTopicPath, function (topicPath) {
return topicPath + "/photos";
});
return makeEndpoint({
getPathname: getPathname,
handleRequest: function handleRequest(_ref4) {
var topicIdOrSlug = _ref4.topicIdOrSlug,
orientation = _ref4.orientation,
feedParams = _objectWithoutPropertiesLoose(_ref4, ["topicIdOrSlug", "orientation"]);
return {
pathname: getTopicPhotosPath({
topicIdOrSlug: topicIdOrSlug
}),
query: compactDefined(_extends({}, getFeedParams(feedParams), {
orientation: orientation
}))
};
},
handleResponse: /*#__PURE__*/handleFeedResponse()
});
return {
pathname: getPathname({
topicIdOrSlug: topicIdOrSlug
}),
query: compactDefined(_extends({}, getFeedParams(feedParams), {
orientation: orientation
}))
};
},
handleResponse: handleFeedResponse()
});
}();

@@ -682,0 +825,0 @@ var trackNonHotLinkedPhotoView = function trackNonHotLinkedPhotoView(_ref) {

{
"name": "unsplash-js",
"version": "7.0.11",
"version": "7.0.12",
"description": "Official JavaScript wrapper for the Unsplash API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -211,2 +211,4 @@ # Unsplash

The types for this library target TypeScript v3.7 and above.
This library is written in TypeScript. This means that even if you are writing plain JavaScript, you can still get useful and accurate type information. We highly recommend that you setup your environment (using an IDE such as [VSCode](https://code.visualstudio.com/)) to fully benefit from this information:

@@ -437,3 +439,3 @@

unsplash.photos.trackDownload({
downloadLocation: photo.links.download_location,
downloadLocation: firstPhoto.links.download_location,
});

@@ -440,0 +442,0 @@ }

@@ -44,4 +44,2 @@ import { flow } from './fp';

export const createRequestGenerator = <Args, T>(handlers: RequestGenerator<Args, T>) => handlers;
/**

@@ -61,2 +59,9 @@ * Initial parameters that apply to all calls

type Endpoint<PathnameParams, RequestArgs, ResponseType> = {
getPathname: (params: PathnameParams) => string;
} & RequestGenerator<RequestArgs, ResponseType>;
export const makeEndpoint = <PathnameParams, RequestArgs, ResponseType>(
endpoint: Endpoint<PathnameParams, RequestArgs, ResponseType>,
) => endpoint;
type GeneratedRequestFunction<Args, ResponseType> = (

@@ -63,0 +68,0 @@ ...a: Parameters<HandleRequest<Args>>

@@ -33,5 +33,3 @@ type Query = {

export const parseQueryAndPathname = (url: string) => {
const { pathname, searchParams } = new URL(url);
const getQueryFromSearchParams = (searchParams: URLSearchParams) => {
const query: Query = {};

@@ -42,4 +40,11 @@

});
return query;
};
export const parseQueryAndPathname = (url: string) => {
const { pathname, searchParams } = new URL(url);
const query: Query = getQueryFromSearchParams(searchParams);
return { query, pathname: pathname === '/' ? undefined : pathname };
};
import { handleFeedResponse } from '../../helpers/feed';
import { compactDefined } from '../../helpers/fp';
import * as Query from '../../helpers/query';
import { createRequestHandler } from '../../helpers/request';
import { createRequestHandler, makeEndpoint } from '../../helpers/request';
import { castResponse } from '../../helpers/response';

@@ -14,40 +14,59 @@ import { OrientationParam, PaginationParams } from '../../types/request';

export const getPhotos = {
handleRequest: createRequestHandler(
({
collectionId,
orientation,
...paginationParams
}: CollectionId & PaginationParams & OrientationParam) => ({
pathname: `${COLLECTIONS_PATH_PREFIX}/${collectionId}/photos`,
query: compactDefined({ ...Query.getFeedParams(paginationParams), orientation }),
}),
),
handleResponse: handleFeedResponse<any>(),
};
export const getPhotos = (() => {
const getPathname = ({ collectionId }: CollectionId) =>
`${COLLECTIONS_PATH_PREFIX}/${collectionId}/photos`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(
({
collectionId,
orientation,
...paginationParams
}: CollectionId & PaginationParams & OrientationParam) => ({
pathname: getPathname({ collectionId }),
query: compactDefined({ ...Query.getFeedParams(paginationParams), orientation }),
}),
),
handleResponse: handleFeedResponse<any>(),
});
})();
export const get = {
handleRequest: createRequestHandler(({ collectionId }: CollectionId) => ({
pathname: `${COLLECTIONS_PATH_PREFIX}/${collectionId}`,
query: {},
})),
handleResponse: castResponse<any>(),
};
export const get = (() => {
const getPathname = ({ collectionId }: CollectionId) =>
`${COLLECTIONS_PATH_PREFIX}/${collectionId}`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(({ collectionId }: CollectionId) => ({
pathname: getPathname({ collectionId }),
query: {},
})),
handleResponse: castResponse<any>(),
});
})();
export const list = {
handleRequest: createRequestHandler(
(paginationParams: Pick<PaginationParams, 'page' | 'perPage'> = {}) => ({
pathname: COLLECTIONS_PATH_PREFIX,
query: Query.getFeedParams(paginationParams),
}),
),
handleResponse: handleFeedResponse<any>(),
};
export const list = (() => {
const getPathname = () => COLLECTIONS_PATH_PREFIX;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(
(paginationParams: Pick<PaginationParams, 'page' | 'perPage'> = {}) => ({
pathname: getPathname(),
query: Query.getFeedParams(paginationParams),
}),
),
handleResponse: handleFeedResponse<any>(),
});
})();
export const getRelated = {
handleRequest: createRequestHandler(({ collectionId }: CollectionId) => ({
pathname: `${COLLECTIONS_PATH_PREFIX}/${collectionId}/related`,
query: {},
})),
handleResponse: castResponse<any>(),
};
export const getRelated = (() => {
const getPathname = ({ collectionId }: CollectionId) =>
`${COLLECTIONS_PATH_PREFIX}/${collectionId}/related`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(({ collectionId }: CollectionId) => ({
pathname: getPathname({ collectionId }),
query: {},
})),
handleResponse: castResponse<any>(),
});
})();
import { handleFeedResponse } from '../../helpers/feed';
import { compactDefined } from '../../helpers/fp';
import * as Query from '../../helpers/query';
import { createRequestHandler } from '../../helpers/request';
import { createRequestHandler, makeEndpoint } from '../../helpers/request';
import { castResponse } from '../../helpers/response';

@@ -17,59 +17,75 @@ import { isDefined } from '../../helpers/typescript';

export const list = {
handleRequest: createRequestHandler((feedParams: PaginationParams = {}) => ({
pathname: PHOTOS_PATH_PREFIX,
query: compactDefined(Query.getFeedParams(feedParams)),
})),
handleResponse: handleFeedResponse<Photo.Basic>(),
};
export const list = (() => {
const getPathname = () => PHOTOS_PATH_PREFIX;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler((feedParams: PaginationParams = {}) => ({
pathname: PHOTOS_PATH_PREFIX,
query: compactDefined(Query.getFeedParams(feedParams)),
})),
handleResponse: handleFeedResponse<Photo.Basic>(),
});
})();
export const get = {
handleRequest: createRequestHandler(({ photoId }: PhotoId) => ({
pathname: `${PHOTOS_PATH_PREFIX}/${photoId}`,
query: {},
})),
handleResponse: castResponse<Photo.Full>(),
};
export const get = (() => {
const getPathname = ({ photoId }: PhotoId) => `${PHOTOS_PATH_PREFIX}/${photoId}`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(({ photoId }: PhotoId) => ({
pathname: getPathname({ photoId }),
query: {},
})),
handleResponse: castResponse<Photo.Full>(),
});
})();
export const getStats = {
handleRequest: createRequestHandler(({ photoId }: PhotoId) => ({
pathname: `${PHOTOS_PATH_PREFIX}/${photoId}/statistics`,
query: {},
})),
handleResponse: castResponse<Photo.Stats>(),
};
export const getStats = (() => {
const getPathname = ({ photoId }: PhotoId) => `${PHOTOS_PATH_PREFIX}/${photoId}/statistics`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(({ photoId }: PhotoId) => ({
pathname: getPathname({ photoId }),
query: {},
})),
handleResponse: castResponse<Photo.Stats>(),
});
})();
export const getRandom = {
handleRequest: createRequestHandler(
({
collectionIds,
contentFilter,
...queryParams
}: {
collectionIds?: string[];
featured?: boolean;
username?: string;
query?: string;
contentFilter?: 'low' | 'high';
count?: number;
} & OrientationParam = {}) => ({
pathname: `${PHOTOS_PATH_PREFIX}/random`,
query: compactDefined({
...queryParams,
content_filter: contentFilter,
...Query.getCollections(collectionIds),
export const getRandom = (() => {
const getPathname = () => `${PHOTOS_PATH_PREFIX}/random`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(
({
collectionIds,
contentFilter,
...queryParams
}: {
collectionIds?: string[];
featured?: boolean;
username?: string;
query?: string;
contentFilter?: 'low' | 'high';
count?: number;
} & OrientationParam = {}) => ({
pathname: getPathname(),
query: compactDefined({
...queryParams,
content_filter: contentFilter,
...Query.getCollections(collectionIds),
}),
headers: {
/**
* Avoid response caching
*/
'cache-control': 'no-cache',
},
}),
headers: {
/**
* Avoid response caching
*/
'cache-control': 'no-cache',
},
}),
),
handleResponse: castResponse<
// An array when the `count` query parameter is used.
Photo.Random | Photo.Random[]
>(),
};
),
handleResponse: castResponse<
// An array when the `count` query parameter is used.
Photo.Random | Photo.Random[]
>(),
});
})();

@@ -76,0 +92,0 @@ export const trackDownload = {

import { compactDefined } from '../../helpers/fp';
import * as Query from '../../helpers/query';
import { createRequestHandler } from '../../helpers/request';
import { createRequestHandler, makeEndpoint } from '../../helpers/request';
import { castResponse } from '../../helpers/response';

@@ -33,43 +33,55 @@ import { OrientationParam, PaginationParams } from '../../types/request';

export const getPhotos = {
handleRequest: createRequestHandler(
({
query,
page,
perPage,
orderBy,
collectionIds,
lang,
contentFilter,
...filters
}: SearchPhotosParams) => ({
pathname: `${SEARCH_PATH_PREFIX}/photos`,
query: compactDefined({
export const getPhotos = (() => {
const getPathname = () => `${SEARCH_PATH_PREFIX}/photos`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(
({
query,
content_filter: contentFilter,
page,
perPage,
orderBy,
collectionIds,
lang,
order_by: orderBy,
...Query.getFeedParams({ page, perPage }),
...Query.getCollections(collectionIds),
...filters,
contentFilter,
...filters
}: SearchPhotosParams) => ({
pathname: getPathname(),
query: compactDefined({
query,
content_filter: contentFilter,
lang,
order_by: orderBy,
...Query.getFeedParams({ page, perPage }),
...Query.getCollections(collectionIds),
...filters,
}),
}),
}),
),
handleResponse: castResponse<SearchResponse.Photos>(),
};
),
handleResponse: castResponse<SearchResponse.Photos>(),
});
})();
export const getCollections = {
handleRequest: createRequestHandler(({ query, ...paginationParams }: SearchParams) => ({
pathname: `${SEARCH_PATH_PREFIX}/collections`,
query: { query, ...Query.getFeedParams(paginationParams) },
})),
handleResponse: castResponse<SearchResponse.Collections>(),
};
export const getCollections = (() => {
const getPathname = () => `${SEARCH_PATH_PREFIX}/collections`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(({ query, ...paginationParams }: SearchParams) => ({
pathname: getPathname(),
query: { query, ...Query.getFeedParams(paginationParams) },
})),
handleResponse: castResponse<SearchResponse.Collections>(),
});
})();
export const getUsers = {
handleRequest: createRequestHandler(({ query, ...paginationParams }: SearchParams) => ({
pathname: `${SEARCH_PATH_PREFIX}/users`,
query: { query, ...Query.getFeedParams(paginationParams) },
})),
handleResponse: castResponse<SearchResponse.Users>(),
};
export const getUsers = (() => {
const getPathname = () => `${SEARCH_PATH_PREFIX}/users`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(({ query, ...paginationParams }: SearchParams) => ({
pathname: getPathname(),
query: { query, ...Query.getFeedParams(paginationParams) },
})),
handleResponse: castResponse<SearchResponse.Users>(),
});
})();
import { handleFeedResponse } from '../../helpers/feed';
import { compactDefined, flow } from '../../helpers/fp';
import * as Query from '../../helpers/query';
import { createRequestGenerator } from '../../helpers/request';
import { makeEndpoint } from '../../helpers/request';
import { castResponse } from '../../helpers/response';

@@ -17,7 +17,7 @@ import { OmitStrict } from '../../helpers/typescript';

const getTopicPath = ({ topicIdOrSlug }: TopicIdOrSlug) => `${BASE_TOPIC_PATH}/${topicIdOrSlug}`;
const getTopicPhotosPath = flow(getTopicPath, topicPath => `${topicPath}/photos`);
type TopicOrderBy = 'latest' | 'oldest' | 'position' | 'featured';
export const list = createRequestGenerator({
export const list = makeEndpoint({
getPathname: getTopicPath,
handleRequest: ({

@@ -45,3 +45,4 @@ page,

export const get = createRequestGenerator({
export const get = makeEndpoint({
getPathname: getTopicPath,
handleRequest: ({ topicIdOrSlug }: TopicIdOrSlug) => ({

@@ -54,15 +55,19 @@ pathname: getTopicPath({ topicIdOrSlug }),

export const getPhotos = createRequestGenerator({
handleRequest: ({
topicIdOrSlug,
orientation,
...feedParams
}: TopicIdOrSlug & PaginationParams & OrientationParam) => ({
pathname: getTopicPhotosPath({ topicIdOrSlug }),
query: compactDefined({
...Query.getFeedParams(feedParams),
export const getPhotos = (() => {
const getPathname = flow(getTopicPath, topicPath => `${topicPath}/photos`);
return makeEndpoint({
getPathname,
handleRequest: ({
topicIdOrSlug,
orientation,
...feedParams
}: TopicIdOrSlug & PaginationParams & OrientationParam) => ({
pathname: getPathname({ topicIdOrSlug }),
query: compactDefined({
...Query.getFeedParams(feedParams),
orientation,
}),
}),
}),
handleResponse: handleFeedResponse<Photo.Basic>(),
});
handleResponse: handleFeedResponse<Photo.Basic>(),
});
})();
import { handleFeedResponse } from '../../helpers/feed';
import { compactDefined } from '../../helpers/fp';
import * as Query from '../../helpers/query';
import { createRequestHandler } from '../../helpers/request';
import { createRequestHandler, makeEndpoint } from '../../helpers/request';
import { castResponse } from '../../helpers/response';

@@ -11,3 +11,3 @@ import { OrientationParam, PaginationParams } from '../../types/request';

type UserName = {
type Username = {
username: string;

@@ -18,57 +18,73 @@ };

export const get = {
handleRequest: createRequestHandler(({ username }: UserName) => ({
pathname: `${USERS_PATH_PREFIX}/${username}`,
query: {},
})),
handleResponse: castResponse<User.Full>(),
};
export const get = (() => {
const getPathname = ({ username }: Username) => `${USERS_PATH_PREFIX}/${username}`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(({ username }: Username) => ({
pathname: getPathname({ username }),
query: {},
})),
handleResponse: castResponse<User.Full>(),
});
})();
export const getPhotos = {
handleRequest: createRequestHandler(
({
username,
stats,
orientation,
...paginationParams
}: {
stats?: boolean;
} & OrientationParam &
UserName &
PaginationParams) => ({
pathname: `${USERS_PATH_PREFIX}/${username}/photos`,
query: compactDefined({
...Query.getFeedParams(paginationParams),
export const getPhotos = (() => {
const getPathname = ({ username }: Username) => `${USERS_PATH_PREFIX}/${username}/photos`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(
({
username,
stats,
orientation,
stats,
...paginationParams
}: {
stats?: boolean;
} & OrientationParam &
Username &
PaginationParams) => ({
pathname: getPathname({ username }),
query: compactDefined({
...Query.getFeedParams(paginationParams),
orientation,
stats,
}),
}),
}),
),
handleResponse: handleFeedResponse<Photo.Basic>(),
};
),
handleResponse: handleFeedResponse<Photo.Basic>(),
});
})();
export const getLikes = {
handleRequest: createRequestHandler(
({
username,
orientation,
...paginationParams
}: OrientationParam & UserName & PaginationParams) => ({
pathname: `${USERS_PATH_PREFIX}/${username}/likes`,
query: compactDefined({
...Query.getFeedParams(paginationParams),
export const getLikes = (() => {
const getPathname = ({ username }: Username) => `${USERS_PATH_PREFIX}/${username}/likes`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(
({
username,
orientation,
...paginationParams
}: OrientationParam & Username & PaginationParams) => ({
pathname: getPathname({ username }),
query: compactDefined({
...Query.getFeedParams(paginationParams),
orientation,
}),
}),
}),
),
handleResponse: handleFeedResponse<Photo.Basic>(),
};
export const getCollections = {
handleRequest: createRequestHandler(
({ username, ...paginationParams }: UserName & PaginationParams) => ({
pathname: `${USERS_PATH_PREFIX}/${username}/collections`,
query: Query.getFeedParams(paginationParams),
}),
),
handleResponse: handleFeedResponse<Collection.Basic>(),
};
),
handleResponse: handleFeedResponse<Photo.Basic>(),
});
})();
export const getCollections = (() => {
const getPathname = ({ username }: Username) => `${USERS_PATH_PREFIX}/${username}/collections`;
return makeEndpoint({
getPathname,
handleRequest: createRequestHandler(
({ username, ...paginationParams }: Username & PaginationParams) => ({
pathname: getPathname({ username }),
query: Query.getFeedParams(paginationParams),
}),
),
handleResponse: handleFeedResponse<Collection.Basic>(),
});
})();

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc